Skip to content
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

helm: simplify TLS configuration of clustermesh peers #24222

Merged
merged 2 commits into from
Mar 10, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions install/kubernetes/cilium/templates/cilium-agent/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,27 @@ spec:
{{- end }}
# To read the clustermesh configuration
- name: clustermesh-secrets
secret:
secretName: cilium-clustermesh
projected:
# note: the leading zero means this number is in octal representation: do not remove it
defaultMode: 0400
optional: true
sources:
- secret:
giorio94 marked this conversation as resolved.
Show resolved Hide resolved
name: cilium-clustermesh
optional: true
# note: items are not explicitly listed here, since the entries of this secret
# depend on the peers configured, and that would cause a restart of all agents
# at every addition/removal. Leaving the field empty makes each secret entry
# to be automatically projected into the volume as a file whose name is the key.
- secret:
name: clustermesh-apiserver-remote-cert
optional: true
items:
- key: tls.key
path: common-etcd-client.key
- key: tls.crt
path: common-etcd-client.crt
- key: ca.crt
path: common-etcd-client-ca.crt
{{- if and .Values.ipMasqAgent .Values.ipMasqAgent.enabled }}
- name: ip-masq-agent
configMap:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{{- define "clustermesh-config-generate-etcd-cfg" }}
{{- $cluster := index . 0 -}}
{{- $domain := index . 1 -}}
{{- /* The parenthesis around $cluster.tls are required, since it can be null: https://stackoverflow.com/a/68807258 */}}
{{- $prefix := ternary "common-" (printf "%s." $cluster.name) (or (empty ($cluster.tls).cert) (empty ($cluster.tls).key)) -}}
kaworu marked this conversation as resolved.
Show resolved Hide resolved

endpoints:
{{- if $cluster.ips }}
- https://{{ $cluster.name }}.{{ $domain }}:{{ $cluster.port }}
{{ else }}
{{- else }}
- https://{{ $cluster.address | required "missing clustermesh.apiserver.config.clusters.address" }}:{{ $cluster.port }}
{{- end }}
trusted-ca-file: /var/lib/cilium/clustermesh/{{ $cluster.name }}.etcd-client-ca.crt
key-file: /var/lib/cilium/clustermesh/{{ $cluster.name }}.etcd-client.key
cert-file: /var/lib/cilium/clustermesh/{{ $cluster.name }}.etcd-client.crt
trusted-ca-file: /var/lib/cilium/clustermesh/{{ $prefix }}etcd-client-ca.crt
key-file: /var/lib/cilium/clustermesh/{{ $prefix }}etcd-client.key
cert-file: /var/lib/cilium/clustermesh/{{ $prefix }}etcd-client.crt
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ metadata:
data:
{{- range .Values.clustermesh.config.clusters }}
{{ .name }}: {{ include "clustermesh-config-generate-etcd-cfg" (list . $.Values.clustermesh.config.domain) | b64enc }}
{{ .name }}.etcd-client-ca.crt: {{ $.Values.clustermesh.apiserver.tls.ca.cert }}
{{- /* The parenthesis around .tls are required, since it can be null: https://stackoverflow.com/a/68807258 */}}
{{- if and (.tls).cert (.tls).key }}
kaworu marked this conversation as resolved.
Show resolved Hide resolved
{{ .name }}.etcd-client-ca.crt: {{ .tls.caCert | default $.Values.clustermesh.apiserver.tls.ca.cert }}
{{ .name }}.etcd-client.key: {{ .tls.key }}
{{ .name }}.etcd-client.crt: {{ .tls.cert }}
{{- end }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions install/kubernetes/cilium/values.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions install/kubernetes/cilium/values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2281,9 +2281,12 @@ clustermesh:
# ips:
# - 172.18.255.201
# # -- base64 encoded PEM values for the cluster client certificate, private key and certificate authority.
# # These fields can (and should) be omitted in case the CA is shared across clusters. In that case, the
# # "remote" private key and certificate available in the local cluster are automatically used instead.
# tls:
# cert: ""
# key: ""
# caCert: ""

apiserver:
# -- Clustermesh API server image.
Expand Down