1
0
Fork 0
home-stack-kustomize/Makefile

38 lines
942 B
Makefile

KUSTOMIZE = kustomize
KUSTOMIZEFLAGS =
KUBECTL = kubectl
KUBECTLFLAGS =
KUBECTLDIFFFLAGS =
KUBECTLDIFFPRINTER = highlight --out-format xterm256 --syntax diff
KUBECTLAPPLYFLAGS = --prune
KUBECTLAPPLYPRINTER = sed -E -e 's/(.+configured)/\o033[32m\1\o033[0m/g' -e 's/(.+pruned)/\o033[31m\1\o033[0m/g'
SRC := $(shell find kustomize/ -type f)
OUT = build
PRODOUT = $(OUT)/prod.yaml
PRODSRC = kustomize/env/prod
.PHONY: prod
prod: diff
.PHONY: diff
diff: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(PRODOUT) | $(KUBECTLDIFFCOLOR)
.PHONY: apply
apply: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -l app.kubernetes.io/managed-by=kustomize -f $(PRODOUT) | $(KUBECTLAPPLYPRINTER)
$(PRODOUT): $(SRC)
mkdir -p $(OUT)
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(PRODSRC) >$(PRODOUT) || (rm $(PRODOUT); exit 1)
.PHONY: clean
clean:
rm -r $(OUT)
.PHONY: infra
infra:
terraform -chdir=terraform apply