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 =
|
2020-05-17 02:17:14 +00:00
|
|
|
KUBECTLDIFFFLAGS =
|
2020-05-14 21:56:01 +00:00
|
|
|
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
|
|
|
|
2020-05-18 20:18:39 +00:00
|
|
|
|
2020-05-14 21:56:01 +00:00
|
|
|
ifeq ($(environment),prod)
|
2020-08-02 01:49:55 +00:00
|
|
|
environment = prod
|
|
|
|
|
2020-05-14 21:56:01 +00:00
|
|
|
# prod
|
2020-08-02 01:49:55 +00:00
|
|
|
KUSTOMIZEDIR = kustomize/overlays/prod
|
|
|
|
KUSTOMIZEOUT = $(OUTDIR)/$(environment)/manifest.yaml
|
|
|
|
|
|
|
|
# base-deploy
|
|
|
|
KUSTOMIZEDIRALL = kustomize/overlays/prod-base-deploy
|
|
|
|
KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/base-deploy.yaml
|
2020-05-14 21:56:01 +00:00
|
|
|
else
|
|
|
|
environment = dev
|
2020-08-02 01:49:55 +00:00
|
|
|
|
|
|
|
# dev
|
|
|
|
#KUBECTLFLAGS += --kubeconfig kubectl/kubeconfig.yaml
|
|
|
|
KUSTOMIZEDIR = kustomize/overlays/dev
|
|
|
|
KUSTOMIZEOUT = $(OUTDIR)/$(environment)/manifest.yaml
|
|
|
|
|
|
|
|
# base-deploy
|
|
|
|
KUSTOMIZEDIRALL = kustomize/overlays/dev-base-deploy
|
|
|
|
KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/base-deploy.yaml
|
2020-05-14 21:56:01 +00:00
|
|
|
endif
|
|
|
|
|
2020-08-02 01:49:55 +00:00
|
|
|
.PHONY: all info base-deploy clean diff apply
|
2020-05-14 21:56:01 +00:00
|
|
|
|
2020-08-02 01:49:55 +00:00
|
|
|
all: info base-deploy $(KUSTOMIZEOUT)
|
2020-05-14 21:56:01 +00:00
|
|
|
|
|
|
|
info:
|
|
|
|
@echo "Building for" $(environment)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -r $(OUTDIR)
|
|
|
|
|
2020-08-02 01:49:55 +00:00
|
|
|
base-deploy: $(SRC)
|
2020-05-18 20:18:39 +00:00
|
|
|
@mkdir -p $(dir $(KUSTOMIZEOUTALL))
|
|
|
|
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIRALL) >$(KUSTOMIZEOUTALL) || (rm $(KUSTOMIZEOUTALL); exit 1)
|
2020-08-02 01:49:55 +00:00
|
|
|
|
|
|
|
$(KUSTOMIZEOUT): $(SRC)
|
|
|
|
@mkdir -p $(dir $(KUSTOMIZEOUT))
|
2020-05-17 02:17:14 +00:00
|
|
|
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIR) >$(KUSTOMIZEOUT) || (rm $(KUSTOMIZEOUT); exit 1)
|
2020-05-14 21:56:01 +00:00
|
|
|
|
|
|
|
diff: $(KUSTOMIZEOUT)
|
|
|
|
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(KUSTOMIZEOUT)
|
|
|
|
|
|
|
|
apply: $(KUSTOMIZEOUT)
|
|
|
|
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -f $(KUSTOMIZEOUT)
|