Skip to content

Commit

Permalink
Fix makefile for vcluster setup
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Bigler <[email protected]>
  • Loading branch information
TheBigLee committed Nov 28, 2024
1 parent c01f596 commit 2bbb9f2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
33 changes: 26 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ lint: ## All-in-one linting
@echo 'Check for uncommitted changes ...'
git diff --exit-code

kind-storage: kind-setup csi-host-path-setup
kind-storage: kind-setup csi-host-path-setup vcluster-setup

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

$(crossplane_sentinel): export KUBECONFIG = $(KIND_KUBECONFIG)
$(crossplane_sentinel): kind-setup csi-host-path-setup vcluster-setup
$(crossplane_sentinel): kind-setup csi-host-path-setup
helm repo add crossplane https://charts.crossplane.io/stable --force-update
$(vcluster_bin) connect controlplane --namespace vcluster
helm upgrade --install crossplane --create-namespace --namespace syn-crossplane crossplane/crossplane \
Expand Down Expand Up @@ -79,6 +79,15 @@ stackgres-setup: kind-setup csi-host-path-setup ## Install StackGres

certmanager-setup: export KUBECONFIG = $(KIND_KUBECONFIG)
certmanager-setup: kind-storage
certmanager-setup:
$(vcluster_bin) connect controlplane --namespace vcluster
$(MAKE) certmanager-install
$(vcluster_bin) disconnect
$(MAKE) certmanager-install
@touch $@

certmanager-install: export KUBECONFIG = $(KIND_KUBECONFIG)
certmanager-install:
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
kubectl -n cert-manager wait --for condition=Available deployment/cert-manager --timeout 120s
kubectl -n cert-manager wait --for condition=Available deployment/cert-manager-webhook --timeout 120s
Expand Down Expand Up @@ -122,17 +131,23 @@ prometheus-setup: $(prometheus_sentinel) ## Install Prometheus stack

$(prometheus_sentinel): export KUBECONFIG = $(KIND_KUBECONFIG)
$(prometheus_sentinel): kind-setup-ingress
$(vcluster_bin) connect controlplane --namespace vcluster
$(MAKE) prometheus-install -e PROM_VALUES=prometheus/values_vcluster.yaml
$(vcluster_bin) disconnect
$(MAKE) prometheus-install
kubectl apply -f prometheus/netpol.yaml
@echo -e "***\n*** Installed Prometheus in http://prometheus.127.0.0.1.nip.io:8088/ and AlertManager in http://alertmanager.127.0.0.1.nip.io:8088/.\n***"
@touch $@
prometheus-install: export KUBECONFIG = $(KIND_KUBECONFIG)
prometheus-install:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm upgrade --install kube-prometheus \
--create-namespace \
--namespace prometheus-system \
--wait \
--values prometheus/values.yaml \
--values ${PROM_VALUES} \
prometheus-community/kube-prometheus-stack
kubectl -n prometheus-system wait --for condition=Available deployment/kube-prometheus-kube-prome-operator --timeout 120s
kubectl apply -f prometheus/netpol.yaml
@echo -e "***\n*** Installed Prometheus in http://prometheus.127.0.0.1.nip.io:8088/ and AlertManager in http://alertmanager.127.0.0.1.nip.io:8088/.\n***"
@touch $@

load-comp-image: ## Load the appcat-comp image if it exists
[[ "$$(docker images -q ghcr.io/vshn/appcat 2> /dev/null)" != "" ]] && kind load docker-image --name kindev ghcr.io/vshn/appcat || true
Expand All @@ -142,12 +157,16 @@ csi-host-path-setup: $(csi_sentinel) ## Setup csi-driver-host-path and set as de

$(csi_sentinel): export KUBECONFIG = $(KIND_KUBECONFIG)
$(csi_sentinel): unset-default-sc
$(MAKE) csi-install
@touch $@

csi-install: export KUBECONFIG = $(KIND_KUBECONFIG)
csi-install:
cd csi-host-path && \
kubectl apply -f snapshot-controller.yaml && \
kubectl apply -f storageclass.yaml && \
./deploy.sh
kubectl patch storageclass csi-hostpath-fast -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
@touch $@

.PHONY: clean
clean: kind-clean ## Clean up local dev environment
Expand Down
4 changes: 4 additions & 0 deletions Makefile.vars.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## These are some common variables for Make
crossplane_sentinel = $(kind_dir)/crossplane-sentinel
certmanager-sentinel = $(kind_dir)/certmanager-sentinel
k8up_sentinel = $(kind_dir)/k8up-sentinel
prometheus_sentinel = $(kind_dir)/prometheus-sentinel
local_pv_sentinel = $(kind_dir)/local_pv
Expand All @@ -26,6 +27,9 @@ KIND_CMD ?= go run sigs.k8s.io/kind
KIND_KUBECONFIG ?= $(kind_dir)/kind-kubeconfig-$(KIND_NODE_VERSION)
KIND_CLUSTER ?= $(PROJECT_NAME)

## PROMETHEUS
PROM_VALUES=prometheus/values.yaml


## VCLUSTER
vcluster_bin = $(go_bin)/vclusterctl
Expand Down
26 changes: 26 additions & 0 deletions prometheus/values_vcluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# See https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack

kubeEtcd:
enabled: false
kubeScheduler:
enabled: false
kubeProxy:
enabled: false
kubeControllerManager:
enabled: false
grafana:
enabled: false
nodeExporter:
enabled: false

prometheus:
prometheusSpec:
# these will cause Prometheus to search in all namespaces
serviceMonitorSelectorNilUsesHelmValues: false
ruleSelectorNilUsesHelmValues: false
podMonitorSelectorNilUsesHelmValues: false

# See https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-state-metrics
kube-state-metrics:
metricLabelsAllowlist:
- namespaces=[*]

0 comments on commit 2bbb9f2

Please sign in to comment.