Deploying an Application on Kubernetes

Create a Workload

kubectl create deploy nginx --image=nginx

View the yaml

kubectl get deploy nginx -o yaml

Expose the Service

kubectl expose deploy nginx  --port 80 --target-port=80 --type=NodePort
kubectl patch svc nginx --type='json' --patch='[{"op": "replace", "path": "/spec/ports/0/nodePort", "value":30000}]'

View the yaml

kubectl get service nginx -o yaml

Access the Service

  • Check the service port
kubectl get svc

nginx   NodePort   10.96.241.21   <none>        80:30000/TCP   4m27s
  • Check the host IP
kubectl get node -o wide
  • Access the service

NODE_IP is the IP address of any host.

http://${NODE_IP}:31237

results matching ""

    No results matching ""