-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Tekton Chains to an ExternalSecret
In order to facilitate backup/restore of a cluster, the signing secret is now stored externally and deployed on the cluster using an ExternalSecret. The original behavior is maintained for local development. rh-pre-commit.version: 2.1.0 rh-pre-commit.check-secrets: ENABLED
- Loading branch information
Showing
8 changed files
with
86 additions
and
53 deletions.
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
55 changes: 55 additions & 0 deletions
55
developer/openshift/gitops/local/openshift-pipelines/chains-secrets-config.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,55 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: tekton-chains-signing-secret | ||
namespace: openshift-pipelines | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation # Delete the job so it can be recreated and updated during the sync. | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: chains-secret-generation | ||
image: quay.io/redhat-appstudio/appstudio-utils:dbbdd82734232e6289e8fbae5b4c858481a7c057 | ||
imagePullPolicy: Always | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
namespace="openshift-pipelines" | ||
secret="signing-secrets" | ||
if [ "$(kubectl get secret "$secret" -n "$namespace" -o jsonpath='{.data}' --ignore-not-found --allow-missing-template-keys)" != "" ]; then | ||
echo "Signing secret exists and is non-empty." | ||
else | ||
# Delete secret/signing-secrets if already exists since by default cosign creates immutable secrets | ||
kubectl delete secrets "$secret" -n "$namespace" --ignore-not-found=true | ||
# To make this run conveniently without user input let's create a random password | ||
RANDOM_PASS=$( openssl rand -base64 30 ) | ||
# Generate the key pair secret directly in the cluster. | ||
echo "Generating k8s secret/$secret in $namespace with key-pair" | ||
env COSIGN_PASSWORD=$RANDOM_PASS cosign generate-key-pair "k8s://$namespace/$secret" | ||
fi | ||
resources: | ||
requests: | ||
cpu: 10m | ||
memory: 10Mi | ||
limits: | ||
cpu: 100m | ||
memory: 250Mi | ||
securityContext: | ||
readOnlyRootFilesystem: true | ||
runAsNonRoot: true | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: OnFailure | ||
terminationGracePeriodSeconds: 30 | ||
serviceAccount: chains-secrets-admin | ||
serviceAccountName: chains-secrets-admin |
6 changes: 6 additions & 0 deletions
6
developer/openshift/gitops/local/openshift-pipelines/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,6 @@ | ||
--- | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- chains-secrets-config.yaml | ||
- namespace.yaml |
10 changes: 10 additions & 0 deletions
10
developer/openshift/gitops/local/openshift-pipelines/namespace.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,10 @@ | ||
# Solves https://issues.redhat.com/browse/PLNSRVCE-1620 | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: openshift-pipelines | ||
labels: | ||
argocd.argoproj.io/managed-by: openshift-gitops | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "-1" |
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