I am running nginx pod and Loadbalancer service in a minikube on ubuntu 20.4. However, I am unable to open nginx default home page from the browser. I couldn't find any issue from my Yaml files of the output endpoints. Do I need to do anything else to hit my Nginx pod from browser?
Yaml file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
type: LoadBalancer
ports:
- protocol: TCP
port: 8081
nodePort: 30001
targetPort: 8080
kubectl describe svc nginx-service output:
Name: nginx-service
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=nginx
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.105.99.220
IPs: 10.105.99.220
Port: <unset> 8081/TCP
TargetPort: 8080/TCP
NodePort: <unset> 30001/TCP
Endpoints: 172.17.0.3:8080
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
kubectl describe svc nginx-service
|-----------|---------------|-------------|-----------------------------| | NAMESPACE | NAME | TARGET PORT | URL | |-----------|---------------|-------------|-----------------------------| | default | nginx-service | 8081 | http://192.168.99.101:30001 | |-----------|---------------|-------------|-----------------------------|
Curl output
curl http://192.168.99.101:30001
curl: (7) Failed to connect to 192.168.99.101 port 30001: Connection refused
CodePudding user response:
You are using a non-default port(8080) to listen on a nginx container. You should change it to port 80
where nginx by default listen. Alternatively you can change(why?!) the port over which nginx listen as described here.