Azure Kubernetes Nodeport

3/18/2021

Does NodePort service work in azure kubernetes ?

My use case is , I'm trying to deploy 3 Nodes (3 VMs) , such that every node has a pod which runs an nginx container, using daemonsets. So 3 nodes -> 3 pods -> 3 docker nginx containers running basic welcome to nginx page.

Now to expose the service, I use load balancer and get a public IP which runs any of the three pods and when i do http://<loadbalancerip> ----> it displays welcome to nginx page using one of the pods.

Now i want to deploy NodePort, so that i can view my nginx page using http://<nodeIP>:nodeport

I'm not able to access this using node public IP and i'm using azure kubernetes service.

What to do next

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-deployment
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30007
  selector:
    app: nginx
-- jhanvi shah
azure
azure-aks
kubernetes
kubernetes-pod
nginx

0 Answers