-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy the tekton catalog nightly to gcr.io
Create a pipeline to deploy the catalog to gcr.io. Add a new trigger/template to the CD event listener, and set up a cronjob to trigger nightly. Fixes: tektoncd/catalog#577 Signed-off-by: Andrea Frittoli <[email protected]>
- Loading branch information
1 parent
50af843
commit 4eafc73
Showing
12 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Cron Job template to deploy a catalog from a git repo to a container registry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
resources: | ||
- trigger-resource-cd.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# 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: catalog-publish-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 | ||
- | | ||
curl -v -H "Content-type: application/json -d @- "$SINK_URL" <<EOF | ||
{ | ||
"trigger-template": "catalog", | ||
"params": { | ||
"git": { | ||
"repository": "$GIT_REPOSITORY", | ||
"revision": "$GIT_REVISION" | ||
}, | ||
"catalog": { | ||
"registry": "$REGISTRY_URL", | ||
"registryPath": "$REGISTRY_PATH", | ||
"description": "$CATALOG_DESCRIPTION" | ||
} | ||
} | ||
} | ||
EOF | ||
volumeMounts: | ||
- mountPath: /workspace | ||
name: workspace | ||
env: | ||
- name: SINK_URL | ||
value: "http://el-tekton-cd.default.svc.cluster.local:8080" | ||
- name: GIT_REPOSITORY | ||
value: "github.com/tektoncd/catalog" | ||
- name: GIT_REVISION | ||
value: "main" | ||
- name: REGISTRY_URL | ||
value: "replace" | ||
- name: REGISTRY_PATH | ||
value: "replace" | ||
- name: CATALOG_DESCRIPTION | ||
value: "tekton" | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
resources: | ||
- tekton-upstream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Tekton Catalog CD - gcr.io/tekton-releases | ||
|
||
Cron Job to daily deploy the Tekton catalog to the | ||
gcr.io/tekton-releases container registry project as bundles. |
24 changes: 24 additions & 0 deletions
24
tekton/cronjobs/dogfooding/catalog/tekton-upstream/cronjob.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: catalog-publish-trigger | ||
spec: | ||
schedule: "30 * * * *" | ||
concurrencyPolicy: Forbid | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: trigger | ||
env: | ||
- name: GIT_REPOSITORY | ||
value: "https://github.com/tektoncd/catalog" | ||
- name: GIT_REVISION | ||
value: "main" | ||
- name: REGISTRY_URL | ||
value: "gcr.io" | ||
- name: REGISTRY_PATH | ||
value: "tekton-releases/catalog/upstream" | ||
- name: CATALOG_DESCRIPTION | ||
value: "tekton" |
5 changes: 5 additions & 0 deletions
5
tekton/cronjobs/dogfooding/catalog/tekton-upstream/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bases: | ||
- ../../../bases/catalog | ||
patchesStrategicMerge: | ||
- cronjob.yaml | ||
nameSuffix: "-tekton-upstream" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ resources: | |
- releases | ||
- tekton | ||
- nightly-tests | ||
- catalog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# Copyright 2021 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: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: catalog-publish | ||
spec: | ||
params: | ||
- name: gitRepository | ||
description: The git URL of the catalog to publish | ||
type: string | ||
default: https://github.com/tektoncd/catalog | ||
- name: gitRevision | ||
description: The git revision of the catalog to publish | ||
type: string | ||
default: main | ||
- name: registry | ||
description: The registry to publish to | ||
type: string | ||
- name: registryPath | ||
description: The base path in the registry | ||
type: string | ||
- name: serviceAccountFilename | ||
description: The name of the GKE service account file on the serviceaccount workspace | ||
type: string | ||
workspaces: | ||
- name: shared | ||
description: Shared workspace for tasks | ||
- name: serviceaccount | ||
description: Hosts a GKE service account file | ||
tasks: | ||
- name: git-clone | ||
taskRef: | ||
name: git-clone | ||
workspaces: | ||
- name: output | ||
workspace: shared | ||
params: | ||
- name: url | ||
value: "$(params.gitRepository)" | ||
- name: revision | ||
value: "$(params.gitRevision)" | ||
- name: create-dockerfile | ||
runAfter: ['git-clone'] | ||
taskSpec: | ||
workspaces: | ||
- name: serviceaccount | ||
- name: dockerfile | ||
params: | ||
- name: serviceAccountFilename | ||
- name: registry | ||
steps: | ||
- name: gke-serviceaccount-to-dockerfile | ||
image: debian:bullseye-slim | ||
env: | ||
- name: DOCKER_CONFIG_FOLDER | ||
value: "$(workspaces.dockerfile.path)" | ||
- name: SERVICE_ACCOUNT_FILE | ||
value: "$(workspaces.serviceaccount.path)/$(params.serviceAccountFilename)" | ||
- name: REGISTRY | ||
value: "$(params.registry)" | ||
script: | | ||
set -e | ||
# This step transforms sensitive information | ||
# Make sure we don't write it to the logs | ||
set +x | ||
cat <<EOF > "${DOCKER_CONFIG_FOLDER}/config.json" | ||
{ | ||
"auths": { | ||
"$REGISTRY": { | ||
"auth": "$(echo "_json_key:$(cat ${SERVICE_ACCOUNT_FILE})" | base64 -w 0)" | ||
} | ||
} | ||
} | ||
EOF | ||
params: | ||
- name: serviceAccountFilename | ||
value: "$(params.serviceAccountFilename)" | ||
- name: registry | ||
value: "$(params.registry)" | ||
workspaces: | ||
- name: serviceaccount | ||
workspace: serviceaccount | ||
- name: dockerfile | ||
workspace: shared | ||
- name: publish | ||
runAfter: ['create-dockerfile'] | ||
workspaces: | ||
- name: catalog | ||
workspace: shared | ||
- name: dockerconfig | ||
workspace: shared | ||
params: | ||
- name: REGISTRY | ||
value: "$(params.registry)" | ||
- name: PATH | ||
value: "$(params.registryPath)" | ||
- name: TAG | ||
value: "$(tasks.git-clone.results.commit)" | ||
taskRef: | ||
name: tekton-catalog-publish | ||
--- | ||
apiVersion: triggers.tekton.dev/v1alpha1 | ||
kind: TriggerTemplate | ||
metadata: | ||
name: publish-catalog | ||
spec: | ||
params: | ||
- name: gitRepository | ||
description: URL of the repository that holds the catalog | ||
- name: gitRevision | ||
description: Git revision | ||
- name: registry | ||
description: The registry to publish to | ||
- name: registryPath | ||
description: The base path in the registry | ||
- name: catalogDescription | ||
description: A descriptive name for the catalog | ||
resourcetemplates: | ||
- apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: publish-catalog-$(tt.params.catalogDescription)- | ||
spec: | ||
pipelineRef: | ||
name: catalog-publish | ||
params: | ||
- name: gitRepository | ||
value: "$(tt.params.gitRepository)" | ||
- name: gitRevision | ||
value: "$(tt.params.gitRevision)" | ||
- name: registry | ||
value: "$(tt.params.registry)" | ||
- name: registryPath | ||
value: "$(tt.params.registryPath)" | ||
- name: serviceAccountFilename | ||
value: "release.json" | ||
workspaces: | ||
- name: shared | ||
volumeClaimTemplate: | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
- name: serviceaccount | ||
secret: | ||
secretName: "release-secret" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters