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 metadata: name: node labels: app: node tier: backend spec: type: LoadBalancer ports: - port: 80 targetPort: 3000 # Replace with the IP of your minikube node / master node externalIPs: - xxx.xxx.xxx.xxx selector: app: node tier: backend
- Your first command created the deployment and POD
- 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