Skip to content

Commit 4d02894

Browse files
authored
Add an option to generate tls cert during helm install (#700)
<!-- markdownlint-disable MD041 --> #### What this PR does / why we need it For clusters with cert-manager installed, we should have an option to deploy the certificate during Helm Install time. The option should be disabled by default to not alter existing installations. This PR also makes some controller and registry values configurable from values.yaml file * container CPU and memory consumptions * tls secret name #### Which issue(s) this PR fixes Fixed [issue 559](open-component-model/ocm-project#559) --------- Signed-off-by: Henry Zeng <[email protected]>
1 parent b62e05a commit 4d02894

File tree

4 files changed

+54
-12
lines changed

4 files changed

+54
-12
lines changed

deploy/templates/cert.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{- if .Values.tlsCert.generateTlsCert }}
2+
apiVersion: cert-manager.io/v1
3+
kind: Certificate
4+
metadata:
5+
name: {{ .Values.tlsCert.defaultSecretName }}
6+
namespace: {{ .Release.Namespace }}
7+
spec:
8+
secretName: {{ .Values.tlsCert.defaultSecretName }}
9+
dnsNames:
10+
- registry.{{ .Release.Namespace }}.svc.cluster.local
11+
- localhost
12+
ipAddresses:
13+
- 127.0.0.1
14+
- ::1
15+
privateKey:
16+
algorithm: RSA
17+
encoding: PKCS8
18+
size: 2048
19+
issuerRef:
20+
name: {{ .Values.tlsCert.defaultIssuerName }}
21+
kind: ClusterIssuer
22+
group: cert-manager.io
23+
---
24+
apiVersion: cert-manager.io/v1
25+
kind: ClusterIssuer
26+
metadata:
27+
name: {{ .Values.tlsCert.defaultIssuerName }}
28+
spec:
29+
ca:
30+
secretName: {{ .Values.tlsCert.defaultSecretName }}
31+
{{- end}}

deploy/templates/deployment_manager.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ spec:
5858
initialDelaySeconds: 5
5959
periodSeconds: 10
6060
resources:
61-
limits:
62-
memory: 1024Mi
63-
requests:
64-
cpu: 200m
65-
memory: 512Mi
61+
{{- toYaml .Values.manager.resources | nindent 10 }}
6662
serviceAccountName: ocm-controller
6763
terminationGracePeriodSeconds: 10
6864
{{- if .Values.registry.tls.enabled }}

deploy/templates/deployment_registry.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ spec:
4949
periodSeconds: 20
5050
successThreshold: 1
5151
failureThreshold: 3
52+
resources:
53+
{{- toYaml .Values.registry.resources | nindent 10 }}
5254
volumes:
5355
- name: registry
5456
emptyDir: {}

deploy/values.yaml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Generate TLS Certificate for registry and manager
2+
tlsCert:
3+
# If cert-manager is installed, set generateTlsCert to true to generate a cert
4+
generateTlsCert: false
5+
defaultSecretName: &tlsSecretName "ocm-registry-tls-certs"
6+
defaultIssuerName: "ocm-certificate-issuer"
7+
18
# This is a YAML-formatted file.
29
# Declare variables to be passed into your templates.
310
registry:
@@ -16,18 +23,24 @@ registry:
1623
value: "/certs/key.pem"
1724
volumeMounts:
1825
- mountPath: "/certs"
19-
name: "ocm-registry-tls-certs"
26+
name: *tlsSecretName
2027
volumes:
21-
- name: "ocm-registry-tls-certs"
28+
- name: *tlsSecretName
2229
secret:
23-
secretName: "ocm-registry-tls-certs"
30+
secretName: *tlsSecretName
2431
items:
2532
- key: "tls.crt"
2633
path: "cert.pem"
2734
- key: "tls.key"
2835
path: "key.pem"
2936
- key: "ca.crt"
3037
path: "ca.pem"
38+
resources:
39+
limits:
40+
memory: 1024Mi
41+
requests:
42+
cpu: 200m
43+
memory: 512Mi
3144
nodeSelector: {}
3245

3346
manager:
@@ -46,16 +59,16 @@ manager:
4659
volumes:
4760
- name: "certificates"
4861
secret:
49-
secretName: "ocm-registry-tls-certs" # must match with ocm-controller's certificate-secret-name argument
62+
secretName: *tlsSecretName # must match with ocm-controller's certificate-secret-name argument
5063
items:
5164
- key: "ca.crt"
5265
path: "registry-root.pem"
5366
resources:
5467
limits:
55-
memory: 2048Mi
56-
requests:
57-
cpu: 300m
5868
memory: 1024Mi
69+
requests:
70+
cpu: 200m
71+
memory: 512Mi
5972
# optional values defined by the user
6073
nodeSelector: {}
6174
tolerations: []

0 commit comments

Comments
 (0)