1

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?

Sabo Boz
  • 1,683
  • 4
  • 13
  • 29
  • 1
    to test it do a kubectl get svc and a port forward. kubectl port-forward service/nginx-service 8010:80 if you want to expose that "outside" think about an ingress – jmvcollaborator Aug 20 '22 at 08:28

1 Answers1

1

Since you are using minikube you might need to run minikube service nginx-service --url, this will create a tunnel to the cluster and expose the service.

agotfrid
  • 507
  • 5
  • 7