lunes, 24 de febrero de 2025

Test kubernetes API connection

 

 Based on this service account to deploy from Azure DevOps

https://github.com/alegarciadelrio/kubernetes/tree/main/service-account-for-eks-azure-devops

 

We can figure out the token and the certificate 

SECRET=deploy-robot-secret
TOKEN=$(kubectl get secret ${SECRET} -n default -o json | jq -Mr '.data.token' | base64 -d) # Extract, decode and write the ca.crt to a temporary location
kubectl get secret ${SECRET} -o json | jq -Mr '.data["ca.crt"]' | base64 -d > /tmp/ca.crt # Get the API Server location
APISERVER=https://$(kubectl -n default get endpoints kubernetes --no-headers | awk '{ print $2 }')


Then you can run the following on your pc:
CA_CERT=ca.crt
TOKEN="wfpZ7Yz7YfsZNwcXOwtXvNQ5Z4OJnSdlcq8vmEsug"
NAMESPACE="dfdfdfd=="
curl --cacert $CA_CERT -H "Authorization: Bearer $TOKEN" "https://host:6443/version"


No hay comentarios:

Publicar un comentario