I create both nginx and app service in k8s on port 80, how can I get to the app service



Recently I am learning kubernetes.
I made a k8s cluster and deployed nginx and my app service on it, both nginx and the app service were exposed on port 80, I can only get to nginx default landing page when I try to access the external IP address on port 80, am I doing something wrong and how can I fix that, need help 🤨
I deploy nginx with this commands

kubectl create deployment nginx --image=nginx:1.21.1
kubectl expose deployment nginx --external-ip=$MASTER_IP --port=80 --target-port=80

This is yam file for my service

apiVersion: v1
kind: Service
  name: node
    app: node
    tier: backend
  type: LoadBalancer
    - port: 80
      targetPort: 3000
  # Replace with the IP of your minikube node / master node
    - xxx.xxx.xxx.xxx
    app: node
    tier: backend


  1. Your first command created the deployment and POD
  2. Your second command exposed the deployment on PORT 80.

When you accessed the page on external-ip:port, the request went to pod via the service created at #2. Default page implies that web server is successfully installed and woking.

Answered By – San

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More