Health probes are failing after enabling network policy in AKS

Tanul 1,291 Reputation points
2023-07-04T16:20:32.89+00:00

This network policy is causing connection refuse in health probes.. This error is coming

"[http://XX.XX.XX.XX:8080/health/ready]": dial tcp XX.XX.XX.XX:8080: connect: connection refused

Can someone help please.

kind: NetworkPolicy

apiVersion: networking.k8s.io/v1

metadata:

  name: deny-all.policy

  namespace: default 

spec:

  podSelector: {}

  policyTypes:

    - Ingress

    - Egress  

  

---

apiVersion: networking.k8s.io/v1

kind: NetworkPolicy

metadata:

  name: allow.policy

  namespace: default

spec:

  podSelector: {}

  policyTypes:

  - Ingress

  - Egress

  ingress: 

  - from:

    - namespaceSelector:

        matchLabels:

          kubernetes.io/metadata.name: default 

  - from:

    - namespaceSelector:

        matchLabels:

          kubernetes.io/metadata.name: ingress-ns 

    - podSelector:

        matchLabels:

          app.kubernetes.io/name: "test"  

  egress:

  - to:

    - namespaceSelector:

        matchLabels:

          kubernetes.io/metadata.name: default

  - to:

    - namespaceSelector:

        matchLabels:

          kubernetes.io/metadata.name: kube-system

    - podSelector:

        matchLabels:

          k8s-app: kube-dns      

    ports:

    - port: 53

      protocol: UDP

    - port: 53

      protocol: TCP    

    - protocol: TCP

      port: 443

      endPort: 443 

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
{count} votes

1 answer

Sort by: Most helpful
  1. Eddie Neto 1,251 Reputation points Microsoft Employee
    2023-07-04T17:04:47.6+00:00

    Hi @Tanul

    Thanks for reaching Microsoft Q&A

    1. Can you confirm once you created your AKS cluster you have enabled any network policy? If yes, which one was it?
    2. If you did not enable any network policy during the creation of the cluster, the network policy that you are trying to apply above will not work.

    Look forward to hearing from you.


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.