|
| 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 | + |
| 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 | +******************************************************************* |
0 commit comments