forked from Edu-CKA-Jan06/Training_Documents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHostpath.txt
70 lines (52 loc) · 1.45 KB
/
Hostpath.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
*******************************************************************
*******************************************************************
# 1. HostPath YAML file
apiVersion: v1
kind: Pod
metadata:
name: nginx-hostpath
spec:
containers:
- name: nginx-container
image: nginx
volumeMounts:
- mountPath: /test-mnt
name: test-vol
volumes:
- name: test-vol
hostPath:
path: /test-vol
*******************************************************************
# 2. Create and Display HostPath
kubectl create -f nginx-hostpath.yaml
kubectl get po
kubectl exec nginx-hostpath df /test-mnt
*******************************************************************
3. Test: Creating "test" file underlying host dir & accessing from from pod
From HOST:
~~~~~~~~~~
cd /test-vol
echo "From Host" > from-host.txt
cat from-host.txt
From POD:
~~~~~~~~
kubectl exec nginx-hostpath cat /test-mnt/from-host.txt
*******************************************************************
4. Test: Creating "test" file inside the POD & accessing from underlying host dir
From POD:
~~~~~~~~~
kubectl exec nginx-hostpath -it -- /bin/bash
cd /test-mnt
echo "From Pod" > from-pod.txt
cat from-pod.txt
From Host:
~~~~~~~~~~
cd /test-vol
ls
cat from-pod.txt
*******************************************************************
5. Clean up
kubectl delete po nginx-hostpath
kubectl get po
ls /test-vol
*******************************************************************