Skip to content

Instantly share code, notes, and snippets.

@mleuthold
Created April 4, 2019 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mleuthold/f5fa5da67a015ccdbecdfef8443fc701 to your computer and use it in GitHub Desktop.
Save mleuthold/f5fa5da67a015ccdbecdfef8443fc701 to your computer and use it in GitHub Desktop.
Using Kubernetes context and Docker endpoint of Minikube in a Makefile
ifeq ($(ENV), local)
# if local, then user docker registry of minikube
export DOCKER_TLS_VERIFY := $(shell minikube docker-env | grep DOCKER_TLS_VERIFY | cut -d\= -f2 | tr -d \")
export DOCKER_HOST := $(shell minikube docker-env | grep DOCKER_HOST | cut -d\= -f2 | tr -d \")
export DOCKER_CERT_PATH := $(shell minikube docker-env | grep DOCKER_CERT_PATH | cut -d\= -f2 | tr -d \")
export DOCKER_API_VERSION := $(shell minikube docker-env | grep DOCKER_API_VERSION | cut -d\= -f2 | tr -d \")
# if local, then user kubernetes context of minikube
export MY_CONTEXT := $(shell kubectl config use-context minikube; echo "using minikube context")
else
# use kubernetes context specified in configuration file
# variable MY_CONTEXT is not used, but the command is executed
export MY_CONTEXT := $(shell kubectl config use-context $(MY_KUBERNETES_CONTEXT); echo "using specific context")
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment