Skip to content

Commit 9d4e55e

Browse files
synaretemergify[bot]
authored andcommitted
docs: openshift+crc howto
CRC allows developers to install minimal OpenShift4 cluster on their local host machine for testing. Provide minimal how-to documentations on how to setup cluster with crc, deploy samba-operator with live share, and test it using sambe toolbox. Signed-off-by: Shachar Sharon <[email protected]>
1 parent 70df8a1 commit 9d4e55e

File tree

1 file changed

+267
-0
lines changed

1 file changed

+267
-0
lines changed

docs/howto-openshift-crc.md

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
# Deploy samba-operator over OpenShift-CRC
2+
3+
The following document describe how to deploy samba-operator and create
4+
SMB shares over OpenShift Container Platform 4 using
5+
[crc](https://crc.dev/crc/). This mode of operation is mainly targeted
6+
at running on developers' Linux desktops and requires
7+
[minimal system resources](https://crc.dev/crc/#minimum-system-requirements-hardware_gsg).
8+
It also requires virtualization enabled on your local machine.
9+
10+
The instructions in this document were tested with the following
11+
settings:
12+
13+
```sh
14+
$ uname -msr
15+
Linux 6.1.18-100.fc36.x86_64 x86_64
16+
$ crc version
17+
CRC version: 2.15.0+cc05160
18+
OpenShift version: 4.12.5
19+
Podman version: 4.3.1
20+
$ qemu-kvm --version
21+
QEMU emulator version 6.2.0 (qemu-6.2.0-17.fc36)
22+
```
23+
24+
## Setup OpenShift CRC cluster
25+
Download openshift's crc to your local Linux machine using the
26+
[crc installing instructions](https://crc.dev/crc/#installing_gsg), and
27+
place the `crc` executable within your `PATH`. Ensure that you have a
28+
valid installation by [setting up crc](https://crc.dev/crc/#setting-up_gsg):
29+
30+
```sh
31+
$ crc version
32+
$ crc config view
33+
$ crc setup
34+
```
35+
36+
Make sure that you have an updated pull-secret stored within a local
37+
file (`pull-secret.txt`), and then start a new crc instance with the
38+
following command (may take few minutes):
39+
40+
```sh
41+
$ crc start -p ./pull-secret.txt
42+
```
43+
44+
Upon successful deployment, you should see information on how to access
45+
your cluster, similar to the following example:
46+
47+
```sh
48+
Started the OpenShift cluster.
49+
50+
The server is accessible via web console at:
51+
https://console-openshift-console.apps-crc.testing
52+
53+
Log in as administrator:
54+
Username: kubeadmin
55+
Password: Y7Dgu-IpHcX-N48UJ-ztphn
56+
57+
Log in as user:
58+
Username: developer
59+
Password: developer
60+
61+
Use the 'oc' command line interface:
62+
$ eval $(crc oc-env)
63+
$ oc login -u developer https://api.crc.testing:6443
64+
65+
```
66+
67+
Use the `oc` command line utility to ensure cluster's pods are alive
68+
and running:
69+
70+
```sh
71+
$ eval $(crc oc-env)
72+
$ export KUBECTL_CMD=oc
73+
$ $KUBECTL_CMD get pods -A
74+
```
75+
76+
Note that some pods (e.g., `redhat-operators` and `redhat-marketplace`)
77+
may be in `ImagePullBackOff` status, which is fine in the context of
78+
this howto document.
79+
80+
When done with the cluster, you may terminate its resources with:
81+
82+
```sh
83+
$ crc stop
84+
...
85+
$ crc delete
86+
...
87+
```
88+
89+
## Setup OpenShift samba-SCC
90+
Samba operator uses a custom
91+
[security-context-constraints](https://docs.openshift.com/container-platform/4.12/authentication/managing-security-context-constraints.html)
92+
(SCC) for its pods and containers. Before deploying the samba operator,
93+
the user should setup the `samba` SCC on the cluster. In order to
94+
deploy samba SCC manually, execute the following commands:
95+
96+
```sh
97+
$ cd samba-operator-dir
98+
$ export KUBECTL_CMD=oc
99+
$ $KUBECTL_CMD create -f config/openshift/scc.yaml
100+
securitycontextconstraints.security.openshift.io/samba created
101+
$KUBECTL_CMD get scc/samba -o yaml
102+
...
103+
```
104+
105+
## Deploy samba-operator
106+
Enable developer mode and deploy the samba-operator using the top-level
107+
Makefile target `make-deploy`. Wait for the `samba-operator` pod to be in
108+
`Running` state:
109+
110+
```sh
111+
$ cd samba-operator-dir
112+
$ export KUBECTL_CMD=oc
113+
$ echo DEVELOPER=1 >> devel.mk
114+
$ make deploy
115+
...
116+
$ $KUBECTL_CMD get pods -n samba-operator-system
117+
NAME READY STATUS RESTARTS AGE
118+
samba-operator-controller-manager-7c877459d4-wln54 2/2 Running 0 27s
119+
```
120+
121+
## Create samba share
122+
Use the `smbtest.yaml` file below to simple SMB share. Wait for the share pod
123+
to be in `Running` state (may take some time):
124+
125+
```sh
126+
$ export KUBECTL_CMD=oc
127+
$ $KUBECTL_CMD create -f smbtest.yaml
128+
...
129+
$ $KUBECTL_CMD get pods -n smbtest
130+
NAME READY STATUS RESTARTS AGE
131+
share1-5f7dbd45bc-bljrv 2/2 Running 0 4m23s
132+
```
133+
134+
135+
```yaml
136+
---
137+
apiVersion: v1
138+
kind: Namespace
139+
metadata:
140+
name: smbtest
141+
---
142+
apiVersion: v1
143+
kind: PersistentVolume
144+
metadata:
145+
name: smb-pv
146+
labels:
147+
type: local
148+
spec:
149+
storageClassName: manual
150+
capacity:
151+
storage: 8Gi
152+
accessModes:
153+
- ReadWriteOnce
154+
hostPath:
155+
path: "/mnt/export"
156+
---
157+
apiVersion: v1
158+
kind: PersistentVolumeClaim
159+
metadata:
160+
name: smb-pvc
161+
namespace: smbtest
162+
spec:
163+
storageClassName: manual
164+
accessModes:
165+
- ReadWriteOnce
166+
resources:
167+
requests:
168+
storage: 4Gi
169+
---
170+
apiVersion: v1
171+
kind: Secret
172+
metadata:
173+
name: users
174+
namespace: smbtest
175+
type: Opaque
176+
stringData:
177+
demousers: |
178+
{
179+
"samba-container-config": "v0",
180+
"users": {
181+
"all_entries": [
182+
{
183+
"name": "user1",
184+
"password": "123456"
185+
},
186+
{
187+
"name": "user2",
188+
"password": "123456"
189+
}
190+
]
191+
}
192+
}
193+
---
194+
apiVersion: samba-operator.samba.org/v1alpha1
195+
kind: SmbSecurityConfig
196+
metadata:
197+
name: users
198+
namespace: smbtest
199+
spec:
200+
mode: user
201+
users:
202+
secret: users
203+
key: demousers
204+
---
205+
apiVersion: samba-operator.samba.org/v1alpha1
206+
kind: SmbCommonConfig
207+
metadata:
208+
name: config
209+
namespace: smbtest
210+
spec:
211+
network:
212+
publish: cluster
213+
---
214+
apiVersion: samba-operator.samba.org/v1alpha1
215+
kind: SmbShare
216+
metadata:
217+
name: share1
218+
namespace: smbtest
219+
spec:
220+
securityConfig: users
221+
readOnly: false
222+
storage:
223+
pvc:
224+
name: "smb-pvc"
225+
```
226+
227+
## Test samba share using smbtoolbox
228+
Deploy smbtoolbox using the following configuration:
229+
230+
```yaml
231+
---
232+
apiVersion: v1
233+
kind: Pod
234+
metadata:
235+
namespace: smbtest
236+
name: smbtoolbox
237+
annotations:
238+
openshift.io/scc: samba
239+
spec:
240+
automountServiceAccountToken: true
241+
containers:
242+
- name: smbtoolbox
243+
image: quay.io/samba.org/samba-toolbox:latest
244+
command: ["sleep"]
245+
args: ["100000"]
246+
```
247+
248+
```sh
249+
$ export KUBECTL_CMD=oc
250+
$ $KUBECTL_CMD create -f smbtoolbox.yaml
251+
...
252+
$ $KUBECTL_CMD get pods -n smbtest
253+
NAME READY STATUS RESTARTS AGE
254+
share1-5f7dbd45bc-bljrv 2/2 Running 0 21m
255+
smbtoolbox 1/1 Running 0 9m25s
256+
```
257+
258+
Use the following shell commands and smbclient to test your smbshare:
259+
260+
```sh
261+
$ SHARE1_POD="$($KUBECTL_CMD get pods -n smbtest -l samba-operator.samba.org/service=share1 --template '{{(index .items 0).metadata.name}}')"
262+
$ SHARE1_POD_IP=$($KUBECTL_CMD get pod $SHARE1_POD -n smbtest --template '{{.status.podIP}}')
263+
$ $KUBECTL_CMD exec -it smbtoolbox -n smbtest -- smbclient -p 445 -U user1%123456 //$SHARE1_POD_IP/share1
264+
smb: \>
265+
...
266+
267+
```

0 commit comments

Comments
 (0)