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
@Kumaran G
Checking in to see if the answer below helped.
If you still have questions, please let us know in the "
comments"
and we would be happy to help you. Comment is the fastest way of notifying the experts.
If the answer below has been helpful, we appreciate hearing from you and would love to help others who may have the same question.
Accepting answers
helps increase visibility of this question for other members of the Microsoft Q&A community.
Thank you for helping to improve Microsoft Q&A!
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.
Can u please confirm if you are able to run any other kubectl commands on that cluster, other than creating a namespace?
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.
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:
Was this working fine before and not working all of the sudden, or is this your first time creating a namespace in this cluster?
Any recent certificate rotations on the cluster?
Is there anything between the client and the cluster (eg. Firewall for instance)?
Hope this helps, look forward to hearing from you.
Thankyou!