Skip to content

Commit 10fac2e

Browse files
feat(ws): add spec.podTemplate.volumes.secrets[] to Workspace (#240)
Signed-off-by: Mathew Wicks <[email protected]>
1 parent fd7a3d8 commit 10fac2e

File tree

7 files changed

+203
-20
lines changed

7 files changed

+203
-20
lines changed

workspaces/controller/api/v1beta1/workspace_types.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ type WorkspacePodVolumes struct {
9898
// +listType:="map"
9999
// +listMapKey:="mountPath"
100100
Data []PodVolumeMount `json:"data,omitempty"`
101+
102+
// secrets to mount
103+
// - these secrets must already exist in the Namespace
104+
// - secrets are mounted as folders with the secret keys as files
105+
// +kubebuilder:validation:Optional
106+
// +listType:="map"
107+
// +listMapKey:="mountPath"
108+
Secrets []PodSecretMount `json:"secrets,omitempty"`
101109
}
102110

103111
type PodVolumeMount struct {
@@ -121,6 +129,33 @@ type PodVolumeMount struct {
121129
ReadOnly *bool `json:"readOnly,omitempty"`
122130
}
123131

132+
type PodSecretMount struct {
133+
// the name of the Secret to mount
134+
// +kubebuilder:validation:MinLength:=2
135+
// +kubebuilder:validation:MaxLength:=63
136+
// +kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
137+
// +kubebuilder:example="my-secret"
138+
SecretName string `json:"secretName"`
139+
140+
// the mount path for the Secret
141+
// +kubebuilder:validation:MinLength:=2
142+
// +kubebuilder:validation:MaxLength:=4096
143+
// +kubebuilder:validation:Pattern:=^/[^/].*$
144+
// +kubebuilder:example="/secrets/my-secret"
145+
MountPath string `json:"mountPath"`
146+
147+
// default mode bits used to set permissions on files in the Secret
148+
// - must be a decimal value between 0 and 511, or an octal value between 0000 and 0777
149+
// - for example, 420 is equivalent to 0644, and 511 is equivalent to 0777
150+
// - YAML accepts both octal and decimal values, JSON requires decimal
151+
// - Defaults to 420 (octal: 0644) if not specified.
152+
// +kubebuilder:validation:Optional
153+
// +kubebuilder:validation:Minimum:=0
154+
// +kubebuilder:validation:Maximum:=511
155+
// +kubebuilder:default=420
156+
DefaultMode int32 `json:"defaultMode,omitempty"`
157+
}
158+
124159
type WorkspacePodOptions struct {
125160
// the id of an imageConfig option
126161
// - options are defined in WorkspaceKind under

workspaces/controller/api/v1beta1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workspaces/controller/config/crd/bases/kubeflow.org_workspaces.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,47 @@ spec:
156156
minLength: 2
157157
pattern: ^[a-z0-9][-a-z0-9]*[a-z0-9]$
158158
type: string
159+
secrets:
160+
description: |-
161+
secrets to mount
162+
- these secrets must already exist in the Namespace
163+
- secrets are mounted as folders with the secret keys as files
164+
items:
165+
properties:
166+
defaultMode:
167+
default: 420
168+
description: |-
169+
default mode bits used to set permissions on files in the Secret
170+
- must be a decimal value between 0 and 511, or an octal value between 0000 and 0777
171+
- for example, 420 is equivalent to 0644, and 511 is equivalent to 0777
172+
- YAML accepts both octal and decimal values, JSON requires decimal
173+
- Defaults to 420 (octal: 0644) if not specified.
174+
format: int32
175+
maximum: 511
176+
minimum: 0
177+
type: integer
178+
mountPath:
179+
description: the mount path for the Secret
180+
example: /secrets/my-secret
181+
maxLength: 4096
182+
minLength: 2
183+
pattern: ^/[^/].*$
184+
type: string
185+
secretName:
186+
description: the name of the Secret to mount
187+
example: my-secret
188+
maxLength: 63
189+
minLength: 2
190+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
191+
type: string
192+
required:
193+
- mountPath
194+
- secretName
195+
type: object
196+
type: array
197+
x-kubernetes-list-map-keys:
198+
- mountPath
199+
x-kubernetes-list-type: map
159200
type: object
160201
required:
161202
- options
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
resources:
22
- workspace_data_pvc.yaml
33
- workspace_home_pvc.yaml
4+
- workspace_secret.yaml
45
- workspace_service_account.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: workspace-secret
5+
type: Opaque
6+
data:
7+
key1: dmFsdWUx
8+
key2: dmFsdWUy

workspaces/controller/config/samples/jupyterlab_v1beta1_workspace.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ spec:
5454
mountPath: "/data/my-data"
5555
readOnly: false
5656

57+
## secrets to mount
58+
## - the secret must already exist in the Namespace
59+
## - secrets are mounted as folders with the secret keys as files
60+
##
61+
secrets:
62+
- secretName: "workspace-secret"
63+
mountPath: "/secrets/my-secret"
64+
defaultMode: 420 # same as 0644 in octal
65+
5766
## the selected podTemplate options
5867
## - these are the user-selected options from the Workspace Spawner UI
5968
## which determine the PodSpec of the Workspace Pod

0 commit comments

Comments
 (0)