59 lines
1.6 KiB
Makefile
59 lines
1.6 KiB
Makefile
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 =
|
|
KUBECTLAPPLYFLAGS = -l managed-by=kustomize --prune
|
|
|
|
SRC := $(shell find kustomize/ -type f)
|
|
OUTDIR = build
|
|
|
|
|
|
ifeq ($(environment),prod)
|
|
environment = prod
|
|
|
|
# prod
|
|
KUSTOMIZEDIR = kustomize/overlays/prod
|
|
KUSTOMIZEOUT = $(OUTDIR)/$(environment)/manifest.yaml
|
|
|
|
# auto-deploy
|
|
KUSTOMIZEDIRALL = kustomize/overlays/prod-auto-deploy
|
|
KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/auto-deploy.yaml
|
|
else
|
|
environment = dev
|
|
|
|
# dev
|
|
#KUBECTLFLAGS += --kubeconfig kubectl/kubeconfig.yaml
|
|
KUSTOMIZEDIR = kustomize/overlays/dev
|
|
KUSTOMIZEOUT = $(OUTDIR)/$(environment)/manifest.yaml
|
|
|
|
# auto-deploy
|
|
KUSTOMIZEDIRALL = kustomize/overlays/dev-auto-deploy
|
|
KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/auto-deploy.yaml
|
|
endif
|
|
|
|
.PHONY: all info auto-deploy clean diff apply
|
|
|
|
all: info auto-deploy $(KUSTOMIZEOUT)
|
|
|
|
info:
|
|
@echo "Building for" $(environment)
|
|
|
|
clean:
|
|
rm -r $(OUTDIR)
|
|
|
|
auto-deploy: $(SRC)
|
|
@mkdir -p $(dir $(KUSTOMIZEOUTALL))
|
|
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIRALL) >$(KUSTOMIZEOUTALL) || (rm $(KUSTOMIZEOUTALL); exit 1)
|
|
|
|
$(KUSTOMIZEOUT): $(SRC)
|
|
@mkdir -p $(dir $(KUSTOMIZEOUT))
|
|
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIR) >$(KUSTOMIZEOUT) || (rm $(KUSTOMIZEOUT); exit 1)
|
|
|
|
diff: $(KUSTOMIZEOUT)
|
|
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(KUSTOMIZEOUT)
|
|
|
|
apply: $(KUSTOMIZEOUT)
|
|
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -f $(KUSTOMIZEOUT)
|