-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: OpenShift Pipelines Configuration
Moving the Tekton Chains configuration to the infrastructure chart, replacing the pre-deploy hook with a post-deploy job that will create the Tekton Chains resources. Improved the Helm chart testing to wait for OpenShift Pipelines to be ready, and using official Chainguard images to run `cosign.`
- Loading branch information
Showing
11 changed files
with
333 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
charts/rhtap-backing-services/templates/openshift-gitops/job-post-deploy.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
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,25 @@ | ||
{{/* | ||
POD container spec to copy scripts. | ||
*/}} | ||
{{- define "infrastructure.copyScripts" -}} | ||
- name: copy-scripts | ||
image: registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
workingDir: /scripts | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
set -x -e | ||
{{- range $path, $content := .Files.Glob "scripts/*.sh" -}} | ||
{{- $script := trimPrefix "scripts/" $path }} | ||
printf '%s' "{{ $content | toString | b64enc }}" | base64 -d >{{ $script }} | ||
chmod +x {{ $script }} | ||
{{- end }} | ||
volumeMounts: | ||
- name: scripts | ||
mountPath: /scripts | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
{{- end -}} |
52 changes: 52 additions & 0 deletions
52
charts/rhtap-infrastructure/templates/openshift-pipelines/job-tekton-chains.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,52 @@ | ||
{{- if .Values.infrastructure.openShiftPipelines.enabled }} | ||
{{- $osp := .Values.infrastructure.openShiftPipelines -}} | ||
{{- $signingSecretName := required | ||
".infrastructure.openShiftPipelines.tektonChains.signingSecretName" | ||
$osp.tektonChains.signingSecretName | ||
-}} | ||
{{- $secretObj := ( | ||
lookup "v1" "Secret" $osp.namespace $signingSecretName | ||
) | default dict | ||
-}} | ||
{{- $secretData := (get $secretObj "data") | default dict -}} | ||
{{- $cosignKey := (get $secretData "cosign.key") | default "" -}} | ||
{{- if eq $cosignKey "" }} | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
annotations: | ||
helm.sh/hook: post-install,post-upgrade | ||
helm.sh/hook-delete-policy: hook-succeeded | ||
helm.sh/hook-weight: "2" | ||
labels: | ||
{{- include "rhtap-infrastructure.labels" . | nindent 4 }} | ||
namespace: {{ $osp.namespace }} | ||
name: {{ printf "cosign-%s-%d" $osp.name .Release.Revision }} | ||
spec: | ||
template: | ||
spec: | ||
serviceAccountName: {{ printf "patch-%s" $osp.name }} | ||
restartPolicy: Never | ||
containers: | ||
- name: tekton-chains-cosign | ||
image: ghcr.io/sigstore/cosign/cosign:latest | ||
env: | ||
- name: COSIGN_PASSWORD | ||
value: {{ randAlphaNum 32 }} | ||
workingDir: /workspace | ||
command: | ||
- cosign | ||
args: | ||
- generate-key-pair | ||
- {{ printf "k8s://%s/%s" $osp.namespace $signingSecretName }} | ||
volumeMounts: | ||
- name: workspace | ||
mountPath: /workspace | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
volumes: | ||
- name: workspace | ||
emppyDir: {} | ||
{{- end }} | ||
{{- end }} |
82 changes: 82 additions & 0 deletions
82
charts/rhtap-infrastructure/templates/openshift-pipelines/job-tekton-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,82 @@ | ||
{{- if .Values.infrastructure.openShiftPipelines.enabled }} | ||
{{- $osp := .Values.infrastructure.openShiftPipelines -}} | ||
{{- if or | ||
$osp.patchClusterTektonConfig.annotations | ||
$osp.patchClusterTektonConfig.labels | ||
}} | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
annotations: | ||
helm.sh/hook: post-install,post-upgrade | ||
helm.sh/hook-delete-policy: hook-succeeded | ||
helm.sh/hook-weight: "1" | ||
labels: | ||
{{- include "rhtap-infrastructure.labels" . | nindent 4 }} | ||
namespace: {{ $osp.namespace }} | ||
name: {{ printf "patch-tekton-%s-%d" $osp.name .Release.Revision }} | ||
spec: | ||
template: | ||
spec: | ||
serviceAccountName: {{ printf "patch-%s" $osp.name }} | ||
restartPolicy: Never | ||
containers: | ||
# | ||
# Copying the scripts that will be used on the subsequent containers, the | ||
# scripts are shared via the "/scripts" volume. | ||
# | ||
{{- include "infrastructure.copyScripts" . | nindent 8 }} | ||
{{- if $osp.patchClusterTektonConfig.annotations }} | ||
# | ||
# Patch the Tekton Config with the provided annotations. | ||
# | ||
- name: patch-annotations | ||
image: quay.io/codeready-toolchain/oc-client-base:latest | ||
env: | ||
- name: KIND | ||
value: tektonconfig | ||
- name: RESOURCE_NAME | ||
value: {{ $osp.patchClusterTektonConfig.resourceName }} | ||
command: | ||
- /scripts/oc-amend.sh | ||
args: | ||
- annotate | ||
{{- range $k, $v := $osp.patchClusterTektonConfig.annotations }} | ||
- {{ printf "%s=%s" $k $v | quote }} | ||
{{- end }} | ||
volumeMounts: | ||
- name: scripts | ||
mountPath: /scripts | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
{{- end }} | ||
{{- if $osp.patchClusterTektonConfig.labels }} | ||
# | ||
# Patch the Tekton Config with the provided labels. | ||
# | ||
- name: patch-labels | ||
image: quay.io/codeready-toolchain/oc-client-base:latest | ||
env: | ||
- name: KIND | ||
value: tektonconfig | ||
- name: RESOURCE_NAME | ||
value: {{ $osp.patchClusterTektonConfig.resourceName }} | ||
command: | ||
- /scripts/oc-amend.sh | ||
args: | ||
- label | ||
{{- range $k, $v := $osp.patchClusterTektonConfig.labels }} | ||
- {{ printf "%s=%s" $k $v | quote }} | ||
{{- end }} | ||
volumeMounts: | ||
- name: scripts | ||
mountPath: /scripts | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
{{- end }} | ||
volumes: | ||
- name: scripts | ||
emppyDir: {} | ||
{{- end }} | ||
{{- end }} |
74 changes: 74 additions & 0 deletions
74
charts/rhtap-infrastructure/templates/openshift-pipelines/service-account.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,74 @@ | ||
{{- if .Values.infrastructure.openShiftPipelines.enabled }} | ||
{{- $osp := .Values.infrastructure.openShiftPipelines -}} | ||
{{- $name := printf "patch-%s" $osp.name }} | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ $name }} | ||
namespace: {{ $osp.namespace }} | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
namespace: {{ $osp.namespace }} | ||
name: {{ $name }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- get | ||
- list | ||
- create | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
namespace: {{ $osp.namespace }} | ||
name: {{ $name }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ $name }} | ||
subjects: | ||
- kind: ServiceAccount | ||
namespace: {{ $osp.namespace }} | ||
name: {{ $name }} | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ $name }} | ||
rules: | ||
- apiGroups: | ||
- operator.tekton.dev | ||
resources: | ||
- tektonconfigs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- create | ||
- update | ||
- patch | ||
- delete | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ $name }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ $name }} | ||
subjects: | ||
- kind: ServiceAccount | ||
namespace: {{ $osp.namespace }} | ||
name: {{ $name }} | ||
{{- end }} |
Oops, something went wrong.