-
Notifications
You must be signed in to change notification settings - Fork 56
/
4.+Pods.txt
74 lines (56 loc) · 1.5 KB
/
4.+Pods.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
*******************************************************************
# 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
# Display Service and find NodePort
kubectl describe svc nginx-pod
# Open Web-browser and access webapge using
http://<external-nodeip>:<nodeport>/test.html
#eg.: http://13.233.174.93:31424/test.html
575 - 1
908 - 1
# Delete pod & svc
kubectl delete svc nginx-pod
kubectl delete pod nginx-pod
*******************************************************************
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