I'm beginning to build out a kubernetes cluster for our applications. We are using Azure for cloud services, so my K8s cluster is built using AKS. The AKs cluster was created using the portal interface for Azure. It has one node, and I am attempting to create a pod with a single container to deploy to the node. Where I am stuck currently is trying to connect to the AKS cluster from Powershell. The steps I have taken are:
az login (followed by logging in)
az account set --subscription <subscription id>
az aks get-credentials --name <cluster name> --resource-group <resource group name>
kubectl get nodes
After entering the last line, I am left with the error: Unable to connect to the server: dial tcp: lookup : no such host
I've also gone down a few other rabbit holes found on SO and other forums, but quite honestly, I'm looking for a straight forward way to access my cluster before complicating it further.
Edit: So in the end, I deleted the resource I was working with and spun up a new version of AKS, and am now having no trouble connecting. Thanks for the suggestions though!
hcp.westeurope.azmk8s.io) — this is the dns that is running your api server(HTTPS:443, UDP: 1194) mcr.microsoft.com , *. data.mcr.microsoft.com — This is required since some AKS images are coming from the Microsoft Container Registry (HTTPS: 443)
To find the cluster IP address of a Kubernetes pod, use the kubectl get pod command on your local machine, with the option -o wide . This option will list more information, including the node the pod resides on, and the pod's cluster IP. The IP column will contain the internal cluster IP address for each pod.
As of now, the aks run command adds a fourth option to connect to private clusters extending @Darius's three options posted earlier:
- Use the AKS Run Command feature.
az aks command invoke -g <resourceGroup> -n <clusterName> -c "kubectl get pods -n kube-system"
az aks command invoke -g <resourceGroup> -n <clusterName> -c "kubectl get nodes"
In case you get a (ResourceGroupNotFound)
error, try adding the subscription, too
az aks command invoke -g <resourceGroup> -n <clusterName> --subscription <subscription> -c "kubectl get nodes"
You can also configure the default subscription:
az account set -s <subscription>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With