How to Install Kube API server cert in Azure Kubernetes Service

Kumaran G 0 Reputation points

When creating namespace using kubectl, got the following message kubectl create namespace dev Unable to connect to the server: x509: certificate is valid for localhost, hcp-kubernetes, kubernetes, kubernetes.default, kubernetes.default.svc, kubernetes.default.svc.cluster.local, hcp-kubernetes.644785187754eb0001225b82.svc.cluster.local,, not

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.
1,663 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Abdul Sajid Mohammed 465 Reputation points Microsoft Employee

    Hello @kumaran G

    Thanks for posting your question here.

    Looking at the error you may have more than one cluster / context in your .kubeconfig file and maybe something got mixed up or recent cert changes.

    1. Can u please confirm if you are able to run any other kubectl commands on that cluster, other than creating a namespace?
    2. Can u please try to pull credentials again? with command az aks get-credentials --resource-group <Your RG> --name <Cluster Name> and --admin flag on the end if required as per your permissions.
    3. Then try to create a namespace using kubectl create namespace <name of your new namespace>.

    If the issue still persists after above steps, can u please confirm:

    1. Was this working fine before and not working all of the sudden, or is this your first time creating a namespace in this cluster?
    2. Any recent certificate rotations on the cluster?
    3. Is there anything between the client and the cluster (eg. Firewall for instance)?

    Hope this helps, look forward to hearing from you.


    0 comments No comments