From f04cbeeddbcbefaf16671fbe5587b156d8fe3902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 3 Oct 2017 13:41:51 +0200 Subject: [PATCH 1/3] Testing new k8s mk --- base.mk | 10 +++++++++- k8s.mk | 13 ++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/base.mk b/base.mk index d0c392b..f170cfa 100644 --- a/base.mk +++ b/base.mk @@ -1,8 +1,13 @@ +export NAME ?= $(shell basename $(CURDIR)) VERSION ?= $(shell git describe --tags --dirty 2>/dev/null) # Get the location of this makefile. MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + +include .env +include ../.env + .FORCE: version: .FORCE @@ -13,7 +18,7 @@ help: ## Show this help. @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/\(.*:\)[^#]*##\s*\(.*\)/\1\t\2/' | column -t -s " " config: ## Load config from the environment. You should run it once in every session before other tasks. Run: eval $(make config) - @echo ". ../.env || true;" + @awk '{ print "export " $$0}' ../.env @awk '{ print "export " $$0}' .env @echo "# Please, run: " @echo "# eval \$$(make config)" @@ -27,4 +32,7 @@ include $(MK_DIR)/makefiles.mk include $(MK_DIR)/docker.mk include $(MK_DIR)/git.mk +info:: ## List all variables + env + .PHONY:: config help ci version .FORCE diff --git a/k8s.mk b/k8s.mk index 96892b2..e380a8c 100644 --- a/k8s.mk +++ b/k8s.mk @@ -11,17 +11,16 @@ # # Check if the KUBE_CA_PEM_FILE exists. Otherwise, create it from KUBE_CA_BUNDLE KUBE_CA_TEMP=false -ifeq ($(wildcard $(KUBE_CA_PEM_FILE)),) - KUBE_CA_PEM_FILE:="$$PWD/.ca.crt" - CREATED:=$(shell echo -e "$$KUBE_CA_BUNDLE" > $(KUBE_CA_PEM_FILE)) +ifndef KUBE_CA_PEM_FILE +KUBE_CA_PEM_FILE:=$$PWD/.ca.crt +CREATED:=$(shell echo -e "$(KUBE_CA_BUNDLE)" > $(KUBE_CA_PEM_FILE)) endif -KUBE_URL?="" KUBE_TOKEN?="" KUBE_NAMESPACE?=$(NAME) KUBECTL=docker run --rm -v $(KUBE_CA_PEM_FILE):/tmp/ca.pem -i lachlanevenson/k8s-kubectl --server="$(KUBE_URL)" --token="$(KUBE_TOKEN)" --certificate-authority="/tmp/ca.pem" -n $(KUBE_NAMESPACE) CI_COMMIT_REF_NAME?=master -info: ## Print variables. Useful for debugging. +info:: ## Print variables. Useful for debugging. @echo "#KUBERNETES" @echo KUBE_URL=$(KUBE_URL) @echo KUBE_CA_PEM_FILE=$(KUBE_CA_PEM_FILE) @@ -35,6 +34,7 @@ info: ## Print variables. Useful for debugging. @echo CI_REGISTRY=$(CI_REGISTRY) @echo CI_REGISTRY_USER=$(CI_REGISTRY_USER) @echo CI_COMMIT_REF_NAME=$(CI_COMMIT_REF_NAME) + @echo "CREATED=$(CREATED)" # # Deployment and advanced features @@ -42,8 +42,7 @@ info: ## Print variables. Useful for debugging. deploy: ## Deploy to kubernetes using the credentials in KUBE_CA_PEM_FILE (or KUBE_CA_BUNDLE ) and TOKEN - @ls k8s/ - @cat k8s/*.yaml k8s/*.yml k8s/*.tmpl 2>/dev/null | envsubst | $(KUBECTL) apply -f - + cat k8s/*.yaml | envsubst | $(KUBECTL) apply -f - deploy-check: ## Get the deployed configuration. @$(KUBECTL) get deploy,pods,svc,ingress From 1543f5550e4ed3e7b990f1a6d22f95db9cad7263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 3 Oct 2017 13:46:09 +0200 Subject: [PATCH 2/3] Updated makefiles from senpy --- base.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base.mk b/base.mk index f170cfa..cc27cfa 100644 --- a/base.mk +++ b/base.mk @@ -5,8 +5,8 @@ VERSION ?= $(shell git describe --tags --dirty 2>/dev/null) # Get the location of this makefile. MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include .env -include ../.env +-include .env +-include ../.env .FORCE: From 8fe7616bae24e4e01e1ae331a47fe82401bc262d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 3 Oct 2017 15:08:16 +0200 Subject: [PATCH 3/3] Updated makefiles from senpy --- k8s.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/k8s.mk b/k8s.mk index e380a8c..a493b4a 100644 --- a/k8s.mk +++ b/k8s.mk @@ -42,7 +42,8 @@ info:: ## Print variables. Useful for debugging. deploy: ## Deploy to kubernetes using the credentials in KUBE_CA_PEM_FILE (or KUBE_CA_BUNDLE ) and TOKEN - cat k8s/*.yaml | envsubst | $(KUBECTL) apply -f - + @ls k8s/*.yaml k8s/*.yml k8s/*.tmpl 2>/dev/null || true + @cat k8s/*.yaml k8s/*.yml k8s/*.tmpl 2>/dev/null | envsubst | $(KUBECTL) apply -f - deploy-check: ## Get the deployed configuration. @$(KUBECTL) get deploy,pods,svc,ingress