Skip to content

Instantly share code, notes, and snippets.

@tshabatyn
Last active April 1, 2024 16:14
Show Gist options
  • Save tshabatyn/398c4fba97070e82a8289d1284031254 to your computer and use it in GitHub Desktop.
Save tshabatyn/398c4fba97070e82a8289d1284031254 to your computer and use it in GitHub Desktop.
Adding context to k8s
# Outputs current value of KUBECONFIG
echo $KUBECONFIG
# Adding PATH of all the context files separated with semicolon
export KUBECONFIG=~/Downloads/dev-cluster-kubeconfig.yaml:~/Downloads/qa-cluster-kubeconfig.yaml
# Outputs merged configuration of the joined context files
kubectl config view --flatten
# Save the merged configuration to the default kube config location
kubectl config view --flatten > ~/.kube/config
# Outputs all the context's with the current context marked with *
kubectl config get-contexts
# Switch to the context of the new cluster
kubectl config use-context qa-cluster
# Set the namespace for the current context
kubectl config set-context --current --namespace=my-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment