kubectl
utility- Connected to Kubernetes cluster
Steps
-
Go to your Azure DevOps Portal, the URL should be something like this:
https://dev.azure.com/<organization>/<project-name>/_settings/adminservices
-
Click on New Service Connection.
-
Select Kubernetes from the list.
-
Select service account.
-
Run the following command to get the server url.
kubectl config view --minify -o jsonpath={.clusters[0].cluster.server}
💡 If you're on zsh terminal, use the double quotes around jsonpath query
kubectl config view --minify -o jsonpath="{.clusters[0].cluster.server}"
-
Copy the output to the Server url field. which will look something like this, Mine's hosted on AWS, so it'll be different for every cloud providers.
https://44444444444444444444444.gr8.us-east-1.eks.amazonaws.com
-
Run the following command to get the secret name
kubectl get serviceAccounts <service-account-name> -n <namespace> -o=jsonpath={.secrets[*].name}
-
Run the following command to get the secret's value.
kubectl get secret <service-account-secret-name> -n <namespace> -o json
-
Copy the whole output to the Secret field in azure devops.
-
Set the service connection name.
-
Click on save.