Write Kubernetes yaml file to deploy a sample app (You can use any publicly available app as deployment image) & make sure: a. App is highly available. b. App/Pods can be updated in rollout manner.
Login to Killercode
yaml
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-app
spec:
replicas: 3 # Adjust the number of replicas based on your high availability requirements
selector:
matchLabels:
app: sample-app
template:
metadata:
labels:
app: sample-app
spec:
containers:
- name: sample-app
image: nginx:latest # Replace with your desired publicly available app image
ports:
- containerPort: 80
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
apt-get update
kubectl get nodes
kubectl version
# bash
kubectl apply -f deployment.yaml
This will create the deployment and the necessary pods for your sample app, ensuring high availability and supporting rolling updates.
kubectl get deployments
kubectl get nodes
kubectl describe deployment sample-app
kubectl describe pods
kubectl get pods -l app=sample-app
kubectl describe pod sample-app-587d9c6687-2gk8r
kubectl describe pod sample-app-587d9c6687-7cgft
kubectl describe pod sample-app-587d9c6687-cxz4h
get pod app details
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
minikube start
kubectl get po -A
minikube kubectl -- get po -A
alias kubectl="minikube kubectl --"
minikube dashboard
kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube --type=NodePort --port=8080
*OR(We have deployed two applications named as hello-minikubes & sample-app)*
apiVersion: apps/v1 kind: Deployment metadata: name: sample-app spec: replicas: 3 # Adjust the number of replicas based on your high availability requirements selector: matchLabels: app: sample-app template: metadata: labels: app: sample-app spec: containers: - name: sample-app image: nginx:latest # Replace with your desired publicly available app image ports: - containerPort: 80 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 type: RollingUpdate
- Let’s break each line down…
kubectl apply -f deployment.yaml
kubectl get services
minikube service --all
Validation
minikube pause
minikube unpause
minikube stop
minikube addons list
minikube start -p aged --kubernetes-version=v1.16.1
Delete Deployments - Delete all of the minikube clusters:
****