1
0
Fork 0
home-stack-kustomize/Makefile

62 lines
1.6 KiB
Makefile
Raw Normal View History

KUSTOMIZE = docker run -v $(HOME)/.aws:/root/.aws:ro -v $(PWD):/host -w /host badjware/kustomize-plugins:latest
2020-05-14 21:56:01 +00:00
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
2020-08-02 03:14:58 +00:00
# auto-deploy
KUSTOMIZEDIRALL = kustomize/overlays/prod-auto-deploy
KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/auto-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
2020-08-02 03:14:58 +00:00
# auto-deploy
KUSTOMIZEDIRALL = kustomize/overlays/dev-auto-deploy
KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/auto-deploy.yaml
2020-05-14 21:56:01 +00:00
endif
2020-08-02 03:14:58 +00:00
.PHONY: all info auto-deploy clean diff apply
2020-05-14 21:56:01 +00:00
all: info $(KUSTOMIZEOUTALL) $(KUSTOMIZEOUT)
2020-05-14 21:56:01 +00:00
info:
@echo "Building for" $(environment)
$(KUSTOMIZE) version
2020-05-14 21:56:01 +00:00
clean:
rm -r $(OUTDIR)
auto-deploy: $(KUSTOMIZEOUTALL)
$(KUSTOMIZEOUTALL): $(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)