-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcerts.yaml
155 lines (155 loc) · 4.94 KB
/
certs.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{{- if .Capabilities.APIVersions.Has "cert-manager.io/v1" }}
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: {{ include "github-actions-runner.fullname" . }}-issuer
labels:
{{- include "github-actions-runner.labels" . | nindent 4 }}
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "github-actions-runner.fullname" . }}
labels:
{{- include "github-actions-runner.labels" . | nindent 4 }}
spec:
secretName: {{ include "github-actions-runner.fullname" . }}-ca
secretTemplate:
labels:
{{- include "github-actions-runner.labels" . | nindent 6 }}
issuerRef:
name: {{ include "github-actions-runner.fullname" . }}-issuer
kind: Issuer
commonName: {{ include "github-actions-runner.fullname" . }}
duration: 26280h # 3y
renewBefore: 26000h # ~3y
privateKey:
algorithm: ECDSA
size: 256
usages:
- server auth
- client auth
- crl sign
isCA: true
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: {{ include "github-actions-runner.fullname" . }}-ca-issuer
labels:
{{- include "github-actions-runner.labels" . | nindent 4 }}
spec:
ca:
secretName: {{ include "github-actions-runner.fullname" . }}-ca
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "github-actions-runner.fullname" . }}-server
labels:
{{- include "github-actions-runner.labels" . | nindent 4 }}
spec:
secretName: {{ include "github-actions-runner.fullname" . }}-server-tls
secretTemplate:
labels:
{{- include "github-actions-runner.labels" . | nindent 6 }}
commonName: {{ include "github-actions-runner.fullname" . }}-server
duration: 26280h # 3y
renewBefore: 8760h # 1y
privateKey:
algorithm: ECDSA
size: 256
usages:
- digital signature
- server auth
- client auth
isCA: false
ipAddresses:
- 127.0.0.1
dnsNames:
- {{ include "github-actions-runner.fullname" . }}
- {{ include "github-actions-runner.fullname" . }}-mirrors.{{ .Release.Namespace }}.svc
- {{ include "github-actions-runner.fullname" . }}-registry.{{ .Release.Namespace }}.svc
{{- range $inx, $val := .Values.registry.ingress.hosts }}
- {{ $val.host }}
{{- end }}
issuerRef:
name: {{ include "github-actions-runner.fullname" . }}-ca-issuer
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "github-actions-runner.fullname" . }}-client
labels:
{{- include "github-actions-runner.labels" . | nindent 4 }}
spec:
secretName: {{ include "github-actions-runner.fullname" . }}-client-tls
secretTemplate:
labels:
{{- include "github-actions-runner.labels" . | nindent 6 }}
commonName: {{ include "github-actions-runner.fullname" . }}
duration: 8760h # 1y
renewBefore: 2190h # 3m
privateKey:
algorithm: ECDSA
size: 256
usages:
- digital signature
- client auth
isCA: false
ipAddresses:
- 127.0.0.1
dnsNames:
- {{ include "github-actions-runner.fullname" . }}
issuerRef:
name: {{ include "github-actions-runner.fullname" . }}-ca-issuer
{{- else }}
---
{{- $ca := genCA (include "github-actions-runner.fullname" .) 3650 }}
{{- $host := printf "%s-mirrors" (include "github-actions-runner.fullname" .) }}
{{- $domain := printf "%s-mirrors.%s.svc" (include "github-actions-runner.fullname" .) .Release.Namespace }}
{{- $server := genSignedCert $host nil (list $host $domain) 3650 $ca }}
{{- $domainReg := printf "%s-registry.%s.svc" (include "github-actions-runner.fullname" .) .Release.Namespace }}
{{- $registry := genSignedCert $host nil (list $domainReg) 3650 $ca }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "github-actions-runner.fullname" . }}-server-tls
labels:
{{- include "github-actions-runner.labels" . | nindent 4 }}
type: Opaque
data:
{{- $serverName := printf "%s-server-tls" (include "github-actions-runner.fullname" .) }}
{{- $serverData := (lookup "v1" "Secret" .Release.Namespace $serverName).data }}
{{- if and $serverData (hasKey $serverData "ca.crt") }}
ca.crt: {{ get $serverData "ca.crt" }}
tls.crt: {{ get $serverData "tls.crt" }}
tls.key: {{ get $serverData "tls.key" }}
{{- else }}
ca.crt: {{ $ca.Cert | b64enc }}
tls.crt: {{ $server.Cert | b64enc }}
tls.key: {{ $server.Key | b64enc }}
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "github-actions-runner.fullname" . }}-client-tls
labels:
{{- include "github-actions-runner.labels" . | nindent 4 }}
type: Opaque
data:
{{- $clientName := printf "%s-client-tls" (include "github-actions-runner.fullname" .) }}
{{- $clientData := (lookup "v1" "Secret" .Release.Namespace $clientName).data }}
{{- if and $clientName (hasKey $clientData "ca.crt") }}
ca.crt: {{ get $clientData "ca.crt" }}
tls.crt: {{ get $clientData "tls.crt" }}
tls.key: {{ get $clientData "tls.key" }}
{{- else }}
ca.crt: {{ $ca.Cert | b64enc }}
tls.crt: {{ $registry.Cert | b64enc }}
tls.key: {{ $registry.Key | b64enc }}
{{- end }}
{{- end }}