Kalai Selvi
Kalai Selvi

Reputation: 399

Unable to launch the web application (asp.net app) in the Azure Kubernetes service (AKS). Getting site is not reachable error

I have tried to host the web application to the AKS (Azure Kubernetes Service).

  1. Create a sample application with docker support(windows container).

    docker file

    FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 ARG source WORKDIR /inetpub/wwwroot COPY ${source:-obj/Docker/publish}

docker-compose details as follow:

version: '3.4'

services:
  akstestapp:
    image: ${DOCKER_REGISTRY-}akstestapp
    build:
      context: .\AKSTestApp
      dockerfile: Dockerfile
  1. I have deployed the application to the Desktop docker container. I could able to deploy and launch the application.

enter image description here

  1. Pushed the image to the Azure content Registry.

enter image description here

  1. Tried to deploy the application to Kubernetes.

    virtualservice.networking.istio.io/aks-test-web-app created deployment.apps/aks-test-web-app created service/aks-test-web-app created

    c:/AKSConfigs>kubectl.exe get service/aks-test-web-app -w

    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE aks-test-web-app LoadBalancer 10.206.4.251 20.253.252.26 80:30614/TCP 4m14s

. 5. when I hit to the launch the application (external IP). I am getting site not reachable error.

  1. deployment yaml file as below.

      apiVersion: apps/v1
         kind: Deployment  
         metadata:  
           name: aks-test-web-app  
           labels:
             app: aks-test-web-app 
         spec:  
           replicas: 1  
           template:  
             metadata:  
               labels:  
                 app: aks-test-web-app   
             spec:  
               nodeSelector:
                 "beta.kubernetes.io/os": windows
               containers:
               - name: aks-test-web-app
                 image: sample.azurecr.io/akstestwebapp:1
                 ports:
                   - containerPort: 80
           selector:
             matchLabels:
               app: aks-test-web-app
         ---  
         apiVersion: v1  
         kind: Service  
         metadata:  
           name: aks-test-web-app   
         spec:  
           type: LoadBalancer  
           ports:  
           - port: 80  
           selector:  
             app: aks-test-web-app
    

and I searched in google and added routing config too.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: aks-test-web-app
spec:
  hosts:
  - "sample.com"
  - "sample.internal"
  gateways:
  - sample
  http:
    - match:
      - uri:
          prefix: /aks-test-webapp
      route:
      - destination:
          host: aks-test-web-app.sample.svc.cluster.local
          port:
            number: 8080

Still, I am facing the site not reachable error. Could you please help me to figure out my mistake?

POD is running

enter image description here

 C:\Users\munirajn> kubectl.exe describe pod aks-test-web-app-84647d8585-ht9wv
Name:             aks-test-web-app-84647d8585-ht9wv
Namespace:        agys-pay
Priority:         0
Service Account:  default
Node:             akspaypgw000000/10.240.132.62
Start Time:       Thu, 15 Dec 2022 15:38:52 +0530
Labels:           app=aks-test-web-app
                  pod-template-hash=84647d8585
Annotations:      <none>
Status:           Running
IP:               10.240.132.63
IPs:
  IP:           10.240.132.63
Controlled By:  ReplicaSet/aks-test-web-app-84647d8585
Containers:
  aks-test-web-app:
    Container ID:   containerd://7cf9d9221ffc011860fde2bbe5f9e226b862a6fc432912c00f475d71d24f29d3
    Image:          sample.azurecr.io/akstestwebapp:1
    Image ID:       sample.azurecr.io/akstestwebapp@sha256:aa70ce0eb14095c198472db68dfd6372f7f6905a593c508da40fdf30b055f899
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Thu, 15 Dec 2022 15:39:00 +0530
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-6bl9z (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  kube-api-access-6bl9z:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              beta.kubernetes.io/os=windows
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

Upvotes: 0

Views: 246

Answers (1)

Swarna Anipindi
Swarna Anipindi

Reputation: 954

Replicated the scenario using below process

Step1: Created a cluster using below code

az aks create --resource-group v-swarna-*****--name democluster --node-count 1 --enable-addons monitoring --generate-ssh-keys

OutPut: enter image description here

enter image description here

Step2: Connect to cluster upon creation by using this command

az aks get-credentials --resource-group v-swarna-*****--name demoCluster

enter image description here

Did slight modifications on deployment yaml file

apiVersion: apps/v1
     kind: Deployment  
     metadata:  
       name: aks-test-web-app  
       labels:
         app: aks-test-web-app 
     spec:  
       replicas: 1  
       selector:
         matchLabels:
           app: aks-test-web-app
       template:  
         metadata:  
           labels:  
             app: aks-test-web-app   
         spec:  
           containers:
           - name: aks-test-web-app
             image: *****.azurecr.io/akstestwebapp:1
             ports:
               - containerPort: 80
     ---  
     apiVersion: v1  
     kind: Service  
     metadata:  
       name: aks-test-web-app   
     spec:  
       type: LoadBalancer  
       ports:  
       - port: 80  
       selector:  
         app: aks-test-web-app

Apply the change on cluster

kubecetl apply -f deployment.yaml

verify the pods or up and running by using below command

kubectl get pods
kubectl get service

verification:

run below command:

kubectl get service

NOTE: Take the public IP [External IP] from the above output Site will be accessible via public ip.

Upvotes: 0

Related Questions