Deployment File – nginx-deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: order-deployment labels: app: orderlabel spec: replicas: 3 selector: matchLabels: app: orderlabel template: metadata: labels: app: orderlabel spec: containers: - name: orderapi image: nginx:1.14.2 ports: - containerPort: 80
Servcie File – service.yaml
apiVersion: v1 kind: Service metadata: name: order-service spec: selector: app: orderlabel type: LoadBalancer ports: - protocol: TCP port: 8083 targetPort: 80
How to execute these files on k8 ?
kubectl get all #display all status cd /to/the/yaml/files/directory/ kubectl apply -f nginx-deployment.yaml kubectl apply -f service.yaml kubectl get all kubectl get pods kubectl get service
How to check if it is working ? – http://localhost:8083/
hit the URL – http://localhost:8083/
How to stop the deployment ?
kubectl scale --replicas=0 deployment.apps/order-deployment kubectl get all #check if no pods exist kubectl delete deploy order-deployment kubectl delete service order-service