From 43dc1ebb3c5445844e10e1bcf75f62788f29ed11 Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Thu, 24 Oct 2019 18:21:04 +0100 Subject: [PATCH] CD prow config using tekton Define an event listener that triggers a tekton task that deploys prow configurations on a target k8s cluster / namespace from a give git repo / path. Move cronjobs into a cronjobs folder and add docs for each of them. Closes #1 --- prow/extra.yaml | 25 ++++ tekton/README.md | 12 ++ tekton/{config => cronjobs}/README.md | 11 +- .../hub-image-nightly-build-cron/README.md | 2 + .../hub-image-nightly-build-cron/cronjob.yaml | 0 .../kustomization.yaml | 0 .../README.md | 2 + .../cronjob.yaml | 0 .../kustomization.yaml | 0 .../ko-image-nightly-build-cron/README.md | 2 + .../ko-image-nightly-build-cron/cronjob.yaml | 0 .../kustomization.yaml | 0 .../README.md | 2 + .../cronjob.yaml | 24 ++++ .../kustomization.yaml | 5 + .../nightly-image-build-cron-base/README.md | 1 + .../kustomization.yaml | 0 .../trigger-image-build.yaml | 0 .../nightly-release-cron-base/README.md | 1 + .../kustomization.yaml | 0 .../trigger-with-uuid.yaml | 0 .../pipeline-nightly-release-cron/README.md | 2 + .../cronjob.yaml | 0 .../kustomization.yaml | 0 .../pipeline-test-runner-build-cron/README.md | 2 + .../cronjob.yaml | 0 .../kustomization.yaml | 0 .../prow-config-cd-hourly-cron/README.md | 1 + .../prow-config-cd-hourly-cron/cronjob.yaml | 26 ++++ .../kustomization.yaml | 5 + .../cronjobs/resource-cd-cron-base/README.md | 1 + .../resource-cd-cron-base/kustomization.yaml | 4 + .../trigger-resource-cd.yaml | 61 +++++++++ .../skopeo-image-nightly-build-cron/README.md | 2 + .../cronjob.yaml | 0 .../kustomization.yaml | 0 .../tkn-image-nightly-build-cron/README.md | 2 + .../tkn-image-nightly-build-cron/cronjob.yaml | 0 .../kustomization.yaml | 0 tekton/images/kubectl/Dockerfile | 21 ++++ tekton/images/tkn/Dockerfile | 3 +- tekton/resources/cd/prow-config-cd.yaml | 117 ++++++++++++++++++ tekton/resources/kustomization.yaml | 1 + 43 files changed, 327 insertions(+), 8 deletions(-) create mode 100644 prow/extra.yaml rename tekton/{config => cronjobs}/README.md (91%) create mode 100644 tekton/cronjobs/hub-image-nightly-build-cron/README.md rename tekton/{config => cronjobs}/hub-image-nightly-build-cron/cronjob.yaml (100%) rename tekton/{config => cronjobs}/hub-image-nightly-build-cron/kustomization.yaml (100%) create mode 100644 tekton/cronjobs/ko-gcloud-image-nightly-build-cron/README.md rename tekton/{config => cronjobs}/ko-gcloud-image-nightly-build-cron/cronjob.yaml (100%) rename tekton/{config => cronjobs}/ko-gcloud-image-nightly-build-cron/kustomization.yaml (100%) create mode 100644 tekton/cronjobs/ko-image-nightly-build-cron/README.md rename tekton/{config => cronjobs}/ko-image-nightly-build-cron/cronjob.yaml (100%) rename tekton/{config => cronjobs}/ko-image-nightly-build-cron/kustomization.yaml (100%) create mode 100644 tekton/cronjobs/kubectl-image-nightly-build-cron/README.md create mode 100644 tekton/cronjobs/kubectl-image-nightly-build-cron/cronjob.yaml create mode 100644 tekton/cronjobs/kubectl-image-nightly-build-cron/kustomization.yaml create mode 100644 tekton/cronjobs/nightly-image-build-cron-base/README.md rename tekton/{config => cronjobs}/nightly-image-build-cron-base/kustomization.yaml (100%) rename tekton/{config => cronjobs}/nightly-image-build-cron-base/trigger-image-build.yaml (100%) create mode 100644 tekton/cronjobs/nightly-release-cron-base/README.md rename tekton/{config => cronjobs}/nightly-release-cron-base/kustomization.yaml (100%) rename tekton/{config => cronjobs}/nightly-release-cron-base/trigger-with-uuid.yaml (100%) create mode 100644 tekton/cronjobs/pipeline-nightly-release-cron/README.md rename tekton/{config => cronjobs}/pipeline-nightly-release-cron/cronjob.yaml (100%) rename tekton/{config => cronjobs}/pipeline-nightly-release-cron/kustomization.yaml (100%) create mode 100644 tekton/cronjobs/pipeline-test-runner-build-cron/README.md rename tekton/{config => cronjobs}/pipeline-test-runner-build-cron/cronjob.yaml (100%) rename tekton/{config => cronjobs}/pipeline-test-runner-build-cron/kustomization.yaml (100%) create mode 100644 tekton/cronjobs/prow-config-cd-hourly-cron/README.md create mode 100644 tekton/cronjobs/prow-config-cd-hourly-cron/cronjob.yaml create mode 100644 tekton/cronjobs/prow-config-cd-hourly-cron/kustomization.yaml create mode 100644 tekton/cronjobs/resource-cd-cron-base/README.md create mode 100644 tekton/cronjobs/resource-cd-cron-base/kustomization.yaml create mode 100644 tekton/cronjobs/resource-cd-cron-base/trigger-resource-cd.yaml create mode 100644 tekton/cronjobs/skopeo-image-nightly-build-cron/README.md rename tekton/{config => cronjobs}/skopeo-image-nightly-build-cron/cronjob.yaml (100%) rename tekton/{config => cronjobs}/skopeo-image-nightly-build-cron/kustomization.yaml (100%) create mode 100644 tekton/cronjobs/tkn-image-nightly-build-cron/README.md rename tekton/{config => cronjobs}/tkn-image-nightly-build-cron/cronjob.yaml (100%) rename tekton/{config => cronjobs}/tkn-image-nightly-build-cron/kustomization.yaml (100%) create mode 100644 tekton/images/kubectl/Dockerfile create mode 100644 tekton/resources/cd/prow-config-cd.yaml diff --git a/prow/extra.yaml b/prow/extra.yaml new file mode 100644 index 0000000000..594a6b9f79 --- /dev/null +++ b/prow/extra.yaml @@ -0,0 +1,25 @@ +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: config-map-updater +rules: +- apiGroups: ["*"] + resources: ["configmaps"] + verbs: ["get", "list", "patch", "update"] +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: prow-config-bot +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: prow-config-bot-config-map-updater +subjects: +- kind: ServiceAccount + name: prow-config-bot +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: config-map-updater diff --git a/tekton/README.md b/tekton/README.md index 8b7a7d8a69..0caeab4a2f 100644 --- a/tekton/README.md +++ b/tekton/README.md @@ -12,3 +12,15 @@ Resources are organised in folders: - The [resources](resources/README.md) folder contains Tekton resources used for various automation tasks: building container images, doing releases, maintaining the GitHub org and more. + +# Secrets + +Some of the resources require secrets to operate. +- `GitHub` secrets: `bot-token-github` used for syncing label configuration and + org configuration requires, `github-token` used to create a draft release +- `GCP` secrets: `nightly-account` is used by nightly releases to push releases + to the nightly bucket. It's a token for service account + `release-right-meow@tekton-releases.iam.gserviceaccount.com`. + `release-secret` is used by Tekton Pipeline to push pipeline artifacts to a + GCS bucket. It's also used to push images built by cron trigger (or Mario) + to the image registry on GCP. diff --git a/tekton/config/README.md b/tekton/cronjobs/README.md similarity index 91% rename from tekton/config/README.md rename to tekton/cronjobs/README.md index 13fdd209c2..9080694a8a 100644 --- a/tekton/config/README.md +++ b/tekton/cronjobs/README.md @@ -1,11 +1,8 @@ # Tekton Deployment Config -This folder holds kustomize overlays, that can be used to deploy resources -defined in the tekton folder. - -For now this is only used to maintain cron job configurations. To add a new -cron job to be deployed to the `dogfooding` cluster, create a folder and add -a kustomization.yaml into it, along with the cronjob overlay. +This folder holds kustomize overlays, that are used to maintain cron job configurations. To add a new cron job to be deployed to the `dogfooding` +cluster, create a folder and add a kustomization.yaml into it, along with the +cronjob overlay. There are two base cronjbs available: * `nightly-image-build-cron-base` which can be used to build container images @@ -18,7 +15,7 @@ Example folders structure: ``` tekton ├── README.md -├── config +├── cronjobs │   ├── README.md │   ├── nightly-image-build-cron-base │   │   ├── kustomization.yaml diff --git a/tekton/cronjobs/hub-image-nightly-build-cron/README.md b/tekton/cronjobs/hub-image-nightly-build-cron/README.md new file mode 100644 index 0000000000..5915c865cd --- /dev/null +++ b/tekton/cronjobs/hub-image-nightly-build-cron/README.md @@ -0,0 +1,2 @@ +Cron Job to build a container image with `hub` installed. +The image is published daily to [gcr.io/tekton-releases/dogfooding/hub:latest](gcr.io/tekton-releases/dogfooding/hub:latest). diff --git a/tekton/config/hub-image-nightly-build-cron/cronjob.yaml b/tekton/cronjobs/hub-image-nightly-build-cron/cronjob.yaml similarity index 100% rename from tekton/config/hub-image-nightly-build-cron/cronjob.yaml rename to tekton/cronjobs/hub-image-nightly-build-cron/cronjob.yaml diff --git a/tekton/config/hub-image-nightly-build-cron/kustomization.yaml b/tekton/cronjobs/hub-image-nightly-build-cron/kustomization.yaml similarity index 100% rename from tekton/config/hub-image-nightly-build-cron/kustomization.yaml rename to tekton/cronjobs/hub-image-nightly-build-cron/kustomization.yaml diff --git a/tekton/cronjobs/ko-gcloud-image-nightly-build-cron/README.md b/tekton/cronjobs/ko-gcloud-image-nightly-build-cron/README.md new file mode 100644 index 0000000000..23fa68cfbb --- /dev/null +++ b/tekton/cronjobs/ko-gcloud-image-nightly-build-cron/README.md @@ -0,0 +1,2 @@ +Cron Job to build a container image with `ko` and `gcloud` installed. +The image is published daily to [gcr.io/tekton-releases/dogfooding/ko:gcloud-latest](gcr.io/tekton-releases/dogfooding/ko:gcloud-latest). diff --git a/tekton/config/ko-gcloud-image-nightly-build-cron/cronjob.yaml b/tekton/cronjobs/ko-gcloud-image-nightly-build-cron/cronjob.yaml similarity index 100% rename from tekton/config/ko-gcloud-image-nightly-build-cron/cronjob.yaml rename to tekton/cronjobs/ko-gcloud-image-nightly-build-cron/cronjob.yaml diff --git a/tekton/config/ko-gcloud-image-nightly-build-cron/kustomization.yaml b/tekton/cronjobs/ko-gcloud-image-nightly-build-cron/kustomization.yaml similarity index 100% rename from tekton/config/ko-gcloud-image-nightly-build-cron/kustomization.yaml rename to tekton/cronjobs/ko-gcloud-image-nightly-build-cron/kustomization.yaml diff --git a/tekton/cronjobs/ko-image-nightly-build-cron/README.md b/tekton/cronjobs/ko-image-nightly-build-cron/README.md new file mode 100644 index 0000000000..93928a8d0e --- /dev/null +++ b/tekton/cronjobs/ko-image-nightly-build-cron/README.md @@ -0,0 +1,2 @@ +Cron Job to build a container image with `ko` installed. +The image is published daily to [gcr.io/tekton-releases/dogfooding/ko:gcloud-latest](gcr.io/tekton-releases/dogfooding/ko:latest). diff --git a/tekton/config/ko-image-nightly-build-cron/cronjob.yaml b/tekton/cronjobs/ko-image-nightly-build-cron/cronjob.yaml similarity index 100% rename from tekton/config/ko-image-nightly-build-cron/cronjob.yaml rename to tekton/cronjobs/ko-image-nightly-build-cron/cronjob.yaml diff --git a/tekton/config/ko-image-nightly-build-cron/kustomization.yaml b/tekton/cronjobs/ko-image-nightly-build-cron/kustomization.yaml similarity index 100% rename from tekton/config/ko-image-nightly-build-cron/kustomization.yaml rename to tekton/cronjobs/ko-image-nightly-build-cron/kustomization.yaml diff --git a/tekton/cronjobs/kubectl-image-nightly-build-cron/README.md b/tekton/cronjobs/kubectl-image-nightly-build-cron/README.md new file mode 100644 index 0000000000..c22f1627ca --- /dev/null +++ b/tekton/cronjobs/kubectl-image-nightly-build-cron/README.md @@ -0,0 +1,2 @@ +Cron Job to build a container image with `kubectl` installed. +The image is published daily to [gcr.io/tekton-releases/dogfooding/kubectl:latest](gcr.io/tekton-releases/dogfooding/kubectl:latest). diff --git a/tekton/cronjobs/kubectl-image-nightly-build-cron/cronjob.yaml b/tekton/cronjobs/kubectl-image-nightly-build-cron/cronjob.yaml new file mode 100644 index 0000000000..428bda4f3e --- /dev/null +++ b/tekton/cronjobs/kubectl-image-nightly-build-cron/cronjob.yaml @@ -0,0 +1,24 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: image-build-cron-trigger +spec: + schedule: "0 2 * * *" + concurrencyPolicy: Forbid + jobTemplate: + spec: + template: + spec: + containers: + - name: trigger + env: + - name: SINK_URL + value: el-image-builder.default.svc.cluster.local:8080 + - name: GIT_REPOSITORY + value: github.com/tekton/plumbing + - name: GIT_REVISION + value: master + - name: TARGET_IMAGE + value: gcr.io/tekton-releases/dogfooding/kubectl:latest + - name: CONTEXT_PATH + value: tekton/images/kubectl diff --git a/tekton/cronjobs/kubectl-image-nightly-build-cron/kustomization.yaml b/tekton/cronjobs/kubectl-image-nightly-build-cron/kustomization.yaml new file mode 100644 index 0000000000..9d9efe7434 --- /dev/null +++ b/tekton/cronjobs/kubectl-image-nightly-build-cron/kustomization.yaml @@ -0,0 +1,5 @@ +bases: +- ../nightly-image-build-cron-base +patchesStrategicMerge: +- cronjob.yaml +nameSuffix: "-kubectl" diff --git a/tekton/cronjobs/nightly-image-build-cron-base/README.md b/tekton/cronjobs/nightly-image-build-cron-base/README.md new file mode 100644 index 0000000000..e0acdb4829 --- /dev/null +++ b/tekton/cronjobs/nightly-image-build-cron-base/README.md @@ -0,0 +1 @@ +Cron Job template to build container images. diff --git a/tekton/config/nightly-image-build-cron-base/kustomization.yaml b/tekton/cronjobs/nightly-image-build-cron-base/kustomization.yaml similarity index 100% rename from tekton/config/nightly-image-build-cron-base/kustomization.yaml rename to tekton/cronjobs/nightly-image-build-cron-base/kustomization.yaml diff --git a/tekton/config/nightly-image-build-cron-base/trigger-image-build.yaml b/tekton/cronjobs/nightly-image-build-cron-base/trigger-image-build.yaml similarity index 100% rename from tekton/config/nightly-image-build-cron-base/trigger-image-build.yaml rename to tekton/cronjobs/nightly-image-build-cron-base/trigger-image-build.yaml diff --git a/tekton/cronjobs/nightly-release-cron-base/README.md b/tekton/cronjobs/nightly-release-cron-base/README.md new file mode 100644 index 0000000000..0075ebb64c --- /dev/null +++ b/tekton/cronjobs/nightly-release-cron-base/README.md @@ -0,0 +1 @@ +Cron Job template to trigger nightly releases. diff --git a/tekton/config/nightly-release-cron-base/kustomization.yaml b/tekton/cronjobs/nightly-release-cron-base/kustomization.yaml similarity index 100% rename from tekton/config/nightly-release-cron-base/kustomization.yaml rename to tekton/cronjobs/nightly-release-cron-base/kustomization.yaml diff --git a/tekton/config/nightly-release-cron-base/trigger-with-uuid.yaml b/tekton/cronjobs/nightly-release-cron-base/trigger-with-uuid.yaml similarity index 100% rename from tekton/config/nightly-release-cron-base/trigger-with-uuid.yaml rename to tekton/cronjobs/nightly-release-cron-base/trigger-with-uuid.yaml diff --git a/tekton/cronjobs/pipeline-nightly-release-cron/README.md b/tekton/cronjobs/pipeline-nightly-release-cron/README.md new file mode 100644 index 0000000000..69d27805ef --- /dev/null +++ b/tekton/cronjobs/pipeline-nightly-release-cron/README.md @@ -0,0 +1,2 @@ +Cron Job to trigger the Tekton Pipeline nightly build. +Results are published to https://storage.cloud.google.com/tekton-releases-nightly/pipeline/latest/release.yaml diff --git a/tekton/config/pipeline-nightly-release-cron/cronjob.yaml b/tekton/cronjobs/pipeline-nightly-release-cron/cronjob.yaml similarity index 100% rename from tekton/config/pipeline-nightly-release-cron/cronjob.yaml rename to tekton/cronjobs/pipeline-nightly-release-cron/cronjob.yaml diff --git a/tekton/config/pipeline-nightly-release-cron/kustomization.yaml b/tekton/cronjobs/pipeline-nightly-release-cron/kustomization.yaml similarity index 100% rename from tekton/config/pipeline-nightly-release-cron/kustomization.yaml rename to tekton/cronjobs/pipeline-nightly-release-cron/kustomization.yaml diff --git a/tekton/cronjobs/pipeline-test-runner-build-cron/README.md b/tekton/cronjobs/pipeline-test-runner-build-cron/README.md new file mode 100644 index 0000000000..49a4b90cd0 --- /dev/null +++ b/tekton/cronjobs/pipeline-test-runner-build-cron/README.md @@ -0,0 +1,2 @@ +Cron Job to build the `test-runner` container image used for CI/CD. +The image is published daily to [gcr.io/tekton-releases/dogfooding/test-runner:latest](gcr.io/tekton-releases/dogfooding/test-runner:latest). diff --git a/tekton/config/pipeline-test-runner-build-cron/cronjob.yaml b/tekton/cronjobs/pipeline-test-runner-build-cron/cronjob.yaml similarity index 100% rename from tekton/config/pipeline-test-runner-build-cron/cronjob.yaml rename to tekton/cronjobs/pipeline-test-runner-build-cron/cronjob.yaml diff --git a/tekton/config/pipeline-test-runner-build-cron/kustomization.yaml b/tekton/cronjobs/pipeline-test-runner-build-cron/kustomization.yaml similarity index 100% rename from tekton/config/pipeline-test-runner-build-cron/kustomization.yaml rename to tekton/cronjobs/pipeline-test-runner-build-cron/kustomization.yaml diff --git a/tekton/cronjobs/prow-config-cd-hourly-cron/README.md b/tekton/cronjobs/prow-config-cd-hourly-cron/README.md new file mode 100644 index 0000000000..898f6cb2b5 --- /dev/null +++ b/tekton/cronjobs/prow-config-cd-hourly-cron/README.md @@ -0,0 +1 @@ +Cron Job to hourly deploy Prow configuration, from the plumbing repo, to the Prow instance in the `prow` cluster; if changes are detected. diff --git a/tekton/cronjobs/prow-config-cd-hourly-cron/cronjob.yaml b/tekton/cronjobs/prow-config-cd-hourly-cron/cronjob.yaml new file mode 100644 index 0000000000..bbcc96035a --- /dev/null +++ b/tekton/cronjobs/prow-config-cd-hourly-cron/cronjob.yaml @@ -0,0 +1,26 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: resource-cd-trigger +spec: + schedule: "12 * * * *" + concurrencyPolicy: Forbid + jobTemplate: + spec: + template: + spec: + containers: + - name: trigger + env: + - name: SINK_URL + value: "http://el-prow-config-deployer.default.svc.cluster.local:8080" + - name: GIT_REPOSITORY + value: "github.com/tektoncd/plumbing" + - name: GIT_REVISION + value: "master" + - name: CONFIG_PATH + value: "prow/config.yaml" + - name: NAMESPACE + value: "default" + - name: CLUSTER_RESOURCE + value: "prow-cluster-config-bot" diff --git a/tekton/cronjobs/prow-config-cd-hourly-cron/kustomization.yaml b/tekton/cronjobs/prow-config-cd-hourly-cron/kustomization.yaml new file mode 100644 index 0000000000..2e3946a453 --- /dev/null +++ b/tekton/cronjobs/prow-config-cd-hourly-cron/kustomization.yaml @@ -0,0 +1,5 @@ +bases: +- ../resource-cd-cron-base +patchesStrategicMerge: +- cronjob.yaml +nameSuffix: "-prow-config" diff --git a/tekton/cronjobs/resource-cd-cron-base/README.md b/tekton/cronjobs/resource-cd-cron-base/README.md new file mode 100644 index 0000000000..0738a95d7c --- /dev/null +++ b/tekton/cronjobs/resource-cd-cron-base/README.md @@ -0,0 +1 @@ +Cron Job template to deploy resources from a folder to a cluster. diff --git a/tekton/cronjobs/resource-cd-cron-base/kustomization.yaml b/tekton/cronjobs/resource-cd-cron-base/kustomization.yaml new file mode 100644 index 0000000000..58210f0d11 --- /dev/null +++ b/tekton/cronjobs/resource-cd-cron-base/kustomization.yaml @@ -0,0 +1,4 @@ +commonLabels: + app: tekton.plumbing +resources: +- trigger-resource-cd.yaml diff --git a/tekton/cronjobs/resource-cd-cron-base/trigger-resource-cd.yaml b/tekton/cronjobs/resource-cd-cron-base/trigger-resource-cd.yaml new file mode 100644 index 0000000000..0ad49c27eb --- /dev/null +++ b/tekton/cronjobs/resource-cd-cron-base/trigger-resource-cd.yaml @@ -0,0 +1,61 @@ +# Copyright 2019 The Tekton Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: resource-cd-trigger +spec: + schedule: "12 * * * *" # Houly at *:12 + jobTemplate: + spec: + template: + spec: + volumes: + - name: workspace + emptyDir: {} + containers: + - name: trigger + image: curlimages/curl + command: + - /bin/sh + args: + - -ce + - | + cat < /workspace/post-body.json + { + "gitRepository": "$GIT_REPOSITORY", + "gitRevision": "$GIT_REVISION", + "configPath": "$CONFIG_PATH", + "namespace": "$NAMESPACE", + "clusterResource": "$CLUSTER_RESOURCE" + } + EOF + curl -d @/workspace/post-body.json $SINK_URL + volumeMounts: + - mountPath: /workspace + name: workspace + env: + - name: SINK_URL + value: "sink-url" + - name: GIT_REPOSITORY + value: "github.com/tektoncd/plumbing" + - name: GIT_REVISION + value: "master" + - name: CONFIG_PATH + value: "config/" + - name: NAMESPACE + value: "default" + - name: CLUSTER_RESOURCE + value: "not-a-real-cluster" + restartPolicy: Never diff --git a/tekton/cronjobs/skopeo-image-nightly-build-cron/README.md b/tekton/cronjobs/skopeo-image-nightly-build-cron/README.md new file mode 100644 index 0000000000..82d160f797 --- /dev/null +++ b/tekton/cronjobs/skopeo-image-nightly-build-cron/README.md @@ -0,0 +1,2 @@ +Cron Job to build a container image with `skopeo` installed. +The image is published daily to [gcr.io/tekton-releases/dogfooding/skopeo:latest](gcr.io/tekton-releases/dogfooding/skopeo:latest). diff --git a/tekton/config/skopeo-image-nightly-build-cron/cronjob.yaml b/tekton/cronjobs/skopeo-image-nightly-build-cron/cronjob.yaml similarity index 100% rename from tekton/config/skopeo-image-nightly-build-cron/cronjob.yaml rename to tekton/cronjobs/skopeo-image-nightly-build-cron/cronjob.yaml diff --git a/tekton/config/skopeo-image-nightly-build-cron/kustomization.yaml b/tekton/cronjobs/skopeo-image-nightly-build-cron/kustomization.yaml similarity index 100% rename from tekton/config/skopeo-image-nightly-build-cron/kustomization.yaml rename to tekton/cronjobs/skopeo-image-nightly-build-cron/kustomization.yaml diff --git a/tekton/cronjobs/tkn-image-nightly-build-cron/README.md b/tekton/cronjobs/tkn-image-nightly-build-cron/README.md new file mode 100644 index 0000000000..7beb9643e7 --- /dev/null +++ b/tekton/cronjobs/tkn-image-nightly-build-cron/README.md @@ -0,0 +1,2 @@ +Cron Job to build a container image with `tkn` installed. +The image is published daily to [gcr.io/tekton-releases/dogfooding/tkn:latest](gcr.io/tekton-releases/dogfooding/tkn:latest). diff --git a/tekton/config/tkn-image-nightly-build-cron/cronjob.yaml b/tekton/cronjobs/tkn-image-nightly-build-cron/cronjob.yaml similarity index 100% rename from tekton/config/tkn-image-nightly-build-cron/cronjob.yaml rename to tekton/cronjobs/tkn-image-nightly-build-cron/cronjob.yaml diff --git a/tekton/config/tkn-image-nightly-build-cron/kustomization.yaml b/tekton/cronjobs/tkn-image-nightly-build-cron/kustomization.yaml similarity index 100% rename from tekton/config/tkn-image-nightly-build-cron/kustomization.yaml rename to tekton/cronjobs/tkn-image-nightly-build-cron/kustomization.yaml diff --git a/tekton/images/kubectl/Dockerfile b/tekton/images/kubectl/Dockerfile new file mode 100644 index 0000000000..33fa8a6428 --- /dev/null +++ b/tekton/images/kubectl/Dockerfile @@ -0,0 +1,21 @@ +# Copyright 2019 The Tekton Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FROM alpine:3.10 +LABEL maintainer "Tekton Authors " + +RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* +RUN update-ca-certificates + +ARG KUBECTL_VERSION=1.16.2 +RUN wget -O/usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl; chmod +x /usr/local/bin/kubectl diff --git a/tekton/images/tkn/Dockerfile b/tekton/images/tkn/Dockerfile index 5d010feeb5..23595a9b87 100644 --- a/tekton/images/tkn/Dockerfile +++ b/tekton/images/tkn/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2018 The Tekton Authors +# Copyright 2019 The Tekton Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,4 +15,5 @@ FROM alpine:3.10 LABEL maintainer "Tekton Authors " ARG TKN_VERSION=0.6.0 + RUN wget -O- https://github.com/tektoncd/cli/releases/download/v${TKN_VERSION}/tkn_${TKN_VERSION}_Linux_x86_64.tar.gz | tar zxf - -C /usr/local/bin diff --git a/tekton/resources/cd/prow-config-cd.yaml b/tekton/resources/cd/prow-config-cd.yaml new file mode 100644 index 0000000000..f18c0607c3 --- /dev/null +++ b/tekton/resources/cd/prow-config-cd.yaml @@ -0,0 +1,117 @@ +apiVersion: tekton.dev/v1alpha1 +kind: TriggerBinding +metadata: + name: trigger-to-deploy-prow-config +spec: + params: + - name: gitRepository + value: $(body.gitRepository) + - name: gitRevision + value: $(body.gitRevision) + - name: configPath + value: $(body.configPath) + - name: namespace + value: $(body.namespace) + - name: clusterResource + value: $(body.clusterResource) +--- +apiVersion: tekton.dev/v1alpha1 +kind: EventListener +metadata: + name: prow-config-deployer +spec: + serviceAccountName: release-right-meow + triggers: + - name: trigger + bindings: + - name: trigger-to-deploy-prow-config + template: + name: deploy-prow-config +--- +apiVersion: tekton.dev/v1alpha1 +kind: TriggerTemplate +metadata: + name: deploy-prow-config +spec: + params: + - name: gitRepository + description: URL of the repository that holds the prow configuration + - name: gitRevision + description: Git revision + - name: namespace + description: Namespace to deploy to in the target cluster + - name: configPath + description: Path in the git repo that holds prow configs + - name: clusterResource + description: Name of the cluster resource that points to the target cluster + resourcetemplates: + - apiVersion: tekton.dev/v1alpha1 + kind: PipelineResource + metadata: + name: git-source-$(uid) + spec: + type: git + params: + - name: revision + value: $(params.gitRevision) + - name: url + value: https://$(params.gitRepository) + - apiVersion: tekton.dev/v1alpha1 + kind: TaskRun + metadata: + name: deploy-prow-config-$(uid) + spec: + taskSpec: + inputs: + params: + - name: configPath + description: Path in the git repo that holds prow configs + - name: namespace + description: Namespace to deploy to in the target cluster + resources: + - name: source + type: git + - name: prow-cluster + type: cluster + stepTemplate: + env: + - name: KUBECONFIG + value: /workspace/$(inputs.resources.prow-cluster.name)/kubeconfig + steps: + - name: fetch-current-config + image: gcr.io/tekton-releases/dogfooding/kubectl + script: | + #!/bin/sh + set -ex + kubectl get configmap config -o template --template='{{ index .data "config.yaml" }}' \ + > /workspace/config.yaml + - name: deploy + image: gcr.io/tekton-releases/dogfooding/kubectl + script: | + #!/bin/sh + set -ex + echo "diff [current-config] [new config]" + has_diff=0 + diff /workspace/config.yaml $(inputs.resources.source.path)/$(inputs.params.configPath) || has_diff=1 + if [ $has_diff -eq 0 ]; then + echo "No change in config detected. Nothing to be done." + exit 0 + fi + # Apply configuration changes + kubectl create configmap config \ + --from-file=config.yaml=$(inputs.resources.source.path)/$(inputs.params.configPath) \ + --dry-run -o yaml | \ + kubectl replace configmap config -n $(inputs.params.namespace) -f - + inputs: + params: + - name: configPath + value: $(params.configPath) + - name: namespace + value: $(params.namespace) + resources: + - name: source + resourceRef: + name: git-source-$(uid) + - name: prow-cluster + resourceRef: + name: $(params.clusterResource) diff --git a/tekton/resources/kustomization.yaml b/tekton/resources/kustomization.yaml index f4574c7e95..dae41de768 100644 --- a/tekton/resources/kustomization.yaml +++ b/tekton/resources/kustomization.yaml @@ -9,3 +9,4 @@ resources: - release/save-release-logs.yaml - release/test_tekton_release.yaml - pipeline-nightly-release/pipeline-nightly-build-trigger.yaml +- cd/prow-config-cd.yaml