Skip to content

Commit 368c18e

Browse files
authored
Add a label to the pubkey configmap. (#322)
This will let us efficiently filter, e.g. when backing them up. Adjust the backup script to filter by label. Existing registrytion can be backfilled by e.g.: ```bash function kc { kubectl --context="${KUBE_CONTEXT}" -n app-token-vendor "$@" } for cm in $(kc get cm -o name | egrep "^configmap/robot-"); do kc label "$cm" --overwrite app.kubernetes.io/managed-by=token-vendor done ``` See also: #320
1 parent 64cbe44 commit 368c18e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

scripts/backup_robots.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ kc get robots -o yaml | \
3636
yq 2>/dev/null -ry '.items[] | del(.metadata.annotations["kubectl.kubernetes.io/last-applied-configuration"],.metadata.creationTimestamp,.metadata.generation,.metadata.managedFields,.metadata.resourceVersion,.metadata.selfLink,.metadata.uid,.status)' -
3737
echo "---"
3838
# the underlying parser yq is using is inserting blank lines into the scalar blocks
39-
# TODO: consider labeling the keys so that we can select them
40-
kc get cm -n app-token-vendor -o yaml --field-selector=metadata.name!=kube-root-ca.crt | \
39+
kc get cm -n app-token-vendor -o yaml -l app.kubernetes.io/managed-by=token-vendor | \
4140
yq 2>/dev/null -ry '.items[] | del(.metadata.creationTimestamp,.metadata.resourceVersion,.metadata.selfLink,.metadata.uid)' - | \
4241
grep "\S"

src/go/cmd/token-vendor/repository/k8s/k8s.go

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ func createPubKeyDeviceConfig(name string, pk string) (*corev1.ConfigMap, error)
120120
},
121121
ObjectMeta: metav1.ObjectMeta{
122122
Name: name,
123+
Labels: map[string]string{
124+
"app.kubernetes.io/managed-by": "token-vendor",
125+
},
123126
},
124127
Data: map[string]string{pubKey: pk},
125128
}, nil

0 commit comments

Comments
 (0)