From ea68bed9c2e04c066c65121036cae3cd5e85c76f Mon Sep 17 00:00:00 2001 From: Vegard Engen Date: Tue, 21 Oct 2025 07:23:07 +0200 Subject: [PATCH] Add helm --- Makefile | 54 +++ helm/INSTALL.md | 298 ++++++++++++++++ helm/README.md | 234 ++++++++++++ helm/unifi-network-operator/.helmignore | 23 ++ helm/unifi-network-operator/Chart.yaml | 16 + helm/unifi-network-operator/README.md | 335 ++++++++++++++++++ .../unifi.engen.priv.no_firewallgroups.yaml | 187 ++++++++++ .../unifi.engen.priv.no_firewallpolicies.yaml | 138 ++++++++ .../unifi.engen.priv.no_firewallzones.yaml | 75 ++++ ...i.engen.priv.no_networkconfigurations.yaml | 117 ++++++ .../unifi.engen.priv.no_portforwards.yaml | 49 +++ .../templates/NOTES.txt | 49 +++ .../templates/_helpers.tpl | 83 +++++ .../templates/clusterrole.yaml | 56 +++ .../templates/clusterrolebinding.yaml | 16 + .../templates/configmap.yaml | 22 ++ .../templates/deployment.yaml | 82 +++++ .../templates/role.yaml | 41 +++ .../templates/rolebinding.yaml | 17 + .../templates/secret.yaml | 15 + .../templates/service.yaml | 22 ++ .../templates/serviceaccount.yaml | 14 + .../templates/servicemonitor.yaml | 24 ++ helm/unifi-network-operator/values.yaml | 159 +++++++++ 24 files changed, 2126 insertions(+) create mode 100644 helm/INSTALL.md create mode 100644 helm/README.md create mode 100644 helm/unifi-network-operator/.helmignore create mode 100644 helm/unifi-network-operator/Chart.yaml create mode 100644 helm/unifi-network-operator/README.md create mode 100644 helm/unifi-network-operator/crds/unifi.engen.priv.no_firewallgroups.yaml create mode 100644 helm/unifi-network-operator/crds/unifi.engen.priv.no_firewallpolicies.yaml create mode 100644 helm/unifi-network-operator/crds/unifi.engen.priv.no_firewallzones.yaml create mode 100644 helm/unifi-network-operator/crds/unifi.engen.priv.no_networkconfigurations.yaml create mode 100644 helm/unifi-network-operator/crds/unifi.engen.priv.no_portforwards.yaml create mode 100644 helm/unifi-network-operator/templates/NOTES.txt create mode 100644 helm/unifi-network-operator/templates/_helpers.tpl create mode 100644 helm/unifi-network-operator/templates/clusterrole.yaml create mode 100644 helm/unifi-network-operator/templates/clusterrolebinding.yaml create mode 100644 helm/unifi-network-operator/templates/configmap.yaml create mode 100644 helm/unifi-network-operator/templates/deployment.yaml create mode 100644 helm/unifi-network-operator/templates/role.yaml create mode 100644 helm/unifi-network-operator/templates/rolebinding.yaml create mode 100644 helm/unifi-network-operator/templates/secret.yaml create mode 100644 helm/unifi-network-operator/templates/service.yaml create mode 100644 helm/unifi-network-operator/templates/serviceaccount.yaml create mode 100644 helm/unifi-network-operator/templates/servicemonitor.yaml create mode 100644 helm/unifi-network-operator/values.yaml diff --git a/Makefile b/Makefile index 2ce1da5..8b40546 100644 --- a/Makefile +++ b/Makefile @@ -229,3 +229,57 @@ mv $(1) $(1)-$(3) ;\ } ;\ ln -sf $(1)-$(3) $(1) endef + +##@ Helm + +HELM_CHART_DIR ?= helm/unifi-network-operator +HELM_RELEASE_NAME ?= unifi-network-operator +HELM_NAMESPACE ?= unifi-network-operator-system + +.PHONY: helm-lint +helm-lint: ## Lint the Helm chart + helm lint $(HELM_CHART_DIR) --set unifi.url="https://test.local" --set unifi.password="test" + +.PHONY: helm-template +helm-template: ## Render Helm templates for inspection + helm template $(HELM_RELEASE_NAME) $(HELM_CHART_DIR) \ + --namespace $(HELM_NAMESPACE) \ + --set unifi.url="https://test.local" \ + --set unifi.password="test" \ + --debug + +.PHONY: helm-install +helm-install: ## Install the Helm chart (requires UNIFI_URL and UNIFI_PASSWORD env vars) + @if [ -z "$(UNIFI_URL)" ]; then echo "Error: UNIFI_URL is not set"; exit 1; fi + @if [ -z "$(UNIFI_PASSWORD)" ]; then echo "Error: UNIFI_PASSWORD is not set"; exit 1; fi + helm install $(HELM_RELEASE_NAME) $(HELM_CHART_DIR) \ + --namespace $(HELM_NAMESPACE) \ + --create-namespace \ + --set unifi.url="$(UNIFI_URL)" \ + --set unifi.password="$(UNIFI_PASSWORD)" \ + --set unifi.site="$(UNIFI_SITE)" \ + --set unifi.username="$(UNIFI_USERNAME)" + +.PHONY: helm-upgrade +helm-upgrade: ## Upgrade the Helm release + helm upgrade $(HELM_RELEASE_NAME) $(HELM_CHART_DIR) \ + --namespace $(HELM_NAMESPACE) + +.PHONY: helm-uninstall +helm-uninstall: ## Uninstall the Helm release + helm uninstall $(HELM_RELEASE_NAME) --namespace $(HELM_NAMESPACE) + +.PHONY: helm-package +helm-package: ## Package the Helm chart + helm package $(HELM_CHART_DIR) -d dist/ + +.PHONY: helm-dry-run +helm-dry-run: ## Dry run Helm installation + @if [ -z "$(UNIFI_URL)" ]; then echo "Error: UNIFI_URL is not set"; exit 1; fi + @if [ -z "$(UNIFI_PASSWORD)" ]; then echo "Error: UNIFI_PASSWORD is not set"; exit 1; fi + helm install $(HELM_RELEASE_NAME) $(HELM_CHART_DIR) \ + --namespace $(HELM_NAMESPACE) \ + --create-namespace \ + --set unifi.url="$(UNIFI_URL)" \ + --set unifi.password="$(UNIFI_PASSWORD)" \ + --dry-run --debug diff --git a/helm/INSTALL.md b/helm/INSTALL.md new file mode 100644 index 0000000..2fed15d --- /dev/null +++ b/helm/INSTALL.md @@ -0,0 +1,298 @@ +# UniFi Network Operator - Helm Installation Guide + +## Quick Start + +### 1. Install the Helm Chart + +The simplest way to install the operator: + +```bash +helm install unifi-network-operator ./helm/unifi-network-operator \ + --namespace unifi-network-operator-system \ + --create-namespace \ + --set unifi.url="https://your-unifi-controller:8443" \ + --set unifi.password="your-password" +``` + +### 2. Verify Installation + +```bash +# Check if the operator is running +kubectl get pods -n unifi-network-operator-system + +# Check the operator logs +kubectl logs -n unifi-network-operator-system -l app.kubernetes.io/name=unifi-network-operator -f + +# Verify CRDs are installed +kubectl get crds | grep unifi.engen.priv.no +``` + +### 3. Create Your First Resource + +Create a FirewallZone: + +```bash +cat <