Skip to content

Instantly share code, notes, and snippets.

@metral
Last active December 24, 2016 18:55
Show Gist options
  • Save metral/28b34fd51ad6a625cb0258f335ed0001 to your computer and use it in GitHub Desktop.
Save metral/28b34fd51ad6a625cb0258f335ed0001 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Local kubeconfig settings
# These values don't affect connectivity to the cluster as they're only meant for
# the end-user's usage & readability
CLUSTER_NAME="kubernetes"
CLUSTER_USER="admin"
CLUSTER_ROOT_CA_PROPERTY="clusters.$CLUSTER_NAME.certificate-authority-data"
# Configure kubectl
/usr/bin/kubectl config set-cluster $CLUSTER_NAME --server=https://$K8S_ENDPOINT
/usr/bin/kubectl config set $CLUSTER_ROOT_CA_PROPERTY $K8S_ROOT_CA
/usr/bin/kubectl config set-credentials $CLUSTER_USER --username=$K8S_USERNAME --password=$K8S_PASSWORD
/usr/bin/kubectl config set-context $CLUSTER_NAME --cluster=$CLUSTER_NAME
/usr/bin/kubectl config set-context $CLUSTER_NAME --user=$CLUSTER_USER
/usr/bin/kubectl config use-context $CLUSTER_NAME
# Test kubectl is working
/usr/bin/kubectl cluster-info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment