Today we get test to deploy our first pod
pro and cons of kubernetes
Pro :
- Scalability and Resilience
- Improved Resource Utilization
- Regenerative Capabilities
Cons :
- Complexity and Learning Curve
- Resource Requirements
- Safety and Regulations
Situation :
If shopee on payday they will up pods if traffic increase then decrease back after traffic slow
Create nameserver :
kubectl create ns ammar
Config to create httpd-pod.yaml :
apiVersion: v1
kind: Pod
metadata:
name: httpd
labels:
app: httpd
spec:
containers:
- name: httpd
image: httpd:latest
ports:
- containerPort: 80
creating pod based on config file
kubectl create -f httpd-pod.yaml -n ammar
create service config file , httpd-service.yaml
apiVersion: v1
kind: Service
metadata:
name: httpd-service
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: httpd
Apply service to pod :
kubectl apply -f httpd-service.yaml -n ammar
Run minikube tunnel to check if success expose the port and services :
minikube tunnel
Result :
ammar@LOKI:~/k8s$ kubectl get pods -n ammar --show-labels
NAME READY STATUS RESTARTS AGE LABELS
httpd 1/1 Running 0 10s app=httpd
ammar@LOKI:~/k8s$ kubectl get endpoints httpd-service -n ammar
NAME ENDPOINTS AGE
httpd-service 10.244.0.12:80 9m55s
ammar@LOKI:~/k8s$ curl http://localhost:80
<html><body><h1>It works!</h1></body></html>