Skip to content

Instantly share code, notes, and snippets.

@jadametz
Created May 25, 2019 03:03
Show Gist options
  • Save jadametz/e308e94805f47ec937a681672cbe3259 to your computer and use it in GitHub Desktop.
Save jadametz/e308e94805f47ec937a681672cbe3259 to your computer and use it in GitHub Desktop.
Updates ~/.kube/config for a Digital Ocean K8s cluster
#!/usr/bin/env bash
# export DO_TOKEN=foo
# export K8S_CLUSTER_ID=bar
if [[ -z "$DO_TOKEN" ]] || [[ -z "$K8S_CLUSTER_ID" ]]; then
echo "DO_TOKEN and K8S_CLUSTER_ID must be set" 1>&2
exit 1
fi
echo "Updating DigitalOcean K8s config file..."
curl -s \
--request GET \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $DO_TOKEN" \
--url https://api.digitalocean.com/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig \
--output config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment