Skip to content

Commit e35bbc8

Browse files
authored
Added etcd encryption support (#559)
* added etcd encryption support * now fails if encryption on but keys undefined * fixed whitespace * etcd keys now generated by hooks per cluster * fixed service account not existing pre-install * now enabled by default and hooks conditional on encryption * renames + added default for CI * rename * typo * allowed CI linting * using default service account + keeps for debugging * removed keeps * debug * removed hook, now depends on capi-operator secret * etcd encryption now off by default
1 parent b7d2e21 commit e35bbc8

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,57 @@ mounts:
6969
{{- end }}
7070
{{- end }}
7171

72+
{{- define "openstack-cluster.controlplane.kubeadmConfigSpec.etcdEncryption" -}}
73+
{{- if .Values.etcd.encryption.enabled }}
74+
preKubeadmCommands:
75+
- mkdir -p /etc/kubernetes/enc
76+
- mkdir -p /etc/kubernetes/patches
77+
initConfiguration:
78+
patches:
79+
directory: /etc/kubernetes/patches
80+
joinConfiguration:
81+
patches:
82+
directory: /etc/kubernetes/patches
83+
clusterConfiguration:
84+
apiServer:
85+
extraArgs:
86+
encryption-provider-config: /etc/kubernetes/enc/enc.yaml
87+
files:
88+
- path: /etc/kubernetes/patches/kube-apiserver1+strategic.yaml
89+
permissions: "0644"
90+
owner: root:root
91+
content: |
92+
spec:
93+
containers:
94+
- name: kube-apiserver
95+
volumeMounts:
96+
- mountPath: /etc/kubernetes/enc
97+
name: kube-enc
98+
readOnly: true
99+
volumes:
100+
- hostPath:
101+
path: /etc/kubernetes/enc
102+
type: DirectoryOrCreate
103+
name: kube-enc
104+
- path: /etc/kubernetes/enc/enc.yaml
105+
content: |
106+
apiVersion: apiserver.config.k8s.io/v1
107+
kind: EncryptionConfiguration
108+
resources:
109+
- resources:
110+
{{- .Values.etcd.encryption.resources | toYaml | nindent 10 }}
111+
providers:
112+
- {{ .Values.etcd.encryption.provider }}:
113+
keys:
114+
- name: key1
115+
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (print .Release.Name "-etcd-key")) -}}
116+
secret: {{ $secret.data.key }}
117+
- identity: {} # fallback to allow reading unencrypted secrets e.g during initial migration
118+
owner: root:root
119+
permissions: "0644"
120+
{{- end }}
121+
{{- end -}}
122+
72123
{{/*
73124
NOTE(mkjpryor)
74125
When Cilium is enabled with the kube-proxy replacement, we need to skip kube-proxy
@@ -146,6 +197,7 @@ spec:
146197
(include "openstack-cluster.controlplane.kubeadmConfigSpec.nodeLabels" . | fromYaml)
147198
(include "openstack-cluster.controlplane.kubeadmConfigSpec.oidc" . | fromYaml)
148199
(include "openstack-cluster.controlplane.kubeadmConfigSpec.etcd" . | fromYaml)
200+
(include "openstack-cluster.controlplane.kubeadmConfigSpec.etcdEncryption" . | fromYaml)
149201
(include "openstack-cluster.controlplane.kubeadmConfigSpec.cilium" . | fromYaml)
150202
(include "openstack-cluster.controlplane.kubeadmConfigSpec.admissionConfigFile" . | fromYaml)
151203
(include "openstack-cluster.kubeadmConfigSpec" (list . .Values.controlPlane.kubeadmConfigSpec) | fromYaml)

charts/openstack-cluster/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ etcd:
151151
quota-backend-bytes: "4294967296"
152152
# Listen for metrics on 0.0.0.0 so Prometheus can collect them
153153
listen-metrics-urls: http://0.0.0.0:2381
154+
# At-rest encryption settings
155+
encryption:
156+
enabled: false
157+
# K8s resources to encrypt
158+
resources:
159+
- secrets
160+
# Encyption provider, see https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/#providers
161+
provider: secretbox
154162
# The block device configuration for etcd
155163
# If not specified, the root device is used
156164
blockDevice:

0 commit comments

Comments
 (0)