Skip to content

Instantly share code, notes, and snippets.

@cmoulliard
Last active November 16, 2021 08:08
Show Gist options
  • Save cmoulliard/4e90ebe8b23f510d647c8a4cf63a6483 to your computer and use it in GitHub Desktop.
Save cmoulliard/4e90ebe8b23f510d647c8a4cf63a6483 to your computer and use it in GitHub Desktop.

How to get the port number of the Server IP address of a k8s cluster using the info of the kubeconfig file

clusterName="kind-kind"
kubectl config view -o json | \
     jq '.clusters[] | select(.name=="'$clusterName'").cluster.server' | \
     sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g'
50211

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment