0
votes

I have service exposed on the kubernetes cluster, I have an ingress controller routing traffic to the service,but it is returning 503, everything is connected and configured, and the service is working when executed with its external IP, but when connected with the ingress its returning 503 Here is the INGRESS YAML-

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: yucreat-ingress
  annotations:
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - yuccoin.org
    secretName: echo-tls
  rules:
  - host: yuccoin.org
    http:
      paths:
      - backend:
          serviceName: yucdocker1
          servicePort: 80

Working scv YAML-

kind: Service
apiVersion: v1
metadata:
  name: yucdocker1
  namespace: default
  uid: 13bb70c3-8....
  resourceVersion: '3449902'
  creationTimestamp: '2021-05-05T13:55:53Z'
  labels:
    app: yucdocker1
  annotations:
    kubernetes.digitalocean.com/load-balancer-id: e25202f7-8422-4...
  managedFields:
    - manager: kubectl-expose
      operation: Update
      apiVersion: v1
      time: '2021-05-05T13:55:53Z'
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:labels':
            .: {}
            'f:app': {}
        'f:spec':
          'f:externalTrafficPolicy': {}
          'f:ports':
            .: {}
            'k:{"port":8080,"protocol":"TCP"}':
              .: {}
              'f:port': {}
              'f:protocol': {}
              'f:targetPort': {}
          'f:selector':
            .: {}
            'f:app': {}
          'f:sessionAffinity': {}
    - manager: digitalocean-cloud-controller-manager
      operation: Update
      apiVersion: v1
      time: '2021-05-05T13:58:25Z'
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            .: {}
            'f:kubernetes.digitalocean.com/load-balancer-id': {}
    - manager: k8saasapi
      operation: Update
      apiVersion: v1
      time: '2021-05-21T08:24:07Z'
      fieldsType: FieldsV1
      fieldsV1:
        'f:spec':
          'f:type': {}
spec:
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 4500
  selector:
    app: yucdocker1
  clusterIP: 10.245.171.173
  clusterIPs:
    - 10.245.171.173
  type: ClusterIP
  sessionAffinity: None
status:
  loadBalancer: {}

So, I've already tried to change svc from loadBalancer to clusterIP... and nothing worked, any help would be welcome.

1

1 Answers

1
votes

Your ingress is sending traffic to service on port 80:

- backend:
    serviceName: yucdocker1
    servicePort: 80

But your service exposes port 8080 only:

spec:
  ports:
  - protocol: TCP
    port: 8080

The ports have to match for your ingress to work properly.