How to configure ku...
Clear all

How to configure kubectl command to access remote kubernetes cluster on azure  


Sathish Kumar
Member Moderator
Joined: 4 months ago
Posts: 1203
31/03/2021 12:36 pm  

I have a kubernetes cluster running on azure. What is the way to access the cluster from local kubectl command. I referred to here but on the kubernetes master node there is no kube config file. Also, kubectl config view results in

apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []

Noble Member
Joined: 4 months ago
Posts: 1161
31/03/2021 12:37 pm  

Found a way to access remote kubernetes cluster without ssh'ing to one of the nodes in cluster. You need to edit ~/.kube/config file as below :

apiVersion: v1 
- cluster:
    server:  http://<master-ip>:<port> 
  name: test 
- context:
    cluster: test
    user: test
  name: test

Then set context by executing:

kubectl config use-context test

After this you should be able to interact with the cluster.

Note : To add certification and key use following link :

Alternately, you can also try following command:

kubectl config set-cluster test-cluster --server= http://<master-ip>:<port>  --api-version=v1
kubectl config use-context test-cluster