forked from Edu-CKA-Jan06/Training_Documents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPods_demo.txt
79 lines (57 loc) · 1.47 KB
/
Pods_demo.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
71
72
73
74
75
76
77
78
79
*******************************************************************
# 1.
# nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
tier: dev
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 80
*******************************************************************
2. Create and display Pods
# Create and display PODs
kubectl create -f nginx-pod.yaml
kubectl get pod
kubectl get pod -o wide
kubectl get pod nginx-pod -o yaml
kubectl describe pod nginx-pod
*******************************************************************
3. Test & Delete
# To get inside the pod
kubectl exec -it nginx-pod -- /bin/sh
# Create test HTML page
cat <<EOF > /usr/share/nginx/html/test.html
<!DOCTYPE html>
<html>
<head>
<title>Testing..</title>
</head>
<body>
<h1 style="color:rgb(90,70,250);">Hello, Everyone...!</h1>
<h2>Welcome to Kubernetes Demo :-) </h2>
</body>
</html>
EOF
exit
# Expose PODS using NodePort service
kubectl expose pod nginx-pod --type=NodePort --port=80
-p <host_port>:<container_port>
kubectl get svc
# Display Service and find NodePort
kubectl describe svc nginx-pod
# Open Web-browser and access webapge using
http://<external-nodeip>:<nodeport>/test.html
13.127.235.18:32289
#eg.: http://43.204.100.215:32707/test.html
43.204.100.215:32707/test.html
# Delete pod & svc
kubectl delete svc nginx-pod
kubectl delete pod nginx-pod
*******************************************************************