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

7/15/2021

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: ****
-- megha
azure-aks
kubectl
kubernetes

2 Answers

7/26/2021

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

-- Ram-msft
Source: StackOverflow

4/21/2022

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
-- arun
Source: StackOverflow