Service deployed in Kubernetes is working only via Proxy??? Not able to consume exposed endpoint

9/24/2018

I have deployed java API in ACR and pushed to Kubernetes. I am able to post the data to the service when I use a proxy. but the same service is not working using exposed endpoint. PFB corresponding Kubernetes YAML file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: taxservice-deployment
  labels:
    app: taxserviceapi
spec:
  replicas: 1
  template:
    metadata:
      name: taxserviceapi
      labels:
        app: taxserviceapi
    spec:
      containers:
      - name: taxserviceapi
        image : 3poacr.azurecr.io/3potaxservice:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
      restartPolicy: Always
      imagePullSecrets:
      - name: regcret5
  selector:
   matchLabels:
    app: taxserviceapi
---
apiVersion: v1
kind: Service
metadata:
  name: taxservice-service
spec:
  type: NodePort
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: taxserviceapi
  externalTrafficPolicy: Local
-- Girish
azure-aks
azure-kubernetes
kubernetes

2 Answers

9/24/2018

Change your service type to LoadBalancer. You can then check the exposed port by describing the service:

kubectl describe svc taxservice-service
-- rishabh.bhardwaj
Source: StackOverflow

9/24/2018

In your service definition, you need to replace spec.type from NodePort to e.g., LoadBalancer.

See more information here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types

-- samhain1138
Source: StackOverflow