'AKS error - Unable to connect to the server: x509: certificate signed by unknown authority

I have docker desktop and kubectl installed , I am trying to connect to cluster from my local pc and getting above error here is my kubeconfig file

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: ****
  name: AKS-CLUSTER
contexts:
- context:
    cluster: AKS-CLUSTER
    user: clusterUser_D-AKS_AKS-CLUSTER
  name: AKS-CLUSTER
current-context: AKS-CLUSTER
kind: Config
preferences: {}
users:
- name: clusterUser_D-AKS_AKS-CLUSTER
  user:
    client-certificate-data: ****
    client-key-data: ****
    token: ****


Solution 1:[1]

This article details some common problems and troubleshooting steps: https://docs.microsoft.com/en-us/azure/aks/troubleshooting

Solution 2:[2]

One reason for this is the AKS cluster certificate getting rotated. See https://docs.microsoft.com/en-us/azure/aks/certificate-rotation.

As outlined there, run:

az aks get-credentials -g <RESOURCE_GROUP_NAME> -n <CLUSTER_NAME> --overwrite-existing

and see if it gives you an output like:

Merged "<CLUSTER_NAME>" as current context in /home/<USER>/.kube/config

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ram-msft
Solution 2