How to Install Kube API server cert in Azure Kubernetes Service

Kumaran G 0 Reputation points
2023-04-26T12:56:24.85+00:00

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, yaksha-mfa-staging-dns-6ssqbxs8.hcp.centralindia.azmk8s.io, not kubelab2-dns-zhre37vl.hcp.centralindia.azmk8s.io

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.
2,116 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Abdul Sajid Mohammed 470 Reputation points Microsoft Employee
    2023-04-26T17:42:35+00:00

    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.

    Thankyou!

    0 comments No comments

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.