1
0
Fork 0
home-stack-kustomize/Makefile

38 lines
976 B
Makefile
Raw Normal View History

KUSTOMIZE = kustomize
KUSTOMIZEFLAGS =
2020-05-14 21:56:01 +00:00
KUBECTL = kubectl
KUBECTLFLAGS =
2023-03-01 18:35:08 +00:00
KUBECTLDIFFFLAGS =
KUBECTLDIFFPRINTER = highlight --out-format xterm256 --syntax diff
2023-10-20 03:48:14 +00:00
KUBECTLAPPLYFLAGS = --prune --server-side --force-conflicts
2023-03-01 18:35:08 +00:00
KUBECTLAPPLYPRINTER = sed -E -e 's/(.+configured)/\o033[32m\1\o033[0m/g' -e 's/(.+pruned)/\o033[31m\1\o033[0m/g'
2020-05-14 21:56:01 +00:00
SRC := $(shell find kustomize/ -type f)
OUT = build
2020-05-14 21:56:01 +00:00
PRODOUT = $(OUT)/prod.yaml
PRODSRC = kustomize/env/prod
2021-08-26 16:42:21 +00:00
.PHONY: prod
2023-03-01 18:35:08 +00:00
prod: diff
2020-05-14 21:56:01 +00:00
2021-08-26 16:42:21 +00:00
.PHONY: diff
2023-03-01 18:35:08 +00:00
diff: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(PRODOUT) | $(KUBECTLDIFFPRINTER)
2020-05-14 21:56:01 +00:00
2021-08-26 16:42:21 +00:00
.PHONY: apply
2023-03-01 18:35:08 +00:00
apply: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -l app.kubernetes.io/managed-by=kustomize -f $(PRODOUT) | $(KUBECTLAPPLYPRINTER)
2020-05-14 21:56:01 +00:00
$(PRODOUT): $(SRC)
mkdir -p $(OUT)
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(PRODSRC) >$(PRODOUT) || (rm $(PRODOUT); exit 1)
2021-08-26 16:42:21 +00:00
.PHONY: clean
clean:
rm -r $(OUT)
2020-05-14 21:56:01 +00:00
.PHONY: infra
infra:
terraform -chdir=terraform apply