2023-02-20 15:25:16 +00:00
|
|
|
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
|
|
|
|
KUBECTLAPPLYFLAGS = --prune
|
|
|
|
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)
|
2023-02-20 15:25:16 +00:00
|
|
|
OUT = build
|
2020-05-14 21:56:01 +00:00
|
|
|
|
2023-02-20 15:25:16 +00:00
|
|
|
PRODOUT = $(OUT)/prod.yaml
|
|
|
|
PRODSRC = kustomize/env/prod
|
2021-08-26 16:42:21 +00:00
|
|
|
|
2023-02-20 15:25:16 +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)
|
2023-03-13 20:20:30 +00:00
|
|
|
$(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
|
|
|
|
2023-02-20 15:25:16 +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:
|
2023-02-20 15:25:16 +00:00
|
|
|
rm -r $(OUT)
|
2020-05-14 21:56:01 +00:00
|
|
|
|
2023-02-20 15:25:16 +00:00
|
|
|
.PHONY: infra
|
|
|
|
infra:
|
|
|
|
terraform -chdir=terraform apply
|