Search code examples
azurekuberneteskubectl

Azure Kubernetes - No connection to Server


when I execute the following PowerShell command:

.\kubectl get nodes

I get no nodes in response. I noticed that the config file from kubectl is empty too:

apiVersion: v1
clusters:
- cluster:
    server: ""
  name: cl-kubernetes
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []

When I enter the server address at the config file, I get the message that the connection was refused. I suspect that it is due to missing certificates. During another installation this (apparently) following information was created automatically, which is now missing:

certificate-authority-data, contexts - cluster, contexts - user, current context, users - name, client-certificate-data, client-key-data, token,

Could that be it? If so, where do I get this information?

Many thanks for the help


Solution

  • You need to use the Azure CLI first to get the credentials. Run

    az aks get-credentials
    

    https://learn.microsoft.com/en-us/cli/azure/aks?view=azure-cli-latest#az-aks-get-credentials