Skip to content

Commit

Permalink
Merge pull request #6 from vshn/change/improvements
Browse files Browse the repository at this point in the history
Change/improvements
  • Loading branch information
Kidswiss authored Mar 31, 2023
2 parents 0fba273 + de24e6c commit b0a848d
Show file tree
Hide file tree
Showing 7 changed files with 1,041 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Run provision
run: make provision
- name: Run crossplane-setup
run: make crossplane-setup
40 changes: 26 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,34 @@ lint: ## All-in-one linting
@echo 'Check for uncommitted changes ...'
git diff --exit-code

.PHONY: crossplane-setup
crossplane-setup: $(crossplane_sentinel) ## Install local Kubernetes cluster and install Crossplane

$(crossplane_sentinel): export KUBECONFIG = $(KIND_KUBECONFIG)
$(crossplane_sentinel): kind-setup
$(crossplane_sentinel): kind-setup local-pv-setup
helm repo add crossplane https://charts.crossplane.io/stable
helm repo add mittwald https://helm.mittwald.de
helm upgrade --install crossplane --create-namespace --namespace crossplane-system crossplane/crossplane --set "args[0]='--debug'" --set "args[1]='--enable-composition-revisions'" --wait
helm upgrade --install secret-generator --create-namespace --namespace secret-generator mittwald/kubernetes-secret-generator --wait
kubectl apply -f crossplane/provider.yaml
kubectl wait --for condition=Healthy provider.pkg.crossplane.io/provider-helm --timeout 60s
kubectl apply -f crossplane/provider-config.yaml
kubectl create clusterrolebinding crossplane:provider-helm-admin --clusterrole cluster-admin --serviceaccount crossplane-system:$$(kubectl get sa -n crossplane-system -o custom-columns=NAME:.metadata.name --no-headers | grep provider-helm)
kubectl create clusterrolebinding crossplane:cluster-admin --clusterrole cluster-admin --serviceaccount crossplane-system:crossplane
helm upgrade --install crossplane --create-namespace --namespace syn-crossplane crossplane/crossplane \
--set "args[0]='--debug'" \
--set "args[1]='--enable-composition-functions'" \
--set "args[2]='--enable-environment-configs'" \
--set "xfn.enabled=true" \
--set "xfn.args={--debug}" \
--wait
@touch $@

.PHONY: minio-setup
stackgres-setup: export KUBECONFIG = $(KIND_KUBECONFIG)
stackgres-setup: $(crossplane_sentinel)
helm upgrade --install --create-namespace --namespace stackgres stackgres-operator stackgres-charts/stackgres-operator

certmanager-setup: export KUBECONFIG = $(KIND_KUBECONFIG)
certmanager-setup: $(crossplane_sentinel)
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml

minio-setup: export KUBECONFIG = $(KIND_KUBECONFIG)
minio-setup: crossplane-setup ## Install Minio Crossplane implementation
kubectl apply -f minio/s3-composite.yaml
kubectl apply -f minio/s3-composition.yaml
kubectl wait --for condition=Offered compositeresourcedefinition/xs3buckets.syn.tools

.PHONY: k8up-setup
k8up-setup: minio-setup prometheus-setup $(k8up_sentinel) ## Install K8up operator

$(k8up_sentinel): export KUBECONFIG = $(KIND_KUBECONFIG)
Expand All @@ -61,7 +65,15 @@ $(k8up_sentinel): kind-setup
kubectl -n k8up-system wait --for condition=Available deployment/k8up --timeout 60s
@touch $@

.PHONY: prometheus-setup
local-pv-setup: $(local_pv_sentinel)

$(local_pv_sentinel): export KUBECONFIG = $(KIND_KUBECONFIG)
$(local_pv_sentinel):
kubectl apply -f local-pv
kubectl patch storageclass standard -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
@touch $@

prometheus-setup: $(prometheus_sentinel) ## Install Prometheus stack

$(prometheus_sentinel): export KUBECONFIG = $(KIND_KUBECONFIG)
Expand All @@ -74,7 +86,7 @@ $(prometheus_sentinel): kind-setup-ingress
--values prometheus/values.yaml \
prometheus-community/kube-prometheus-stack
kubectl -n prometheus-system wait --for condition=Available deployment/kube-prometheus-kube-prome-operator --timeout 120s
@echo -e "***\n*** Installed Prometheus in http://127.0.0.1.nip.io:8081/prometheus/ and AlertManager in http://127.0.0.1.nip.io:8081/alertmanager/.\n***"
@echo -e "***\n*** Installed Prometheus in http://127.0.0.1.nip.io:8088/prometheus/ and AlertManager in http://127.0.0.1.nip.io:8088/alertmanager/.\n***"
@touch $@

.PHONY: clean
Expand Down
3 changes: 2 additions & 1 deletion Makefile.vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
crossplane_sentinel = $(kind_dir)/crossplane-sentinel
k8up_sentinel = $(kind_dir)/k8up-sentinel
prometheus_sentinel = $(kind_dir)/prometheus-sentinel
local_pv_sentinel = $(kind_dir)/local_pv

PROJECT_ROOT_DIR = .
PROJECT_NAME ?= kindev
Expand All @@ -13,7 +14,7 @@ DOCKER_CMD ?= docker
## KIND:setup

# https://hub.docker.com/r/kindest/node/tags
KIND_NODE_VERSION ?= v1.23.0
KIND_NODE_VERSION ?= v1.24.4
KIND_IMAGE ?= docker.io/kindest/node:$(KIND_NODE_VERSION)
KIND_CMD ?= go run sigs.k8s.io/kind
KIND_KUBECONFIG ?= $(kind_dir)/kind-kubeconfig-$(KIND_NODE_VERSION)
Expand Down
5 changes: 4 additions & 1 deletion kind/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ nodes:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 8081
hostPort: 8088
protocol: TCP
- containerPort: 443
hostPort: 8443
protocol: TCP
- role: worker
- role: worker
- role: worker
46 changes: 29 additions & 17 deletions kind/kind.mk
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
kind_dir ?= .kind
ingress_sentinel = $(kind_dir)/ingress-sentinel
go_bin ?= $(PWD)/.work/bin
$(go_bin):
@mkdir -p $@

kind_dir ?= $(PWD)/.kind
kind_bin = $(go_bin)/kind

# Prepare kind binary
$(kind_bin): export GOOS = $(shell go env GOOS)
$(kind_bin): export GOARCH = $(shell go env GOARCH)
$(kind_bin): export GOBIN = $(go_bin)
$(kind_bin): | $(go_bin)
go install sigs.k8s.io/kind@latest


.PHONY: kind
kind: export KUBECONFIG = $(KIND_KUBECONFIG)
kind: kind-setup-ingress ## All-in-one kind target
kind: kind-setup-ingress kind-load-image ## All-in-one kind target

.PHONY: kind-setup
kind-setup: export KUBECONFIG = $(KIND_KUBECONFIG)
kind-setup: $(KIND_KUBECONFIG) ## Creates the kind cluster

.PHONY: kind-setup-ingress
kind-setup-ingress: export KUBECONFIG = $(KIND_KUBECONFIG)
kind-setup-ingress: $(ingress_sentinel) ### Install NGINX as ingress controller onto kind cluster (localhost:8081 / localhost:8443)

$(ingress_sentinel): export KUBECONFIG = $(KIND_KUBECONFIG)
$(ingress_sentinel): $(KIND_KUBECONFIG)
kind-setup-ingress: kind-setup ## Install NGINX as ingress controller onto kind cluster (localhost:8088)
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
kubectl wait -n ingress-nginx --for condition=Complete jobs/ingress-nginx-admission-patch --timeout 180s
kubectl wait -n ingress-nginx --for condition=ContainersReady --timeout 180s $$(kubectl -n ingress-nginx get pods -o name --no-headers | grep controller)
@touch $@

# .PHONY: kind-load-image
# kind-load-image: kind-setup build-docker ### Load the container image onto kind cluster
# @$(KIND) load docker-image --name $(KIND_CLUSTER) $(CONTAINER_IMG)
.PHONY: kind-load-image
# We fix the arch to linux/amd64 since kind runs in amd64 even on Mac/arm.
kind-load-image: export GOOS = linux
kind-load-image: export GOARCH = amd64
kind-load-image: kind-setup build-docker ## Load the container image onto kind cluster
@$(kind_bin) load docker-image --name $(KIND_CLUSTER) $(CONTAINER_IMG)

.PHONY: kind-clean
kind-clean: export KUBECONFIG = $(KIND_KUBECONFIG)
kind-clean: ## Removes the kind Cluster
@$(KIND_CMD) delete cluster --name $(KIND_CLUSTER) || true
@rm -rf $(kind_dir)/*
@$(kind_bin) delete cluster --name $(KIND_CLUSTER) || true
rm -rf $(kind_dir) $(kind_bin)

$(KIND_KUBECONFIG): export KUBECONFIG = $(KIND_KUBECONFIG)
$(KIND_KUBECONFIG):
$(KIND_CMD) create cluster \
$(KIND_KUBECONFIG): $(kind_bin)
$(kind_bin) create cluster \
--name $(KIND_CLUSTER) \
--image $(KIND_IMAGE) \
--config kind/config.yaml
Expand Down
Loading

0 comments on commit b0a848d

Please sign in to comment.