Skip to content

Commit a98d87a

Browse files
ibottyphlogistonjohn
authored andcommitted
document consuming within the cluster
1 parent 8690a90 commit a98d87a

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

docs/howto.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
99
kind: SmbShare
1010
metadata:
1111
name: myshare
12+
namespace mynamespace
1213
spec:
1314
readOnly: false
1415
storage:
@@ -36,6 +37,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
3637
kind: SmbShare
3738
metadata:
3839
name: myshare
40+
namespace mynamespace
3941
spec:
4042
shareName: "My Great Share"
4143
readOnly: false
@@ -87,6 +89,7 @@ apiVersion: v1
8789
kind: Secret
8890
metadata:
8991
name: users1
92+
namespace mynamespace
9093
type: Opaque
9194
stringData:
9295
demousers: |
@@ -111,6 +114,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
111114
kind: SmbSecurityConfig
112115
metadata:
113116
name: myusers
117+
namespace mynamespace
114118
spec:
115119
mode: user
116120
users:
@@ -122,6 +126,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
122126
kind: SmbShare
123127
metadata:
124128
name: myshare
129+
namespace mynamespace
125130
spec:
126131
securityConfig: myusers
127132
readOnly: false
@@ -153,6 +158,7 @@ apiVersion: v1
153158
kind: Secret
154159
metadata:
155160
name: join1
161+
namespace mynamespace
156162
type: Opaque
157163
stringData:
158164
# Change the value below to match the username and password for a user that
@@ -165,6 +171,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
165171
kind: SmbSecurityConfig
166172
metadata:
167173
name: mydomain
174+
namespace mynamespace
168175
spec:
169176
mode: active-directory
170177
realm: cooldomain.myorg.example.com
@@ -178,6 +185,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
178185
kind: SmbShare
179186
metadata:
180187
name: myshare
188+
namespace mynamespace
181189
spec:
182190
securityConfig: mydomain
183191
readOnly: false
@@ -198,6 +206,98 @@ future. Do note that by separating the credentials in the secret, the password
198206
is never directly accessed by the operator itself.
199207

200208

209+
# Use a cluster internal share as persistent volume (without auto-provisioning)
210+
211+
Kubernetes does not by default support mounting SMB shares. For now
212+
it's neccessary to install the [smb csi
213+
driver](https://github.com/kubernetes-csi/csi-driver-smb). Please refer
214+
to its documentation on how to install the csi driver.
215+
216+
First create a (non provisioning) storage class to differentiate SMB shares
217+
from other storage.
218+
219+
```
220+
apiVersion: storage.k8s.io/v1
221+
kind: StorageClass
222+
metadata:
223+
name: smb
224+
parameters:
225+
type: smb
226+
provisioner: kubernetes.io/no-provisioner
227+
reclaimPolicy: Retain
228+
volumeBindingMode: Immediate
229+
```
230+
231+
When using Active Directory, the username and password to mount the share must match a
232+
username/password pair that exists in your AD. When using pre-defined users &
233+
groups the username/password pair must match one that is defined in the JSON
234+
embedded in the secret associated with your SmbSecurityConfig.
235+
236+
```
237+
apiVersion: v1
238+
kind: Secret
239+
metadata:
240+
name: myshare-mount-creds
241+
namespace mynamespace
242+
type: Opaque
243+
stringData:
244+
username: user1
245+
password: T0Psecre7
246+
```
247+
248+
The following persistent volume will allow mounting the share.
249+
Note the `spec.csi.volumeAttributes.source`: `myshare` is the share's service name, `mynamespace` the namespace the `SmbShare` is in and `My Great Share` is the share's `shareName` as configured or the share's name if not.
250+
251+
```
252+
apiVersion: v1
253+
kind: PersistentVolume
254+
metadata:
255+
name: pv-mynamespace-myshare
256+
spec:
257+
capacity:
258+
storage: 1Gi
259+
accessModes:
260+
- ReadWriteMany
261+
persistentVolumeReclaimPolicy: Retain
262+
mountOptions:
263+
- dir_mode=0777
264+
- file_mode=0777
265+
- vers=3.0
266+
csi:
267+
driver: smb.csi.k8s.io
268+
readOnly: false
269+
volumeHandle: mynamespace-myshare # make sure it's a unique id in the cluster
270+
volumeAttributes:
271+
source: "//myshare.mynamespace/My Great Share"
272+
nodeStageSecretRef:
273+
name: myshare-mount-creds
274+
namespace: mynamespace
275+
claimRef:
276+
apiVersion: v1
277+
kind: PersistentVolumeClaim
278+
name: myshare-smb
279+
namespace: mynamespace
280+
```
281+
282+
Then the volume claim can be created and should bind shorty after to the persistent volume.
283+
```
284+
apiVersion: v1
285+
kind: PersistentVolumeClaim
286+
metadata:
287+
name: myshare-smb
288+
namespace mynamespace
289+
spec:
290+
accessModes:
291+
- ReadWriteMany
292+
resources:
293+
requests:
294+
storage: 1Gi
295+
storageClassName: smb
296+
volumeMode: Filesystem
297+
volumeName: mynamespace-myshare-smb
298+
```
299+
300+
201301
# Create shares that are accessible outside the cluster
202302
203303
Unless you took extra steps on your own, the shares created in the previous
@@ -215,6 +315,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
215315
kind: SmbCommonConfig
216316
metadata:
217317
name: mypublished
318+
namespace mynamespace
218319
spec:
219320
network:
220321
publish: external
@@ -224,6 +325,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
224325
kind: SmbShare
225326
metadata:
226327
name: myshare
328+
namespace mynamespace
227329
spec:
228330
commonConfig: mypublished
229331
readOnly: false
@@ -256,6 +358,7 @@ apiVersion: v1
256358
kind: Secret
257359
metadata:
258360
name: join1
361+
namespace mynamespace
259362
type: Opaque
260363
stringData:
261364
# Change the value below to match the username and password for a user that
@@ -268,6 +371,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
268371
kind: SmbSecurityConfig
269372
metadata:
270373
name: mydomain
374+
namespace mynamespace
271375
spec:
272376
mode: active-directory
273377
realm: cooldomain.myorg.example.com
@@ -283,6 +387,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
283387
kind: SmbCommonConfig
284388
metadata:
285389
name: mypublished
390+
namespace mynamespace
286391
spec:
287392
network:
288393
publish: external
@@ -292,6 +397,7 @@ apiVersion: samba-operator.samba.org/v1alpha1
292397
kind: SmbShare
293398
metadata:
294399
name: myshare
400+
namespace mynamespace
295401
spec:
296402
securityConfig: mydomain
297403
commonConfig: mypublished

0 commit comments

Comments
 (0)