82 lines
2.5 KiB
Makefile
82 lines
2.5 KiB
Makefile
KUSTOMIZE = KUSTOMIZE_PLUGIN_HOME=$(PWD)/plugins kustomize
|
|
KUSTOMIZEFLAGS = --enable-alpha-plugins
|
|
|
|
KUBECTL = kubectl
|
|
KUBECTLFLAGS =
|
|
KUBECTLDIFFFLAGS =
|
|
KUBECTLAPPLYFLAGS = --prune
|
|
|
|
SRC := $(shell find kustomize/ -type f)
|
|
OUTDIR = build
|
|
|
|
# DEVOUT = $(OUTDIR)/dev
|
|
# DEVMANIFESTSRC = kustomize/overlays/dev
|
|
# DEVMANIFESTOUT = $(DEVOUT)/manifest.yaml
|
|
# DEVCLUSTERSRC = kustomize/overlays/dev-cluster
|
|
# DEVCLUSTEROUT = $(DEVOUT)/cluster.yaml
|
|
|
|
PRODOUT = $(OUTDIR)/prod
|
|
PRODMANIFESTOUT = $(PRODOUT)/manifest.yaml
|
|
PRODMANIFESTSRC = kustomize/overlays/prod
|
|
PRODCLUSTEROUT = $(PRODOUT)/cluster.yaml
|
|
PRODCLUSTERSRC = kustomize/overlays/prod-cluster
|
|
|
|
# ifeq ($(environment),prod)
|
|
# environment = prod
|
|
|
|
# ENVOUTDIR = $(PRODOUT)
|
|
# ENVOUTFILE = $(PRODMANIFESTOUT) $(PRODCLUSTEROUT)
|
|
# else
|
|
# environment = dev
|
|
|
|
# ENVOUTDIR = $(DEVOUT)
|
|
# ENVOUTFILE = $(DEVMANIFESTOUT) $(DEVCLUSTERTOUT)
|
|
# endif
|
|
|
|
environment=prod
|
|
ENVOUTDIR = $(PRODOUT)
|
|
ENVOUTFILE = $(PRODMANIFESTOUT) $(PRODCLUSTEROUT)
|
|
|
|
.PHONY: diff
|
|
diff: $(environment)
|
|
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(ENVOUTDIR) | highlight --out-format xterm256 --syntax diff
|
|
|
|
.PHONY: apply
|
|
apply: $(environment)
|
|
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -l managed-by=kustomize-cluster -f $(ENVOUTDIR)
|
|
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -l managed-by=kustomize -f $(ENVOUTDIR)
|
|
|
|
.PHONY: all dev prod
|
|
all: dev prod
|
|
# dev: $(DEVMANIFESTOUT) $(DEVCLUSTEROUT)
|
|
prod: $(PRODMANIFESTOUT) $(PRODCLUSTEROUT)
|
|
|
|
# $(DEVMANIFESTOUT): $(SRC)
|
|
# mkdir -p $(DEVOUT)
|
|
# $(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(DEVMANIFESTSRC) >$(DEVMANIFESTOUT) || (rm $(DEVMANIFESTOUT); exit 1)
|
|
|
|
# $(DEVCLUSTEROUT): $(SRC)
|
|
# mkdir -p $(DEVOUT)
|
|
# $(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(DEVCLUSTERSRC) >$(DEVCLUSTEROUT) || (rm $(DEVCLUSTEROUT); exit 1)
|
|
|
|
$(PRODMANIFESTOUT): $(SRC)
|
|
mkdir -p $(PRODOUT)
|
|
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(PRODMANIFESTSRC) >$(PRODMANIFESTOUT) || (rm $(PRODMANIFESTOUT); exit 1)
|
|
|
|
$(PRODCLUSTEROUT): $(SRC)
|
|
mkdir -p $(PRODOUT)
|
|
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(PRODCLUSTERSRC) >$(PRODCLUSTEROUT) || (rm $(PRODCLUSTEROUT); exit 1)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -r $(OUTDIR)
|
|
|
|
# $(KUSTOMIZEOUTALL): $(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)
|
|
|