1
0
Fork 0

create makefile

This commit is contained in:
Massaki Archambault 2020-05-14 17:56:01 -04:00
parent 4ca0a7e325
commit 79dcd4d4eb
3 changed files with 44 additions and 1 deletions

1
.gitignore vendored
View File

@ -36,4 +36,5 @@ tags
# End of https://www.gitignore.io/api/vim,code
.env
kubectl/
build/

43
Makefile Normal file
View File

@ -0,0 +1,43 @@
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 = --server-side
KUBECTLAPPLYFLAGS = -l managed-by=kustomize --prune
SRC := $(shell find kustomize/ -type f)
OUTDIR = build/
ifeq ($(environment),prod)
# prod
KUSTOMIZEDIR = kustomize/environment/prod
KUSTOMIZEOUT = $(OUTDIR)/prod/out.yaml
else
# dev
environment = dev
KUBECTLFLAGS += --kubeconfig kubectl/kubeconfig.yaml
KUSTOMIZEDIR = kustomize/environment/dev
KUSTOMIZEOUT = $(OUTDIR)/dev/out.yaml
endif
.PHONY: info clean diff apply
all: info $(KUSTOMIZEOUT)
info:
@echo "Building for" $(environment)
clean:
rm -r $(OUTDIR)
$(KUSTOMIZEOUT): $(SRC)
@mkdir -p $(dir $(KUSTOMIZEOUT))
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIR) >$(KUSTOMIZEOUT) || rm $(KUSTOMIZEOUT)
diff: $(KUSTOMIZEOUT)
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(KUSTOMIZEOUT)
apply: $(KUSTOMIZEOUT)
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -f $(KUSTOMIZEOUT)

View File

@ -15,7 +15,6 @@ services:
volumes:
- k3s_data:/var/lib/rancher/k3s
- .:/host
- ./manifests:/var/lib/rancher/k3s/server/manifests/host
ports:
- 80:80
- 443:443