1
0
Fork 0
home-stack-kustomize/Makefile

36 lines
852 B
Makefile

KUSTOMIZE = kustomize
KUSTOMIZEFLAGS =
KUBECTL = kubectl
KUBECTLFLAGS =
KUBECTLDIFFFLAGS = --server-side=true --force-conflicts
KUBECTLAPPLYFLAGS = --server-side=true --force-conflicts --prune
SRC := $(shell find kustomize/ -type f)
OUT = build
PRODOUT = $(OUT)/prod.yaml
PRODSRC = kustomize/env/prod
.PHONY: prod
prod: prod-diff
.PHONY: diff
prod-diff: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(PRODOUT) | highlight --out-format xterm256 --syntax diff
.PHONY: apply
prod-apply: $(PRODOUT)
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -l app.kubernetes.io/managed-by=kustomize -f $(PRODOUT)
$(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