-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write Tekton image tag outputs to a ConfigMap (#1100)
This allows watching the `nativelink-image-tags` configmap to detect changes to the images running in the cluster. Preparation for the NativeLink operator.
- Loading branch information
1 parent
5de75cc
commit 1b8e23b
Showing
4 changed files
with
85 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
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
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,38 @@ | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: update-image-tags | ||
labels: | ||
app.kubernetes.io/versions: "0.1" | ||
spec: | ||
description: > | ||
Update or add image tags in a ConfigMap. | ||
Note: This task requires running under a ServiceAccount that has permissions | ||
to "get", "patch" and "create" configmaps. | ||
params: | ||
- name: imageName | ||
- name: imageTag | ||
steps: | ||
- name: update-configmap | ||
image: bitnami/kubectl | ||
env: | ||
- name: CM_NAME | ||
value: "nativelink-image-tags" | ||
script: | | ||
#!/bin/bash | ||
set -e | ||
# Transform the key to a format that flux accepts. The transformation | ||
# here looks like `nativelink-worker` -> `NATIVELINK_WORKER_TAG`. | ||
TRANSFORMED_KEY=$(echo "$(params.imageName)" | tr '[:lower:]' '[:upper:]' | tr '-' '_')_TAG | ||
# Check if the ConfigMap exists | ||
if kubectl get configmap $CM_NAME &>/dev/null; then | ||
# ConfigMap exists, update it | ||
kubectl patch configmap $CM_NAME --type=json -p='[{"op": "add", "path": "/data/'$TRANSFORMED_KEY'", "value": "$(params.imageTag)"}]' | ||
else | ||
# ConfigMap doesn't exist, create it | ||
kubectl create configmap $CM_NAME --from-literal=$TRANSFORMED_KEY=$(params.imageTag) | ||
fi |