Skip to content

feat: gitops operator custom CA certificates injection #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/gitops-runtime/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies:
condition: tunnel-client.enabled
- name: codefresh-gitops-operator
repository: oci://quay.io/codefresh/charts
version: 0.1.5
version: 0.2.0
alias: gitops-operator
condition: gitops-operator.enabled
- name: garage
Expand Down
65 changes: 65 additions & 0 deletions charts/gitops-runtime/ci/default-values-custom-tls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
global:
codefresh:
accountId: 628a80b693a15c0f9c13ab75 # Codefresh Account id for ilia-codefresh for now, needs to be some test account
userToken:
secretKeyRef:
name: mysecret
key: myvalue
optional: true
tls:
# -- Custom CA certificates bundle for platform access with ssl
caCerts:
# -- Reference to existing secret
secretKeyRef: {}
# -- Chart managed secret for custom platform CA certificates
secret:
# -- Whether to create the secret.
create: true
# -- The secret key that holds the ca bundle
key: 'ca-bundle.crt'
# Annotations
annotations: {}
# Certificate content
content: |
-----BEGIN CERTIFICATE-----
MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB
gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEk
MCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRY
UmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQxMTA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9NmXmd4c8nnxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSy
i6mx5O+aGtA9aZnuqCij4Tyz8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQ
O+7ETPTsJ3xCwnR8gooJybQDJbw=
-----END CERTIFICATE-----

runtime:
name: default

ingress:
className: "nginx"
hosts:
- runtime.codefresh.local

repoCredentialsTemplate:
url: 'https://github.com'
username: 'username'
password: 'dummy'


argo-rollouts:
enabled: true
6 changes: 6 additions & 0 deletions charts/gitops-runtime/templates/gitops-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
{{- end }}
{{- end}}

{{/* Set certificates */}}
{{- if or .Values.global.codefresh.tls.caCerts.secret.create .Values.global.codefresh.tls.caCerts.secretKeyRef}}
{{- $_ := set $gitopsOperatorContext.Values.global.codefresh.tls.caCerts.secretKeyRef "name" (.Values.global.codefresh.tls.caCerts.secret.create | ternary "codefresh-tls-certs" .Values.global.codefresh.tls.caCerts.secretKeyRef.name) }}
{{- $_ := set $gitopsOperatorContext.Values.global.codefresh.tls.caCerts.secretKeyRef "key" (.Values.global.codefresh.tls.caCerts.secret.create | ternary (default "ca-bundle.crt" .Values.global.codefresh.tls.caCerts.secret.key) .Values.global.codefresh.tls.caCerts.secretKeyRef.key) }}
{{- end }}

{{- include "gitops-operator.resources" $gitopsOperatorContext}}

{{- end }}
63 changes: 63 additions & 0 deletions charts/gitops-runtime/tests/custom-ca_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ templates:
- event-reporters/events-reporter/sensor.yaml
- event-reporters/rollout-reporter/sensor.yaml
- hooks/pre-uninstall/delete-runtime-from-platform.yaml
- "gitops-operator.yaml"
- charts/gitops-operator/*
tests:

- it: test chart created secret contents - default secret key
Expand Down Expand Up @@ -441,3 +443,64 @@ tests:
-----BEGIN CERTIFICATE-----
override
-----END CERTIFICATE-----

- it: gitops operator chart created secret
template: gitops-operator.yaml
documentSelector:
path: kind
value: Deployment
values:
- ./values/mandatory-values.yaml
set:
global.codefresh.tls.caCerts.secret.annotations.test: 'test'
global.codefresh.tls.caCerts.secret.create: true
global.codefresh.tls.caCerts.secret.key: my-key
global.codefresh.tls.caCerts.secret.content: |
-----BEGIN CERTIFICATE-----
... encoded certificate data here ...
-----END CERTIFICATE-----
asserts:
- contains:
path: spec.template.spec.containers[1].env
content:
name: CF_CA_CERT
value: /app/config/codefresh-tls/my-key
- contains:
path: spec.template.spec.containers[1].volumeMounts
content:
name: codefresh-tls
mountPath: /app/config/codefresh-tls
- contains:
path: spec.template.spec.volumes
content:
name: codefresh-tls
secret:
secretName: codefresh-tls-certs

- it: gitops operator existing secret
template: gitops-operator.yaml
documentSelector:
path: kind
value: Deployment
values:
- ./values/mandatory-values.yaml
set:
global.codefresh.tls.caCerts.secretKeyRef.name: my-tls
global.codefresh.tls.caCerts.secretKeyRef.key: my-key
asserts:
- contains:
path: spec.template.spec.containers[1].env
content:
name: CF_CA_CERT
value: /app/config/codefresh-tls/my-key
- contains:
path: spec.template.spec.containers[1].volumeMounts
content:
name: codefresh-tls
mountPath: /app/config/codefresh-tls
- contains:
path: spec.template.spec.volumes
content:
name: codefresh-tls
secret:
secretName: my-tls