Skip to content

Commit a20b98a

Browse files
Add files via upload
1 parent 648d172 commit a20b98a

17 files changed

+1587
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
*******************************************************************
2+
.
3+
. Demo: POD | Raman Sharma
4+
.
5+
6+
*******************************************************************
7+
8+
# 1. https://labs.play-with-k8s.com/
9+
10+
# nginx-pod.yaml
11+
apiVersion: v1
12+
kind: Pod
13+
metadata:
14+
name: nginx-pod
15+
labels:
16+
app: nginx
17+
tier: dev
18+
spec:
19+
containers:
20+
- name: nginx-container
21+
image: nginx
22+
23+
*******************************************************************
24+
25+
2. Create and display Pods
26+
27+
# Create and display PODs
28+
kubectl create -f nginx-pod.yaml
29+
kubectl get pod
30+
kubectl get pod -o wide
31+
kubectl get pod nginx-pod -o yaml
32+
kubectl describe pod nginx-pod
33+
34+
35+
*******************************************************************
36+
37+
3. Test & Delete
38+
39+
# To get inside the pod
40+
kubectl exec -it nginx-pod -- /bin/sh
41+
42+
# Create test HTML page
43+
cat <<EOF > /usr/share/nginx/html/test.html
44+
<!DOCTYPE html>
45+
<html>
46+
<head>
47+
<title>Testing..</title>
48+
</head>
49+
<body>
50+
<h1 style="color:rgb(90,70,250);">Hello, Kubernetes...!</h1>
51+
<h2>Congratulations, you passed :-) </h2>
52+
</body>
53+
</html>
54+
EOF
55+
exit
56+
57+
# Expose PODS using NodePort service
58+
kubectl expose pod nginx-pod --type=NodePort --port=80
59+
60+
# Display Service and find NodePort
61+
kubectl describe svc nginx-pod
62+
kubectl get svc
63+
# Open Web-browser and access webapge using
64+
http://nodeip:nodeport/test.html
65+
66+
# Delete pod & svc
67+
kubectl delete svc nginx-pod
68+
kubectl delete pod nginx-pod
69+
70+
71+
*******************************************************************
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
2+
*******************************************************************
3+
*
4+
* Demo: Load Balancer Service | Srinath Challa
5+
*
6+
*
7+
*******************************************************************
8+
9+
# 1. YAML: Deployment & Load Balancer Service
10+
11+
# Deployment
12+
# controllers/nginx-deploy.yaml
13+
apiVersion: apps/v1
14+
kind: Deployment
15+
metadata:
16+
name: nginx-deployment
17+
labels:
18+
app: nginx-app
19+
spec:
20+
replicas: 1
21+
selector:
22+
matchLabels:
23+
app: nginx-app
24+
template:
25+
metadata:
26+
labels:
27+
app: nginx-app
28+
spec:
29+
containers:
30+
- name: nginx-container
31+
image: nginx:1.7.9
32+
ports:
33+
- containerPort: 80
34+
35+
------------------------------------
36+
37+
# Service - LoadBalancer
38+
#lb.yaml
39+
apiVersion: v1
40+
kind: Service
41+
metadata:
42+
name: my-service
43+
labels:
44+
app: nginx-app
45+
spec:
46+
selector:
47+
app: nginx-app
48+
type: LoadBalancer
49+
ports:
50+
- nodePort: 31000
51+
port: 80
52+
targetPort: 80
53+
54+
55+
*******************************************************************
56+
2. Create & Display: Deployment & Load Balancer Service
57+
58+
kubectl create �f nginx-deploy.yaml
59+
kubectl create -f lb.yaml
60+
kubectl get pod -l app=nginx-app
61+
kubectl get deploy -l app=nginx-app
62+
kubectl get service -l app=nginx-app
63+
kubectl describe service my-service
64+
65+
*******************************************************************
66+
3. Testing Load Balancer Service
67+
68+
# To get inside the pod
69+
kubectl exec -it [pod-name] -- /bin/sh
70+
71+
# Create test HTML page
72+
cat <<EOF > /usr/share/nginx/html/test.html
73+
<!DOCTYPE html>
74+
<html>
75+
<head>
76+
<title>Testing..</title>
77+
</head>
78+
<body>
79+
<h1 style="color:rgb(90,70,250);">Hello, Kubernetes...!</h1>
80+
<h2>Load Balancer is working successfully. Congratulations, you passed :-) </h2>
81+
</body>
82+
</html>
83+
EOF
84+
exit
85+
86+
# Test using load-balancer-ip
87+
http://load-balancer-ip
88+
http://load-balancer-ip/test.html
89+
90+
# Testing using nodePort
91+
http://nodeip:nodeport
92+
http://nodeip:nodeport/test.html
93+
94+
95+
*******************************************************************
96+
4. Cleanup
97+
98+
kubectl delete �f nginx-deploy.yaml
99+
kubectl delete -f lb.yaml
100+
kubectl get pod
101+
kubectl get deploy
102+
kubectl get service
103+
104+
105+
*******************************************************************
106+
107+

0 commit comments

Comments
 (0)