1
0
Fork 0
home-stack-kustomize/Makefile

36 lines
852 B
Makefile
Raw Normal View History

KUSTOMIZE = kustomize
KUSTOMIZEFLAGS =
2020-05-14 21:56:01 +00:00
KUBECTL = kubectl
KUBECTLFLAGS =
KUBECTLDIFFFLAGS = --server-side=true --force-conflicts
2023-02-20 14:47:13 +00:00
KUBECTLAPPLYFLAGS = --server-side=true --force-conflicts --prune
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
prod: prod-diff
2020-05-14 21:56:01 +00:00
2021-08-26 16:42:21 +00:00
.PHONY: diff
prod-diff: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(PRODOUT) | highlight --out-format xterm256 --syntax diff
2020-05-14 21:56:01 +00:00
2021-08-26 16:42:21 +00:00
.PHONY: apply
prod-apply: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -l app.kubernetes.io/managed-by=kustomize -f $(PRODOUT)
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