1
0
Fork 0
home-stack-kustomize/Makefile

50 lines
1.3 KiB
Makefile
Raw Normal View History

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