My External ip in AKS for deployed Nodejs api app not working

80 views Asked by At

I try to deploy simple nodejs API to AKS. API works fine in local docker. I get no errors. AKS that status is running. However browser does not respond. Could someone check yaml and give me some tips?

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodejs
  labels:
    app: nodejs
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nodejs
  template:
    metadata:
      labels:
        app: nodejs
    spec:
      nodeSelector:
        "kubernetes.io/os": linux
      containers:
        - name: nodejs
          image: dileepamabulage/node-app:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 3003
          resources:
            limits:
              cpu: 100m
              memory: 128Mi
            requests:
              cpu: 100m
              memory: 128Mi
---
apiVersion: v1
kind: Service
metadata:
  name: nodejs
  labels:
    app: nodejs
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 3003
      protocol: TCP

my docker file used to build the docker image

FROM node:20

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3003

CMD ["node", "server.js"]

When I try to access the external Ip it fails, are there any port mapping errors?

1

There are 1 answers

0
Suresh Chikkam On

Thanks @arko for your insights, Here I have create a nodeJS application in my local and deployed it to my desktop docker using Dockerfile.

FROM node:20

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3003

CMD ["npm", "start"]

enter image description here

  • Then I have created ACR in azure portal and signed-IN using powershell CLI and pushed by docker image to acr container successfully.

enter image description here

Then created a deployment.yaml file and service.yaml file in my project directory and configured AKS configuration.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test023
  labels:
    app: test023
spec:
  replicas: 3
  selector:
    matchLabels:
      app: test023
  template:
    metadata:
      labels:
        app: test023
    spec:
      nodeSelector:
        "kubernetes.io/os": linux
      containers:
        - name: test023
          image: your-acr.azurecr.io/suresh/nodejs-app:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 3003
          resources:
            limits:
              cpu: 100m
              memory: 128Mi
            requests:
              cpu: 100m
              memory: 128Mi



**service.yaml:**

apiVersion: v1
kind: Service
metadata:
  name: test023
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 3003
      protocol: TCP
  selector:
    app: test023

Status: enter image description here

enter image description here

enter image description here