In kubernetes (I am using minikube) I have deployed the following deployment using kubectl apply -f nginx-deployment
:
# nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
I get deployment.apps/nginx-deployment created
as an output, and when I run kubectl get deployment
I get:
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-deployment 3/3 3 3 22s
I have also deployed the following service file using kubectl apply -f nginx-service.yml
command
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
selector:
app: nginx
ports:
- name: "http"
port: 80
targetPort: 80
nodePort: 30080
The output is service/nginx-service created
and the output of kubectl get service
is:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 127d
nginx-service NodePort 10.99.253.196 <none> 80:30080/TCP 75s
However, when I try to access the app by entering 10.99.253.196
into the browser, it doesn't load and when I try localhost:30080 it says Unable to connect
. Could someone help me to understand why this is happening/provide further directions for troubleshooting?