2020-05-14 21:56:01 +00:00
|
|
|
KUSTOMIZE = docker run -v $(HOME)/.aws:/root/.aws:ro -v $(PWD):/host:ro -w /host badjware/kustomize-plugins:latest
|
|
|
|
KUSTOMIZEFLAGS = --enable_alpha_plugins
|
|
|
|
|
|
|
|
KUBECTL = kubectl
|
|
|
|
KUBECTLFLAGS =
|
|
|
|
KUBECTLDIFFFLAGS = --server-side
|
|
|
|
KUBECTLAPPLYFLAGS = -l managed-by=kustomize --prune
|
|
|
|
|
|
|
|
SRC := $(shell find kustomize/ -type f)
|
2020-05-16 02:19:37 +00:00
|
|
|
OUTDIR = build
|
2020-05-14 21:56:01 +00:00
|
|
|
|
|
|
|
ifeq ($(environment),prod)
|
|
|
|
# prod
|
|
|
|
KUSTOMIZEDIR = kustomize/environment/prod
|
|
|
|
KUSTOMIZEOUT = $(OUTDIR)/prod/out.yaml
|
|
|
|
else
|
|
|
|
# dev
|
|
|
|
environment = dev
|
|
|
|
KUBECTLFLAGS += --kubeconfig kubectl/kubeconfig.yaml
|
|
|
|
KUSTOMIZEDIR = kustomize/environment/dev
|
|
|
|
KUSTOMIZEOUT = $(OUTDIR)/dev/out.yaml
|
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: info clean diff apply
|
|
|
|
|
|
|
|
all: info $(KUSTOMIZEOUT)
|
|
|
|
|
|
|
|
info:
|
|
|
|
@echo "Building for" $(environment)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -r $(OUTDIR)
|
|
|
|
|
|
|
|
$(KUSTOMIZEOUT): $(SRC)
|
|
|
|
@mkdir -p $(dir $(KUSTOMIZEOUT))
|
|
|
|
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIR) >$(KUSTOMIZEOUT) || rm $(KUSTOMIZEOUT)
|
|
|
|
|
|
|
|
diff: $(KUSTOMIZEOUT)
|
|
|
|
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(KUSTOMIZEOUT)
|
|
|
|
|
|
|
|
apply: $(KUSTOMIZEOUT)
|
|
|
|
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -f $(KUSTOMIZEOUT)
|
|
|
|
|