Cannot access application deployed in Azure ACS Kubernetes Cluster using Azure CICD Pipeline

11/7/2018

I am following this document.

https://github.com/Azure/DevOps-For-AI-Apps/blob/master/Tutorial.md

The CICD pipeline works fine. But I want to validate the application using the external ip that is being deployed to Kubernete cluster.

Deploy.yaml

apiVersion: v1
kind: Pod
metadata:
 name: imageclassificationapp
spec:
 containers:
   - name: model-api
     image: crrq51278013.azurecr.io/model-api:156
     ports:
       - containerPort: 88
 imagePullSecrets:
   - name: imageclassificationappdemosecret

Pod details

C:\Users\nareshkumar_h>kubectl describe pod imageclassificationapp
Name:         imageclassificationapp
Namespace:    default
Node:         aks-nodepool1-97378755-2/10.240.0.5
Start Time:   Mon, 05 Nov 2018 17:10:34 +0530
Labels:       new-label=imageclassification-label
Annotations:  kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"imageclassificationapp","namespace":"default"},"spec":{"containers":[{"image":"crr...
Status:       Running
IP:           10.244.1.87
Containers:
  model-api:
    Container ID:   docker://db8687866d25eb4311175c5ccb5a7205379168c64cdfe716b09557fc98e2bd6a
    Image:          crrq51278013.azurecr.io/model-api:156
    Image ID:       docker-pullable://crrq51278013.azurecr.io/model-api@sha256:766673989a59fe0b1e849469f38acda96853a1d84e4b4d64ffe07810dd5d04e9
    Port:           88/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 05 Nov 2018 17:12:49 +0530
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-qhdjr (ro)
Conditions:
  Type           Status
  Initialized    True
  Ready          True
  PodScheduled   True
Volumes:
  default-token-qhdjr:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-qhdjr
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

Service details:

C:\Users\nareshkumar_h>kubectl describe service imageclassification-service
Name:                     imageclassification-service
Namespace:                default
Labels:                   run=load-balancer-example
Annotations:              <none>
Selector:                 run=load-balancer-example
Type:                     LoadBalancer
IP:                       10.0.24.9
LoadBalancer Ingress:     52.163.191.28
Port:                     <unset>  88/TCP
TargetPort:               88/TCP
NodePort:                 <unset>  32672/TCP
Endpoints:                10.244.1.65:88,10.244.1.88:88,10.244.2.119:88
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

I am hitting the below url but the request times out. http://52.163.191.28:88/

Can some one please help? Please let me know if you need any further details.

-- Naresh
azure
docker
kubernetes

2 Answers

11/22/2018

For your issue, I did a test and it worked in my side. The yaml file here:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
---

apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  type: LoadBalancer
  ports:
  - port: 88
    targetPort: 80
  selector:
    app: nginx

And there are some points should pay attention to.

  1. You should make sure which port the service listen to in the container. For example, in my test, the nginx service listens to port 80 default.
  2. The port that you want to expose in the node should be idle. In other words, the port was not used by other services.
  3. When all the steps have done. You can access the public IP with the port you have exposed in the node.

The screenshots show the result of my test:

enter image description here enter image description here

Hope this will help you!

-- Charles Xu
Source: StackOverflow

12/4/2018

We are able to solve this issue after reconfiguring Kubernetes Service with Right configuration and changing deploy.yaml file as follows -

apiVersion: apps/v1beta1
kind: Deployment 
metadata: 
name: imageclassificationapp 
spec: 
  selector: 
   matchLabels: 
     app: imageclassificationapp 
replicas: 1 # tells deployment to run 2 pods matching the template 
template:
 metadata: 
  labels: 
    app: imageclassificationapp 
spec: 
   containers: 
    - name: model-api 
     image: crrq51278013.azurecr.io/model-api:205
     ports: 
     - containerPort: 88
---
apiVersion: v1
kind: Service   
metadata:   
  name: imageclassificationapp  
spec:   
 type: LoadBalancer 
 ports: 
 - port: 85
 targetPort: 88 
selector:   
 app: imageclassificationapp

We can close this thread now.

-- Parag
Source: StackOverflow