diff --git a/Makefile b/Makefile index 0b88c02..41daf96 100644 --- a/Makefile +++ b/Makefile @@ -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 \ @@ -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 @@ -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 @@ -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 diff --git a/Makefile.vars.mk b/Makefile.vars.mk index ad62f64..b2753d1 100644 --- a/Makefile.vars.mk +++ b/Makefile.vars.mk @@ -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 @@ -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 diff --git a/prometheus/values_vcluster.yaml b/prometheus/values_vcluster.yaml new file mode 100644 index 0000000..6a6ed9d --- /dev/null +++ b/prometheus/values_vcluster.yaml @@ -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=[*]