1
0
Fork 0
home-stack-kustomize/Makefile

43 lines
1.2 KiB
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-11-17 18:03:48 +00:00
KUBECTLAPPLYFLAGS = --server-side --force-conflicts
2024-07-06 21:05:18 +00:00
KUBECTLAPPLYPRUNEFLAGS = --server-side --force-conflicts --prune
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
2024-07-06 21:05:18 +00:00
.PHONY: apply-prune
apply-prune: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYPRUNEFLAGS) -l app.kubernetes.io/managed-by=kustomize -f $(PRODOUT) | $(KUBECTLAPPLYPRINTER)
$(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