Skip to content

Commit 44a5809

Browse files
committed
Secret-aware pod scheduling (#125)
## Description Fixes #57 This requires pod volume definitions to switch from using the `csi` volume type (which are fully contained within the Kubelet's Pod lifecycle) to the `ephemeral` volume type (which is reified into a full `PersistentVolumeClaim` by the scheduler). For example: ```yaml --- apiVersion: v1 kind: Pod metadata: name: example-secret-consumer spec: volumes: - name: tls csi: driver: secrets.stackable.tech volumeAttributes: secrets.stackable.tech/class: tls secrets.stackable.tech/scope: node,pod,service=secret-consumer-nginx containers: - name: ubuntu image: ubuntu stdin: true tty: true volumeMounts: - name: tls mountPath: /tls ``` should be changed into: ```yaml --- apiVersion: v1 kind: Pod metadata: name: example-secret-consumer spec: volumes: - name: tls ephemeral: volumeClaimTemplate: metadata: annotations: secrets.stackable.tech/class: secret secrets.stackable.tech/scope: node,pod,service=secret-consumer-nginx spec: storageClassName: secrets.stackable.tech accessModes: - ReadWriteOnce resources: requests: storage: "1" containers: - name: ubuntu image: ubuntu stdin: true tty: true volumeMounts: - name: tls mountPath: /tls ``` `csi` volumes still work for now, but won't be able to take advantage of secret-aware scheduling. We will probably want to remove it after all operators and documentation have been migrated.
1 parent 2fc96cb commit 44a5809

30 files changed

+1178
-729
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Pods that consume Node-scoped `k8sSearch` secrets will now only be scheduled to Nodes that have the secret provisioned ([#125]).
10+
- This is only supported for pods that use the new-style `ephemeral` volume definitions rather than `csi`.
11+
12+
### Changed
13+
14+
- Pods that consume secrets should now use the `ephemeral` volume type rather than `csi` ([#125]).
15+
- `csi` volumes will keep working for now, but should be considered deprecated, and will not be compatible
16+
with all new features.
17+
18+
[#125]: https://github.com/stackabletech/secret-operator/pull/125
19+
720
## [0.3.0] - 2022-05-05
821

922
### Added

Cargo.lock

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tiltfile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,26 @@ custom_build(
55
# ignore=['result*', 'Cargo.nix', 'target', *.yaml],
66
outputs_image_ref_to='result/ref',
77
)
8-
k8s_yaml('provisioner.yaml')
9-
k8s_yaml('examples/simple-consumer-nginx.yaml')
8+
9+
# Load the latest CRDs from Nix
1010
watch_file('result')
1111
if os.path.exists('result'):
1212
k8s_yaml('result/crds.yaml')
13+
14+
# Exclude stale CRDs from Helm chart, and apply the rest
15+
helm_crds, helm_non_crds = filter_yaml(
16+
helm(
17+
'deploy/helm/secret-operator',
18+
name='secret-operator',
19+
set=[
20+
'image.repository=docker.stackable.tech/teozkr/secret-provisioner',
21+
],
22+
),
23+
api_version = "^apiextensions\\.k8s\\.io/.*$",
24+
kind = "^CustomResourceDefinition$",
25+
)
26+
k8s_yaml(helm_non_crds)
27+
28+
# Load examples
29+
k8s_yaml('examples/simple-consumer-nginx.yaml')
30+
k8s_yaml('examples/simple-consumer-shell.yaml')

deploy/helm/secret-operator/templates/csidriver.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ spec:
99
fsGroupPolicy: File
1010
volumeLifecycleModes:
1111
- Ephemeral
12+
- Persistent

deploy/helm/secret-operator/templates/daemonset.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,26 @@ spec:
3636
env:
3737
- name: CSI_ENDPOINT
3838
value: /csi/csi.sock
39+
- name: NODE_NAME
40+
valueFrom:
41+
fieldRef:
42+
apiVersion: v1
43+
fieldPath: spec.nodeName
3944
volumeMounts:
4045
- name: csi
4146
mountPath: /csi
4247
- name: mountpoint
4348
mountPath: /var/lib/kubelet/pods
4449
mountPropagation: Bidirectional
50+
- name: external-provisioner
51+
image: k8s.gcr.io/sig-storage/csi-provisioner:v3.1.0
52+
args:
53+
- --csi-address=/csi/csi.sock
54+
- --feature-gates=Topology=true
55+
- --extra-create-metadata
56+
volumeMounts:
57+
- name: csi
58+
mountPath: /csi
4559
- name: node-driver-registrar
4660
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.4.0
4761
args:

deploy/helm/secret-operator/templates/roles.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,40 @@ rules:
88
- ""
99
resources:
1010
- secrets
11+
- events
1112
verbs:
13+
- get
1214
- list
15+
- watch
1316
- create
17+
- apiGroups:
18+
- ""
19+
resources:
20+
- persistentvolumes
21+
verbs:
1422
- get
23+
- list
24+
- watch
25+
- create
26+
- delete
1527
- apiGroups:
1628
- ""
1729
resources:
1830
- nodes
31+
- persistentvolumeclaims
1932
verbs:
2033
- get
34+
- list
35+
- watch
36+
- apiGroups:
37+
- storage.k8s.io
38+
resources:
39+
- csinodes
40+
- storageclasses
41+
verbs:
42+
- get
43+
- list
44+
- watch
2145
- apiGroups:
2246
- ""
2347
resources:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
apiVersion: storage.k8s.io/v1
3+
kind: StorageClass
4+
metadata:
5+
name: secrets.stackable.tech
6+
provisioner: secrets.stackable.tech

deploy/manifests/csidriver.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ spec:
99
fsGroupPolicy: File
1010
volumeLifecycleModes:
1111
- Ephemeral
12+
- Persistent

deploy/manifests/daemonset.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,26 @@ spec:
3131
env:
3232
- name: CSI_ENDPOINT
3333
value: /csi/csi.sock
34+
- name: NODE_NAME
35+
valueFrom:
36+
fieldRef:
37+
apiVersion: v1
38+
fieldPath: spec.nodeName
3439
volumeMounts:
3540
- name: csi
3641
mountPath: /csi
3742
- name: mountpoint
3843
mountPath: /var/lib/kubelet/pods
3944
mountPropagation: Bidirectional
45+
- name: external-provisioner
46+
image: k8s.gcr.io/sig-storage/csi-provisioner:v3.1.0
47+
args:
48+
- --csi-address=/csi/csi.sock
49+
- --feature-gates=Topology=true
50+
- --extra-create-metadata
51+
volumeMounts:
52+
- name: csi
53+
mountPath: /csi
4054
- name: node-driver-registrar
4155
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.4.0
4256
args:

deploy/manifests/roles.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,40 @@ rules:
88
- ""
99
resources:
1010
- secrets
11+
- events
1112
verbs:
13+
- get
1214
- list
15+
- watch
1316
- create
17+
- apiGroups:
18+
- ""
19+
resources:
20+
- persistentvolumes
21+
verbs:
1422
- get
23+
- list
24+
- watch
25+
- create
26+
- delete
1527
- apiGroups:
1628
- ""
1729
resources:
1830
- nodes
31+
- persistentvolumeclaims
1932
verbs:
2033
- get
34+
- list
35+
- watch
36+
- apiGroups:
37+
- storage.k8s.io
38+
resources:
39+
- csinodes
40+
- storageclasses
41+
verbs:
42+
- get
43+
- list
44+
- watch
2145
- apiGroups:
2246
- ""
2347
resources:

0 commit comments

Comments
 (0)