diff --git a/Makefile b/Makefile index cffc851..9e7e4a2 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,9 @@ ifeq ($(environment),prod) KUSTOMIZEDIR = kustomize/overlays/prod KUSTOMIZEOUT = $(OUTDIR)/$(environment)/manifest.yaml - # base-deploy - KUSTOMIZEDIRALL = kustomize/overlays/prod-base-deploy - KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/base-deploy.yaml + # auto-deploy + KUSTOMIZEDIRALL = kustomize/overlays/prod-auto-deploy + KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/auto-deploy.yaml else environment = dev @@ -28,14 +28,14 @@ else KUSTOMIZEDIR = kustomize/overlays/dev KUSTOMIZEOUT = $(OUTDIR)/$(environment)/manifest.yaml - # base-deploy - KUSTOMIZEDIRALL = kustomize/overlays/dev-base-deploy - KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/base-deploy.yaml + # auto-deploy + KUSTOMIZEDIRALL = kustomize/overlays/dev-auto-deploy + KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/auto-deploy.yaml endif -.PHONY: all info base-deploy clean diff apply +.PHONY: all info auto-deploy clean diff apply -all: info base-deploy $(KUSTOMIZEOUT) +all: info auto-deploy $(KUSTOMIZEOUT) info: @echo "Building for" $(environment) @@ -43,7 +43,7 @@ info: clean: rm -r $(OUTDIR) -base-deploy: $(SRC) +auto-deploy: $(SRC) @mkdir -p $(dir $(KUSTOMIZEOUTALL)) $(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIRALL) >$(KUSTOMIZEOUTALL) || (rm $(KUSTOMIZEOUTALL); exit 1) diff --git a/kustomize/namespaces/cert-manager/kustomization.yaml b/kustomize/namespaces/cert-manager/kustomization.yaml index 8042cfa..642906a 100644 --- a/kustomize/namespaces/cert-manager/kustomization.yaml +++ b/kustomize/namespaces/cert-manager/kustomization.yaml @@ -1,4 +1,4 @@ bases: - ../../bases/cert-manager -namespace: cert-manager +# namespace: cert-manager diff --git a/kustomize/namespaces/ingress-nginx/kustomization.yaml b/kustomize/namespaces/ingress-nginx/kustomization.yaml index 9bf085c..28b62ab 100644 --- a/kustomize/namespaces/ingress-nginx/kustomization.yaml +++ b/kustomize/namespaces/ingress-nginx/kustomization.yaml @@ -1,4 +1,4 @@ bases: - ../../bases/ingress-nginx -namespace: ingress-nginx +# namespace: ingress-nginx diff --git a/kustomize/overlays/dev-base-deploy/kustomization.yaml b/kustomize/overlays/dev-auto-deploy/kustomization.yaml similarity index 84% rename from kustomize/overlays/dev-base-deploy/kustomization.yaml rename to kustomize/overlays/dev-auto-deploy/kustomization.yaml index 4f3f857..db42d52 100644 --- a/kustomize/overlays/dev-base-deploy/kustomization.yaml +++ b/kustomize/overlays/dev-auto-deploy/kustomization.yaml @@ -4,4 +4,4 @@ bases: # allow "kubectl apply -l managed-by=k3s --prune ..." commonlabels: - managed-by: k3s + managed-by: auto-deploy diff --git a/setup-dev-cluster.sh b/setup-dev-cluster.sh new file mode 100755 index 0000000..3ec9bc5 --- /dev/null +++ b/setup-dev-cluster.sh @@ -0,0 +1,49 @@ +#!/bin/bash -e + +cluster_name='local' +k3s_registry_config="$HOME/.config/k3d/registries.yaml" + +# generate manifest to be deployed on boot +make auto-deploy +auto_deploy_manifest="$(dirname "$(readlink -f "$0")")/build/dev/auto-deploy.yaml" + +# cluster registry configuration +if [[ ! -f "$k3s_registry_cofing" ]]; then + mkdir -p "$(dirname "$k3s_registry_config")" + cat >"$k3s_registry_config" </dev/null; then + k3d cluster create "$cluster_name" \ + --servers 1 \ + --agents 3 \ + --k3s-server-arg '--no-deploy=traefik' \ + --volume "$k3s_registry_config:/etc/rancher/k3s/registries.yaml" \ + -p 8080:80@loadbalancer + sleep 1 +fi + # --volume ":/var/lib/rancher/k3s/server/manifests/auto-deploy.yaml" \ + +# local docker registry +if ! docker ps -a | grep registry.localhost &>/dev/null; then + docker volume create local_registry + docker run -d \ + --name registry.localhost \ + --volume local_registry:/var/lib/registry \ + --restart always \ + -p 5000:5000 \ + registry:2 + docker network connect "k3d-$cluster_name" registry.localhost +fi + +k3d kubeconfig merge "$cluster_name" --switch-context >/dev/null +kubectl apply -f "$auto_deploy_manifest" +kubectl get nodes \ No newline at end of file diff --git a/startup.sh b/startup.sh deleted file mode 100755 index 1846e5b..0000000 --- a/startup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#/bin/bash -cp /host/build/all/* /manifests