How to access service in AKS

Lê Xuân Hoàng 20 Reputation points
2023-06-09T10:39:36.1833333+00:00

Hello there,

I am a beginner with AKS. I am trying to build a system with a gateway. I want to access the gateway from the internet and have tried adding a LoadBalancer for the Ingress, but it's not working. The files are as follows:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: gateway
  labels:
    app: gateway
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gateway
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 3
  template:
    metadata:
      labels:
        app: gateway
    spec:
      containers:
        - name: gateway
          image: xuanhoangf/gateway:lastest
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: gateway-ingress
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
    nginx.ingress.kubernetes.io/ssl-passthrough: "false"
spec:
  ingressClassName: nginx
  tls:
    - secretName: gateway-certificate
  rules:  
    - host: enkai.id.vn
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: gateway
                port:
                  number: 8000
---
apiVersion: v1
kind: Service
metadata:
  name: gateway-front
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: gateway-ingress
Azure Kubernetes Service
Azure Kubernetes Service
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,456 questions
0 comments No comments
{count} votes

Accepted answer
  1. AirGordon 7,150 Reputation points
    2023-06-09T11:18:40.0833333+00:00

    You've connected the objects SERVICE -> INGRESS -> DEPLOYMENT.
    This is incorrect.

    It should be INGRESS -> SERVICE -> DEPLOYMENT.

    As such it's not the Service that should be of type load balancer, your Ingress controller (Nginix) will already have a Public IP and Load balancer created. Your ingress object is what creates that configuration with the controller.

    You don't require Ingress to expose your service, you can continue to do what you've done with having a type LoadBalancer, but you will need to change the app selector to that of your deployment. SERVICE -> DEPLOYMENT


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.