Created
April 4, 2019 16:40
-
-
Save mleuthold/f5fa5da67a015ccdbecdfef8443fc701 to your computer and use it in GitHub Desktop.
Using Kubernetes context and Docker endpoint of Minikube in a Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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