How to access the service that I have deployed to Azure K8s?

Yuxuan Che 0 Reputation points
2023-08-25T22:28:05.0066667+00:00

I have created a 2 node Kubernetes cluster on Azure.

Then I deploy my service using the following yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-st
  labels:
    app: cloud-test
spec:
  replicas: 3
  selector:
    matchLabels:
      app: cloud-test
  template:
    metadata:
      labels:
        app: cloud-test
    spec:
      containers:
      - name: cloud-test
        image: test:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 3046
---
apiVersion: v1
kind: Service
metadata:
  name: service-st
spec:
  type: ClusterIP
  selector:
    app: cloud-test
  ports:
    - protocol: TCP
      port: 3046
      targetPort: 3046


I am using cluster IP, so I created an ingress for this :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: k8s-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/proxy-body-size: 100m
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /v1(/|$)(.*)
        pathType: Prefix
        backend:
              service:
                name: service-st
                port:
                  number: 3046

it seems they are working:

Screenshot 2023-08-25 at 15.26.39

i also chekc this box :

Screenshot 2023-08-25 at 15.27.39

Now, if I access the address of the nginx in services (External Ip), i get 404 from nginx. Also,if i access ip/v1 , get 404 again.

Am I missing anything here?

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,365 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AirGordon 7,145 Reputation points
    2023-08-26T05:24:28.7333333+00:00

    I think you have a misconfiguration. Your screengrab shows that your using a Azure Application Gateway Ingress Controller. However your ingress manifest is targeting nginx.

    Try deploying an application with a known good configuration for Azure Application Gateway Ingress. Once you see it working, modify for your app.

    Here's my go-to manifest for AGIC: https://github.com/Gordonby/Snippets/blob/master/AKS/Agic-simple.yml


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.