Skip to content

Commit

Permalink
Move namespace.yaml to avoid unintended deletion of other components
Browse files Browse the repository at this point in the history
  • Loading branch information
hidehitof authored and tekton-robot committed Mar 15, 2022
1 parent f2da9a8 commit 66e3491
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
12 changes: 9 additions & 3 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ The `ko` command is the preferred method to manage (i.e., create, modify or dele
You can stand up a version of Tekton using your local clone's code to the currently configured K8s context (i.e., `kubectl config current-context`):
```shell
ko apply -f config/
ko apply -R -f config/
```
#### Verify installation
Expand All @@ -379,9 +379,15 @@ kubectl get pods -n tekton-pipelines
You can clean up everything with:
```shell
# If you should not delete the namespace of a pipeline component
ko delete -f config/
# If you also can delete the namespace of a pipeline component
ko delete -R -f config/
```
**Note:** If you use a pipeline component in the same namespace as other components such as dashboard or triggers, executing `ko delete -R -f config/` deletes these other components too.
#### Redeploy controller
As you make changes to the code, you can redeploy your controller with:
Expand All @@ -403,9 +409,9 @@ set -e
# Set your target namespace here
TARGET_NAMESPACE=new-target-namespace
ko resolve -f config | sed -e '/kind: Namespace/!b;n;n;s/:.*/: '"${TARGET_NAMESPACE}"'/' | \
ko resolve -R -f config | sed -e '/kind: Namespace/!b;n;n;s/:.*/: '"${TARGET_NAMESPACE}"'/' | \
sed "s/namespace: tekton-pipelines$/namespace: ${TARGET_NAMESPACE}/" | \
kubectl apply -f-
kubectl apply -R -f-
kubectl set env deployments --all SYSTEM_NAMESPACE=${TARGET_NAMESPACE} -n ${TARGET_NAMESPACE}
```
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ KO = $(or ${KO_BIN},${KO_BIN},$(BIN)/ko)
$(BIN)/ko: PACKAGE=github.com/google/ko

.PHONY: apply
apply: | $(KO) ; $(info $(M) ko apply -f config/) @ ## Apply config to the current cluster
$Q $(KO) apply -f config
apply: | $(KO) ; $(info $(M) ko apply -R -f config/) @ ## Apply config to the current cluster
$Q $(KO) apply -R -f config

.PHONY: resolve
resolve: | $(KO) ; $(info $(M) ko resolve -f config/) @ ## Resolve config to the current cluster
$Q $(KO) resolve --push=false --oci-layout-path=$(BIN)/oci -f config
resolve: | $(KO) ; $(info $(M) ko resolve -R -f config/) @ ## Resolve config to the current cluster
$Q $(KO) resolve --push=false --oci-layout-path=$(BIN)/oci -R -f config

.PHONY: generated
generated: | vendor ; $(info $(M) update generated files) ## Update generated files
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tekton/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ spec:
# Publish images and create release.yaml
mkdir -p $OUTPUT_RELEASE_DIR
ko resolve --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.yaml
ko resolve --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.yaml
# Publish images and create release.notags.yaml
# This is useful if your container runtime doesn't support the `image-reference:tag@digest` notation
# This is currently the case for `cri-o` (and most likely others)
ko resolve --platform=$(params.platforms) --preserve-import-paths -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.notags.yaml
ko resolve --platform=$(params.platforms) --preserve-import-paths -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.notags.yaml
- name: koparse
image: gcr.io/tekton-releases/dogfooding/koparse:latest
Expand Down
2 changes: 1 addition & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ To run tests:

```shell
# Land the latest codes
ko apply -f ./config/
ko apply -R -f ./config/

# Unit tests
go test ./...
Expand Down
6 changes: 3 additions & 3 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ source $(git rev-parse --show-toplevel)/vendor/github.com/tektoncd/plumbing/scri

function install_pipeline_crd() {
echo ">> Deploying Tekton Pipelines"
ko resolve -f config/ \
ko resolve -R -f config/ \
| sed -e 's%"level": "info"%"level": "debug"%' \
| sed -e 's%loglevel.controller: "info"%loglevel.controller: "debug"%' \
| sed -e 's%loglevel.webhook: "info"%loglevel.webhook: "debug"%' \
| kubectl apply -f - || fail_test "Build pipeline installation failed"
| kubectl apply -R -f - || fail_test "Build pipeline installation failed"
verify_pipeline_installation

export SYSTEM_NAMESPACE=tekton-pipelines
Expand All @@ -47,7 +47,7 @@ function verify_pipeline_installation() {

function uninstall_pipeline_crd() {
echo ">> Uninstalling Tekton Pipelines"
ko delete --ignore-not-found=true -f config/
ko delete --ignore-not-found=true -R -f config/

# Make sure that everything is cleaned up in the current namespace.
delete_pipeline_resources
Expand Down
2 changes: 1 addition & 1 deletion test/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function check_yaml_lint() {

function ko_resolve() {
header "Running `ko resolve`"
KO_DOCKER_REPO=example.com ko resolve --platform=all --push=false -f config 1>/dev/null
KO_DOCKER_REPO=example.com ko resolve --platform=all --push=false -R -f config 1>/dev/null
}

function post_build_tests() {
Expand Down

0 comments on commit 66e3491

Please sign in to comment.