Compare commits
206 Commits
9-add-watc
...
feature/ad
| Author | SHA1 | Date | |
|---|---|---|---|
| 599bf7c3a9 | |||
| 3cc169713e | |||
| 60544f1449 | |||
| 35173add36 | |||
| 3757027b01 | |||
| c4f7cf63fa | |||
| ea68bed9c2 | |||
| 32a595d160 | |||
| 834f52c015 | |||
| 9d43b517e6 | |||
| 2b38f08a1a | |||
| 3a63034e26 | |||
| 37d8060995 | |||
| 8623d6cbc0 | |||
| 61606e8a7e | |||
| 44d89a5a50 | |||
| 19f24add0a | |||
| 2e95d29373 | |||
| 990140ee1c | |||
| 24c88264c9 | |||
| 938d53fa8f | |||
| 768c61020e | |||
| 8d70a78a50 | |||
| 5885daac55 | |||
| 440dc04e5b | |||
| 22c8df6833 | |||
| 35d95d107c | |||
| 4bb45b0128 | |||
| 9eefd08823 | |||
| d53810b714 | |||
| 33f1fd5eac | |||
| 9ae7d91365 | |||
| 6fe5fdf859 | |||
| 37b5eb830a | |||
| 1834527d43 | |||
| b562c200ba | |||
| 2485365728 | |||
| efeaf521fd | |||
| 7ce8682ecb | |||
| 744e43c1f4 | |||
| 8095723337 | |||
| 9e7b6123c2 | |||
| 062b386f7f | |||
| aca35507ba | |||
| 4ede272b70 | |||
| 5e413a64e8 | |||
| 1cfd5ef55c | |||
| c89dad396b | |||
| cddda7098c | |||
| 9a186ad190 | |||
| 4ece12d18b | |||
| 6d0df79c87 | |||
| 445dd7830e | |||
| a73aef4f9d | |||
| a99de02594 | |||
| 893318ad53 | |||
| 201edb1b82 | |||
| b1c0a4ee11 | |||
| 13677136a7 | |||
| cb296c3881 | |||
| 3c6b48803d | |||
| f71fa2af8e | |||
| 1819ef2b60 | |||
| 74d7ca84a5 | |||
| 0f7ffe3c85 | |||
| 3020510c6f | |||
| 475e226b69 | |||
| a5521013b9 | |||
| 4aa3436f28 | |||
| 6e32555e9e | |||
| 13c23863be | |||
| 918b45c940 | |||
| 3cb65a5a14 | |||
| 4ae70ecf74 | |||
| 3aa4d1a24a | |||
| 1231bc50e5 | |||
| e1847f4cf9 | |||
| 55a206d509 | |||
| 00179595e4 | |||
| f09e008fb7 | |||
| 14a8155dcf | |||
| 93ef66f01d | |||
| 80746321a9 | |||
| 6423ef7d6e | |||
| fdefd05608 | |||
| 760fd3903f | |||
| cda1c7ddff | |||
| 1274fe610f | |||
| f091ec148b | |||
| 66e1d854d3 | |||
| f43c1f3b63 | |||
| 0046157633 | |||
| 56a781a260 | |||
| 29fb9601fd | |||
| c34eea5e13 | |||
| fe90ac7ea4 | |||
| 31679a3f53 | |||
| de38c76e24 | |||
| 2a396ad981 | |||
| f147ec8108 | |||
| b6a2b73eb8 | |||
| 2304e33586 | |||
| a40f1342fe | |||
| bd8d1f7c01 | |||
| ac47c880ed | |||
| 481091160b | |||
| 14e4fe1c46 | |||
| 4901dfbad5 | |||
| c454c78478 | |||
| c30e27efc4 | |||
| f2a943de3c | |||
| 720865c984 | |||
| 913a24a613 | |||
| 719ba853bc | |||
| 4e26fe02f5 | |||
| cd61d5c82a | |||
| 6983253c9e | |||
| 1d7c7c864e | |||
| 1a2def25bf | |||
| 6c8503bf15 | |||
| b9b86e0d5d | |||
| 2c9659409c | |||
| 20c4dda5ad | |||
| bb28850ca5 | |||
| f08c165628 | |||
| 46e6217557 | |||
| 36f337434d | |||
| 3f14d82679 | |||
| 2817272082 | |||
| 1545f05d53 | |||
| 47116c70b5 | |||
| 0eb5b5c2eb | |||
| 7e6573deb4 | |||
| e22a4c4992 | |||
| 401f4a7cf7 | |||
| 68e8782da4 | |||
| e95a4c13e6 | |||
| d82d7d2902 | |||
| 3091c89fa8 | |||
| 853fca1635 | |||
| 07208979e3 | |||
| c86196aa88 | |||
| a35bc7220d | |||
| 446fb89d00 | |||
| 4bf3adaf87 | |||
| d7f2d8031e | |||
| 604cc20505 | |||
| 572521747f | |||
| acea7fd46e | |||
| 634021854d | |||
| 1e0a51f83b | |||
| cab7bc2f5a | |||
| cef43b9c3e | |||
| 019a33a69a | |||
| c2ff504510 | |||
| 55ef068855 | |||
| babbf2ed97 | |||
| 8765a94893 | |||
| 54ade7cc49 | |||
| bf666f0a89 | |||
| b59fc563f3 | |||
| b444690400 | |||
| bcf73d64bf | |||
| d372e4c7a7 | |||
| c80473d9e8 | |||
| bcffdfede7 | |||
| d7a444c8d7 | |||
| df9926e3da | |||
| c2ffce2d4d | |||
| fc0bda1e7b | |||
| dd4df6ee07 | |||
| 86b58cb5a9 | |||
| 6aed3728cc | |||
| 3167397a81 | |||
| 0233e71b7e | |||
| 5f7b39b76e | |||
| 5468aac185 | |||
| 92ee1eeade | |||
| 52afa7365d | |||
| 6b85bf78c0 | |||
| a018b3e258 | |||
| 70a2987230 | |||
| 4fd0a7dc14 | |||
| 54d94a90d5 | |||
| c63d52bb46 | |||
| 89a811bef9 | |||
| 4c873ea723 | |||
| 7e93d04c4a | |||
| 625e8e0423 | |||
| d63566b794 | |||
| 8ec57323fe | |||
| 664e56def8 | |||
| 3f59db13f0 | |||
| a023204d6c | |||
| 46d5e2ce2a | |||
| 72c13517b0 | |||
| 7b2acb168a | |||
| 46a0832aea | |||
| c61a555d8a | |||
| b4b3888bc9 | |||
| 6636314010 | |||
| 8168f00038 | |||
| c681a0c987 | |||
| f31d386bd0 | |||
| 2aeb2dd25a | |||
| 4af8b3f78c |
26
.gitea/workflows/build.yaml
Normal file
26
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Build project
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- main
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container: registry.engen.priv.no/gitea-build:0.1.0
|
||||
steps:
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan gitea-ssh.engen.priv.no >> ~/.ssh/known_hosts
|
||||
- name: Install node and go
|
||||
run: apt update && apt -y install nodejs
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: ssh repo
|
||||
run: git config --global url.git@gitea-ssh.engen.priv.no:.insteadOf https://gitea.engen.priv.no/
|
||||
- name: Build
|
||||
run: go build cmd/main.go
|
||||
- name: Build manifest
|
||||
run: make build-installer
|
||||
50
.gitea/workflows/kobuild.yaml
Normal file
50
.gitea/workflows/kobuild.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Publish
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container: registry.engen.priv.no/gitea-build:0.1.0
|
||||
env:
|
||||
GITEA_USER: ${{ secrets.GITEAUSER }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEATOKEN }}
|
||||
GITEA_REGISTRY: gitea.engen.priv.no
|
||||
GITEA_ORG: klauvsteinen
|
||||
steps:
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan gitea-ssh.engen.priv.no >> ~/.ssh/known_hosts
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: ssh repo
|
||||
run: git config --global url.git@gitea-ssh.engen.priv.no:.insteadOf https://gitea.engen.priv.no/
|
||||
- name: Docker login
|
||||
run: echo "${GITEA_TOKEN}" | docker login "${GITEA_REGISTRY}" --username "${GITEA_USER}" --password-stdin
|
||||
- name: Build
|
||||
run: |
|
||||
export KO_DOCKER_REPO="${GITEA_REGISTRY}/${GITEA_ORG}/unifi-network-operator-controller"
|
||||
ko publish ./cmd \
|
||||
--tags "latest" \
|
||||
--image-label 'org.opencontainers.image.authors=Klauvsteinen <vegard@engen.priv.no>' \
|
||||
--image-label 'org.opencontainers.image.vendor=Klauvsteinen' \
|
||||
--image-label 'org.opencontainers.image.source=https://gitea.engen.priv.no/klauvsteinen/unifi-network-operator' \
|
||||
--image-label 'org.opencontainers.image.url=https://gitea.engen.priv.no/klauvsteinen/unifi-network-operator' \
|
||||
--image-label 'dev.chainguard.package.main=' \
|
||||
--bare
|
||||
- name: Build manifest
|
||||
run: |
|
||||
make IMG="${GITEA_REGISTRY}/${GITEA_ORG}/unifi-network-operator-controller:latest" build-installer
|
||||
curl -X DELETE \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/x-yaml" \
|
||||
https://gitea.engen.priv.no/api/packages/klauvsteinen/generic/unifi-network-operator/latest/install.yaml
|
||||
curl -X PUT \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/x-yaml" \
|
||||
--data-binary @./dist/install.yaml \
|
||||
https://gitea.engen.priv.no/api/packages/klauvsteinen/generic/unifi-network-operator/latest/install.yaml
|
||||
54
.gitea/workflows/publish.yaml
Normal file
54
.gitea/workflows/publish.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Publish
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+-alpha[0-9]+'
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container: registry.engen.priv.no/gitea-build:0.1.0
|
||||
env:
|
||||
GITEA_USER: ${{ secrets.GITEAUSER }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEATOKEN }}
|
||||
GITEA_REGISTRY: gitea.engen.priv.no
|
||||
GITEA_ORG: klauvsteinen
|
||||
steps:
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan gitea-ssh.engen.priv.no >> ~/.ssh/known_hosts
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: ssh repo
|
||||
run: git config --global url.git@gitea-ssh.engen.priv.no:.insteadOf https://gitea.engen.priv.no/
|
||||
- name: Extract tag (outside container)
|
||||
shell: bash
|
||||
run: |
|
||||
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
env
|
||||
- name: Docker login
|
||||
run: echo "${GITEA_TOKEN}" | docker login "${GITEA_REGISTRY}" --username "${GITEA_USER}" --password-stdin
|
||||
- name: Build
|
||||
run: |
|
||||
export KO_DOCKER_REPO="${GITEA_REGISTRY}/${GITEA_ORG}/unifi-network-operator-controller"
|
||||
ko publish ./cmd \
|
||||
--tags "$TAG" \
|
||||
--image-label 'org.opencontainers.image.authors=Klauvsteinen <vegard@engen.priv.no>' \
|
||||
--image-label 'org.opencontainers.image.vendor=Klauvsteinen' \
|
||||
--image-label 'org.opencontainers.image.source=https://gitea.engen.priv.no/klauvsteinen/unifi-network-operator' \
|
||||
--image-label 'org.opencontainers.image.url=https://gitea.engen.priv.no/klauvsteinen/unifi-network-operator' \
|
||||
--image-label 'dev.chainguard.package.main=' \
|
||||
--bare
|
||||
- name: Build manifest
|
||||
run: |
|
||||
make IMG="${GITEA_REGISTRY}/${GITEA_ORG}/unifi-network-operator-controller:$TAG" build-installer
|
||||
curl -X PUT \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/x-yaml" \
|
||||
--data-binary @./dist/install.yaml \
|
||||
https://gitea.engen.priv.no/api/packages/klauvsteinen/generic/unifi-network-operator/$TAG/install.yaml
|
||||
|
||||
264
.github/README.md
vendored
Normal file
264
.github/README.md
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
# GitHub Workflows Documentation
|
||||
|
||||
This directory contains GitHub Actions workflows for automating the build, test, and release process of the UniFi Network Operator.
|
||||
|
||||
## Workflows Overview
|
||||
|
||||
### 1. Docker Build and Push (`docker-build-push.yaml`)
|
||||
|
||||
**Triggers:**
|
||||
- Push to `main` branch
|
||||
- Push to `feature/**` branches
|
||||
- Push of tags starting with `v*`
|
||||
- Pull requests to `main`
|
||||
- Manual dispatch
|
||||
|
||||
**What it does:**
|
||||
- Runs Go tests with coverage
|
||||
- Builds multi-architecture Docker images (amd64, arm64)
|
||||
- Pushes images to GitHub Container Registry (ghcr.io)
|
||||
- Creates tags based on branch/tag names
|
||||
|
||||
**Image naming:**
|
||||
- `ghcr.io/vegardengen/unifi-network-operator:main` - Latest from main branch
|
||||
- `ghcr.io/vegardengen/unifi-network-operator:feature-xyz` - Feature branch builds
|
||||
- `ghcr.io/vegardengen/unifi-network-operator:v1.0.0` - Version tags
|
||||
- `ghcr.io/vegardengen/unifi-network-operator:latest` - Latest stable release
|
||||
|
||||
### 2. Helm Chart Release (`helm-release.yaml`)
|
||||
|
||||
**Triggers:**
|
||||
- Push to `main` branch with changes in `helm/` directory
|
||||
- Manual dispatch
|
||||
|
||||
**What it does:**
|
||||
- Packages the Helm chart
|
||||
- Creates GitHub releases for chart versions
|
||||
- Publishes chart to GitHub Pages
|
||||
- Updates the Helm repository index
|
||||
|
||||
**Chart repository:** https://vegardengen.github.io/unifi-network-operator
|
||||
|
||||
### 3. Full Release (`release.yaml`)
|
||||
|
||||
**Triggers:**
|
||||
- Push of version tags (e.g., `v1.0.0`, `v1.2.3`)
|
||||
- Manual dispatch with version input
|
||||
|
||||
**What it does:**
|
||||
1. Builds and pushes multi-arch Docker images
|
||||
2. Updates Chart.yaml and values.yaml with release version
|
||||
3. Packages and releases Helm chart
|
||||
4. Creates GitHub release with release notes
|
||||
5. Attaches Helm chart package to release
|
||||
|
||||
**Pre-release detection:** Automatically marks releases as pre-release if tag contains `alpha`, `beta`, or `rc`
|
||||
|
||||
### 4. PR Validation (`pr-validation.yaml`)
|
||||
|
||||
**Triggers:**
|
||||
- Pull requests to `main` branch
|
||||
- Manual dispatch
|
||||
|
||||
**What it does:**
|
||||
- Validates Go code formatting
|
||||
- Runs `go vet`
|
||||
- Executes tests with race detection
|
||||
- Uploads coverage to Codecov
|
||||
- Lints Helm chart
|
||||
- Validates rendered Kubernetes manifests
|
||||
- Test builds Docker image
|
||||
|
||||
## Setup Requirements
|
||||
|
||||
### 1. Enable GitHub Pages
|
||||
|
||||
1. Go to repository Settings → Pages
|
||||
2. Source: Deploy from a branch
|
||||
3. Branch: `gh-pages` / `/ (root)`
|
||||
4. Save
|
||||
|
||||
The Helm chart will be available at: https://vegardengen.github.io/unifi-network-operator
|
||||
|
||||
### 2. Enable GitHub Packages
|
||||
|
||||
GitHub Container Registry is enabled by default. Images are automatically pushed to:
|
||||
`ghcr.io/vegardengen/unifi-network-operator`
|
||||
|
||||
To pull images:
|
||||
```bash
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:latest
|
||||
```
|
||||
|
||||
### 3. Configure Secrets (Optional)
|
||||
|
||||
The workflows use `GITHUB_TOKEN` which is automatically provided. Additional secrets you might want to add:
|
||||
|
||||
- `CODECOV_TOKEN` - For uploading coverage reports (optional)
|
||||
|
||||
### 4. Branch Protection (Recommended)
|
||||
|
||||
Configure branch protection for `main`:
|
||||
1. Go to Settings → Branches → Branch protection rules
|
||||
2. Add rule for `main`
|
||||
3. Enable:
|
||||
- Require pull request reviews
|
||||
- Require status checks to pass (select PR Validation workflow)
|
||||
- Require branches to be up to date
|
||||
|
||||
## Usage
|
||||
|
||||
### Creating a Release
|
||||
|
||||
#### Method 1: Using Git Tags (Recommended)
|
||||
|
||||
```bash
|
||||
# Create and push a version tag
|
||||
git tag -a v1.0.0 -m "Release v1.0.0"
|
||||
git push github v1.0.0
|
||||
```
|
||||
|
||||
This automatically:
|
||||
1. Builds Docker images for `v1.0.0` and `latest`
|
||||
2. Packages Helm chart with version `1.0.0`
|
||||
3. Creates GitHub release
|
||||
4. Publishes to Helm repository
|
||||
|
||||
#### Method 2: Manual Dispatch
|
||||
|
||||
1. Go to Actions → Release workflow
|
||||
2. Click "Run workflow"
|
||||
3. Enter the version tag (e.g., `v1.0.0`)
|
||||
4. Click "Run workflow"
|
||||
|
||||
### Installing from the Helm Repository
|
||||
|
||||
Once the release workflow completes:
|
||||
|
||||
```bash
|
||||
# Add the Helm repository
|
||||
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
|
||||
|
||||
# Update repository cache
|
||||
helm repo update
|
||||
|
||||
# Install the operator
|
||||
helm install unifi-network-operator unifi-network-operator/unifi-network-operator \
|
||||
--namespace unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://your-unifi-controller:8443" \
|
||||
--set unifi.password="your-password"
|
||||
```
|
||||
|
||||
### Using Development Builds
|
||||
|
||||
Feature branch builds are automatically pushed:
|
||||
|
||||
```bash
|
||||
# Use a specific feature branch build
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
--set image.repository=ghcr.io/vegardengen/unifi-network-operator \
|
||||
--set image.tag=feature-xyz
|
||||
```
|
||||
|
||||
## Workflow Files
|
||||
|
||||
- [`docker-build-push.yaml`](workflows/docker-build-push.yaml) - Docker image CI/CD
|
||||
- [`helm-release.yaml`](workflows/helm-release.yaml) - Helm chart publishing
|
||||
- [`release.yaml`](workflows/release.yaml) - Complete release process
|
||||
- [`pr-validation.yaml`](workflows/pr-validation.yaml) - PR checks
|
||||
- [`cr.yaml`](cr.yaml) - Chart Releaser configuration
|
||||
|
||||
## Versioning Strategy
|
||||
|
||||
### Docker Images
|
||||
|
||||
- `latest` - Latest stable release from main branch
|
||||
- `vX.Y.Z` - Specific version tag
|
||||
- `X.Y.Z` - Version without 'v' prefix
|
||||
- `X.Y` - Major.minor version
|
||||
- `X` - Major version only
|
||||
- `main` - Latest commit on main branch
|
||||
- `feature-name` - Feature branch builds
|
||||
|
||||
### Helm Charts
|
||||
|
||||
- Chart version follows semantic versioning (X.Y.Z)
|
||||
- AppVersion matches Docker image tag
|
||||
- Both are automatically updated during release
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Docker Build Fails
|
||||
|
||||
Check:
|
||||
- Dockerfile syntax
|
||||
- Go dependencies in go.mod
|
||||
- Build context includes all necessary files
|
||||
|
||||
### Helm Release Fails
|
||||
|
||||
Check:
|
||||
- Chart.yaml is valid
|
||||
- All template files are valid YAML
|
||||
- No syntax errors in templates
|
||||
- Version in Chart.yaml is unique
|
||||
|
||||
### GitHub Pages Not Updating
|
||||
|
||||
1. Check workflow completed successfully
|
||||
2. Verify `gh-pages` branch exists
|
||||
3. Check Pages is enabled in repository settings
|
||||
4. Wait a few minutes for CDN propagation
|
||||
|
||||
### Images Not Accessible
|
||||
|
||||
Public images require:
|
||||
1. Repository → Settings → Packages
|
||||
2. Find the package
|
||||
3. Package settings → Change visibility → Public
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Always test locally first:**
|
||||
```bash
|
||||
make helm-lint
|
||||
make helm-template
|
||||
docker build -t test .
|
||||
```
|
||||
|
||||
2. **Use semantic versioning:**
|
||||
- Major (X): Breaking changes
|
||||
- Minor (Y): New features, backward compatible
|
||||
- Patch (Z): Bug fixes
|
||||
|
||||
3. **Create release notes:**
|
||||
- Describe what changed
|
||||
- Highlight breaking changes
|
||||
- Document upgrade path
|
||||
|
||||
4. **Test releases in a dev environment:**
|
||||
- Use pre-release tags (`v1.0.0-beta1`)
|
||||
- Validate before promoting to stable
|
||||
|
||||
## Monitoring
|
||||
|
||||
### Check Workflow Status
|
||||
|
||||
- Go to repository → Actions
|
||||
- View workflow runs
|
||||
- Check logs for failures
|
||||
|
||||
### View Published Artifacts
|
||||
|
||||
- **Docker images:** https://github.com/vegardengen/unifi-network-operator/pkgs/container/unifi-network-operator
|
||||
- **Helm charts:** https://github.com/vegardengen/unifi-network-operator/releases
|
||||
- **Chart repository:** https://vegardengen.github.io/unifi-network-operator
|
||||
|
||||
## Support
|
||||
|
||||
For issues with workflows:
|
||||
1. Check the Actions tab for detailed logs
|
||||
2. Review the workflow YAML files
|
||||
3. Consult GitHub Actions documentation
|
||||
4. Open an issue in the repository
|
||||
244
.github/SETUP.md
vendored
Normal file
244
.github/SETUP.md
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
# GitHub Actions Setup Guide
|
||||
|
||||
Quick guide to get the CI/CD workflows running for the UniFi Network Operator.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Repository pushed to GitHub
|
||||
- Admin access to the repository
|
||||
|
||||
## Step-by-Step Setup
|
||||
|
||||
### 1. Enable GitHub Container Registry
|
||||
|
||||
Images will be pushed to `ghcr.io/vegardengen/unifi-network-operator`
|
||||
|
||||
**Make the package public (after first push):**
|
||||
|
||||
1. Go to your GitHub profile → Packages
|
||||
2. Find `unifi-network-operator`
|
||||
3. Package settings → Change visibility → Public
|
||||
4. Confirm by typing the package name
|
||||
|
||||
### 2. Enable GitHub Pages
|
||||
|
||||
**Set up GitHub Pages for Helm chart hosting:**
|
||||
|
||||
1. Go to repository **Settings** → **Pages**
|
||||
2. Under "Build and deployment":
|
||||
- **Source:** Deploy from a branch
|
||||
- **Branch:** `gh-pages` / `/ (root)`
|
||||
- Click **Save**
|
||||
|
||||
3. Wait for initial deployment (workflow will create the branch)
|
||||
|
||||
Your Helm repository will be available at:
|
||||
```
|
||||
https://vegardengen.github.io/unifi-network-operator
|
||||
```
|
||||
|
||||
### 3. Configure Repository Permissions
|
||||
|
||||
**Allow workflows to create releases:**
|
||||
|
||||
1. Go to **Settings** → **Actions** → **General**
|
||||
2. Scroll to "Workflow permissions"
|
||||
3. Select **Read and write permissions**
|
||||
4. Check **Allow GitHub Actions to create and approve pull requests**
|
||||
5. Click **Save**
|
||||
|
||||
### 4. Set Up Branch Protection (Optional but Recommended)
|
||||
|
||||
**Protect the main branch:**
|
||||
|
||||
1. Go to **Settings** → **Branches**
|
||||
2. Click **Add branch protection rule**
|
||||
3. Branch name pattern: `main`
|
||||
4. Enable:
|
||||
- ☑ Require a pull request before merging
|
||||
- ☑ Require status checks to pass before merging
|
||||
- Search and select: `lint-and-test`, `helm-lint`, `docker-build`
|
||||
- ☑ Require branches to be up to date before merging
|
||||
5. Click **Create** or **Save changes**
|
||||
|
||||
### 5. Test the Workflows
|
||||
|
||||
**Test PR validation:**
|
||||
|
||||
```bash
|
||||
# Create a test branch
|
||||
git checkout -b test-workflows
|
||||
|
||||
# Make a small change
|
||||
echo "# Test" >> README.md
|
||||
|
||||
# Commit and push
|
||||
git add README.md
|
||||
git commit -m "Test workflows"
|
||||
git push github test-workflows
|
||||
|
||||
# Create a PR on GitHub
|
||||
# Check Actions tab to see PR validation running
|
||||
```
|
||||
|
||||
**Test Docker build:**
|
||||
|
||||
```bash
|
||||
# Push to main branch (after PR is merged)
|
||||
git checkout main
|
||||
git pull github main
|
||||
git push github main
|
||||
|
||||
# Check Actions → Docker Build and Push workflow
|
||||
```
|
||||
|
||||
**Test full release:**
|
||||
|
||||
```bash
|
||||
# Create and push a version tag
|
||||
git tag -a v0.1.0 -m "First release"
|
||||
git push github v0.1.0
|
||||
|
||||
# Check Actions → Release workflow
|
||||
# This will:
|
||||
# 1. Build Docker images
|
||||
# 2. Package Helm chart
|
||||
# 3. Create GitHub release
|
||||
# 4. Publish to Helm repository
|
||||
```
|
||||
|
||||
### 6. Verify Everything Works
|
||||
|
||||
**Check Docker image:**
|
||||
|
||||
```bash
|
||||
# Pull the image
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:v0.1.0
|
||||
|
||||
# Verify it works
|
||||
docker run --rm ghcr.io/vegardengen/unifi-network-operator:v0.1.0 --version
|
||||
```
|
||||
|
||||
**Check Helm repository:**
|
||||
|
||||
```bash
|
||||
# Add the Helm repo
|
||||
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
|
||||
|
||||
# Update
|
||||
helm repo update
|
||||
|
||||
# Search for charts
|
||||
helm search repo unifi-network-operator
|
||||
|
||||
# Show chart info
|
||||
helm show chart unifi-network-operator/unifi-network-operator
|
||||
```
|
||||
|
||||
## Optional: Add Codecov Integration
|
||||
|
||||
**For test coverage reports:**
|
||||
|
||||
1. Go to https://codecov.io
|
||||
2. Sign in with GitHub
|
||||
3. Add your repository
|
||||
4. Copy the token
|
||||
5. Go to repository **Settings** → **Secrets and variables** → **Actions**
|
||||
6. Click **New repository secret**
|
||||
- Name: `CODECOV_TOKEN`
|
||||
- Value: [paste token]
|
||||
7. Click **Add secret**
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Workflow Fails with "Resource not accessible by integration"
|
||||
|
||||
**Fix:** Enable read and write permissions (see Step 3 above)
|
||||
|
||||
### Docker Image Push Fails with "Permission denied"
|
||||
|
||||
**Fix:**
|
||||
1. Go to package settings
|
||||
2. Add repository access
|
||||
3. Or change package visibility to public
|
||||
|
||||
### Helm Chart Not Appearing on GitHub Pages
|
||||
|
||||
**Check:**
|
||||
1. `gh-pages` branch was created
|
||||
2. Pages is enabled in settings
|
||||
3. Workflow completed successfully
|
||||
4. Wait 5-10 minutes for CDN
|
||||
|
||||
**Manually create gh-pages branch if needed:**
|
||||
```bash
|
||||
git checkout --orphan gh-pages
|
||||
git rm -rf .
|
||||
echo "# Helm Charts" > README.md
|
||||
git add README.md
|
||||
git commit -m "Initialize gh-pages"
|
||||
git push github gh-pages
|
||||
```
|
||||
|
||||
### Release Workflow Fails
|
||||
|
||||
**Common issues:**
|
||||
- Chart version already exists → Bump version in Chart.yaml
|
||||
- Invalid YAML → Run `make helm-lint` locally first
|
||||
- Missing permissions → Check Step 3
|
||||
|
||||
## Next Steps
|
||||
|
||||
Once everything is working:
|
||||
|
||||
1. **Update README.md** with installation instructions:
|
||||
```markdown
|
||||
## Installation
|
||||
|
||||
### Using Helm
|
||||
|
||||
```bash
|
||||
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
|
||||
helm repo update
|
||||
helm install unifi-network-operator unifi-network-operator/unifi-network-operator \
|
||||
--namespace unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://your-controller:8443" \
|
||||
--set unifi.password="your-password"
|
||||
```
|
||||
```
|
||||
|
||||
2. **Add badges to README.md:**
|
||||
```markdown
|
||||

|
||||

|
||||
```
|
||||
|
||||
3. **Create your first official release:**
|
||||
```bash
|
||||
git tag -a v0.1.0 -m "Initial release"
|
||||
git push github v0.1.0
|
||||
```
|
||||
|
||||
4. **Monitor the Actions tab** to ensure everything completes successfully
|
||||
|
||||
## Workflow Files Summary
|
||||
|
||||
| File | Purpose | Trigger |
|
||||
|------|---------|---------|
|
||||
| `docker-build-push.yaml` | Build and push Docker images | Push to main, tags, PRs |
|
||||
| `helm-release.yaml` | Publish Helm chart to GitHub Pages | Push to main (helm changes) |
|
||||
| `release.yaml` | Complete release process | Version tags (v*) |
|
||||
| `pr-validation.yaml` | Validate PRs | Pull requests to main |
|
||||
|
||||
## Getting Help
|
||||
|
||||
- **GitHub Actions Docs:** https://docs.github.com/en/actions
|
||||
- **Helm Chart Releaser:** https://github.com/helm/chart-releaser-action
|
||||
- **GitHub Container Registry:** https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
|
||||
|
||||
## Configuration Files
|
||||
|
||||
- [`.github/cr.yaml`](cr.yaml) - Chart Releaser configuration
|
||||
- [`.github/README.md`](README.md) - Detailed workflow documentation
|
||||
- [`workflows/`](workflows/) - All workflow definitions
|
||||
6
.github/cr.yaml
vendored
Normal file
6
.github/cr.yaml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# Chart Releaser configuration
|
||||
owner: vegardengen
|
||||
git-repo: unifi-network-operator
|
||||
charts-repo-url: https://vegardengen.github.io/unifi-network-operator
|
||||
# Skip packaging if the chart version already exists
|
||||
skip-existing: true
|
||||
94
.github/workflows/docker-build-push.yaml
vendored
Normal file
94
.github/workflows/docker-build-push.yaml
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'feature/**'
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
cache: true
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
go test -v ./... -coverprofile=coverage.out
|
||||
go tool cover -func=coverage.out
|
||||
env:
|
||||
SKIP_INTEGRATION_TESTS: "true"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Container Registry
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha,prefix={{branch}}-
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
VERSION=${{ github.ref_name }}
|
||||
COMMIT=${{ github.sha }}
|
||||
BUILD_DATE=${{ github.event.head_commit.timestamp }}
|
||||
|
||||
- name: Upload coverage reports
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-report
|
||||
path: coverage.out
|
||||
retention-days: 7
|
||||
65
.github/workflows/helm-release.yaml
vendored
Normal file
65
.github/workflows/helm-release.yaml
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
name: Release Helm Chart
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'helm/unifi-network-operator/**'
|
||||
- '.github/workflows/helm-release.yaml'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config user.name "$GITHUB_ACTOR"
|
||||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
|
||||
- name: Install Helm
|
||||
uses: azure/setup-helm@v4
|
||||
with:
|
||||
version: v3.14.0
|
||||
|
||||
- name: Run chart-releaser
|
||||
uses: helm/chart-releaser-action@v1.6.0
|
||||
with:
|
||||
charts_dir: helm
|
||||
config: .github/cr.yaml
|
||||
env:
|
||||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
CR_SKIP_EXISTING: true
|
||||
|
||||
publish-pages:
|
||||
needs: release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout gh-pages
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: gh-pages
|
||||
path: gh-pages
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v4
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: ./gh-pages
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
92
.github/workflows/pr-validation.yaml
vendored
Normal file
92
.github/workflows/pr-validation.yaml
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
name: PR Validation
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
lint-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
cache: true
|
||||
|
||||
- name: Run go fmt
|
||||
run: |
|
||||
if [ -n "$(gofmt -s -l .)" ]; then
|
||||
echo "Go code is not formatted:"
|
||||
gofmt -s -d .
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run go vet
|
||||
run: go vet ./...
|
||||
|
||||
- name: Run tests
|
||||
run: go test -v -race -coverprofile=coverage.out ./...
|
||||
env:
|
||||
SKIP_INTEGRATION_TESTS: "true"
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
file: ./coverage.out
|
||||
fail_ci_if_error: false
|
||||
|
||||
helm-lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Helm
|
||||
uses: azure/setup-helm@v4
|
||||
with:
|
||||
version: v3.14.0
|
||||
|
||||
- name: Lint Helm chart
|
||||
run: |
|
||||
helm lint helm/unifi-network-operator \
|
||||
--set unifi.url="https://test.local" \
|
||||
--set unifi.password="test"
|
||||
|
||||
- name: Template Helm chart
|
||||
run: |
|
||||
helm template test-release helm/unifi-network-operator \
|
||||
--namespace test \
|
||||
--set unifi.url="https://test.local" \
|
||||
--set unifi.password="test" \
|
||||
> /tmp/rendered.yaml
|
||||
|
||||
- name: Validate rendered manifests
|
||||
run: |
|
||||
# Check that the rendered output is valid YAML
|
||||
kubectl --dry-run=client apply -f /tmp/rendered.yaml
|
||||
|
||||
docker-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build Docker image (test only)
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: false
|
||||
tags: test:latest
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
225
.github/workflows/release.yaml
vendored
Normal file
225
.github/workflows/release.yaml
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag to release (e.g., v1.0.0)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
# Build and push multi-arch Docker images
|
||||
build-images:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
cache: true
|
||||
|
||||
- name: Run tests
|
||||
run: go test -v ./...
|
||||
env:
|
||||
SKIP_INTEGRATION_TESTS: "true"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract version
|
||||
id: version
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
VERSION="${{ github.event.inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
echo "version_no_v=${VERSION#v}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
|
||||
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version_no_v }}
|
||||
ghcr.io/${{ github.repository }}:latest
|
||||
labels: |
|
||||
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
org.opencontainers.image.version=${{ steps.version.outputs.version }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
# Package and release Helm chart
|
||||
release-chart:
|
||||
needs: build-images
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config user.name "$GITHUB_ACTOR"
|
||||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
|
||||
- name: Install Helm
|
||||
uses: azure/setup-helm@v4
|
||||
with:
|
||||
version: v3.14.0
|
||||
|
||||
- name: Extract version
|
||||
id: version
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
VERSION="${{ github.event.inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
VERSION_NO_V="${VERSION#v}"
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
echo "version_no_v=${VERSION_NO_V}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update Chart.yaml version and appVersion
|
||||
run: |
|
||||
sed -i "s/^version:.*/version: ${{ steps.version.outputs.version_no_v }}/" helm/unifi-network-operator/Chart.yaml
|
||||
sed -i "s/^appVersion:.*/appVersion: \"${{ steps.version.outputs.version }}\"/" helm/unifi-network-operator/Chart.yaml
|
||||
|
||||
- name: Update values.yaml image tag
|
||||
run: |
|
||||
sed -i "s/tag: \".*\"/tag: \"${{ steps.version.outputs.version }}\"/" helm/unifi-network-operator/values.yaml
|
||||
sed -i "s|repository: .*|repository: ghcr.io/${{ github.repository }}|" helm/unifi-network-operator/values.yaml
|
||||
|
||||
- name: Package Helm chart
|
||||
run: |
|
||||
mkdir -p .cr-release-packages
|
||||
helm package helm/unifi-network-operator -d .cr-release-packages
|
||||
|
||||
- name: Run chart-releaser
|
||||
uses: helm/chart-releaser-action@v1.6.0
|
||||
with:
|
||||
charts_dir: helm
|
||||
skip_packaging: true
|
||||
config: .github/cr.yaml
|
||||
env:
|
||||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
- name: Upload Helm chart as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: helm-chart
|
||||
path: .cr-release-packages/*.tgz
|
||||
retention-days: 90
|
||||
|
||||
# Create GitHub Release
|
||||
create-release:
|
||||
needs: [build-images, release-chart]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Extract version
|
||||
id: version
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
VERSION="${{ github.event.inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Download Helm chart artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: helm-chart
|
||||
path: ./artifacts
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
cat > release_notes.md << 'EOF'
|
||||
## UniFi Network Operator ${{ steps.version.outputs.version }}
|
||||
|
||||
### Installation
|
||||
|
||||
#### Using Helm
|
||||
|
||||
```bash
|
||||
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
|
||||
helm repo update
|
||||
helm install unifi-network-operator unifi-network-operator/unifi-network-operator \
|
||||
--namespace unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://your-unifi-controller:8443" \
|
||||
--set unifi.password="your-password"
|
||||
```
|
||||
|
||||
#### Using Docker
|
||||
|
||||
```bash
|
||||
docker pull ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
|
||||
```
|
||||
|
||||
### What's Changed
|
||||
|
||||
See the full changelog for details of changes in this release.
|
||||
|
||||
### Container Images
|
||||
|
||||
- `ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}`
|
||||
- Available for `linux/amd64` and `linux/arm64`
|
||||
|
||||
### Helm Chart
|
||||
|
||||
- Chart version: Automatically generated
|
||||
- App version: ${{ steps.version.outputs.version }}
|
||||
- Repository: https://vegardengen.github.io/unifi-network-operator
|
||||
EOF
|
||||
cat release_notes.md
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.version }}
|
||||
name: Release ${{ steps.version.outputs.version }}
|
||||
body_path: release_notes.md
|
||||
draft: false
|
||||
prerelease: ${{ contains(steps.version.outputs.version, 'alpha') || contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'rc') }}
|
||||
files: |
|
||||
./artifacts/*.tgz
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
399
CICD.md
Normal file
399
CICD.md
Normal file
@@ -0,0 +1,399 @@
|
||||
# CI/CD Pipeline Documentation
|
||||
|
||||
This document describes the continuous integration and deployment pipeline for the UniFi Network Operator.
|
||||
|
||||
## Overview
|
||||
|
||||
The CI/CD pipeline is built using GitHub Actions and provides:
|
||||
|
||||
- **Automated testing** on every pull request
|
||||
- **Multi-architecture Docker image builds** (amd64, arm64)
|
||||
- **Automated Helm chart releases** to GitHub Pages
|
||||
- **Complete release automation** with version tagging
|
||||
- **Public Docker images** via GitHub Container Registry
|
||||
|
||||
## Quick Start
|
||||
|
||||
### For Users
|
||||
|
||||
**Install the operator using Helm:**
|
||||
|
||||
```bash
|
||||
# Add the Helm repository
|
||||
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
|
||||
helm repo update
|
||||
|
||||
# Install
|
||||
helm install unifi-network-operator unifi-network-operator/unifi-network-operator \
|
||||
--namespace unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://your-unifi-controller:8443" \
|
||||
--set unifi.password="your-password"
|
||||
```
|
||||
|
||||
**Or use Docker directly:**
|
||||
|
||||
```bash
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:latest
|
||||
```
|
||||
|
||||
### For Contributors
|
||||
|
||||
**Run checks locally before pushing:**
|
||||
|
||||
```bash
|
||||
# Format code
|
||||
make fmt
|
||||
|
||||
# Run linters
|
||||
make vet
|
||||
|
||||
# Run tests
|
||||
make test
|
||||
|
||||
# Lint Helm chart
|
||||
make helm-lint
|
||||
|
||||
# Test Docker build
|
||||
docker build -t test .
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ GitHub Repository │
|
||||
│ vegardengen/unifi-network-operator │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
┌────────────────┼────────────────┐
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
┌──────────────┐ ┌──────────────┐ ┌─────────────┐
|
||||
│ Pull Request │ │ Push to Main │ │ Tag Push │
|
||||
│ Validation │ │ │ │ (v*.*) │
|
||||
└──────────────┘ └──────────────┘ └─────────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
┌──────────────┐ ┌──────────────┐ ┌─────────────┐
|
||||
│ • Go Fmt │ │ Docker Build │ │ Release │
|
||||
│ • Go Vet │ │ & Push │ │ Workflow │
|
||||
│ • Tests │ │ │ │ │
|
||||
│ • Helm │ │ Helm Chart │ │ • Docker │
|
||||
│ Lint │ │ Release │ │ • Helm │
|
||||
│ • Docker │ │ │ │ • GitHub │
|
||||
│ Build │ │ │ │ Release │
|
||||
└──────────────┘ └──────────────┘ └─────────────┘
|
||||
│ │
|
||||
▼ ▼
|
||||
┌───────────────────────────┐
|
||||
│ GitHub Container Registry │
|
||||
│ ghcr.io/vegardengen/... │
|
||||
└───────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌───────────────────────────┐
|
||||
│ GitHub Pages (Helm) │
|
||||
│ vegardengen.github.io/ │
|
||||
└───────────────────────────┘
|
||||
```
|
||||
|
||||
## Workflows
|
||||
|
||||
### 1. PR Validation (`pr-validation.yaml`)
|
||||
|
||||
**Triggers:** Pull requests to `main`
|
||||
|
||||
**Steps:**
|
||||
1. Code formatting check (`go fmt`)
|
||||
2. Static analysis (`go vet`)
|
||||
3. Unit tests with race detection
|
||||
4. Coverage upload to Codecov
|
||||
5. Helm chart linting
|
||||
6. Template rendering validation
|
||||
7. Test Docker build
|
||||
|
||||
**Purpose:** Ensure code quality before merging
|
||||
|
||||
### 2. Docker Build & Push (`docker-build-push.yaml`)
|
||||
|
||||
**Triggers:**
|
||||
- Push to `main` or `feature/**` branches
|
||||
- Push of tags starting with `v*`
|
||||
- Pull requests (build only, no push)
|
||||
|
||||
**Steps:**
|
||||
1. Run tests
|
||||
2. Set up QEMU for cross-compilation
|
||||
3. Set up Docker Buildx
|
||||
4. Extract metadata for tags
|
||||
5. Build for multiple architectures
|
||||
6. Push to GitHub Container Registry
|
||||
|
||||
**Image Tags Created:**
|
||||
- Branch builds: `main`, `feature-xyz`
|
||||
- Version tags: `v1.0.0`, `1.0.0`, `1.0`, `1`
|
||||
- Latest: `latest` (from main branch)
|
||||
- Commit SHA: `main-abc1234`
|
||||
|
||||
### 3. Helm Chart Release (`helm-release.yaml`)
|
||||
|
||||
**Triggers:**
|
||||
- Push to `main` with changes in `helm/` directory
|
||||
- Manual workflow dispatch
|
||||
|
||||
**Steps:**
|
||||
1. Package Helm chart
|
||||
2. Create GitHub release for chart
|
||||
3. Update Helm repository index
|
||||
4. Publish to GitHub Pages
|
||||
|
||||
**Output:** Helm repository at `https://vegardengen.github.io/unifi-network-operator`
|
||||
|
||||
### 4. Complete Release (`release.yaml`)
|
||||
|
||||
**Triggers:**
|
||||
- Push of version tags (e.g., `v1.0.0`)
|
||||
- Manual workflow dispatch with version input
|
||||
|
||||
**Steps:**
|
||||
1. **Build Phase:**
|
||||
- Run tests
|
||||
- Build multi-arch Docker images
|
||||
- Push with version tags and `latest`
|
||||
|
||||
2. **Chart Phase:**
|
||||
- Update Chart.yaml with version
|
||||
- Update values.yaml with image tag
|
||||
- Package Helm chart
|
||||
- Release chart to repository
|
||||
|
||||
3. **Release Phase:**
|
||||
- Generate release notes
|
||||
- Create GitHub release
|
||||
- Attach Helm chart package
|
||||
- Mark as pre-release if needed
|
||||
|
||||
**Pre-release Detection:** Tags containing `alpha`, `beta`, or `rc` are marked as pre-releases
|
||||
|
||||
## Release Process
|
||||
|
||||
### Creating a New Release
|
||||
|
||||
1. **Prepare the release:**
|
||||
```bash
|
||||
# Ensure you're on main and up to date
|
||||
git checkout main
|
||||
git pull github main
|
||||
|
||||
# Update CHANGELOG.md with release notes
|
||||
# Commit any final changes
|
||||
```
|
||||
|
||||
2. **Create and push the tag:**
|
||||
```bash
|
||||
# Create an annotated tag
|
||||
git tag -a v1.0.0 -m "Release v1.0.0: Description of changes"
|
||||
|
||||
# Push the tag
|
||||
git push github v1.0.0
|
||||
```
|
||||
|
||||
3. **Monitor the release:**
|
||||
- Go to Actions tab on GitHub
|
||||
- Watch the "Release" workflow
|
||||
- Check for any errors
|
||||
|
||||
4. **Verify the release:**
|
||||
```bash
|
||||
# Check Docker image
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:v1.0.0
|
||||
|
||||
# Check Helm chart
|
||||
helm repo update
|
||||
helm search repo unifi-network-operator
|
||||
|
||||
# Check GitHub release page
|
||||
# https://github.com/vegardengen/unifi-network-operator/releases
|
||||
```
|
||||
|
||||
### Version Numbering
|
||||
|
||||
Follow [Semantic Versioning](https://semver.org/):
|
||||
|
||||
- **MAJOR** (X.0.0): Breaking changes
|
||||
- **MINOR** (0.X.0): New features, backward compatible
|
||||
- **PATCH** (0.0.X): Bug fixes, backward compatible
|
||||
|
||||
**Pre-release tags:**
|
||||
- `v1.0.0-alpha.1` - Early preview
|
||||
- `v1.0.0-beta.1` - Feature complete, testing
|
||||
- `v1.0.0-rc.1` - Release candidate
|
||||
|
||||
## Artifact Locations
|
||||
|
||||
### Docker Images
|
||||
|
||||
**Repository:** `ghcr.io/vegardengen/unifi-network-operator`
|
||||
|
||||
**Access:**
|
||||
```bash
|
||||
# Pull latest
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:latest
|
||||
|
||||
# Pull specific version
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:v1.0.0
|
||||
```
|
||||
|
||||
**Platforms:** `linux/amd64`, `linux/arm64`
|
||||
|
||||
### Helm Charts
|
||||
|
||||
**Repository:** `https://vegardengen.github.io/unifi-network-operator`
|
||||
|
||||
**Access:**
|
||||
```bash
|
||||
# Add repository
|
||||
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
|
||||
|
||||
# Search charts
|
||||
helm search repo unifi-network-operator
|
||||
|
||||
# Install
|
||||
helm install my-release unifi-network-operator/unifi-network-operator
|
||||
```
|
||||
|
||||
**Also available:** As attachments on GitHub Releases
|
||||
|
||||
## Configuration
|
||||
|
||||
### Repository Settings Required
|
||||
|
||||
1. **Actions Permissions:**
|
||||
- Settings → Actions → General
|
||||
- Workflow permissions: Read and write
|
||||
- Allow GitHub Actions to create releases: ✓
|
||||
|
||||
2. **GitHub Pages:**
|
||||
- Settings → Pages
|
||||
- Source: Deploy from branch
|
||||
- Branch: `gh-pages` / `/ (root)`
|
||||
|
||||
3. **Package Visibility (After First Push):**
|
||||
- Profile → Packages → unifi-network-operator
|
||||
- Package settings → Change visibility → Public
|
||||
|
||||
### Branch Protection (Recommended)
|
||||
|
||||
- Settings → Branches → Add rule for `main`
|
||||
- Require pull request reviews
|
||||
- Require status checks: `lint-and-test`, `helm-lint`, `docker-build`
|
||||
- Require branches to be up to date
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
**"Resource not accessible by integration"**
|
||||
- Fix: Enable read/write permissions in repository settings
|
||||
|
||||
**Docker push fails**
|
||||
- Check package visibility settings
|
||||
- Verify GITHUB_TOKEN permissions
|
||||
|
||||
**Helm chart not updating**
|
||||
- Ensure gh-pages branch exists
|
||||
- Check GitHub Pages is enabled
|
||||
- Wait 5-10 minutes for CDN propagation
|
||||
|
||||
**Release workflow fails**
|
||||
- Check Chart.yaml version is unique
|
||||
- Verify all templates are valid YAML
|
||||
- Review workflow logs for specific error
|
||||
|
||||
### Debug Locally
|
||||
|
||||
```bash
|
||||
# Test Helm rendering
|
||||
make helm-template
|
||||
|
||||
# Lint Helm chart
|
||||
make helm-lint
|
||||
|
||||
# Build Docker image
|
||||
docker build -t test:latest .
|
||||
|
||||
# Run tests
|
||||
make test
|
||||
|
||||
# Check formatting
|
||||
make fmt
|
||||
make vet
|
||||
```
|
||||
|
||||
## Monitoring
|
||||
|
||||
### Workflow Status
|
||||
|
||||
Check at: https://github.com/vegardengen/unifi-network-operator/actions
|
||||
|
||||
### Artifacts
|
||||
|
||||
- **Docker Images:** https://github.com/vegardengen/unifi-network-operator/pkgs/container/unifi-network-operator
|
||||
- **Releases:** https://github.com/vegardengen/unifi-network-operator/releases
|
||||
- **Helm Repository:** https://vegardengen.github.io/unifi-network-operator
|
||||
|
||||
### Metrics
|
||||
|
||||
- Build success rate
|
||||
- Test coverage (via Codecov)
|
||||
- Release frequency
|
||||
- Download statistics (via GitHub Insights)
|
||||
|
||||
## Security
|
||||
|
||||
### Container Scanning
|
||||
|
||||
Consider adding:
|
||||
- Trivy vulnerability scanning
|
||||
- Dependabot alerts
|
||||
- SBOM generation
|
||||
|
||||
### Secrets Management
|
||||
|
||||
- Use GitHub Secrets for sensitive data
|
||||
- Never commit credentials
|
||||
- Rotate tokens regularly
|
||||
|
||||
### Supply Chain Security
|
||||
|
||||
- Images built from source
|
||||
- Signed releases (future enhancement)
|
||||
- SBOM attached to releases (future enhancement)
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
- [ ] Automated vulnerability scanning
|
||||
- [ ] Signed container images (cosign)
|
||||
- [ ] SBOM generation
|
||||
- [ ] Automated changelog generation
|
||||
- [ ] Release drafter for draft releases
|
||||
- [ ] Automated version bumping
|
||||
- [ ] Integration tests in CI
|
||||
- [ ] Performance benchmarking
|
||||
- [ ] Automated security scanning
|
||||
|
||||
## References
|
||||
|
||||
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
|
||||
- [Helm Chart Best Practices](https://helm.sh/docs/chart_best_practices/)
|
||||
- [Container Best Practices](https://docs.docker.com/develop/dev-best-practices/)
|
||||
- [Semantic Versioning](https://semver.org/)
|
||||
|
||||
## Support
|
||||
|
||||
For CI/CD issues:
|
||||
1. Check workflow logs in Actions tab
|
||||
2. Review [.github/README.md](.github/README.md) for detailed docs
|
||||
3. See [.github/SETUP.md](.github/SETUP.md) for setup instructions
|
||||
4. Open an issue with workflow logs attached
|
||||
259
GITHUB_SETUP_SUMMARY.md
Normal file
259
GITHUB_SETUP_SUMMARY.md
Normal file
@@ -0,0 +1,259 @@
|
||||
# GitHub Setup Summary - UniFi Network Operator
|
||||
|
||||
## ✅ What Has Been Completed
|
||||
|
||||
### 1. Repository Structure
|
||||
- ✅ Repository pushed to GitHub: `vegardengen/unifi-network-operator`
|
||||
- ✅ Remote `github` configured
|
||||
- ✅ Main branch pushed
|
||||
- ✅ Feature branch `feature/add-helm` pushed with Helm chart and CI/CD
|
||||
- ✅ All 39 version tags pushed
|
||||
|
||||
### 2. Helm Chart Created
|
||||
- ✅ Complete Helm chart in `helm/unifi-network-operator/`
|
||||
- ✅ All CRDs included
|
||||
- ✅ Comprehensive values.yaml with 50+ configuration options
|
||||
- ✅ Updated to use GitHub URLs and ghcr.io images
|
||||
- ✅ Full documentation and README
|
||||
|
||||
### 3. CI/CD Workflows Created
|
||||
- ✅ **docker-build-push.yaml** - Builds multi-arch images (amd64, arm64)
|
||||
- ✅ **helm-release.yaml** - Publishes Helm charts to GitHub Pages
|
||||
- ✅ **release.yaml** - Complete release automation
|
||||
- ✅ **pr-validation.yaml** - PR checks and validation
|
||||
- ✅ Chart Releaser configuration
|
||||
- ✅ Comprehensive documentation
|
||||
|
||||
### 4. Documentation Created
|
||||
- ✅ `.github/README.md` - Workflow documentation
|
||||
- ✅ `.github/SETUP.md` - Step-by-step setup guide
|
||||
- ✅ `CICD.md` - Complete CI/CD pipeline docs
|
||||
- ✅ `helm/README.md` - Helm chart overview
|
||||
- ✅ `helm/INSTALL.md` - Installation guide
|
||||
- ✅ `helm/unifi-network-operator/README.md` - Chart documentation
|
||||
|
||||
## 🚀 Next Steps (Required)
|
||||
|
||||
### Step 1: Enable GitHub Pages (Required for Helm Repository)
|
||||
|
||||
1. Go to https://github.com/vegardengen/unifi-network-operator/settings/pages
|
||||
2. Under "Build and deployment":
|
||||
- **Source:** Deploy from a branch
|
||||
- **Branch:** `gh-pages` / `/ (root)`
|
||||
- Click **Save**
|
||||
|
||||
**Note:** The `gh-pages` branch will be automatically created by the workflow on first run.
|
||||
|
||||
### Step 2: Configure Workflow Permissions (Required)
|
||||
|
||||
1. Go to https://github.com/vegardengen/unifi-network-operator/settings/actions
|
||||
2. Scroll to "Workflow permissions"
|
||||
3. Select **Read and write permissions**
|
||||
4. Check ✅ **Allow GitHub Actions to create and approve pull requests**
|
||||
5. Click **Save**
|
||||
|
||||
### Step 3: Make Container Images Public (Do After First Build)
|
||||
|
||||
1. After first workflow run, go to https://github.com/vegardengen?tab=packages
|
||||
2. Find `unifi-network-operator`
|
||||
3. Click on it → **Package settings**
|
||||
4. Scroll to "Danger Zone"
|
||||
5. Click **Change visibility** → **Public**
|
||||
6. Type package name to confirm
|
||||
|
||||
### Step 4: Merge the Helm Chart PR
|
||||
|
||||
1. Create PR: https://github.com/vegardengen/unifi-network-operator/pull/new/feature/add-helm
|
||||
2. Review changes
|
||||
3. Merge to main
|
||||
|
||||
This will trigger:
|
||||
- Docker image build
|
||||
- Helm chart release
|
||||
- Publication to GitHub Pages
|
||||
|
||||
### Step 5: Create Your First Release
|
||||
|
||||
Once Steps 1-4 are complete:
|
||||
|
||||
```bash
|
||||
# Make sure you're on main and up to date
|
||||
git checkout main
|
||||
git pull github main
|
||||
|
||||
# Create a release tag
|
||||
git tag -a v0.1.0 -m "Initial release with Helm chart and CI/CD"
|
||||
|
||||
# Push the tag
|
||||
git push github v0.1.0
|
||||
```
|
||||
|
||||
This will automatically:
|
||||
1. Build and push Docker images (linux/amd64, linux/arm64)
|
||||
2. Package and release Helm chart
|
||||
3. Create GitHub release with notes
|
||||
4. Publish to Helm repository
|
||||
|
||||
## 📦 What Will Be Available
|
||||
|
||||
### Docker Images
|
||||
**Location:** `ghcr.io/vegardengen/unifi-network-operator`
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:latest
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:v0.1.0
|
||||
```
|
||||
|
||||
**Platforms:** linux/amd64, linux/arm64
|
||||
|
||||
### Helm Repository
|
||||
**Location:** `https://vegardengen.github.io/unifi-network-operator`
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Add repository
|
||||
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
|
||||
|
||||
# Update
|
||||
helm repo update
|
||||
|
||||
# Install
|
||||
helm install unifi-network-operator unifi-network-operator/unifi-network-operator \
|
||||
--namespace unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://your-unifi-controller:8443" \
|
||||
--set unifi.password="your-password"
|
||||
```
|
||||
|
||||
## 🔍 How to Verify Everything Works
|
||||
|
||||
### Check Workflow Status
|
||||
1. Go to https://github.com/vegardengen/unifi-network-operator/actions
|
||||
2. Verify workflows are running/passing
|
||||
|
||||
### Test Docker Image Pull
|
||||
```bash
|
||||
# After first successful build
|
||||
docker pull ghcr.io/vegardengen/unifi-network-operator:main
|
||||
```
|
||||
|
||||
### Test Helm Repository
|
||||
```bash
|
||||
# After first helm release
|
||||
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
|
||||
helm repo update
|
||||
helm search repo unifi-network-operator
|
||||
```
|
||||
|
||||
## 📊 Repository URLs
|
||||
|
||||
| Resource | URL |
|
||||
|----------|-----|
|
||||
| **GitHub Repository** | https://github.com/vegardengen/unifi-network-operator |
|
||||
| **Actions (Workflows)** | https://github.com/vegardengen/unifi-network-operator/actions |
|
||||
| **Releases** | https://github.com/vegardengen/unifi-network-operator/releases |
|
||||
| **Packages** | https://github.com/vegardengen/unifi-network-operator/pkgs/container/unifi-network-operator |
|
||||
| **Helm Repository** | https://vegardengen.github.io/unifi-network-operator |
|
||||
| **Create PR** | https://github.com/vegardengen/unifi-network-operator/pull/new/feature/add-helm |
|
||||
|
||||
## 📚 Documentation References
|
||||
|
||||
| Document | Location | Purpose |
|
||||
|----------|----------|---------|
|
||||
| **CI/CD Overview** | [CICD.md](CICD.md) | Complete CI/CD pipeline documentation |
|
||||
| **Workflow Details** | [.github/README.md](.github/README.md) | Detailed workflow documentation |
|
||||
| **Setup Guide** | [.github/SETUP.md](.github/SETUP.md) | Step-by-step setup instructions |
|
||||
| **Helm Overview** | [helm/README.md](helm/README.md) | Helm chart overview |
|
||||
| **Installation Guide** | [helm/INSTALL.md](helm/INSTALL.md) | Helm installation examples |
|
||||
| **Chart Documentation** | [helm/unifi-network-operator/README.md](helm/unifi-network-operator/README.md) | Complete chart reference |
|
||||
|
||||
## 🎯 Workflow Summary
|
||||
|
||||
### PR Validation (`pr-validation.yaml`)
|
||||
**Triggers:** Pull requests to main
|
||||
- Go formatting check
|
||||
- Static analysis (go vet)
|
||||
- Unit tests with race detection
|
||||
- Helm chart linting
|
||||
- Docker build test
|
||||
|
||||
### Docker Build & Push (`docker-build-push.yaml`)
|
||||
**Triggers:** Push to main, feature branches, tags
|
||||
- Runs tests
|
||||
- Builds multi-arch images
|
||||
- Pushes to GitHub Container Registry
|
||||
- Creates multiple tags
|
||||
|
||||
### Helm Release (`helm-release.yaml`)
|
||||
**Triggers:** Push to main (helm changes)
|
||||
- Packages Helm chart
|
||||
- Creates releases
|
||||
- Publishes to GitHub Pages
|
||||
|
||||
### Complete Release (`release.yaml`)
|
||||
**Triggers:** Version tags (v*)
|
||||
- Builds Docker images
|
||||
- Packages Helm chart
|
||||
- Creates GitHub release
|
||||
- Publishes everything
|
||||
|
||||
## ⚠️ Common Issues & Solutions
|
||||
|
||||
### "Resource not accessible by integration"
|
||||
**Solution:** Enable read/write permissions (Step 2 above)
|
||||
|
||||
### Docker images not public
|
||||
**Solution:** Change package visibility to public (Step 3 above)
|
||||
|
||||
### Helm chart not appearing
|
||||
**Solution:**
|
||||
- Enable GitHub Pages (Step 1)
|
||||
- Wait 5-10 minutes for initial setup
|
||||
- Check workflow logs
|
||||
|
||||
### Workflow fails on first run
|
||||
**Solution:** Complete Steps 1 and 2 first, then re-run workflow
|
||||
|
||||
## 🎉 Success Checklist
|
||||
|
||||
Once everything is set up, you should have:
|
||||
|
||||
- ✅ GitHub Pages enabled
|
||||
- ✅ Workflow permissions configured
|
||||
- ✅ PR merged to main
|
||||
- ✅ First release created (v0.1.0)
|
||||
- ✅ Docker images available at ghcr.io
|
||||
- ✅ Helm repository accessible
|
||||
- ✅ All workflows passing
|
||||
- ✅ Package visibility set to public
|
||||
|
||||
## 🔗 Quick Links for Setup
|
||||
|
||||
1. **Enable Pages:** https://github.com/vegardengen/unifi-network-operator/settings/pages
|
||||
2. **Configure Actions:** https://github.com/vegardengen/unifi-network-operator/settings/actions
|
||||
3. **View Actions:** https://github.com/vegardengen/unifi-network-operator/actions
|
||||
4. **Create PR:** https://github.com/vegardengen/unifi-network-operator/pull/new/feature/add-helm
|
||||
5. **Manage Packages:** https://github.com/vegardengen?tab=packages
|
||||
|
||||
## 💡 Tips
|
||||
|
||||
- **Test locally first:** Always run `make helm-lint` and `make test` before pushing
|
||||
- **Use semantic versioning:** Major.Minor.Patch (e.g., v1.2.3)
|
||||
- **Pre-releases:** Use alpha/beta/rc tags (e.g., v1.0.0-beta.1)
|
||||
- **Monitor workflows:** Check Actions tab after every push
|
||||
- **Read the logs:** Workflow logs contain detailed information about any failures
|
||||
|
||||
## 🆘 Need Help?
|
||||
|
||||
1. **Workflow issues:** Check [.github/README.md](.github/README.md)
|
||||
2. **Setup problems:** See [.github/SETUP.md](.github/SETUP.md)
|
||||
3. **Helm questions:** Read [helm/README.md](helm/README.md)
|
||||
4. **General CI/CD:** Review [CICD.md](CICD.md)
|
||||
|
||||
---
|
||||
|
||||
**Status:** Ready to deploy! Follow Steps 1-5 above to complete the setup.
|
||||
|
||||
**Created:** $(date)
|
||||
**Repository:** https://github.com/vegardengen/unifi-network-operator
|
||||
58
Makefile
58
Makefile
@@ -1,5 +1,5 @@
|
||||
# Image URL to use all building/pushing image targets
|
||||
IMG ?= registry.engen.priv.no/unifi-network-operator-controller:latest
|
||||
IMG ?= gitea.engen.priv.no/klauvsteinen/unifi-network-operator-controller:latest
|
||||
|
||||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
|
||||
ifeq (,$(shell go env GOBIN))
|
||||
@@ -8,7 +8,7 @@ else
|
||||
GOBIN=$(shell go env GOBIN)
|
||||
endif
|
||||
|
||||
export KO_DOCKER_REPO=registry.engen.priv.no/unifi-network-operator-controller
|
||||
export KO_DOCKER_REPO=gitea.engen.priv.no/klauvsteinen/unifi-network-operator-controller
|
||||
|
||||
# CONTAINER_TOOL defines the container tool to be used for building images.
|
||||
# Be aware that the target commands are only tested with Docker which is
|
||||
@@ -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
|
||||
|
||||
31
PROJECT
31
PROJECT
@@ -6,7 +6,7 @@ domain: engen.priv.no
|
||||
layout:
|
||||
- go.kubebuilder.io/v4
|
||||
projectName: unifi-network-operator
|
||||
repo: github.com/vegardengen/unifi-network-operator
|
||||
repo: gitea.engen.priv.no/klauvsteinen/unifi-network-operator
|
||||
resources:
|
||||
- api:
|
||||
crdVersion: v1
|
||||
@@ -15,6 +15,33 @@ resources:
|
||||
domain: engen.priv.no
|
||||
group: unifi
|
||||
kind: Networkconfiguration
|
||||
path: github.com/vegardengen/unifi-network-operator/api/v1beta1
|
||||
path: gitea.engen.priv.no/klauvsteinen/unifi-network-operator/api/v1beta1
|
||||
version: v1beta1
|
||||
- api:
|
||||
crdVersion: v1
|
||||
namespaced: true
|
||||
controller: true
|
||||
domain: engen.priv.no
|
||||
group: unifi
|
||||
kind: FirewallZone
|
||||
path: gitea.engen.priv.no/klauvsteinen/unifi-network-operator/api/v1beta1
|
||||
version: v1beta1
|
||||
- api:
|
||||
crdVersion: v1
|
||||
namespaced: true
|
||||
controller: true
|
||||
domain: engen.priv.no
|
||||
group: unifi
|
||||
kind: FirewallPolicy
|
||||
path: gitea.engen.priv.no/klauvsteinen/unifi-network-operator/api/v1beta1
|
||||
version: v1beta1
|
||||
- api:
|
||||
crdVersion: v1
|
||||
namespaced: true
|
||||
controller: true
|
||||
domain: engen.priv.no
|
||||
group: unifi
|
||||
kind: PortForward
|
||||
path: gitea.engen.priv.no/klauvsteinen/unifi-network-operator/api/v1beta1
|
||||
version: v1beta1
|
||||
version: "3"
|
||||
|
||||
40
api/v1beta1/common_types.go
Normal file
40
api/v1beta1/common_types.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package v1beta1
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||
|
||||
type NamedUnifiResource struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type ServiceEntry struct {
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type FirewallGroupEntry struct {
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
type FirewallZoneEntry struct {
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
type FirewallPolicyEntry struct {
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
type NetworkEntry struct {
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
type FirewallSource struct {
|
||||
FirewallZones []FirewallZoneEntry `json:"from_zones,omitempty"`
|
||||
Networks []NetworkEntry `json:"from_networks,omitempty"`
|
||||
}
|
||||
|
||||
type FirewallDestination struct {
|
||||
FirewallGroups []FirewallGroupEntry `json:"firewall_groups,omitempty"`
|
||||
Services []ServiceEntry `json:"services,omitempty"`
|
||||
}
|
||||
@@ -24,27 +24,28 @@ import (
|
||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||
|
||||
// FirewallGroupSpec defines the desired state of FirewallGroup.
|
||||
|
||||
type FirewallGroupSpec struct {
|
||||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
|
||||
// Foo is an example field of FirewallGroup. Edit firewallgroup_types.go to remove/update
|
||||
// Description is a human-readable explanation for the object
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
MatchServicesInAllNamespaces bool `json:"matchServicesInAllNamespaces,omitempty"`
|
||||
// ManualAddresses is a list of manual IPs or CIDRs (IPv4 or IPv6)
|
||||
// +optional
|
||||
ManualAddresses []string `json:"manualAddresses,omitempty"`
|
||||
ManualPorts []string `json:"manualPorts,omitempty"`
|
||||
ManualServices []ServiceEntry `json:"manual_services,omitempty"`
|
||||
|
||||
AutoCreatedFrom FirewallPolicyEntry `json:"auto_created_from,omitempty"`
|
||||
|
||||
// AutoIncludeSelector defines which services to extract addresses from
|
||||
// +optional
|
||||
AutoIncludeSelector *metav1.LabelSelector `json:"autoIncludeSelector,omitempty"`
|
||||
|
||||
// AddressType can be "ip", "cidr", or "both"
|
||||
// +kubebuilder:validation:Enum=ip;cidr;both
|
||||
// +optional
|
||||
AddressType string `json:"addressType,omitempty"`
|
||||
}
|
||||
|
||||
// FirewallGroupStatus defines the observed state of FirewallGroup.
|
||||
@@ -52,17 +53,29 @@ type FirewallGroupStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
|
||||
ResolvedAddresses []string `json:"resolvedAddresses,omitempty"`
|
||||
ResolvedIPV4Addresses []string `json:"resolvedIPV4Addresses,omitempty"`
|
||||
ResolvedIPV6Addresses []string `json:"resolvedIPV6Addresses,omitempty"`
|
||||
ResolvedTCPPorts []string `json:"resolvedTCPorts,omitempty"`
|
||||
ResolvedUDPPorts []string `json:"resolvedUDPorts,omitempty"`
|
||||
|
||||
// SyncedWithUnifi indicates whether the addresses are successfully pushed
|
||||
// +optional
|
||||
SyncedWithUnifi bool `json:"syncedWithUnifi,omitempty"`
|
||||
|
||||
ResourcesManaged *FirewallGroupResourcesManaged `json:"resources_managed,omitempty"`
|
||||
|
||||
// LastSyncTime is the last time the object was synced
|
||||
// +optional
|
||||
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
|
||||
}
|
||||
|
||||
type FirewallGroupResourcesManaged struct {
|
||||
IPV4Object *NamedUnifiResource `json:"ipv4_object,omitempty"`
|
||||
IPV6Object *NamedUnifiResource `json:"ipv6_object,omitempty"`
|
||||
TCPPortsObject *NamedUnifiResource `json:"tcp_ports_object,omitempty"`
|
||||
UDPPortsObject *NamedUnifiResource `json:"udp_ports_object,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
|
||||
|
||||
92
api/v1beta1/firewallpolicy_types.go
Normal file
92
api/v1beta1/firewallpolicy_types.go
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
Copyright 2025 Vegard Engen.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||
|
||||
// FirewallPolicySpec defines the desired state of FirewallPolicy.
|
||||
// type ServiceSpec struct {
|
||||
// Namespace string `json:"namespace,omitempty"`
|
||||
// Name string `json:"name,omitempty"`
|
||||
// }
|
||||
|
||||
// type FirewallSource struct {
|
||||
// Zones []string `json:"from_zones,omitempty"`
|
||||
// Networks []string `json:"from_networks,omitempty"`
|
||||
//}
|
||||
|
||||
//type FirewallDestination struct {
|
||||
// FirewallGroups []string `json:"firewall_group,omitempty"`
|
||||
// Services []ServiceSpec `json:"service,omitempty"`
|
||||
//}
|
||||
|
||||
type FirewallPolicySpec struct {
|
||||
Name string `json:"name"`
|
||||
Source FirewallSource `json:"source"`
|
||||
Destination FirewallDestination `json:"destination"`
|
||||
MatchFirewallGroupsInAllNamespaces bool `json:"match_firewall_groups_in_all_namespaces,omitempty"`
|
||||
MatchServicesInAllNamespaces bool `json:"match_services_in_all_namespaces,omitempty"`
|
||||
}
|
||||
|
||||
// FirewallPolicyStatus defines the observed state of FirewallPolicy.
|
||||
type FirewallPolicyStatus struct {
|
||||
ResourcesManaged *FirewallPolicyResourcesManaged `json:"resources_managed,omitempty"`
|
||||
}
|
||||
|
||||
type FirewallPolicyResourcesManaged struct {
|
||||
UnifiFirewallPolicies []UnifiFirewallPolicyEntry `json:"firewall_policies_managed,omitempty"`
|
||||
FirewallGroups []FirewallGroupEntry `json:"firewall_groups_managed,omitempty"`
|
||||
}
|
||||
|
||||
type UnifiFirewallPolicyEntry struct {
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
TcpIpv4ID string `json:"tcpipv4_id"`
|
||||
UdpIpv4ID string `json:"udpipv4_id"`
|
||||
TcpIpv6ID string `json:"tcpipv6_id"`
|
||||
UdpIpv6ID string `json:"udpipv6_id"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
|
||||
// FirewallPolicy is the Schema for the firewallpolicies API.
|
||||
type FirewallPolicy struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec FirewallPolicySpec `json:"spec,omitempty"`
|
||||
Status FirewallPolicyStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// FirewallPolicyList contains a list of FirewallPolicy.
|
||||
type FirewallPolicyList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []FirewallPolicy `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&FirewallPolicy{}, &FirewallPolicyList{})
|
||||
}
|
||||
73
api/v1beta1/firewallzone_types.go
Normal file
73
api/v1beta1/firewallzone_types.go
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright 2025 Vegard Engen.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||
|
||||
// FirewallZoneSpec defines the desired state of FirewallZone.
|
||||
type FirewallZoneSpec struct {
|
||||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
ID string `json:"_id,omitempty"`
|
||||
DefaultZone bool `json:"default_zone,omitempty"`
|
||||
ZoneKey string `json:"zone_key,omitempty"`
|
||||
NetworkIDs []string `json:"network_ids,omitempty"`
|
||||
}
|
||||
|
||||
// FirewallZoneStatus defines the observed state of FirewallZone.
|
||||
type FirewallZoneStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
|
||||
ResourcesManaged *FirewallZoneResourcesManaged `json:"resources_managed,omitempty"`
|
||||
}
|
||||
|
||||
type FirewallZoneResourcesManaged struct {
|
||||
UnifiFirewallZones []NamedUnifiResource `json:"firewall_zones_managed,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
|
||||
// FirewallZone is the Schema for the firewallzones API.
|
||||
type FirewallZone struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec FirewallZoneSpec `json:"spec,omitempty"`
|
||||
Status FirewallZoneStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// FirewallZoneList contains a list of FirewallZone.
|
||||
type FirewallZoneList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []FirewallZone `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&FirewallZone{}, &FirewallZoneList{})
|
||||
}
|
||||
@@ -29,8 +29,9 @@ type NetworkconfigurationSpec struct {
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
|
||||
// Foo is an example field of Networkconfiguration. Edit networkconfiguration_types.go to remove/update
|
||||
ID string `json:"_id,omitempty"`
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
FirewallZoneID string `json:"firewall_zone_id,omitempty"`
|
||||
FirewallZone string `json:"firewall_zone,omitempty"`
|
||||
GatewayType string `json:"gateway_type,omitempty"`
|
||||
IPSubnet string `json:"ip_subnet,omitempty"`
|
||||
Ipv6InterfaceType string `json:"ipv6_interface_type,omitempty"`
|
||||
@@ -39,8 +40,6 @@ type NetworkconfigurationSpec struct {
|
||||
Ipv6SettingPreference string `json:"ipv6_setting_preference,omitempty"`
|
||||
Ipv6Subnet string `json:"ipv6_subnet,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Networkname string `json:"network_name"`
|
||||
NetworkID string `json:"network_id,omitempty"`
|
||||
Networkgroup string `json:"networkgroup,omitempty"`
|
||||
Purpose string `json:"purpose,omitempty"`
|
||||
SettingPreference string `json:"setting_preference,omitempty"`
|
||||
@@ -52,7 +51,21 @@ type NetworkconfigurationSpec struct {
|
||||
type NetworkconfigurationStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
FirewallZoneID string `json:"firewall_zone_id,omitempty"`
|
||||
Ipv6SubnetStatus string `json:"ipv6_subnet_status,omitempty"`
|
||||
|
||||
// SyncedWithUnifi indicates whether the addresses are successfully pushed
|
||||
// +optional
|
||||
SyncedWithUnifi bool `json:"syncedWithUnifi,omitempty"`
|
||||
|
||||
ResourcesManaged *NetworkconfigurationResourcesManaged `json:"resources_managed,omitempty"`
|
||||
// LastSyncTime is the last time the object was synced
|
||||
// +optional
|
||||
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
|
||||
}
|
||||
|
||||
type NetworkconfigurationResourcesManaged struct {
|
||||
UnifiNetworks []NamedUnifiResource `json:"networks_managed,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
48
api/v1beta1/portforward_types.go
Normal file
48
api/v1beta1/portforward_types.go
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright 2025 Vegard Engen.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// PortForward is a placeholder type to allow future CRD support if needed.
|
||||
// Right now, port forwards are managed entirely through annotations on Services.
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
type PortForward struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec PortForwardSpec `json:"spec,omitempty"`
|
||||
Status PortForwardStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type PortForwardSpec struct {
|
||||
// Reserved for future CRD-based management
|
||||
}
|
||||
|
||||
type PortForwardStatus struct {
|
||||
// Reserved for future CRD-based status
|
||||
}
|
||||
|
||||
// PortForwardList contains a list of PortForward
|
||||
// Currently unused, defined for completeness
|
||||
type PortForwardList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []PortForward `json:"items"`
|
||||
}
|
||||
@@ -25,6 +25,31 @@ import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallDestination) DeepCopyInto(out *FirewallDestination) {
|
||||
*out = *in
|
||||
if in.FirewallGroups != nil {
|
||||
in, out := &in.FirewallGroups, &out.FirewallGroups
|
||||
*out = make([]FirewallGroupEntry, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Services != nil {
|
||||
in, out := &in.Services, &out.Services
|
||||
*out = make([]ServiceEntry, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallDestination.
|
||||
func (in *FirewallDestination) DeepCopy() *FirewallDestination {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallDestination)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallGroup) DeepCopyInto(out *FirewallGroup) {
|
||||
*out = *in
|
||||
@@ -52,6 +77,21 @@ func (in *FirewallGroup) DeepCopyObject() runtime.Object {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallGroupEntry) DeepCopyInto(out *FirewallGroupEntry) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallGroupEntry.
|
||||
func (in *FirewallGroupEntry) DeepCopy() *FirewallGroupEntry {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallGroupEntry)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallGroupList) DeepCopyInto(out *FirewallGroupList) {
|
||||
*out = *in
|
||||
@@ -84,6 +124,41 @@ func (in *FirewallGroupList) DeepCopyObject() runtime.Object {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallGroupResourcesManaged) DeepCopyInto(out *FirewallGroupResourcesManaged) {
|
||||
*out = *in
|
||||
if in.IPV4Object != nil {
|
||||
in, out := &in.IPV4Object, &out.IPV4Object
|
||||
*out = new(NamedUnifiResource)
|
||||
**out = **in
|
||||
}
|
||||
if in.IPV6Object != nil {
|
||||
in, out := &in.IPV6Object, &out.IPV6Object
|
||||
*out = new(NamedUnifiResource)
|
||||
**out = **in
|
||||
}
|
||||
if in.TCPPortsObject != nil {
|
||||
in, out := &in.TCPPortsObject, &out.TCPPortsObject
|
||||
*out = new(NamedUnifiResource)
|
||||
**out = **in
|
||||
}
|
||||
if in.UDPPortsObject != nil {
|
||||
in, out := &in.UDPPortsObject, &out.UDPPortsObject
|
||||
*out = new(NamedUnifiResource)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallGroupResourcesManaged.
|
||||
func (in *FirewallGroupResourcesManaged) DeepCopy() *FirewallGroupResourcesManaged {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallGroupResourcesManaged)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallGroupSpec) DeepCopyInto(out *FirewallGroupSpec) {
|
||||
*out = *in
|
||||
@@ -92,6 +167,17 @@ func (in *FirewallGroupSpec) DeepCopyInto(out *FirewallGroupSpec) {
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.ManualPorts != nil {
|
||||
in, out := &in.ManualPorts, &out.ManualPorts
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.ManualServices != nil {
|
||||
in, out := &in.ManualServices, &out.ManualServices
|
||||
*out = make([]ServiceEntry, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
out.AutoCreatedFrom = in.AutoCreatedFrom
|
||||
if in.AutoIncludeSelector != nil {
|
||||
in, out := &in.AutoIncludeSelector, &out.AutoIncludeSelector
|
||||
*out = new(v1.LabelSelector)
|
||||
@@ -112,11 +198,31 @@ func (in *FirewallGroupSpec) DeepCopy() *FirewallGroupSpec {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallGroupStatus) DeepCopyInto(out *FirewallGroupStatus) {
|
||||
*out = *in
|
||||
if in.ResolvedAddresses != nil {
|
||||
in, out := &in.ResolvedAddresses, &out.ResolvedAddresses
|
||||
if in.ResolvedIPV4Addresses != nil {
|
||||
in, out := &in.ResolvedIPV4Addresses, &out.ResolvedIPV4Addresses
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.ResolvedIPV6Addresses != nil {
|
||||
in, out := &in.ResolvedIPV6Addresses, &out.ResolvedIPV6Addresses
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.ResolvedTCPPorts != nil {
|
||||
in, out := &in.ResolvedTCPPorts, &out.ResolvedTCPPorts
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.ResolvedUDPPorts != nil {
|
||||
in, out := &in.ResolvedUDPPorts, &out.ResolvedUDPPorts
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.ResourcesManaged != nil {
|
||||
in, out := &in.ResourcesManaged, &out.ResourcesManaged
|
||||
*out = new(FirewallGroupResourcesManaged)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.LastSyncTime != nil {
|
||||
in, out := &in.LastSyncTime, &out.LastSyncTime
|
||||
*out = (*in).DeepCopy()
|
||||
@@ -133,13 +239,338 @@ func (in *FirewallGroupStatus) DeepCopy() *FirewallGroupStatus {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallPolicy) DeepCopyInto(out *FirewallPolicy) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallPolicy.
|
||||
func (in *FirewallPolicy) DeepCopy() *FirewallPolicy {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallPolicy)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *FirewallPolicy) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallPolicyEntry) DeepCopyInto(out *FirewallPolicyEntry) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallPolicyEntry.
|
||||
func (in *FirewallPolicyEntry) DeepCopy() *FirewallPolicyEntry {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallPolicyEntry)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallPolicyList) DeepCopyInto(out *FirewallPolicyList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]FirewallPolicy, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallPolicyList.
|
||||
func (in *FirewallPolicyList) DeepCopy() *FirewallPolicyList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallPolicyList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *FirewallPolicyList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallPolicyResourcesManaged) DeepCopyInto(out *FirewallPolicyResourcesManaged) {
|
||||
*out = *in
|
||||
if in.UnifiFirewallPolicies != nil {
|
||||
in, out := &in.UnifiFirewallPolicies, &out.UnifiFirewallPolicies
|
||||
*out = make([]UnifiFirewallPolicyEntry, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.FirewallGroups != nil {
|
||||
in, out := &in.FirewallGroups, &out.FirewallGroups
|
||||
*out = make([]FirewallGroupEntry, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallPolicyResourcesManaged.
|
||||
func (in *FirewallPolicyResourcesManaged) DeepCopy() *FirewallPolicyResourcesManaged {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallPolicyResourcesManaged)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallPolicySpec) DeepCopyInto(out *FirewallPolicySpec) {
|
||||
*out = *in
|
||||
in.Source.DeepCopyInto(&out.Source)
|
||||
in.Destination.DeepCopyInto(&out.Destination)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallPolicySpec.
|
||||
func (in *FirewallPolicySpec) DeepCopy() *FirewallPolicySpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallPolicySpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallPolicyStatus) DeepCopyInto(out *FirewallPolicyStatus) {
|
||||
*out = *in
|
||||
if in.ResourcesManaged != nil {
|
||||
in, out := &in.ResourcesManaged, &out.ResourcesManaged
|
||||
*out = new(FirewallPolicyResourcesManaged)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallPolicyStatus.
|
||||
func (in *FirewallPolicyStatus) DeepCopy() *FirewallPolicyStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallPolicyStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallSource) DeepCopyInto(out *FirewallSource) {
|
||||
*out = *in
|
||||
if in.FirewallZones != nil {
|
||||
in, out := &in.FirewallZones, &out.FirewallZones
|
||||
*out = make([]FirewallZoneEntry, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Networks != nil {
|
||||
in, out := &in.Networks, &out.Networks
|
||||
*out = make([]NetworkEntry, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallSource.
|
||||
func (in *FirewallSource) DeepCopy() *FirewallSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallZone) DeepCopyInto(out *FirewallZone) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallZone.
|
||||
func (in *FirewallZone) DeepCopy() *FirewallZone {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallZone)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *FirewallZone) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallZoneEntry) DeepCopyInto(out *FirewallZoneEntry) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallZoneEntry.
|
||||
func (in *FirewallZoneEntry) DeepCopy() *FirewallZoneEntry {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallZoneEntry)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallZoneList) DeepCopyInto(out *FirewallZoneList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]FirewallZone, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallZoneList.
|
||||
func (in *FirewallZoneList) DeepCopy() *FirewallZoneList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallZoneList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *FirewallZoneList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallZoneResourcesManaged) DeepCopyInto(out *FirewallZoneResourcesManaged) {
|
||||
*out = *in
|
||||
if in.UnifiFirewallZones != nil {
|
||||
in, out := &in.UnifiFirewallZones, &out.UnifiFirewallZones
|
||||
*out = make([]NamedUnifiResource, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallZoneResourcesManaged.
|
||||
func (in *FirewallZoneResourcesManaged) DeepCopy() *FirewallZoneResourcesManaged {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallZoneResourcesManaged)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallZoneSpec) DeepCopyInto(out *FirewallZoneSpec) {
|
||||
*out = *in
|
||||
if in.NetworkIDs != nil {
|
||||
in, out := &in.NetworkIDs, &out.NetworkIDs
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallZoneSpec.
|
||||
func (in *FirewallZoneSpec) DeepCopy() *FirewallZoneSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallZoneSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FirewallZoneStatus) DeepCopyInto(out *FirewallZoneStatus) {
|
||||
*out = *in
|
||||
if in.ResourcesManaged != nil {
|
||||
in, out := &in.ResourcesManaged, &out.ResourcesManaged
|
||||
*out = new(FirewallZoneResourcesManaged)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallZoneStatus.
|
||||
func (in *FirewallZoneStatus) DeepCopy() *FirewallZoneStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FirewallZoneStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NamedUnifiResource) DeepCopyInto(out *NamedUnifiResource) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamedUnifiResource.
|
||||
func (in *NamedUnifiResource) DeepCopy() *NamedUnifiResource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NamedUnifiResource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkEntry) DeepCopyInto(out *NetworkEntry) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkEntry.
|
||||
func (in *NetworkEntry) DeepCopy() *NetworkEntry {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkEntry)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Networkconfiguration) DeepCopyInto(out *Networkconfiguration) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
out.Status = in.Status
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Networkconfiguration.
|
||||
@@ -192,6 +623,26 @@ func (in *NetworkconfigurationList) DeepCopyObject() runtime.Object {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkconfigurationResourcesManaged) DeepCopyInto(out *NetworkconfigurationResourcesManaged) {
|
||||
*out = *in
|
||||
if in.UnifiNetworks != nil {
|
||||
in, out := &in.UnifiNetworks, &out.UnifiNetworks
|
||||
*out = make([]NamedUnifiResource, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkconfigurationResourcesManaged.
|
||||
func (in *NetworkconfigurationResourcesManaged) DeepCopy() *NetworkconfigurationResourcesManaged {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkconfigurationResourcesManaged)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkconfigurationSpec) DeepCopyInto(out *NetworkconfigurationSpec) {
|
||||
*out = *in
|
||||
@@ -210,6 +661,15 @@ func (in *NetworkconfigurationSpec) DeepCopy() *NetworkconfigurationSpec {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkconfigurationStatus) DeepCopyInto(out *NetworkconfigurationStatus) {
|
||||
*out = *in
|
||||
if in.ResourcesManaged != nil {
|
||||
in, out := &in.ResourcesManaged, &out.ResourcesManaged
|
||||
*out = new(NetworkconfigurationResourcesManaged)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.LastSyncTime != nil {
|
||||
in, out := &in.LastSyncTime, &out.LastSyncTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkconfigurationStatus.
|
||||
@@ -221,3 +681,114 @@ func (in *NetworkconfigurationStatus) DeepCopy() *NetworkconfigurationStatus {
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PortForward) DeepCopyInto(out *PortForward) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
out.Status = in.Status
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortForward.
|
||||
func (in *PortForward) DeepCopy() *PortForward {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PortForward)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *PortForward) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PortForwardList) DeepCopyInto(out *PortForwardList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]PortForward, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortForwardList.
|
||||
func (in *PortForwardList) DeepCopy() *PortForwardList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PortForwardList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PortForwardSpec) DeepCopyInto(out *PortForwardSpec) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortForwardSpec.
|
||||
func (in *PortForwardSpec) DeepCopy() *PortForwardSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PortForwardSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PortForwardStatus) DeepCopyInto(out *PortForwardStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortForwardStatus.
|
||||
func (in *PortForwardStatus) DeepCopy() *PortForwardStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PortForwardStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ServiceEntry) DeepCopyInto(out *ServiceEntry) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceEntry.
|
||||
func (in *ServiceEntry) DeepCopy() *ServiceEntry {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ServiceEntry)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *UnifiFirewallPolicyEntry) DeepCopyInto(out *UnifiFirewallPolicyEntry) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UnifiFirewallPolicyEntry.
|
||||
func (in *UnifiFirewallPolicyEntry) DeepCopy() *UnifiFirewallPolicyEntry {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(UnifiFirewallPolicyEntry)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
38
cmd/main.go
38
cmd/main.go
@@ -21,11 +21,13 @@ import (
|
||||
"flag"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
|
||||
// to ensure that exec-entrypoint and run can make use of them.
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
|
||||
"k8s.io/utils/pointer"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
@@ -38,6 +40,7 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||
|
||||
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/config"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/controller"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/unifi"
|
||||
// +kubebuilder:scaffold:imports
|
||||
@@ -186,6 +189,10 @@ func main() {
|
||||
HealthProbeBindAddress: probeAddr,
|
||||
LeaderElection: enableLeaderElection,
|
||||
LeaderElectionID: "f05533b6.engen.priv.no",
|
||||
LeaseDuration: pointer.Duration(30 * time.Second),
|
||||
RenewDeadline: pointer.Duration(20 * time.Second),
|
||||
RetryPeriod: pointer.Duration(5 * time.Second),
|
||||
|
||||
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
|
||||
// when the Manager ends. This requires the binary to immediately end when the
|
||||
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
|
||||
@@ -203,6 +210,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
configLoader := config.NewConfigLoader(mgr.GetClient())
|
||||
|
||||
// Unifi client
|
||||
setupLog.Info("Setting up UniFi client")
|
||||
unifiClient, err := unifi.CreateUnifiClient()
|
||||
@@ -216,16 +225,45 @@ func main() {
|
||||
Client: mgr.GetClient(),
|
||||
Scheme: mgr.GetScheme(),
|
||||
UnifiClient: unifiClient,
|
||||
ConfigLoader: configLoader,
|
||||
}).SetupWithManager(mgr); err != nil {
|
||||
setupLog.Error(err, "unable to create controller", "controller", "Networkconfiguration")
|
||||
os.Exit(1)
|
||||
}
|
||||
if err = (&controller.FirewallZoneReconciler{
|
||||
Client: mgr.GetClient(),
|
||||
Scheme: mgr.GetScheme(),
|
||||
UnifiClient: unifiClient,
|
||||
ConfigLoader: configLoader,
|
||||
}).SetupWithManager(mgr); err != nil {
|
||||
setupLog.Error(err, "unable to create controller", "controller", "FirewallZone")
|
||||
os.Exit(1)
|
||||
}
|
||||
if err = (&controller.FirewallPolicyReconciler{
|
||||
Client: mgr.GetClient(),
|
||||
Scheme: mgr.GetScheme(),
|
||||
UnifiClient: unifiClient,
|
||||
ConfigLoader: configLoader,
|
||||
}).SetupWithManager(mgr); err != nil {
|
||||
setupLog.Error(err, "unable to create controller", "controller", "FirewallPolicy")
|
||||
os.Exit(1)
|
||||
}
|
||||
if err = (&controller.PortForwardReconciler{
|
||||
Client: mgr.GetClient(),
|
||||
Scheme: mgr.GetScheme(),
|
||||
UnifiClient: unifiClient,
|
||||
ConfigLoader: configLoader,
|
||||
}).SetupWithManager(mgr); err != nil {
|
||||
setupLog.Error(err, "unable to create controller", "controller", "PortForward")
|
||||
os.Exit(1)
|
||||
}
|
||||
// +kubebuilder:scaffold:builder
|
||||
|
||||
if err = (&controller.FirewallGroupReconciler{
|
||||
Client: mgr.GetClient(),
|
||||
Scheme: mgr.GetScheme(),
|
||||
UnifiClient: unifiClient,
|
||||
ConfigLoader: configLoader,
|
||||
}).SetupWithManager(mgr); err != nil {
|
||||
setupLog.Error(err, "unable to create controller", "controller", "FirewallGroup")
|
||||
os.Exit(1)
|
||||
|
||||
@@ -37,15 +37,14 @@ spec:
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: FirewallGroupSpec defines the desired state of FirewallGroup.
|
||||
properties:
|
||||
addressType:
|
||||
description: AddressType can be "ip", "cidr", or "both"
|
||||
enum:
|
||||
- ip
|
||||
- cidr
|
||||
- both
|
||||
auto_created_from:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
autoIncludeSelector:
|
||||
description: AutoIncludeSelector defines which services to extract
|
||||
addresses from
|
||||
@@ -93,18 +92,33 @@ spec:
|
||||
type: object
|
||||
type: object
|
||||
x-kubernetes-map-type: atomic
|
||||
id:
|
||||
description: |-
|
||||
Foo is an example field of FirewallGroup. Edit firewallgroup_types.go to remove/update
|
||||
Description is a human-readable explanation for the object
|
||||
type: string
|
||||
manual_services:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
manualAddresses:
|
||||
description: ManualAddresses is a list of manual IPs or CIDRs (IPv4
|
||||
or IPv6)
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
manualPorts:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
matchServicesInAllNamespaces:
|
||||
type: boolean
|
||||
name:
|
||||
description: |-
|
||||
Foo is an example field of FirewallGroup. Edit firewallgroup_types.go to remove/update
|
||||
Description is a human-readable explanation for the object
|
||||
type: string
|
||||
type: object
|
||||
status:
|
||||
@@ -114,10 +128,53 @@ spec:
|
||||
description: LastSyncTime is the last time the object was synced
|
||||
format: date-time
|
||||
type: string
|
||||
resolvedAddresses:
|
||||
resolvedIPV4Addresses:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resolvedIPV6Addresses:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resolvedTCPorts:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resolvedUDPorts:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resources_managed:
|
||||
properties:
|
||||
ipv4_object:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
ipv6_object:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
tcp_ports_object:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
udp_ports_object:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
syncedWithUnifi:
|
||||
description: SyncedWithUnifi indicates whether the addresses are successfully
|
||||
pushed
|
||||
|
||||
138
config/crd/bases/unifi.engen.priv.no_firewallpolicies.yaml
Normal file
138
config/crd/bases/unifi.engen.priv.no_firewallpolicies.yaml
Normal file
@@ -0,0 +1,138 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: firewallpolicies.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: FirewallPolicy
|
||||
listKind: FirewallPolicyList
|
||||
plural: firewallpolicies
|
||||
singular: firewallpolicy
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: FirewallPolicy is the Schema for the firewallpolicies API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
properties:
|
||||
destination:
|
||||
properties:
|
||||
firewall_groups:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
services:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
match_firewall_groups_in_all_namespaces:
|
||||
type: boolean
|
||||
match_services_in_all_namespaces:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
source:
|
||||
properties:
|
||||
from_networks:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
from_zones:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
required:
|
||||
- destination
|
||||
- name
|
||||
- source
|
||||
type: object
|
||||
status:
|
||||
description: FirewallPolicyStatus defines the observed state of FirewallPolicy.
|
||||
properties:
|
||||
resources_managed:
|
||||
properties:
|
||||
firewall_groups_managed:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
firewall_policies_managed:
|
||||
items:
|
||||
properties:
|
||||
from:
|
||||
type: string
|
||||
tcpipv4_id:
|
||||
type: string
|
||||
tcpipv6_id:
|
||||
type: string
|
||||
to:
|
||||
type: string
|
||||
udpipv4_id:
|
||||
type: string
|
||||
udpipv6_id:
|
||||
type: string
|
||||
required:
|
||||
- from
|
||||
- tcpipv4_id
|
||||
- tcpipv6_id
|
||||
- to
|
||||
- udpipv4_id
|
||||
- udpipv6_id
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
75
config/crd/bases/unifi.engen.priv.no_firewallzones.yaml
Normal file
75
config/crd/bases/unifi.engen.priv.no_firewallzones.yaml
Normal file
@@ -0,0 +1,75 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: firewallzones.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: FirewallZone
|
||||
listKind: FirewallZoneList
|
||||
plural: firewallzones
|
||||
singular: firewallzone
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: FirewallZone is the Schema for the firewallzones API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: FirewallZoneSpec defines the desired state of FirewallZone.
|
||||
properties:
|
||||
_id:
|
||||
type: string
|
||||
default_zone:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
network_ids:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
zone_key:
|
||||
type: string
|
||||
type: object
|
||||
status:
|
||||
description: FirewallZoneStatus defines the observed state of FirewallZone.
|
||||
properties:
|
||||
resources_managed:
|
||||
properties:
|
||||
firewall_zones_managed:
|
||||
items:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -40,11 +40,13 @@ spec:
|
||||
spec:
|
||||
description: NetworkconfigurationSpec defines the desired state of Networkconfiguration.
|
||||
properties:
|
||||
enabled:
|
||||
_id:
|
||||
description: Foo is an example field of Networkconfiguration. Edit
|
||||
networkconfiguration_types.go to remove/update
|
||||
type: string
|
||||
enabled:
|
||||
type: boolean
|
||||
firewall_zone_id:
|
||||
firewall_zone:
|
||||
type: string
|
||||
gateway_type:
|
||||
type: string
|
||||
@@ -62,10 +64,6 @@ spec:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
network_id:
|
||||
type: string
|
||||
network_name:
|
||||
type: string
|
||||
networkgroup:
|
||||
type: string
|
||||
purpose:
|
||||
@@ -79,17 +77,38 @@ spec:
|
||||
type: boolean
|
||||
required:
|
||||
- name
|
||||
- network_name
|
||||
type: object
|
||||
status:
|
||||
description: NetworkconfigurationStatus defines the observed state of
|
||||
Networkconfiguration.
|
||||
properties:
|
||||
ipv6_subnet_status:
|
||||
firewall_zone_id:
|
||||
description: |-
|
||||
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
Important: Run "make" to regenerate code after modifying this file
|
||||
type: string
|
||||
ipv6_subnet_status:
|
||||
type: string
|
||||
lastSyncTime:
|
||||
description: LastSyncTime is the last time the object was synced
|
||||
format: date-time
|
||||
type: string
|
||||
resources_managed:
|
||||
properties:
|
||||
networks_managed:
|
||||
items:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
syncedWithUnifi:
|
||||
description: SyncedWithUnifi indicates whether the addresses are successfully
|
||||
pushed
|
||||
type: boolean
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
|
||||
49
config/crd/bases/unifi.engen.priv.no_portforwards.yaml
Normal file
49
config/crd/bases/unifi.engen.priv.no_portforwards.yaml
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: portforwards.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: PortForward
|
||||
listKind: PortForwardList
|
||||
plural: portforwards
|
||||
singular: portforward
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: |-
|
||||
PortForward is a placeholder type to allow future CRD support if needed.
|
||||
Right now, port forwards are managed entirely through annotations on Services.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
type: object
|
||||
status:
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -3,6 +3,9 @@
|
||||
# It should be run by config/default
|
||||
resources:
|
||||
- bases/unifi.engen.priv.no_networkconfigurations.yaml
|
||||
- bases/unifi.engen.priv.no_firewallzones.yaml
|
||||
- bases/unifi.engen.priv.no_firewallpolicies.yaml
|
||||
- bases/unifi.engen.priv.no_portforwards.yaml
|
||||
# +kubebuilder:scaffold:crdkustomizeresource
|
||||
|
||||
patches:
|
||||
|
||||
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
images:
|
||||
- name: controller
|
||||
newName: registry.engen.priv.no/unifi-network-operator-controller
|
||||
newName: github.com/vegardengen/unifi-network-operator-controller
|
||||
newTag: latest
|
||||
|
||||
27
config/rbac/firewallpolicy_admin_role.yaml
Normal file
27
config/rbac/firewallpolicy_admin_role.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants full permissions ('*') over unifi.engen.priv.no.
|
||||
# This role is intended for users authorized to modify roles and bindings within the cluster,
|
||||
# enabling them to delegate specific permissions to other users or groups as needed.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: firewallpolicy-admin-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies/status
|
||||
verbs:
|
||||
- get
|
||||
33
config/rbac/firewallpolicy_editor_role.yaml
Normal file
33
config/rbac/firewallpolicy_editor_role.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants permissions to create, update, and delete resources within the unifi.engen.priv.no.
|
||||
# This role is intended for users who need to manage these resources
|
||||
# but should not control RBAC or manage permissions for others.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: firewallpolicy-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies/status
|
||||
verbs:
|
||||
- get
|
||||
29
config/rbac/firewallpolicy_viewer_role.yaml
Normal file
29
config/rbac/firewallpolicy_viewer_role.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants read-only access to unifi.engen.priv.no resources.
|
||||
# This role is intended for users who need visibility into these resources
|
||||
# without permissions to modify them. It is ideal for monitoring purposes and limited-access viewing.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: firewallpolicy-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies/status
|
||||
verbs:
|
||||
- get
|
||||
27
config/rbac/firewallzone_admin_role.yaml
Normal file
27
config/rbac/firewallzone_admin_role.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants full permissions ('*') over unifi.engen.priv.no.
|
||||
# This role is intended for users authorized to modify roles and bindings within the cluster,
|
||||
# enabling them to delegate specific permissions to other users or groups as needed.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: firewallzone-admin-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones/status
|
||||
verbs:
|
||||
- get
|
||||
33
config/rbac/firewallzone_editor_role.yaml
Normal file
33
config/rbac/firewallzone_editor_role.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants permissions to create, update, and delete resources within the unifi.engen.priv.no.
|
||||
# This role is intended for users who need to manage these resources
|
||||
# but should not control RBAC or manage permissions for others.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: firewallzone-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones/status
|
||||
verbs:
|
||||
- get
|
||||
29
config/rbac/firewallzone_viewer_role.yaml
Normal file
29
config/rbac/firewallzone_viewer_role.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants read-only access to unifi.engen.priv.no resources.
|
||||
# This role is intended for users who need visibility into these resources
|
||||
# without permissions to modify them. It is ideal for monitoring purposes and limited-access viewing.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: firewallzone-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones/status
|
||||
verbs:
|
||||
- get
|
||||
@@ -22,6 +22,15 @@ resources:
|
||||
# default, aiding admins in cluster management. Those roles are
|
||||
# not used by the {{ .ProjectName }} itself. You can comment the following lines
|
||||
# if you do not want those helpers be installed with your Project.
|
||||
- portforward_admin_role.yaml
|
||||
- portforward_editor_role.yaml
|
||||
- portforward_viewer_role.yaml
|
||||
- firewallpolicy_admin_role.yaml
|
||||
- firewallpolicy_editor_role.yaml
|
||||
- firewallpolicy_viewer_role.yaml
|
||||
- firewallzone_admin_role.yaml
|
||||
- firewallzone_editor_role.yaml
|
||||
- firewallzone_viewer_role.yaml
|
||||
- networkconfiguration_admin_role.yaml
|
||||
- networkconfiguration_editor_role.yaml
|
||||
- networkconfiguration_viewer_role.yaml
|
||||
|
||||
27
config/rbac/portforward_admin_role.yaml
Normal file
27
config/rbac/portforward_admin_role.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants full permissions ('*') over unifi.engen.priv.no.
|
||||
# This role is intended for users authorized to modify roles and bindings within the cluster,
|
||||
# enabling them to delegate specific permissions to other users or groups as needed.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: portforward-admin-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
33
config/rbac/portforward_editor_role.yaml
Normal file
33
config/rbac/portforward_editor_role.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants permissions to create, update, and delete resources within the unifi.engen.priv.no.
|
||||
# This role is intended for users who need to manage these resources
|
||||
# but should not control RBAC or manage permissions for others.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: portforward-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
29
config/rbac/portforward_viewer_role.yaml
Normal file
29
config/rbac/portforward_viewer_role.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
# This rule is not used by the project unifi-network-operator itself.
|
||||
# It is provided to allow the cluster admin to help manage permissions for users.
|
||||
#
|
||||
# Grants read-only access to unifi.engen.priv.no resources.
|
||||
# This role is intended for users who need visibility into these resources
|
||||
# without permissions to modify them. It is ideal for monitoring purposes and limited-access viewing.
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: portforward-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
@@ -7,6 +7,7 @@ rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
- services
|
||||
verbs:
|
||||
- get
|
||||
@@ -16,7 +17,10 @@ rules:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups
|
||||
- firewallpolicies
|
||||
- firewallzones
|
||||
- networkconfigurations
|
||||
- portforwards
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
@@ -29,14 +33,20 @@ rules:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups/finalizers
|
||||
- firewallpolicies/finalizers
|
||||
- firewallzones/finalizers
|
||||
- networkconfigurations/finalizers
|
||||
- portforwards/finalizers
|
||||
verbs:
|
||||
- update
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups/status
|
||||
- firewallpolicies/status
|
||||
- firewallzones/status
|
||||
- networkconfigurations/status
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
- patch
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
## Append samples of your project ##
|
||||
resources:
|
||||
- unifi_v1beta1_networkconfiguration.yaml
|
||||
- unifi_v1beta1_firewallzone.yaml
|
||||
- unifi_v1beta1_firewallrule.yaml
|
||||
- unifi_v1beta1_portforward.yaml
|
||||
# +kubebuilder:scaffold:manifestskustomizesamples
|
||||
|
||||
8
config/samples/unifi_v1beta1_firewallpolicy.yaml
Normal file
8
config/samples/unifi_v1beta1_firewallpolicy.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: unifi.engen.priv.no/v1beta1
|
||||
kind: FirewallPolicy
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: firewallpolicy-sample
|
||||
spec:
|
||||
9
config/samples/unifi_v1beta1_firewallzone.yaml
Normal file
9
config/samples/unifi_v1beta1_firewallzone.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: unifi.engen.priv.no/v1beta1
|
||||
kind: FirewallZone
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: firewallzone-sample
|
||||
spec:
|
||||
# TODO(user): Add fields here
|
||||
9
config/samples/unifi_v1beta1_portforward.yaml
Normal file
9
config/samples/unifi_v1beta1_portforward.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: unifi.engen.priv.no/v1beta1
|
||||
kind: PortForward
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: portforward-sample
|
||||
spec:
|
||||
# TODO(user): Add fields here
|
||||
952
dist/install.yaml
vendored
Normal file
952
dist/install.yaml
vendored
Normal file
@@ -0,0 +1,952 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
control-plane: controller-manager
|
||||
name: unifi-network-operator-system
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: firewallpolicies.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: FirewallPolicy
|
||||
listKind: FirewallPolicyList
|
||||
plural: firewallpolicies
|
||||
singular: firewallpolicy
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: FirewallPolicy is the Schema for the firewallpolicies API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
properties:
|
||||
destination:
|
||||
properties:
|
||||
firewall_groups:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
services:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
match_firewall_groups_in_all_namespaces:
|
||||
type: boolean
|
||||
match_services_in_all_namespaces:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
source:
|
||||
properties:
|
||||
from_networks:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
from_zones:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
required:
|
||||
- destination
|
||||
- name
|
||||
- source
|
||||
type: object
|
||||
status:
|
||||
description: FirewallPolicyStatus defines the observed state of FirewallPolicy.
|
||||
properties:
|
||||
resources_managed:
|
||||
properties:
|
||||
firewall_groups_managed:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
firewall_policies_managed:
|
||||
items:
|
||||
properties:
|
||||
from:
|
||||
type: string
|
||||
tcpipv4_id:
|
||||
type: string
|
||||
tcpipv6_id:
|
||||
type: string
|
||||
to:
|
||||
type: string
|
||||
udpipv4_id:
|
||||
type: string
|
||||
udpipv6_id:
|
||||
type: string
|
||||
required:
|
||||
- from
|
||||
- tcpipv4_id
|
||||
- tcpipv6_id
|
||||
- to
|
||||
- udpipv4_id
|
||||
- udpipv6_id
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: firewallzones.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: FirewallZone
|
||||
listKind: FirewallZoneList
|
||||
plural: firewallzones
|
||||
singular: firewallzone
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: FirewallZone is the Schema for the firewallzones API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: FirewallZoneSpec defines the desired state of FirewallZone.
|
||||
properties:
|
||||
_id:
|
||||
type: string
|
||||
default_zone:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
network_ids:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
zone_key:
|
||||
type: string
|
||||
type: object
|
||||
status:
|
||||
description: FirewallZoneStatus defines the observed state of FirewallZone.
|
||||
properties:
|
||||
resources_managed:
|
||||
properties:
|
||||
firewall_zones_managed:
|
||||
items:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: networkconfigurations.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: Networkconfiguration
|
||||
listKind: NetworkconfigurationList
|
||||
plural: networkconfigurations
|
||||
singular: networkconfiguration
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: Networkconfiguration is the Schema for the networkconfigurations
|
||||
API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: NetworkconfigurationSpec defines the desired state of Networkconfiguration.
|
||||
properties:
|
||||
_id:
|
||||
description: Foo is an example field of Networkconfiguration. Edit
|
||||
networkconfiguration_types.go to remove/update
|
||||
type: string
|
||||
enabled:
|
||||
type: boolean
|
||||
firewall_zone:
|
||||
type: string
|
||||
gateway_type:
|
||||
type: string
|
||||
ip_subnet:
|
||||
type: string
|
||||
ipv6_interface_type:
|
||||
type: string
|
||||
ipv6_pd_auto_prefixid_enabled:
|
||||
type: boolean
|
||||
ipv6_ra_enabled:
|
||||
type: boolean
|
||||
ipv6_setting_preference:
|
||||
type: string
|
||||
ipv6_subnet:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
networkgroup:
|
||||
type: string
|
||||
purpose:
|
||||
type: string
|
||||
setting_preference:
|
||||
type: string
|
||||
vlan:
|
||||
format: int64
|
||||
type: integer
|
||||
vlan_enabled:
|
||||
type: boolean
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
status:
|
||||
description: NetworkconfigurationStatus defines the observed state of
|
||||
Networkconfiguration.
|
||||
properties:
|
||||
firewall_zone_id:
|
||||
description: |-
|
||||
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
Important: Run "make" to regenerate code after modifying this file
|
||||
type: string
|
||||
ipv6_subnet_status:
|
||||
type: string
|
||||
lastSyncTime:
|
||||
description: LastSyncTime is the last time the object was synced
|
||||
format: date-time
|
||||
type: string
|
||||
resources_managed:
|
||||
properties:
|
||||
networks_managed:
|
||||
items:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
syncedWithUnifi:
|
||||
description: SyncedWithUnifi indicates whether the addresses are successfully
|
||||
pushed
|
||||
type: boolean
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: portforwards.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: PortForward
|
||||
listKind: PortForwardList
|
||||
plural: portforwards
|
||||
singular: portforward
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: |-
|
||||
PortForward is a placeholder type to allow future CRD support if needed.
|
||||
Right now, port forwards are managed entirely through annotations on Services.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
type: object
|
||||
status:
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-controller-manager
|
||||
namespace: unifi-network-operator-system
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-leader-election-role
|
||||
namespace: unifi-network-operator-system
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- events
|
||||
verbs:
|
||||
- create
|
||||
- patch
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-firewallpolicy-admin-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-firewallpolicy-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-firewallpolicy-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallpolicies/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-firewallzone-admin-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-firewallzone-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-firewallzone-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallzones/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: unifi-network-operator-manager-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
- services
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups
|
||||
- firewallpolicies
|
||||
- firewallzones
|
||||
- networkconfigurations
|
||||
- portforwards
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups/finalizers
|
||||
- firewallpolicies/finalizers
|
||||
- firewallzones/finalizers
|
||||
- networkconfigurations/finalizers
|
||||
- portforwards/finalizers
|
||||
verbs:
|
||||
- update
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups/status
|
||||
- firewallpolicies/status
|
||||
- firewallzones/status
|
||||
- networkconfigurations/status
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
- patch
|
||||
- update
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: unifi-network-operator-metrics-auth-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- authentication.k8s.io
|
||||
resources:
|
||||
- tokenreviews
|
||||
verbs:
|
||||
- create
|
||||
- apiGroups:
|
||||
- authorization.k8s.io
|
||||
resources:
|
||||
- subjectaccessreviews
|
||||
verbs:
|
||||
- create
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: unifi-network-operator-metrics-reader
|
||||
rules:
|
||||
- nonResourceURLs:
|
||||
- /metrics
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-networkconfiguration-admin-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- networkconfigurations
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- networkconfigurations/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-networkconfiguration-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- networkconfigurations
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- networkconfigurations/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-networkconfiguration-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- networkconfigurations
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- networkconfigurations/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-portforward-admin-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-portforward-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-portforward-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-leader-election-rolebinding
|
||||
namespace: unifi-network-operator-system
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: unifi-network-operator-leader-election-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: unifi-network-operator-controller-manager
|
||||
namespace: unifi-network-operator-system
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
name: unifi-network-operator-manager-rolebinding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: unifi-network-operator-manager-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: unifi-network-operator-controller-manager
|
||||
namespace: unifi-network-operator-system
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: unifi-network-operator-metrics-auth-rolebinding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: unifi-network-operator-metrics-auth-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: unifi-network-operator-controller-manager
|
||||
namespace: unifi-network-operator-system
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
control-plane: controller-manager
|
||||
name: unifi-network-operator-controller-manager-metrics-service
|
||||
namespace: unifi-network-operator-system
|
||||
spec:
|
||||
ports:
|
||||
- name: https
|
||||
port: 8443
|
||||
protocol: TCP
|
||||
targetPort: 8443
|
||||
selector:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
control-plane: controller-manager
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
control-plane: controller-manager
|
||||
name: unifi-network-operator-controller-manager
|
||||
namespace: unifi-network-operator-system
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
control-plane: controller-manager
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
kubectl.kubernetes.io/default-container: manager
|
||||
labels:
|
||||
app.kubernetes.io/name: unifi-network-operator
|
||||
control-plane: controller-manager
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
- --metrics-bind-address=:8443
|
||||
- --leader-elect
|
||||
- --health-probe-bind-address=:8081
|
||||
env:
|
||||
- name: UNIFI_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: UNIFI_URL
|
||||
name: unifi-configuration
|
||||
- name: UNIFI_SITE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: UNIFI_SITE
|
||||
name: unifi-configuration
|
||||
- name: UNIFI_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: UNIFI_USERNAME
|
||||
name: unifi-configuration
|
||||
- name: UNIFI_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: UNIFI_PASSWORD
|
||||
name: unifi-configuration
|
||||
image: gitea.engen.priv.no/klauvsteinen/unifi-network-operator-controller:latest
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8081
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
name: manager
|
||||
ports: []
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /readyz
|
||||
port: 8081
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 128Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 64Mi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
volumeMounts: []
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
serviceAccountName: unifi-network-operator-controller-manager
|
||||
terminationGracePeriodSeconds: 10
|
||||
volumes: []
|
||||
108
go.mod
108
go.mod
@@ -1,90 +1,94 @@
|
||||
module github.com/vegardengen/unifi-network-operator
|
||||
|
||||
go 1.23.0
|
||||
go 1.24.0
|
||||
|
||||
godebug default=go1.23
|
||||
toolchain go1.24.1
|
||||
|
||||
require (
|
||||
github.com/onsi/ginkgo/v2 v2.22.0
|
||||
github.com/onsi/gomega v1.36.1
|
||||
github.com/vegardengen/go-unifi v0.0.0-20250408133614-8e97d8aceca3
|
||||
gitea.engen.priv.no/klauvsteinen/go-unifi v0.0.1-alpha26
|
||||
github.com/onsi/ginkgo/v2 v2.23.4
|
||||
github.com/onsi/gomega v1.37.0
|
||||
k8s.io/api v0.32.1
|
||||
k8s.io/apimachinery v0.32.1
|
||||
k8s.io/client-go v0.32.1
|
||||
sigs.k8s.io/controller-runtime v0.20.2
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e
|
||||
sigs.k8s.io/controller-runtime v0.20.4
|
||||
)
|
||||
|
||||
require (
|
||||
cel.dev/expr v0.18.0 // indirect
|
||||
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
|
||||
cel.dev/expr v0.23.1 // indirect
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
|
||||
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.8.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-logr/zapr v1.3.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/swag v0.23.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.21.1 // indirect
|
||||
github.com/go-openapi/jsonreference v0.21.0 // indirect
|
||||
github.com/go-openapi/swag v0.23.1 // indirect
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/btree v1.1.3 // indirect
|
||||
github.com/google/cel-go v0.22.0 // indirect
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/gnostic-models v0.6.9 // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mailru/easyjson v0.9.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/prometheus/client_golang v1.19.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.55.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/spf13/cobra v1.8.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/prometheus/client_golang v1.22.0 // indirect
|
||||
github.com/prometheus/client_model v0.6.2 // indirect
|
||||
github.com/prometheus/common v0.63.0 // indirect
|
||||
github.com/prometheus/procfs v0.16.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/spf13/cobra v1.9.1 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/stoewer/go-strcase v1.3.0 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
|
||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
|
||||
go.opentelemetry.io/otel v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.35.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/oauth2 v0.23.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
golang.org/x/term v0.25.0 // indirect
|
||||
golang.org/x/text v0.19.0 // indirect
|
||||
golang.org/x/time v0.7.0 // indirect
|
||||
golang.org/x/tools v0.26.0 // indirect
|
||||
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect
|
||||
google.golang.org/grpc v1.65.0 // indirect
|
||||
google.golang.org/protobuf v1.35.1 // indirect
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
|
||||
golang.org/x/net v0.39.0 // indirect
|
||||
golang.org/x/oauth2 v0.29.0 // indirect
|
||||
golang.org/x/sync v0.13.0 // indirect
|
||||
golang.org/x/sys v0.32.0 // indirect
|
||||
golang.org/x/term v0.31.0 // indirect
|
||||
golang.org/x/text v0.24.0 // indirect
|
||||
golang.org/x/time v0.11.0 // indirect
|
||||
golang.org/x/tools v0.32.0 // indirect
|
||||
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250409194420-de1ac958c67a // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250409194420-de1ac958c67a // indirect
|
||||
google.golang.org/grpc v1.71.1 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
@@ -92,10 +96,10 @@ require (
|
||||
k8s.io/apiserver v0.32.1 // indirect
|
||||
k8s.io/component-base v0.32.1 // indirect
|
||||
k8s.io/klog/v2 v2.130.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
|
||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.32.0 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
|
||||
sigs.k8s.io/randfill v1.0.0 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
||||
|
||||
231
go.sum
231
go.sum
@@ -1,7 +1,9 @@
|
||||
cel.dev/expr v0.18.0 h1:CJ6drgk+Hf96lkLikr4rFf19WrU0BOWEihyZnI2TAzo=
|
||||
cel.dev/expr v0.18.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
|
||||
cel.dev/expr v0.23.1 h1:K4KOtPCJQjVggkARsjG9RWXP6O4R73aHeJMa/dmCQQg=
|
||||
cel.dev/expr v0.23.1/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
|
||||
gitea.engen.priv.no/klauvsteinen/go-unifi v0.0.1-alpha26 h1:nM5XNYGPCR+6U5ypssm5iuwJrubeKwD2axLZeZXl/EQ=
|
||||
gitea.engen.priv.no/klauvsteinen/go-unifi v0.0.1-alpha26/go.mod h1:0cA32wEhA7BTHHI4frsPjXFctHkJq9VZe9yrOwVlpQE=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
@@ -12,24 +14,23 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
|
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
|
||||
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
||||
github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
|
||||
github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
||||
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=
|
||||
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
|
||||
github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU=
|
||||
github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/fxamacker/cbor/v2 v2.8.0 h1:fFtUGXUzXPHTIUdne5+zzMPTfffl3RD5qYnkY40vtxU=
|
||||
github.com/fxamacker/cbor/v2 v2.8.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
@@ -37,14 +38,12 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
|
||||
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
|
||||
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
|
||||
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
|
||||
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
|
||||
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
|
||||
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
|
||||
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
|
||||
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
|
||||
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
|
||||
github.com/go-openapi/jsonpointer v0.21.1 h1:whnzv/pNXtK2FbX/W9yJfRmE2gsmkfahjMKB0fZvcic=
|
||||
github.com/go-openapi/jsonpointer v0.21.1/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk=
|
||||
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
|
||||
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
|
||||
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU=
|
||||
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0=
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
@@ -55,20 +54,20 @@ github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
|
||||
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
|
||||
github.com/google/cel-go v0.22.0 h1:b3FJZxpiv1vTMo2/5RDUqAHPxkT8mmMfJIrq1llbf7g=
|
||||
github.com/google/cel-go v0.22.0/go.mod h1:BuznPXXfQDpXKWQ9sPW3TzlAJN5zzFe+i9tIs0yC4s8=
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 h1:0VpGH+cDhbDtdcweoyCVsF3fhN8kejK6rFe/2FFX2nU=
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49/go.mod h1:BkkQ4L1KS1xMt2aWSPStnn55ChGC0DPOn2FQYj+f25M=
|
||||
github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw=
|
||||
github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo=
|
||||
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||
@@ -77,15 +76,16 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
|
||||
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@@ -93,30 +93,32 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
|
||||
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
|
||||
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
|
||||
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
|
||||
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
|
||||
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
|
||||
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
|
||||
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
|
||||
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
||||
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
|
||||
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
|
||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||
github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k=
|
||||
github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18=
|
||||
github.com/prometheus/procfs v0.16.0 h1:xh6oHhKwnOJKMYiYBDWmkHqQPyiY40sny36Cmx2bbsM=
|
||||
github.com/prometheus/procfs v0.16.0/go.mod h1:8veyXUu3nGP7oaCxhX6yeaM5u4stL2FeMXnCqhDthZg=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
|
||||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
|
||||
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
|
||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs=
|
||||
github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -126,32 +128,36 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
|
||||
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
|
||||
github.com/vegardengen/go-unifi v0.0.0-20250408133614-8e97d8aceca3 h1:Qvy/EgeaVSF0GnLVPeAb3VQYp5DSytxEcmqQjbSCuDM=
|
||||
github.com/vegardengen/go-unifi v0.0.0-20250408133614-8e97d8aceca3/go.mod h1:iwGJACYaRNb8eElwajOM7uYtyZraV9+5171gv3Q1QSc=
|
||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg=
|
||||
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
|
||||
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0/go.mod h1:s75jGIWA9OfCMzF0xr+ZgfrB5FEbbV7UuYo32ahUiFI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0/go.mod h1:MOiCmryaYtc+V0Ei+Tx9o5S1ZjA7kzLucuVuyzBZloQ=
|
||||
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
|
||||
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
|
||||
go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE=
|
||||
go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg=
|
||||
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
|
||||
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ=
|
||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 h1:1fTNlAIJZGWLP5FVu0fikVry1IsiUnXjf7QFvoNN3Xw=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0/go.mod h1:zjPK58DtkqQFn+YUMbx0M2XV3QgKU0gS9LeGohREyK4=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 h1:m639+BofXTvcY1q8CGs4ItwQarYtJPOWmVobfM1HpVI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0/go.mod h1:LjReUci/F4BUyv+y4dwnq3h/26iNOeC3wAIqgvTIZVo=
|
||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
|
||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
||||
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4=
|
||||
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
|
||||
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
||||
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
@@ -161,56 +167,56 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
|
||||
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
|
||||
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
|
||||
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
||||
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
|
||||
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
|
||||
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
|
||||
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
||||
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
|
||||
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
|
||||
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
|
||||
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
|
||||
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
|
||||
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
|
||||
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
|
||||
golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU=
|
||||
golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
|
||||
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 h1:YcyjlL1PRr2Q17/I0dPk2JmYS5CDXfcdb2Z3YRioEbw=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:OCdP9MfskevB/rbYvHTsXTtKC+3bHWajPdoKgjcYkfo=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 h1:2035KHhUv+EpyB+hWgJnaWKJOdX1E95w2S8Rr4uWKTs=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
|
||||
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
|
||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gomodules.xyz/jsonpatch/v2 v2.5.0 h1:JELs8RLM12qJGXU4u/TO3V25KW8GreMKl9pdkk14RM0=
|
||||
gomodules.xyz/jsonpatch/v2 v2.5.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250409194420-de1ac958c67a h1:OQ7sHVzkx6L57dQpzUS4ckfWJ51KDH74XHTDe23xWAs=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250409194420-de1ac958c67a/go.mod h1:2R6XrVC8Oc08GlNh8ujEpc7HkLiEZ16QeY7FxIs20ac=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250409194420-de1ac958c67a h1:GIqLhp/cYUkuGuiT+vJk8vhOP86L4+SP5j8yXgeVpvI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250409194420-de1ac958c67a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI=
|
||||
google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
@@ -235,17 +241,20 @@ k8s.io/component-base v0.32.1 h1:/5IfJ0dHIKBWysGV0yKTFfacZ5yNV1sulPh3ilJjRZk=
|
||||
k8s.io/component-base v0.32.1/go.mod h1:j1iMMHi/sqAHeG5z+O9BFNCF698a1u0186zkjMZQ28w=
|
||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
|
||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
|
||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4=
|
||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro=
|
||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 h1:CPT0ExVicCzcpeN4baWEV2ko2Z/AsiZgEdwgcfwLgMo=
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
|
||||
sigs.k8s.io/controller-runtime v0.20.2 h1:/439OZVxoEc02psi1h4QO3bHzTgu49bb347Xp4gW1pc=
|
||||
sigs.k8s.io/controller-runtime v0.20.2/go.mod h1:xg2XB0K5ShQzAgsoujxuKN4LNXR2LfwwHsPj7Iaw+XY=
|
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
|
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4=
|
||||
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4=
|
||||
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8=
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e h1:KqK5c/ghOm8xkHYhlodbp6i6+r+ChV2vuAuVRdFbLro=
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.32.0 h1:XotDXzqvJ8Nx5eiZZueLpTuafJz8SiodgOemI+w87QU=
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.32.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
|
||||
sigs.k8s.io/controller-runtime v0.20.4 h1:X3c+Odnxz+iPTRobG4tp092+CvBU9UK0t/bRf+n0DGU=
|
||||
sigs.k8s.io/controller-runtime v0.20.4/go.mod h1:xg2XB0K5ShQzAgsoujxuKN4LNXR2LfwwHsPj7Iaw+XY=
|
||||
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=
|
||||
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
|
||||
sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
|
||||
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
|
||||
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 h1:qPeWmscJcXP0snki5IYF79Z8xrl8ETFxgMd7wez1XkI=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.7.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps=
|
||||
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
|
||||
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
|
||||
|
||||
298
helm/INSTALL.md
Normal file
298
helm/INSTALL.md
Normal file
@@ -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 <<EOF | kubectl apply -f -
|
||||
apiVersion: unifi.engen.priv.no/v1beta1
|
||||
kind: FirewallZone
|
||||
metadata:
|
||||
name: test-zone
|
||||
namespace: default
|
||||
spec:
|
||||
zoneName: "test-zone"
|
||||
EOF
|
||||
```
|
||||
|
||||
## Production Installation
|
||||
|
||||
For production deployments, create a `values.yaml` file:
|
||||
|
||||
```yaml
|
||||
# production-values.yaml
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: gitea.engen.priv.no/klauvsteinen/unifi-network-operator-controller
|
||||
tag: "latest"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
unifi:
|
||||
url: "https://unifi.example.com:8443"
|
||||
site: "default"
|
||||
username: "operator-user"
|
||||
# Use existingSecret in production!
|
||||
existingSecret: "unifi-credentials"
|
||||
|
||||
config:
|
||||
defaultNamespace: "default"
|
||||
fullSyncZone: "gateway"
|
||||
fullSyncNetwork: "core"
|
||||
kubernetesUnifiZone: "kubernetes"
|
||||
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 256Mi
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 128Mi
|
||||
|
||||
metrics:
|
||||
serviceMonitor:
|
||||
enabled: true
|
||||
additionalLabels:
|
||||
prometheus: kube-prometheus
|
||||
|
||||
leaderElection:
|
||||
enabled: true
|
||||
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 100
|
||||
podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app.kubernetes.io/name
|
||||
operator: In
|
||||
values:
|
||||
- unifi-network-operator
|
||||
topologyKey: kubernetes.io/hostname
|
||||
```
|
||||
|
||||
Create the secret first:
|
||||
|
||||
```bash
|
||||
kubectl create namespace unifi-network-operator-system
|
||||
|
||||
kubectl create secret generic unifi-credentials \
|
||||
--from-literal=UNIFI_URL="https://unifi.example.com:8443" \
|
||||
--from-literal=UNIFI_SITE="default" \
|
||||
--from-literal=UNIFI_USERNAME="operator-user" \
|
||||
--from-literal=UNIFI_PASSWORD="your-secure-password" \
|
||||
-n unifi-network-operator-system
|
||||
```
|
||||
|
||||
Then install with the values file:
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
-f production-values.yaml
|
||||
```
|
||||
|
||||
## Upgrading
|
||||
|
||||
```bash
|
||||
helm upgrade unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
-f production-values.yaml
|
||||
```
|
||||
|
||||
## Uninstalling
|
||||
|
||||
```bash
|
||||
# Remove the operator (keeps CRDs and CRs by default)
|
||||
helm uninstall unifi-network-operator -n unifi-network-operator-system
|
||||
|
||||
# To also remove CRDs (this will delete all custom resources!)
|
||||
kubectl delete crds -l app.kubernetes.io/name=unifi-network-operator
|
||||
```
|
||||
|
||||
## Testing Locally
|
||||
|
||||
You can test the chart rendering without installing:
|
||||
|
||||
```bash
|
||||
# Render templates
|
||||
helm template unifi-network-operator ./helm/unifi-network-operator \
|
||||
--set unifi.url="https://test.local" \
|
||||
--set unifi.password="test" \
|
||||
--debug
|
||||
|
||||
# Lint the chart
|
||||
helm lint ./helm/unifi-network-operator \
|
||||
--set unifi.url="https://test.local" \
|
||||
--set unifi.password="test"
|
||||
|
||||
# Dry run installation
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://test.local" \
|
||||
--set unifi.password="test" \
|
||||
--dry-run --debug
|
||||
```
|
||||
|
||||
## Packaging for Distribution
|
||||
|
||||
To package the chart for distribution:
|
||||
|
||||
```bash
|
||||
# Package the chart
|
||||
helm package helm/unifi-network-operator
|
||||
|
||||
# This creates: unifi-network-operator-0.1.0.tgz
|
||||
|
||||
# Generate index (if hosting a chart repository)
|
||||
helm repo index .
|
||||
```
|
||||
|
||||
## Common Configuration Scenarios
|
||||
|
||||
### Scenario 1: Development Environment
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://192.168.1.1:8443" \
|
||||
--set unifi.password="admin" \
|
||||
--set resources.limits.memory="128Mi" \
|
||||
--set resources.requests.memory="64Mi"
|
||||
```
|
||||
|
||||
### Scenario 2: Multiple Sites
|
||||
|
||||
For managing multiple UniFi sites, deploy separate instances:
|
||||
|
||||
```bash
|
||||
# Site 1
|
||||
helm install unifi-operator-site1 ./helm/unifi-network-operator \
|
||||
-n unifi-site1 \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://unifi-site1.example.com:8443" \
|
||||
--set unifi.site="site1" \
|
||||
--set unifi.password="password1"
|
||||
|
||||
# Site 2
|
||||
helm install unifi-operator-site2 ./helm/unifi-network-operator \
|
||||
-n unifi-site2 \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://unifi-site2.example.com:8443" \
|
||||
--set unifi.site="site2" \
|
||||
--set unifi.password="password2"
|
||||
```
|
||||
|
||||
### Scenario 3: Using with ArgoCD
|
||||
|
||||
Create an ArgoCD Application:
|
||||
|
||||
```yaml
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: unifi-network-operator
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://github.com/yourusername/unifi-network-operator
|
||||
targetRevision: main
|
||||
path: helm/unifi-network-operator
|
||||
helm:
|
||||
values: |
|
||||
unifi:
|
||||
existingSecret: unifi-credentials
|
||||
config:
|
||||
fullSyncZone: "gateway"
|
||||
fullSyncNetwork: "core"
|
||||
metrics:
|
||||
serviceMonitor:
|
||||
enabled: true
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: unifi-network-operator-system
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Operator Won't Start
|
||||
|
||||
Check the logs:
|
||||
```bash
|
||||
kubectl logs -n unifi-network-operator-system \
|
||||
-l app.kubernetes.io/name=unifi-network-operator
|
||||
```
|
||||
|
||||
### Connection Issues to UniFi Controller
|
||||
|
||||
Verify the secret:
|
||||
```bash
|
||||
kubectl get secret -n unifi-network-operator-system
|
||||
kubectl describe secret unifi-network-operator-unifi \
|
||||
-n unifi-network-operator-system
|
||||
```
|
||||
|
||||
### CRDs Not Installing
|
||||
|
||||
Manually install CRDs:
|
||||
```bash
|
||||
kubectl apply -f helm/unifi-network-operator/crds/
|
||||
```
|
||||
|
||||
### Resources Not Syncing
|
||||
|
||||
Check operator configuration:
|
||||
```bash
|
||||
kubectl get configmap -n unifi-network-operator-system
|
||||
kubectl describe configmap unifi-network-operator-config \
|
||||
-n unifi-network-operator-system
|
||||
```
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- [Helm Chart README](./unifi-network-operator/README.md)
|
||||
- [Values Reference](./unifi-network-operator/values.yaml)
|
||||
- [Custom Resource Examples](../config/samples/)
|
||||
234
helm/README.md
Normal file
234
helm/README.md
Normal file
@@ -0,0 +1,234 @@
|
||||
# UniFi Network Operator - Helm Chart
|
||||
|
||||
This directory contains the Helm chart for deploying the UniFi Network Operator to Kubernetes.
|
||||
|
||||
## Quick Links
|
||||
|
||||
- **[Installation Guide](./INSTALL.md)** - Detailed installation instructions and examples
|
||||
- **[Chart Documentation](./unifi-network-operator/README.md)** - Full configuration reference
|
||||
- **[Values Reference](./unifi-network-operator/values.yaml)** - All configurable values
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Install with minimal configuration
|
||||
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"
|
||||
```
|
||||
|
||||
## Chart Structure
|
||||
|
||||
```
|
||||
helm/unifi-network-operator/
|
||||
├── Chart.yaml # Chart metadata
|
||||
├── values.yaml # Default configuration values
|
||||
├── README.md # Detailed chart documentation
|
||||
├── .helmignore # Files to ignore when packaging
|
||||
├── crds/ # Custom Resource Definitions
|
||||
│ ├── unifi.engen.priv.no_firewallgroups.yaml
|
||||
│ ├── unifi.engen.priv.no_firewallpolicies.yaml
|
||||
│ ├── unifi.engen.priv.no_firewallzones.yaml
|
||||
│ ├── unifi.engen.priv.no_networkconfigurations.yaml
|
||||
│ └── unifi.engen.priv.no_portforwards.yaml
|
||||
└── templates/ # Kubernetes resource templates
|
||||
├── NOTES.txt # Post-installation notes
|
||||
├── _helpers.tpl # Template helpers
|
||||
├── deployment.yaml # Operator deployment
|
||||
├── serviceaccount.yaml # Service account
|
||||
├── clusterrole.yaml # Cluster-level permissions
|
||||
├── clusterrolebinding.yaml
|
||||
├── role.yaml # Namespace-level permissions
|
||||
├── rolebinding.yaml
|
||||
├── configmap.yaml # Operator configuration
|
||||
├── secret.yaml # UniFi credentials
|
||||
├── service.yaml # Metrics service
|
||||
└── servicemonitor.yaml # Prometheus integration
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- **Secure by Default**: Runs with restricted security context and non-root user
|
||||
- **Flexible Configuration**: Extensive values for customization
|
||||
- **Production Ready**: Leader election, resource limits, health checks
|
||||
- **Monitoring**: Built-in Prometheus ServiceMonitor support
|
||||
- **GitOps Friendly**: Works with ArgoCD, Flux, and other GitOps tools
|
||||
- **Credential Management**: Support for external secrets
|
||||
|
||||
## Key Configuration Options
|
||||
|
||||
### Required Settings
|
||||
|
||||
- `unifi.url` - UniFi controller URL (e.g., `https://unifi.example.com:8443`)
|
||||
- `unifi.password` - UniFi password (or use `unifi.existingSecret`)
|
||||
|
||||
### Common Optional Settings
|
||||
|
||||
- `unifi.site` - UniFi site ID (default: `default`)
|
||||
- `unifi.username` - UniFi username (default: `admin`)
|
||||
- `config.fullSyncZone` - Zone name for bidirectional sync
|
||||
- `config.fullSyncNetwork` - Network name for bidirectional sync
|
||||
- `metrics.serviceMonitor.enabled` - Enable Prometheus monitoring
|
||||
- `resources.*` - Resource limits and requests
|
||||
|
||||
## Using Make Targets
|
||||
|
||||
The project Makefile includes helpful Helm targets:
|
||||
|
||||
```bash
|
||||
# Lint the chart
|
||||
make helm-lint
|
||||
|
||||
# Render templates (for debugging)
|
||||
make helm-template
|
||||
|
||||
# Install (requires env vars)
|
||||
export UNIFI_URL="https://unifi.example.com:8443"
|
||||
export UNIFI_PASSWORD="your-password"
|
||||
make helm-install
|
||||
|
||||
# Upgrade
|
||||
make helm-upgrade
|
||||
|
||||
# Uninstall
|
||||
make helm-uninstall
|
||||
|
||||
# Package the chart
|
||||
make helm-package
|
||||
|
||||
# Dry run
|
||||
make helm-dry-run
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Development Installation
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://192.168.1.1:8443" \
|
||||
--set unifi.password="admin"
|
||||
```
|
||||
|
||||
### Production with Existing Secret
|
||||
|
||||
```bash
|
||||
# Create secret
|
||||
kubectl create secret generic unifi-creds \
|
||||
--from-literal=UNIFI_URL="https://unifi.example.com:8443" \
|
||||
--from-literal=UNIFI_SITE="default" \
|
||||
--from-literal=UNIFI_USERNAME="operator" \
|
||||
--from-literal=UNIFI_PASSWORD="secure-password" \
|
||||
-n unifi-network-operator-system
|
||||
|
||||
# Install with secret reference
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--set unifi.existingSecret="unifi-creds"
|
||||
```
|
||||
|
||||
### With Full Sync and Monitoring
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://unifi.example.com:8443" \
|
||||
--set unifi.password="password" \
|
||||
--set config.fullSyncZone="gateway" \
|
||||
--set config.fullSyncNetwork="core" \
|
||||
--set metrics.serviceMonitor.enabled=true
|
||||
```
|
||||
|
||||
## Upgrading
|
||||
|
||||
To upgrade the operator:
|
||||
|
||||
```bash
|
||||
helm upgrade unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system
|
||||
```
|
||||
|
||||
## Uninstalling
|
||||
|
||||
```bash
|
||||
# Remove the operator (CRDs remain)
|
||||
helm uninstall unifi-network-operator -n unifi-network-operator-system
|
||||
|
||||
# Also remove CRDs (WARNING: deletes all custom resources)
|
||||
kubectl delete crds \
|
||||
firewallgroups.unifi.engen.priv.no \
|
||||
firewallpolicies.unifi.engen.priv.no \
|
||||
firewallzones.unifi.engen.priv.no \
|
||||
networkconfigurations.unifi.engen.priv.no \
|
||||
portforwards.unifi.engen.priv.no
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
Create a `custom-values.yaml` file:
|
||||
|
||||
```yaml
|
||||
image:
|
||||
tag: "v1.0.0"
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
unifi:
|
||||
existingSecret: "my-unifi-secret"
|
||||
|
||||
config:
|
||||
fullSyncZone: "gateway"
|
||||
fullSyncNetwork: "core"
|
||||
kubernetesUnifiZone: "k8s"
|
||||
|
||||
resources:
|
||||
limits:
|
||||
memory: 256Mi
|
||||
requests:
|
||||
memory: 128Mi
|
||||
|
||||
metrics:
|
||||
serviceMonitor:
|
||||
enabled: true
|
||||
additionalLabels:
|
||||
prometheus: kube-prometheus
|
||||
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
|
||||
tolerations:
|
||||
- key: "node-role.kubernetes.io/control-plane"
|
||||
operator: "Exists"
|
||||
effect: "NoSchedule"
|
||||
```
|
||||
|
||||
Install with:
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
-f custom-values.yaml
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
- **[INSTALL.md](./INSTALL.md)** - Complete installation guide with examples
|
||||
- **[Chart README](./unifi-network-operator/README.md)** - Full configuration reference
|
||||
- **[values.yaml](./unifi-network-operator/values.yaml)** - Commented default values
|
||||
|
||||
## Support
|
||||
|
||||
For issues and questions:
|
||||
- Check the [Installation Guide](./INSTALL.md)
|
||||
- Review the [Chart Documentation](./unifi-network-operator/README.md)
|
||||
- Check operator logs: `kubectl logs -n unifi-network-operator-system -l app.kubernetes.io/name=unifi-network-operator`
|
||||
|
||||
## License
|
||||
|
||||
This Helm chart is provided under the same license as the UniFi Network Operator project.
|
||||
23
helm/unifi-network-operator/.helmignore
Normal file
23
helm/unifi-network-operator/.helmignore
Normal file
@@ -0,0 +1,23 @@
|
||||
# Patterns to ignore when building packages.
|
||||
# This supports shell glob matching, relative path matching, and
|
||||
# negation (prefixed with !). Only one pattern per line.
|
||||
.DS_Store
|
||||
# Common VCS dirs
|
||||
.git/
|
||||
.gitignore
|
||||
.bzr/
|
||||
.bzrignore
|
||||
.hg/
|
||||
.hgignore
|
||||
.svn/
|
||||
# Common backup files
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*.orig
|
||||
*~
|
||||
# Various IDEs
|
||||
.project
|
||||
.idea/
|
||||
*.tmproj
|
||||
.vscode/
|
||||
18
helm/unifi-network-operator/Chart.yaml
Normal file
18
helm/unifi-network-operator/Chart.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
apiVersion: v2
|
||||
name: unifi-network-operator
|
||||
description: A Kubernetes operator for managing UniFi network configurations
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "latest"
|
||||
home: https://github.com/vegardengen/unifi-network-operator
|
||||
maintainers:
|
||||
- name: Vegar Dengen
|
||||
url: https://github.com/vegardengen
|
||||
keywords:
|
||||
- unifi
|
||||
- network
|
||||
- operator
|
||||
- firewall
|
||||
- ubiquiti
|
||||
sources:
|
||||
- https://github.com/vegardengen/unifi-network-operator
|
||||
335
helm/unifi-network-operator/README.md
Normal file
335
helm/unifi-network-operator/README.md
Normal file
@@ -0,0 +1,335 @@
|
||||
# UniFi Network Operator Helm Chart
|
||||
|
||||
A Kubernetes operator for managing UniFi network configurations declaratively through Kubernetes Custom Resources.
|
||||
|
||||
## Introduction
|
||||
|
||||
This Helm chart deploys the UniFi Network Operator on a Kubernetes cluster. The operator enables you to manage UniFi network infrastructure (firewall zones, groups, policies, networks, and port forwards) using Kubernetes resources.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Kubernetes 1.19+
|
||||
- Helm 3.0+
|
||||
- Access to a UniFi Network Controller
|
||||
- UniFi controller credentials (URL, username, password)
|
||||
|
||||
## Installing the Chart
|
||||
|
||||
To install the chart with the release name `unifi-network-operator`:
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
--namespace unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://unifi.example.com:8443" \
|
||||
--set unifi.username="admin" \
|
||||
--set unifi.password="your-password" \
|
||||
--set unifi.site="default"
|
||||
```
|
||||
|
||||
## Uninstalling the Chart
|
||||
|
||||
To uninstall/delete the `unifi-network-operator` deployment:
|
||||
|
||||
```bash
|
||||
helm uninstall unifi-network-operator -n unifi-network-operator-system
|
||||
```
|
||||
|
||||
This command removes all the Kubernetes components associated with the chart. Note that CRDs are not deleted by default to prevent data loss.
|
||||
|
||||
## Configuration
|
||||
|
||||
The following table lists the configurable parameters of the UniFi Network Operator chart and their default values.
|
||||
|
||||
### General Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `replicaCount` | Number of operator replicas | `1` |
|
||||
| `image.repository` | Operator image repository | `gitea.engen.priv.no/klauvsteinen/unifi-network-operator-controller` |
|
||||
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
|
||||
| `image.tag` | Image tag (overrides appVersion) | `latest` |
|
||||
| `imagePullSecrets` | Image pull secrets | `[]` |
|
||||
| `nameOverride` | Override chart name | `""` |
|
||||
| `fullnameOverride` | Override full chart name | `""` |
|
||||
|
||||
### Service Account Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `serviceAccount.create` | Create service account | `true` |
|
||||
| `serviceAccount.automount` | Auto-mount service account token | `true` |
|
||||
| `serviceAccount.annotations` | Service account annotations | `{}` |
|
||||
| `serviceAccount.name` | Service account name | `""` |
|
||||
|
||||
### Security Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `podSecurityContext.runAsNonRoot` | Run as non-root user | `true` |
|
||||
| `podSecurityContext.seccompProfile.type` | Seccomp profile type | `RuntimeDefault` |
|
||||
| `securityContext.allowPrivilegeEscalation` | Allow privilege escalation | `false` |
|
||||
| `securityContext.capabilities.drop` | Dropped capabilities | `["ALL"]` |
|
||||
|
||||
### Resource Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `resources.limits.cpu` | CPU limit | `500m` |
|
||||
| `resources.limits.memory` | Memory limit | `128Mi` |
|
||||
| `resources.requests.cpu` | CPU request | `10m` |
|
||||
| `resources.requests.memory` | Memory request | `64Mi` |
|
||||
|
||||
### UniFi Controller Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `unifi.url` | UniFi controller URL | `""` (required) |
|
||||
| `unifi.site` | UniFi site ID | `"default"` |
|
||||
| `unifi.username` | UniFi username | `"admin"` |
|
||||
| `unifi.password` | UniFi password | `""` (required) |
|
||||
| `unifi.existingSecret` | Use existing secret for credentials | `""` |
|
||||
| `unifi.existingSecretKeys.url` | Key for URL in existing secret | `UNIFI_URL` |
|
||||
| `unifi.existingSecretKeys.site` | Key for site in existing secret | `UNIFI_SITE` |
|
||||
| `unifi.existingSecretKeys.username` | Key for username in existing secret | `UNIFI_USERNAME` |
|
||||
| `unifi.existingSecretKeys.password` | Key for password in existing secret | `UNIFI_PASSWORD` |
|
||||
|
||||
### Operator Configuration Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `config.create` | Create ConfigMap for operator config | `true` |
|
||||
| `config.defaultNamespace` | Default namespace for resources | `"default"` |
|
||||
| `config.fullSyncZone` | Full sync zone name | `""` |
|
||||
| `config.fullSyncNetwork` | Full sync network name | `""` |
|
||||
| `config.kubernetesUnifiZone` | Kubernetes UniFi zone name | `""` |
|
||||
| `config.existingConfigMap` | Use existing ConfigMap | `""` |
|
||||
|
||||
### RBAC Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `rbac.create` | Create RBAC resources | `true` |
|
||||
|
||||
### CRD Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `crds.install` | Install CRDs | `true` |
|
||||
| `crds.keep` | Keep CRDs on uninstall | `true` |
|
||||
|
||||
### Service Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `service.enabled` | Enable metrics service | `true` |
|
||||
| `service.type` | Service type | `ClusterIP` |
|
||||
| `service.port` | Service port | `8443` |
|
||||
| `service.annotations` | Service annotations | `{}` |
|
||||
|
||||
### Metrics Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `metrics.serviceMonitor.enabled` | Enable Prometheus ServiceMonitor | `false` |
|
||||
| `metrics.serviceMonitor.additionalLabels` | Additional labels for ServiceMonitor | `{}` |
|
||||
| `metrics.serviceMonitor.interval` | Scrape interval | `30s` |
|
||||
| `metrics.serviceMonitor.scrapeTimeout` | Scrape timeout | `10s` |
|
||||
|
||||
### Other Parameters
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `leaderElection.enabled` | Enable leader election | `true` |
|
||||
| `nodeSelector` | Node selector | `{}` |
|
||||
| `tolerations` | Tolerations | `[]` |
|
||||
| `affinity` | Affinity rules | `{}` |
|
||||
| `podAnnotations` | Pod annotations | `{"kubectl.kubernetes.io/default-container": "manager"}` |
|
||||
| `podLabels` | Pod labels | `{"control-plane": "controller-manager"}` |
|
||||
|
||||
## Using an Existing Secret
|
||||
|
||||
If you prefer to manage the UniFi credentials separately, you can create a secret manually and reference it:
|
||||
|
||||
```bash
|
||||
kubectl create secret generic my-unifi-secret \
|
||||
--from-literal=UNIFI_URL="https://unifi.example.com:8443" \
|
||||
--from-literal=UNIFI_SITE="default" \
|
||||
--from-literal=UNIFI_USERNAME="admin" \
|
||||
--from-literal=UNIFI_PASSWORD="your-password" \
|
||||
-n unifi-network-operator-system
|
||||
```
|
||||
|
||||
Then install the chart with:
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
--namespace unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.existingSecret="my-unifi-secret"
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Installation
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://192.168.1.1:8443" \
|
||||
--set unifi.password="mypassword"
|
||||
```
|
||||
|
||||
### Installation with Custom Configuration
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
--set unifi.url="https://unifi.example.com:8443" \
|
||||
--set unifi.username="operator" \
|
||||
--set unifi.password="secure-password" \
|
||||
--set unifi.site="main" \
|
||||
--set config.defaultNamespace="production" \
|
||||
--set config.fullSyncZone="gateway" \
|
||||
--set config.fullSyncNetwork="core" \
|
||||
--set resources.limits.memory="256Mi" \
|
||||
--set metrics.serviceMonitor.enabled=true
|
||||
```
|
||||
|
||||
### Using a Values File
|
||||
|
||||
Create a `my-values.yaml` file:
|
||||
|
||||
```yaml
|
||||
unifi:
|
||||
url: "https://unifi.example.com:8443"
|
||||
username: "operator"
|
||||
password: "my-secure-password"
|
||||
site: "default"
|
||||
|
||||
config:
|
||||
defaultNamespace: "default"
|
||||
fullSyncZone: "gateway"
|
||||
fullSyncNetwork: "core"
|
||||
|
||||
resources:
|
||||
limits:
|
||||
memory: 256Mi
|
||||
requests:
|
||||
memory: 128Mi
|
||||
|
||||
metrics:
|
||||
serviceMonitor:
|
||||
enabled: true
|
||||
additionalLabels:
|
||||
prometheus: kube-prometheus
|
||||
```
|
||||
|
||||
Install with:
|
||||
|
||||
```bash
|
||||
helm install unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system \
|
||||
--create-namespace \
|
||||
-f my-values.yaml
|
||||
```
|
||||
|
||||
## Custom Resources
|
||||
|
||||
After installing the operator, you can create the following custom resources:
|
||||
|
||||
### FirewallZone
|
||||
|
||||
```yaml
|
||||
apiVersion: unifi.engen.priv.no/v1beta1
|
||||
kind: FirewallZone
|
||||
metadata:
|
||||
name: my-zone
|
||||
spec:
|
||||
zoneName: "my-zone"
|
||||
```
|
||||
|
||||
### FirewallGroup
|
||||
|
||||
```yaml
|
||||
apiVersion: unifi.engen.priv.no/v1beta1
|
||||
kind: FirewallGroup
|
||||
metadata:
|
||||
name: web-servers
|
||||
spec:
|
||||
addresses:
|
||||
- "10.0.1.100/32"
|
||||
- "10.0.1.101/32"
|
||||
ports:
|
||||
- "80/tcp"
|
||||
- "443/tcp"
|
||||
```
|
||||
|
||||
### FirewallPolicy
|
||||
|
||||
```yaml
|
||||
apiVersion: unifi.engen.priv.no/v1beta1
|
||||
kind: FirewallPolicy
|
||||
metadata:
|
||||
name: allow-web
|
||||
spec:
|
||||
sourceZone: "wan"
|
||||
destinationGroup: "web-servers"
|
||||
```
|
||||
|
||||
### Networkconfiguration
|
||||
|
||||
```yaml
|
||||
apiVersion: unifi.engen.priv.no/v1beta1
|
||||
kind: Networkconfiguration
|
||||
metadata:
|
||||
name: vlan10
|
||||
spec:
|
||||
networkName: "VLAN10"
|
||||
```
|
||||
|
||||
## Upgrading
|
||||
|
||||
To upgrade the operator to a new version:
|
||||
|
||||
```bash
|
||||
helm upgrade unifi-network-operator ./helm/unifi-network-operator \
|
||||
-n unifi-network-operator-system
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Check Operator Logs
|
||||
|
||||
```bash
|
||||
kubectl logs -n unifi-network-operator-system -l app.kubernetes.io/name=unifi-network-operator -f
|
||||
```
|
||||
|
||||
### Check Operator Status
|
||||
|
||||
```bash
|
||||
kubectl get deployment -n unifi-network-operator-system
|
||||
kubectl get pods -n unifi-network-operator-system
|
||||
```
|
||||
|
||||
### Verify CRDs are Installed
|
||||
|
||||
```bash
|
||||
kubectl get crds | grep unifi.engen.priv.no
|
||||
```
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Authentication Failures**: Verify your UniFi credentials and URL are correct
|
||||
2. **CRD Not Found**: Ensure CRDs are installed with `crds.install=true`
|
||||
3. **Operator Not Starting**: Check resource limits and image pull secrets
|
||||
|
||||
## License
|
||||
|
||||
This chart is provided as-is under the same license as the UniFi Network Operator project.
|
||||
|
||||
## Support
|
||||
|
||||
For issues and questions, please refer to the project repository.
|
||||
@@ -0,0 +1,187 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: firewallgroups.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: FirewallGroup
|
||||
listKind: FirewallGroupList
|
||||
plural: firewallgroups
|
||||
singular: firewallgroup
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: FirewallGroup is the Schema for the firewallgroups API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
properties:
|
||||
auto_created_from:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
autoIncludeSelector:
|
||||
description: AutoIncludeSelector defines which services to extract
|
||||
addresses from
|
||||
properties:
|
||||
matchExpressions:
|
||||
description: matchExpressions is a list of label selector requirements.
|
||||
The requirements are ANDed.
|
||||
items:
|
||||
description: |-
|
||||
A label selector requirement is a selector that contains values, a key, and an operator that
|
||||
relates the key and values.
|
||||
properties:
|
||||
key:
|
||||
description: key is the label key that the selector applies
|
||||
to.
|
||||
type: string
|
||||
operator:
|
||||
description: |-
|
||||
operator represents a key's relationship to a set of values.
|
||||
Valid operators are In, NotIn, Exists and DoesNotExist.
|
||||
type: string
|
||||
values:
|
||||
description: |-
|
||||
values is an array of string values. If the operator is In or NotIn,
|
||||
the values array must be non-empty. If the operator is Exists or DoesNotExist,
|
||||
the values array must be empty. This array is replaced during a strategic
|
||||
merge patch.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-kubernetes-list-type: atomic
|
||||
required:
|
||||
- key
|
||||
- operator
|
||||
type: object
|
||||
type: array
|
||||
x-kubernetes-list-type: atomic
|
||||
matchLabels:
|
||||
additionalProperties:
|
||||
type: string
|
||||
description: |-
|
||||
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
|
||||
map is equivalent to an element of matchExpressions, whose key field is "key", the
|
||||
operator is "In", and the values array contains only "value". The requirements are ANDed.
|
||||
type: object
|
||||
type: object
|
||||
x-kubernetes-map-type: atomic
|
||||
id:
|
||||
description: |-
|
||||
Foo is an example field of FirewallGroup. Edit firewallgroup_types.go to remove/update
|
||||
Description is a human-readable explanation for the object
|
||||
type: string
|
||||
manual_services:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
manualAddresses:
|
||||
description: ManualAddresses is a list of manual IPs or CIDRs (IPv4
|
||||
or IPv6)
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
manualPorts:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
matchServicesInAllNamespaces:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
status:
|
||||
description: FirewallGroupStatus defines the observed state of FirewallGroup.
|
||||
properties:
|
||||
lastSyncTime:
|
||||
description: LastSyncTime is the last time the object was synced
|
||||
format: date-time
|
||||
type: string
|
||||
resolvedIPV4Addresses:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resolvedIPV6Addresses:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resolvedTCPorts:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resolvedUDPorts:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resources_managed:
|
||||
properties:
|
||||
ipv4_object:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
ipv6_object:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
tcp_ports_object:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
udp_ports_object:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
syncedWithUnifi:
|
||||
description: SyncedWithUnifi indicates whether the addresses are successfully
|
||||
pushed
|
||||
type: boolean
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -0,0 +1,138 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: firewallpolicies.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: FirewallPolicy
|
||||
listKind: FirewallPolicyList
|
||||
plural: firewallpolicies
|
||||
singular: firewallpolicy
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: FirewallPolicy is the Schema for the firewallpolicies API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
properties:
|
||||
destination:
|
||||
properties:
|
||||
firewall_groups:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
services:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
match_firewall_groups_in_all_namespaces:
|
||||
type: boolean
|
||||
match_services_in_all_namespaces:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
source:
|
||||
properties:
|
||||
from_networks:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
from_zones:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
required:
|
||||
- destination
|
||||
- name
|
||||
- source
|
||||
type: object
|
||||
status:
|
||||
description: FirewallPolicyStatus defines the observed state of FirewallPolicy.
|
||||
properties:
|
||||
resources_managed:
|
||||
properties:
|
||||
firewall_groups_managed:
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
namespace:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
firewall_policies_managed:
|
||||
items:
|
||||
properties:
|
||||
from:
|
||||
type: string
|
||||
tcpipv4_id:
|
||||
type: string
|
||||
tcpipv6_id:
|
||||
type: string
|
||||
to:
|
||||
type: string
|
||||
udpipv4_id:
|
||||
type: string
|
||||
udpipv6_id:
|
||||
type: string
|
||||
required:
|
||||
- from
|
||||
- tcpipv4_id
|
||||
- tcpipv6_id
|
||||
- to
|
||||
- udpipv4_id
|
||||
- udpipv6_id
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: firewallzones.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: FirewallZone
|
||||
listKind: FirewallZoneList
|
||||
plural: firewallzones
|
||||
singular: firewallzone
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: FirewallZone is the Schema for the firewallzones API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: FirewallZoneSpec defines the desired state of FirewallZone.
|
||||
properties:
|
||||
_id:
|
||||
type: string
|
||||
default_zone:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
network_ids:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
zone_key:
|
||||
type: string
|
||||
type: object
|
||||
status:
|
||||
description: FirewallZoneStatus defines the observed state of FirewallZone.
|
||||
properties:
|
||||
resources_managed:
|
||||
properties:
|
||||
firewall_zones_managed:
|
||||
items:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -0,0 +1,117 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: networkconfigurations.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: Networkconfiguration
|
||||
listKind: NetworkconfigurationList
|
||||
plural: networkconfigurations
|
||||
singular: networkconfiguration
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: Networkconfiguration is the Schema for the networkconfigurations
|
||||
API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: NetworkconfigurationSpec defines the desired state of Networkconfiguration.
|
||||
properties:
|
||||
_id:
|
||||
description: Foo is an example field of Networkconfiguration. Edit
|
||||
networkconfiguration_types.go to remove/update
|
||||
type: string
|
||||
enabled:
|
||||
type: boolean
|
||||
firewall_zone:
|
||||
type: string
|
||||
gateway_type:
|
||||
type: string
|
||||
ip_subnet:
|
||||
type: string
|
||||
ipv6_interface_type:
|
||||
type: string
|
||||
ipv6_pd_auto_prefixid_enabled:
|
||||
type: boolean
|
||||
ipv6_ra_enabled:
|
||||
type: boolean
|
||||
ipv6_setting_preference:
|
||||
type: string
|
||||
ipv6_subnet:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
networkgroup:
|
||||
type: string
|
||||
purpose:
|
||||
type: string
|
||||
setting_preference:
|
||||
type: string
|
||||
vlan:
|
||||
format: int64
|
||||
type: integer
|
||||
vlan_enabled:
|
||||
type: boolean
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
status:
|
||||
description: NetworkconfigurationStatus defines the observed state of
|
||||
Networkconfiguration.
|
||||
properties:
|
||||
firewall_zone_id:
|
||||
description: |-
|
||||
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
Important: Run "make" to regenerate code after modifying this file
|
||||
type: string
|
||||
ipv6_subnet_status:
|
||||
type: string
|
||||
lastSyncTime:
|
||||
description: LastSyncTime is the last time the object was synced
|
||||
format: date-time
|
||||
type: string
|
||||
resources_managed:
|
||||
properties:
|
||||
networks_managed:
|
||||
items:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
syncedWithUnifi:
|
||||
description: SyncedWithUnifi indicates whether the addresses are successfully
|
||||
pushed
|
||||
type: boolean
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -0,0 +1,49 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.2
|
||||
name: portforwards.unifi.engen.priv.no
|
||||
spec:
|
||||
group: unifi.engen.priv.no
|
||||
names:
|
||||
kind: PortForward
|
||||
listKind: PortForwardList
|
||||
plural: portforwards
|
||||
singular: portforward
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: |-
|
||||
PortForward is a placeholder type to allow future CRD support if needed.
|
||||
Right now, port forwards are managed entirely through annotations on Services.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: |-
|
||||
APIVersion defines the versioned schema of this representation of an object.
|
||||
Servers should convert recognized schemas to the latest internal value, and
|
||||
may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
type: string
|
||||
kind:
|
||||
description: |-
|
||||
Kind is a string value representing the REST resource this object represents.
|
||||
Servers may infer this from the endpoint the client submits requests to.
|
||||
Cannot be updated.
|
||||
In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
type: object
|
||||
status:
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
49
helm/unifi-network-operator/templates/NOTES.txt
Normal file
49
helm/unifi-network-operator/templates/NOTES.txt
Normal file
@@ -0,0 +1,49 @@
|
||||
Thank you for installing {{ .Chart.Name }}!
|
||||
|
||||
Your release is named {{ .Release.Name }}.
|
||||
|
||||
The UniFi Network Operator has been deployed to namespace: {{ .Release.Namespace }}
|
||||
|
||||
To learn more about the release, try:
|
||||
|
||||
$ helm status {{ .Release.Name }} -n {{ .Release.Namespace }}
|
||||
$ helm get all {{ .Release.Name }} -n {{ .Release.Namespace }}
|
||||
|
||||
{{- if not .Values.unifi.existingSecret }}
|
||||
|
||||
IMPORTANT: Make sure to configure your UniFi controller credentials properly.
|
||||
The operator requires the following environment variables to be set:
|
||||
- UNIFI_URL: {{ .Values.unifi.url }}
|
||||
- UNIFI_SITE: {{ .Values.unifi.site }}
|
||||
- UNIFI_USER: {{ .Values.unifi.username }}
|
||||
- UNIFI_PASSWORD: [CONFIGURED]
|
||||
{{- end }}
|
||||
|
||||
{{- if .Values.config.create }}
|
||||
|
||||
Operator configuration has been created with:
|
||||
{{- if .Values.config.defaultNamespace }}
|
||||
- Default Namespace: {{ .Values.config.defaultNamespace }}
|
||||
{{- end }}
|
||||
{{- if .Values.config.fullSyncZone }}
|
||||
- Full Sync Zone: {{ .Values.config.fullSyncZone }}
|
||||
{{- end }}
|
||||
{{- if .Values.config.fullSyncNetwork }}
|
||||
- Full Sync Network: {{ .Values.config.fullSyncNetwork }}
|
||||
{{- end }}
|
||||
{{- if .Values.config.kubernetesUnifiZone }}
|
||||
- Kubernetes UniFi Zone: {{ .Values.config.kubernetesUnifiZone }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
To get the operator logs:
|
||||
$ kubectl logs -n {{ .Release.Namespace }} -l {{ include "unifi-network-operator.selectorLabels" . | replace "\n" "," }} -f
|
||||
|
||||
Next steps:
|
||||
1. Create FirewallZone resources to manage UniFi firewall zones
|
||||
2. Create FirewallGroup resources to group IP addresses and ports
|
||||
3. Create FirewallPolicy resources to define firewall rules
|
||||
4. Create Networkconfiguration resources to manage network settings
|
||||
5. Annotate Services for port forwarding
|
||||
|
||||
For more information, visit: {{ .Chart.Home }}
|
||||
83
helm/unifi-network-operator/templates/_helpers.tpl
Normal file
83
helm/unifi-network-operator/templates/_helpers.tpl
Normal file
@@ -0,0 +1,83 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "unifi-network-operator.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
*/}}
|
||||
{{- define "unifi-network-operator.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "unifi-network-operator.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "unifi-network-operator.labels" -}}
|
||||
helm.sh/chart: {{ include "unifi-network-operator.chart" . }}
|
||||
{{ include "unifi-network-operator.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "unifi-network-operator.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "unifi-network-operator.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
control-plane: controller-manager
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "unifi-network-operator.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "unifi-network-operator.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the secret to use
|
||||
*/}}
|
||||
{{- define "unifi-network-operator.secretName" -}}
|
||||
{{- if .Values.unifi.existingSecret }}
|
||||
{{- .Values.unifi.existingSecret }}
|
||||
{{- else }}
|
||||
{{- include "unifi-network-operator.fullname" . }}-unifi
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the configmap to use
|
||||
*/}}
|
||||
{{- define "unifi-network-operator.configMapName" -}}
|
||||
{{- if .Values.config.existingConfigMap }}
|
||||
{{- .Values.config.existingConfigMap }}
|
||||
{{- else }}
|
||||
{{- include "unifi-network-operator.fullname" . }}-config
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
56
helm/unifi-network-operator/templates/clusterrole.yaml
Normal file
56
helm/unifi-network-operator/templates/clusterrole.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.fullname" . }}-manager-role
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
- services
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups
|
||||
- firewallpolicies
|
||||
- firewallzones
|
||||
- networkconfigurations
|
||||
- portforwards
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups/finalizers
|
||||
- firewallpolicies/finalizers
|
||||
- firewallzones/finalizers
|
||||
- networkconfigurations/finalizers
|
||||
- portforwards/finalizers
|
||||
verbs:
|
||||
- update
|
||||
- apiGroups:
|
||||
- unifi.engen.priv.no
|
||||
resources:
|
||||
- firewallgroups/status
|
||||
- firewallpolicies/status
|
||||
- firewallzones/status
|
||||
- networkconfigurations/status
|
||||
- portforwards/status
|
||||
verbs:
|
||||
- get
|
||||
- patch
|
||||
- update
|
||||
{{- end }}
|
||||
@@ -0,0 +1,16 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.fullname" . }}-manager-rolebinding
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: {{ include "unifi-network-operator.fullname" . }}-manager-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "unifi-network-operator.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end }}
|
||||
22
helm/unifi-network-operator/templates/configmap.yaml
Normal file
22
helm/unifi-network-operator/templates/configmap.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
{{- if .Values.config.create -}}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.configMapName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
data:
|
||||
{{- if .Values.config.defaultNamespace }}
|
||||
defaultNamespace: {{ .Values.config.defaultNamespace | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.config.fullSyncZone }}
|
||||
fullSyncZone: {{ .Values.config.fullSyncZone | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.config.fullSyncNetwork }}
|
||||
fullSyncNetwork: {{ .Values.config.fullSyncNetwork | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.config.kubernetesUnifiZone }}
|
||||
kubernetesUnifiZone: {{ .Values.config.kubernetesUnifiZone | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
82
helm/unifi-network-operator/templates/deployment.yaml
Normal file
82
helm/unifi-network-operator/templates/deployment.yaml
Normal file
@@ -0,0 +1,82 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.fullname" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "unifi-network-operator.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
{{- with .Values.podAnnotations }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "unifi-network-operator.serviceAccountName" . }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: manager
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
args:
|
||||
{{- if .Values.leaderElection.enabled }}
|
||||
- --leader-elect
|
||||
{{- end }}
|
||||
- --health-probe-bind-address=:8081
|
||||
env:
|
||||
- name: UNIFI_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "unifi-network-operator.secretName" . }}
|
||||
key: {{ .Values.unifi.existingSecretKeys.url }}
|
||||
- name: UNIFI_SITE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "unifi-network-operator.secretName" . }}
|
||||
key: {{ .Values.unifi.existingSecretKeys.site }}
|
||||
- name: UNIFI_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "unifi-network-operator.secretName" . }}
|
||||
key: {{ .Values.unifi.existingSecretKeys.username }}
|
||||
- name: UNIFI_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "unifi-network-operator.secretName" . }}
|
||||
key: {{ .Values.unifi.existingSecretKeys.password }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 10 }}
|
||||
livenessProbe:
|
||||
{{- toYaml .Values.livenessProbe | nindent 10 }}
|
||||
readinessProbe:
|
||||
{{- toYaml .Values.readinessProbe | nindent 10 }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 10 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
terminationGracePeriodSeconds: 10
|
||||
41
helm/unifi-network-operator/templates/role.yaml
Normal file
41
helm/unifi-network-operator/templates/role.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.fullname" . }}-leader-election-role
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- events
|
||||
verbs:
|
||||
- create
|
||||
- patch
|
||||
{{- end }}
|
||||
17
helm/unifi-network-operator/templates/rolebinding.yaml
Normal file
17
helm/unifi-network-operator/templates/rolebinding.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.fullname" . }}-leader-election-rolebinding
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ include "unifi-network-operator.fullname" . }}-leader-election-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "unifi-network-operator.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end }}
|
||||
15
helm/unifi-network-operator/templates/secret.yaml
Normal file
15
helm/unifi-network-operator/templates/secret.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
{{- if not .Values.unifi.existingSecret -}}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.fullname" . }}-unifi
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
type: Opaque
|
||||
stringData:
|
||||
{{ .Values.unifi.existingSecretKeys.url }}: {{ .Values.unifi.url | required "unifi.url is required when not using an existing secret" | quote }}
|
||||
{{ .Values.unifi.existingSecretKeys.site }}: {{ .Values.unifi.site | quote }}
|
||||
{{ .Values.unifi.existingSecretKeys.username }}: {{ .Values.unifi.username | quote }}
|
||||
{{ .Values.unifi.existingSecretKeys.password }}: {{ .Values.unifi.password | required "unifi.password is required when not using an existing secret" | quote }}
|
||||
{{- end }}
|
||||
22
helm/unifi-network-operator/templates/service.yaml
Normal file
22
helm/unifi-network-operator/templates/service.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
{{- if .Values.service.enabled -}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.fullname" . }}-metrics
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
{{- with .Values.service.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- name: https
|
||||
port: {{ .Values.service.port }}
|
||||
targetPort: 8443
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "unifi-network-operator.selectorLabels" . | nindent 4 }}
|
||||
{{- end }}
|
||||
14
helm/unifi-network-operator/templates/serviceaccount.yaml
Normal file
14
helm/unifi-network-operator/templates/serviceaccount.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
|
||||
{{- end }}
|
||||
24
helm/unifi-network-operator/templates/servicemonitor.yaml
Normal file
24
helm/unifi-network-operator/templates/servicemonitor.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
{{- if .Values.metrics.serviceMonitor.enabled -}}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ include "unifi-network-operator.fullname" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "unifi-network-operator.labels" . | nindent 4 }}
|
||||
{{- with .Values.metrics.serviceMonitor.additionalLabels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
endpoints:
|
||||
- interval: {{ .Values.metrics.serviceMonitor.interval }}
|
||||
path: /metrics
|
||||
port: https
|
||||
scheme: https
|
||||
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
|
||||
tlsConfig:
|
||||
insecureSkipVerify: true
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "unifi-network-operator.selectorLabels" . | nindent 6 }}
|
||||
{{- end }}
|
||||
159
helm/unifi-network-operator/values.yaml
Normal file
159
helm/unifi-network-operator/values.yaml
Normal file
@@ -0,0 +1,159 @@
|
||||
# Default values for unifi-network-operator
|
||||
|
||||
# -- Number of replicas for the operator deployment
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
# -- Container image repository
|
||||
repository: ghcr.io/vegardengen/unifi-network-operator
|
||||
# -- Image pull policy
|
||||
pullPolicy: IfNotPresent
|
||||
# -- Overrides the image tag whose default is the chart appVersion
|
||||
tag: "latest"
|
||||
|
||||
# -- Image pull secrets for private registries
|
||||
imagePullSecrets: []
|
||||
|
||||
# -- Override the name of the chart
|
||||
nameOverride: ""
|
||||
# -- Override the full name of the chart
|
||||
fullnameOverride: ""
|
||||
|
||||
serviceAccount:
|
||||
# -- Specifies whether a service account should be created
|
||||
create: true
|
||||
# -- Automatically mount a ServiceAccount's API credentials
|
||||
automount: true
|
||||
# -- Annotations to add to the service account
|
||||
annotations: {}
|
||||
# -- The name of the service account to use.
|
||||
# If not set and create is true, a name is generated using the fullname template
|
||||
name: ""
|
||||
|
||||
# -- Annotations to add to the pod
|
||||
podAnnotations:
|
||||
kubectl.kubernetes.io/default-container: manager
|
||||
|
||||
# -- Labels to add to the pod
|
||||
podLabels:
|
||||
control-plane: controller-manager
|
||||
|
||||
podSecurityContext:
|
||||
runAsNonRoot: true
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
|
||||
service:
|
||||
# -- Enable metrics service
|
||||
enabled: true
|
||||
# -- Service type
|
||||
type: ClusterIP
|
||||
# -- Metrics port
|
||||
port: 8443
|
||||
# -- Annotations to add to the service
|
||||
annotations: {}
|
||||
|
||||
resources:
|
||||
limits:
|
||||
# -- CPU limit
|
||||
cpu: 500m
|
||||
# -- Memory limit
|
||||
memory: 128Mi
|
||||
requests:
|
||||
# -- CPU request
|
||||
cpu: 10m
|
||||
# -- Memory request
|
||||
memory: 64Mi
|
||||
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8081
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /readyz
|
||||
port: 8081
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
|
||||
# -- Node selector for pod assignment
|
||||
nodeSelector: {}
|
||||
|
||||
# -- Tolerations for pod assignment
|
||||
tolerations: []
|
||||
|
||||
# -- Affinity for pod assignment
|
||||
affinity: {}
|
||||
|
||||
# Leader election configuration
|
||||
leaderElection:
|
||||
# -- Enable leader election for high availability
|
||||
enabled: true
|
||||
|
||||
# UniFi controller configuration
|
||||
unifi:
|
||||
# -- UniFi controller URL (e.g., https://unifi.example.com:8443)
|
||||
url: ""
|
||||
# -- UniFi site ID (e.g., default)
|
||||
site: "default"
|
||||
# -- UniFi username
|
||||
username: "admin"
|
||||
# -- UniFi password (leave empty to use existing secret)
|
||||
password: ""
|
||||
# -- Use existing secret for UniFi credentials
|
||||
# If set, the chart will not create a secret
|
||||
existingSecret: ""
|
||||
# -- Keys in the existing secret for UniFi credentials
|
||||
existingSecretKeys:
|
||||
url: UNIFI_URL
|
||||
site: UNIFI_SITE
|
||||
username: UNIFI_USERNAME
|
||||
password: UNIFI_PASSWORD
|
||||
|
||||
# Operator configuration
|
||||
config:
|
||||
# -- Create a ConfigMap for operator configuration
|
||||
create: true
|
||||
# -- Default namespace for resources
|
||||
defaultNamespace: "default"
|
||||
# -- Full sync zone name (zone for bidirectional sync)
|
||||
fullSyncZone: ""
|
||||
# -- Full sync network name (network for bidirectional sync)
|
||||
fullSyncNetwork: ""
|
||||
# -- Kubernetes UniFi zone name
|
||||
kubernetesUnifiZone: ""
|
||||
# -- Use existing ConfigMap for operator configuration
|
||||
existingConfigMap: ""
|
||||
|
||||
# CRD configuration
|
||||
crds:
|
||||
# -- Install CRDs as part of the Helm chart
|
||||
install: true
|
||||
# -- Keep CRDs on chart uninstall
|
||||
keep: true
|
||||
|
||||
# RBAC configuration
|
||||
rbac:
|
||||
# -- Create RBAC resources
|
||||
create: true
|
||||
|
||||
# Metrics configuration
|
||||
metrics:
|
||||
# -- Enable Prometheus ServiceMonitor
|
||||
serviceMonitor:
|
||||
enabled: false
|
||||
# -- Additional labels for the ServiceMonitor
|
||||
additionalLabels: {}
|
||||
# -- Scrape interval
|
||||
interval: 30s
|
||||
# -- Scrape timeout
|
||||
scrapeTimeout: 10s
|
||||
44
internal/config/config.go
Normal file
44
internal/config/config.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
type ConfigLoaderType struct {
|
||||
Client client.Client
|
||||
|
||||
mu sync.Mutex
|
||||
loaded bool
|
||||
config *corev1.ConfigMap
|
||||
err error
|
||||
}
|
||||
|
||||
func NewConfigLoader(k8sClient client.Client) *ConfigLoaderType {
|
||||
return &ConfigLoaderType{Client: k8sClient}
|
||||
}
|
||||
|
||||
func (c *ConfigLoaderType) GetConfig(ctx context.Context, name string) (*corev1.ConfigMap, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
if c.loaded {
|
||||
return c.config, c.err
|
||||
}
|
||||
|
||||
cm := &corev1.ConfigMap{}
|
||||
err := c.Client.Get(ctx, types.NamespacedName{
|
||||
Name: name,
|
||||
Namespace: "unifi-network-operator-system",
|
||||
}, cm)
|
||||
|
||||
c.loaded = true
|
||||
c.config = cm
|
||||
c.err = err
|
||||
|
||||
return cm, err
|
||||
}
|
||||
@@ -21,36 +21,44 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
"sigs.k8s.io/controller-runtime/pkg/handler"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
// "sigs.k8s.io/controller-runtime/pkg/source"
|
||||
|
||||
|
||||
goUnifi "github.com/vegardengen/go-unifi/unifi"
|
||||
goUnifi "gitea.engen.priv.no/klauvsteinen/go-unifi/unifi"
|
||||
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/config"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/unifi"
|
||||
)
|
||||
|
||||
const firewallGroupFinalizer = "finalizer.unifi.engen.priv.no/firewallgroup"
|
||||
|
||||
// FirewallGroupReconciler reconciles a FirewallGroup object
|
||||
type FirewallGroupReconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
UnifiClient *unifi.UnifiClient
|
||||
ConfigLoader *config.ConfigLoaderType
|
||||
}
|
||||
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallgroups,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallgroups/status,verbs=get;update;patch
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallgroups/finalizers,verbs=update
|
||||
// +kubebuilder:rbac:groups="",resources=services,verbs=list;get;watch
|
||||
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=list;get;watch
|
||||
|
||||
// Reconcile is part of the main kubernetes reconciliation loop which aims to
|
||||
// move the current state of the cluster closer to the desired state.
|
||||
@@ -64,14 +72,159 @@ type FirewallGroupReconciler struct {
|
||||
|
||||
func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
|
||||
log := log.FromContext(ctx)
|
||||
var nwObj unifiv1beta1.FirewallGroup
|
||||
if err := r.Get(ctx, req.NamespacedName, &nwObj); err != nil {
|
||||
|
||||
cfg, err := r.ConfigLoader.GetConfig(ctx, "unifi-operator-config")
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
defaultNs := cfg.Data["defaultNamespace"]
|
||||
log.Info(defaultNs)
|
||||
|
||||
var firewallGroup unifiv1beta1.FirewallGroup
|
||||
if err := r.Get(ctx, req.NamespacedName, &firewallGroup); err != nil {
|
||||
return reconcile.Result{}, client.IgnoreNotFound(err)
|
||||
}
|
||||
log.Info(nwObj.Spec.Name)
|
||||
var ipv4, ipv6 []string
|
||||
log.Info(firewallGroup.Spec.Name)
|
||||
|
||||
for _, addressEntry := range nwObj.Spec.ManualAddresses {
|
||||
// Check if the object is being deleted
|
||||
if firewallGroup.DeletionTimestamp != nil {
|
||||
if controllerutil.ContainsFinalizer(&firewallGroup, firewallGroupFinalizer) {
|
||||
err := r.UnifiClient.Reauthenticate()
|
||||
if err != nil {
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
log.Info("Running finalizer logic for FirewallGroup", "name", firewallGroup.Name)
|
||||
|
||||
if len(firewallGroup.Status.ResourcesManaged.IPV4Object.ID) > 0 {
|
||||
log.Info(fmt.Sprintf("Trying to delete ipv4 object %s", firewallGroup.Status.ResourcesManaged.IPV4Object.ID))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.IPV4Object.ID)
|
||||
if err != nil {
|
||||
msg := strings.ToLower(err.Error())
|
||||
log.Info(msg)
|
||||
if strings.Contains(msg, "api.err.objectreferredby") {
|
||||
firewall_group, err := r.UnifiClient.Client.GetFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.IPV4Object.ID)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not get object for renaming.")
|
||||
return reconcile.Result{}, err
|
||||
} else {
|
||||
log.Info("Firewall group is in use. Invoking workaround...!")
|
||||
firewall_group.GroupMembers = []string{"127.0.0.1"}
|
||||
firewall_group.Name = firewall_group.Name + "-deleted"
|
||||
_, updateerr := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewall_group)
|
||||
if updateerr != nil {
|
||||
log.Error(updateerr, "Could neither delete or rename firewall group")
|
||||
return reconcile.Result{}, updateerr
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResourcesManaged.IPV6Object.ID) > 0 {
|
||||
log.Info(fmt.Sprintf("Trying to delete ipv6 object %s", firewallGroup.Status.ResourcesManaged.IPV6Object.ID))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.IPV6Object.ID)
|
||||
if err != nil {
|
||||
msg := strings.ToLower(err.Error())
|
||||
log.Info(msg)
|
||||
if strings.Contains(msg, "api.err.objectreferredby") {
|
||||
firewall_group, err := r.UnifiClient.Client.GetFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.IPV6Object.ID)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not get object for renaming.")
|
||||
return reconcile.Result{}, err
|
||||
} else {
|
||||
log.Info("Firewall group is in use. Invoking workaround...!")
|
||||
firewall_group.GroupMembers = []string{"::1"}
|
||||
firewall_group.Name = firewall_group.Name + "-deleted"
|
||||
_, updateerr := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewall_group)
|
||||
if updateerr != nil {
|
||||
log.Error(updateerr, "Could neither delete or rename firewall group")
|
||||
return reconcile.Result{}, updateerr
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID) > 0 {
|
||||
log.Info(fmt.Sprintf("Trying to delete tcp object %s", firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID)
|
||||
if err != nil {
|
||||
msg := strings.ToLower(err.Error())
|
||||
log.Info(msg)
|
||||
if strings.Contains(msg, "api.err.objectreferredby") {
|
||||
firewall_group, err := r.UnifiClient.Client.GetFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not get object for renaming.")
|
||||
return reconcile.Result{}, err
|
||||
} else {
|
||||
log.Info("Firewall group is in use. Invoking workaround...!")
|
||||
firewall_group.GroupMembers = []string{"0"}
|
||||
firewall_group.Name = firewall_group.Name + "-deleted"
|
||||
_, updateerr := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewall_group)
|
||||
if updateerr != nil {
|
||||
log.Error(updateerr, "Could neither delete or rename firewall group")
|
||||
return reconcile.Result{}, updateerr
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID) > 0 {
|
||||
log.Info(fmt.Sprintf("Trying to delete udp object %s", firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID)
|
||||
if err != nil {
|
||||
msg := strings.ToLower(err.Error())
|
||||
log.Info(msg)
|
||||
if strings.Contains(msg, "api.err.objectreferredby") {
|
||||
firewall_group, err := r.UnifiClient.Client.GetFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not get object for renaming.")
|
||||
return reconcile.Result{}, err
|
||||
} else {
|
||||
log.Info("Firewall group is in use. Invoking workaround...!")
|
||||
firewall_group.GroupMembers = []string{"0"}
|
||||
firewall_group.Name = firewall_group.Name + "-deleted"
|
||||
_, updateerr := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewall_group)
|
||||
if updateerr != nil {
|
||||
log.Error(updateerr, "Could neither delete or rename firewall group")
|
||||
return reconcile.Result{}, updateerr
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
controllerutil.RemoveFinalizer(&firewallGroup, firewallGroupFinalizer)
|
||||
if err := r.Update(ctx, &firewallGroup); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
log.Info("Successfully finalized FirewallGroup")
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
if !controllerutil.ContainsFinalizer(&firewallGroup, firewallGroupFinalizer) {
|
||||
controllerutil.AddFinalizer(&firewallGroup, firewallGroupFinalizer)
|
||||
if err := r.Update(ctx, &firewallGroup); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
|
||||
var ipv4, ipv6, tcpports, udpports []string
|
||||
|
||||
for _, addressEntry := range firewallGroup.Spec.ManualAddresses {
|
||||
ip := net.ParseIP(addressEntry)
|
||||
|
||||
if ip != nil {
|
||||
@@ -99,8 +252,28 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, portEntry := range firewallGroup.Spec.ManualPorts {
|
||||
port_type := "tcp"
|
||||
port := portEntry
|
||||
if match, _ := regexp.MatchString("(?:tcp|udp)\\/?)\\d+", string(portEntry)); match {
|
||||
fields := strings.Split("/", portEntry)
|
||||
port_type = fields[0]
|
||||
port = fields[1]
|
||||
}
|
||||
if port_type == "tcp" {
|
||||
if !slices.Contains(tcpports, port) {
|
||||
tcpports = append(tcpports, port)
|
||||
}
|
||||
}
|
||||
if port_type == "udp" {
|
||||
if !slices.Contains(udpports, port) {
|
||||
tcpports = append(udpports, port)
|
||||
}
|
||||
}
|
||||
}
|
||||
var services corev1.ServiceList
|
||||
if nwObj.Spec.MatchServicesInAllNamespaces {
|
||||
if firewallGroup.Spec.MatchServicesInAllNamespaces {
|
||||
if err := r.List(ctx, &services); err != nil {
|
||||
log.Error(err, "unable to list services")
|
||||
return reconcile.Result{}, err
|
||||
@@ -112,8 +285,18 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
}
|
||||
serviceNamespaceNames := make(map[string]struct{})
|
||||
for _, serviceEntry := range firewallGroup.Spec.ManualServices {
|
||||
serviceNamespaceNames[serviceEntry.Namespace+"/"+serviceEntry.Name] = struct{}{}
|
||||
}
|
||||
log.Info(fmt.Sprintf("Manually specified: %+v", serviceNamespaceNames))
|
||||
for _, service := range services.Items {
|
||||
if val, found := service.Annotations["unifi.engen.priv.no/firewall-group"]; found && val == nwObj.Name && service.Status.LoadBalancer.Ingress != nil {
|
||||
_, manually_specified := serviceNamespaceNames[service.Namespace+"/"+service.Name]
|
||||
val, found := service.Annotations["unifi.engen.priv.no/firewall-group"]
|
||||
log.Info(fmt.Sprintf("%s %sv %+v %+v", service.Name, val, manually_specified, found))
|
||||
|
||||
// if val, found := service.Annotations["unifi.engen.priv.no/firewall-group"]; (manually_specified || (found && val == firewallGroup.Name)) && service.Status.LoadBalancer.Ingress != nil {
|
||||
if (manually_specified || (found && val == firewallGroup.Name)) && service.Status.LoadBalancer.Ingress != nil {
|
||||
for _, ingress := range service.Status.LoadBalancer.Ingress {
|
||||
if ingress.IP != "" {
|
||||
ip := ingress.IP
|
||||
@@ -124,15 +307,52 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
}
|
||||
}
|
||||
}
|
||||
if service.Spec.Ports != nil {
|
||||
for _, portSpec := range service.Spec.Ports {
|
||||
log.Info(fmt.Sprintf("portSpec: %+v", portSpec))
|
||||
log.Info(fmt.Sprintf("Port: %s %d", strconv.Itoa(int(portSpec.Port)), portSpec.Port))
|
||||
if portSpec.Protocol == "TCP" {
|
||||
if !slices.Contains(tcpports, strconv.Itoa(int(portSpec.Port))) {
|
||||
tcpports = append(tcpports, strconv.Itoa(int(portSpec.Port)))
|
||||
}
|
||||
}
|
||||
nwObj.Status.ResolvedAddresses = ipv4
|
||||
nwObj.Status.ResolvedAddresses = append(nwObj.Status.ResolvedAddresses, ipv6...)
|
||||
if portSpec.Protocol == "UDP" {
|
||||
if !slices.Contains(udpports, strconv.Itoa(int(portSpec.Port))) {
|
||||
udpports = append(udpports, strconv.Itoa(int(portSpec.Port)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
firewallGroup.Status.ResolvedIPV4Addresses = ipv4
|
||||
firewallGroup.Status.ResolvedIPV6Addresses = ipv6
|
||||
firewallGroup.Status.ResolvedTCPPorts = tcpports
|
||||
firewallGroup.Status.ResolvedUDPPorts = udpports
|
||||
currentTime := metav1.Now()
|
||||
nwObj.Status.LastSyncTime = ¤tTime;
|
||||
nwObj.Status.SyncedWithUnifi = true
|
||||
|
||||
err := r.UnifiClient.Reauthenticate()
|
||||
firewallGroup.Status.LastSyncTime = ¤tTime
|
||||
firewallGroup.Status.SyncedWithUnifi = true
|
||||
if firewallGroup.Status.ResourcesManaged == nil {
|
||||
firewallGroup.Status.ResourcesManaged = &unifiv1beta1.FirewallGroupResourcesManaged{
|
||||
IPV4Object: &unifiv1beta1.NamedUnifiResource{
|
||||
ID: "",
|
||||
Name: "",
|
||||
},
|
||||
IPV6Object: &unifiv1beta1.NamedUnifiResource{
|
||||
ID: "",
|
||||
Name: "",
|
||||
},
|
||||
TCPPortsObject: &unifiv1beta1.NamedUnifiResource{
|
||||
ID: "",
|
||||
Name: "",
|
||||
},
|
||||
UDPPortsObject: &unifiv1beta1.NamedUnifiResource{
|
||||
ID: "",
|
||||
Name: "",
|
||||
},
|
||||
}
|
||||
}
|
||||
err = r.UnifiClient.Reauthenticate()
|
||||
if err != nil {
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
@@ -141,19 +361,23 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
log.Error(err, "Could not list network objects")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
ipv4_name := "k8s-" + nwObj.Spec.Name + "-ipv4"
|
||||
ipv6_name := "k8s-" + nwObj.Spec.Name + "-ipv6"
|
||||
ipv4_name := "k8s-" + firewallGroup.Namespace + "/" + firewallGroup.Name + "-ipv4"
|
||||
ipv6_name := "k8s-" + firewallGroup.Namespace + "/" + firewallGroup.Name + "-ipv6"
|
||||
tcpports_name := "k8s-" + firewallGroup.Namespace + "/" + firewallGroup.Name + "-tcpports"
|
||||
udpports_name := "k8s-" + firewallGroup.Namespace + "/" + firewallGroup.Name + "-udpports"
|
||||
ipv4_done := false
|
||||
ipv6_done := false
|
||||
tcpports_done := false
|
||||
udpports_done := false
|
||||
for _, firewall_group := range firewall_groups {
|
||||
if firewall_group.Name == ipv4_name {
|
||||
if len(ipv4) == 0 {
|
||||
log.Info(fmt.Sprintf("Delete %s", ipv4_name))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewall_group.ID)
|
||||
log.Info(fmt.Sprintf("Delete %s: %s", ipv4_name, firewallGroup.Status.ResourcesManaged.IPV4Object.ID))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.IPV4Object.ID)
|
||||
if err != nil {
|
||||
msg := strings.ToLower(err.Error())
|
||||
log.Info(msg)
|
||||
if strings.Contains(msg, "api.err.objectreferredby") {
|
||||
if strings.Contains(msg, "api.err.objectreferredby") || strings.Contains(msg, "invalid character") {
|
||||
log.Info("Firewall group is in use. Invoking workaround...!")
|
||||
firewall_group.GroupMembers = []string{"127.0.0.1"}
|
||||
firewall_group.Name = firewall_group.Name + "-deleted"
|
||||
@@ -162,10 +386,15 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
log.Error(updateerr, "Could neither delete or rename firewall group")
|
||||
return reconcile.Result{}, updateerr
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.IPV4Object.Name = ""
|
||||
firewallGroup.Status.ResourcesManaged.IPV4Object.ID = ""
|
||||
} else {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
} else {
|
||||
firewallGroup.Status.ResourcesManaged.IPV4Object.Name = ""
|
||||
firewallGroup.Status.ResourcesManaged.IPV4Object.ID = ""
|
||||
}
|
||||
ipv4_done = true
|
||||
} else {
|
||||
@@ -184,11 +413,11 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
if firewall_group.Name == ipv6_name {
|
||||
if len(ipv6) == 0 {
|
||||
log.Info(fmt.Sprintf("Delete %s", ipv6_name))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewall_group.ID)
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.IPV6Object.ID)
|
||||
if err != nil {
|
||||
msg := strings.ToLower(err.Error())
|
||||
log.Info(msg)
|
||||
if strings.Contains(msg, "api.err.objectreferredby") {
|
||||
if strings.Contains(msg, "api.err.objectreferredby") || strings.Contains(msg, "invalid character") {
|
||||
log.Info("Firewall group is in use. Invoking workaround...!")
|
||||
firewall_group.GroupMembers = []string{"::1"}
|
||||
firewall_group.Name = firewall_group.Name + "-deleted"
|
||||
@@ -197,10 +426,15 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
log.Error(updateerr, "Could neither delete or rename firewall group")
|
||||
return reconcile.Result{}, updateerr
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.IPV6Object.Name = ""
|
||||
firewallGroup.Status.ResourcesManaged.IPV6Object.ID = ""
|
||||
} else {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
} else {
|
||||
firewallGroup.Status.ResourcesManaged.IPV6Object.Name = ""
|
||||
firewallGroup.Status.ResourcesManaged.IPV6Object.ID = ""
|
||||
}
|
||||
ipv6_done = true
|
||||
} else {
|
||||
@@ -216,6 +450,86 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
ipv6_done = true
|
||||
}
|
||||
}
|
||||
if firewall_group.Name == tcpports_name {
|
||||
if len(tcpports) == 0 {
|
||||
log.Info(fmt.Sprintf("Delete %s", tcpports_name))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID)
|
||||
if err != nil {
|
||||
msg := strings.ToLower(err.Error())
|
||||
log.Info(msg)
|
||||
if strings.Contains(msg, "api.err.objectreferredby") || strings.Contains(msg, "invalid character") {
|
||||
log.Info("Firewall group is in use. Invoking workaround...!")
|
||||
firewall_group.GroupMembers = []string{"0"}
|
||||
firewall_group.Name = firewall_group.Name + "-deleted"
|
||||
_, updateerr := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
if updateerr != nil {
|
||||
log.Error(updateerr, "Could neither delete or rename firewall group")
|
||||
return reconcile.Result{}, updateerr
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.TCPPortsObject.Name = ""
|
||||
firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID = ""
|
||||
} else {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
} else {
|
||||
firewallGroup.Status.ResourcesManaged.TCPPortsObject.Name = ""
|
||||
firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID = ""
|
||||
}
|
||||
tcpports_done = true
|
||||
} else {
|
||||
if !reflect.DeepEqual(firewall_group.GroupMembers, tcpports) {
|
||||
firewall_group.GroupMembers = tcpports
|
||||
log.Info(fmt.Sprintf("Updating %s", tcpports_name))
|
||||
_, err := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not update firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
}
|
||||
tcpports_done = true
|
||||
}
|
||||
}
|
||||
if firewall_group.Name == udpports_name {
|
||||
if len(udpports) == 0 {
|
||||
log.Info(fmt.Sprintf("Delete %s", udpports_name))
|
||||
err := r.UnifiClient.Client.DeleteFirewallGroup(context.Background(), r.UnifiClient.SiteID, firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID)
|
||||
if err != nil {
|
||||
msg := strings.ToLower(err.Error())
|
||||
log.Info(msg)
|
||||
if strings.Contains(msg, "api.err.objectreferredby") || strings.Contains(msg, "invalid character") {
|
||||
log.Info("Firewall group is in use. Invoking workaround...!")
|
||||
firewall_group.GroupMembers = []string{"127.0.0.1"}
|
||||
firewall_group.Name = firewall_group.Name + "-deleted"
|
||||
_, updateerr := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
if updateerr != nil {
|
||||
log.Error(updateerr, "Could neither delete or rename firewall group")
|
||||
return reconcile.Result{}, updateerr
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.UDPPortsObject.Name = ""
|
||||
firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID = ""
|
||||
} else {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
} else {
|
||||
firewallGroup.Status.ResourcesManaged.UDPPortsObject.Name = ""
|
||||
firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID = ""
|
||||
}
|
||||
udpports_done = true
|
||||
} else {
|
||||
if !reflect.DeepEqual(firewall_group.GroupMembers, udpports) {
|
||||
firewall_group.GroupMembers = udpports
|
||||
log.Info(fmt.Sprintf("Updating %s", udpports_name))
|
||||
_, err := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not update firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
}
|
||||
udpports_done = true
|
||||
}
|
||||
}
|
||||
if firewall_group.Name == ipv4_name+"-deleted" && len(ipv4) > 0 {
|
||||
firewall_group.Name = ipv4_name
|
||||
firewall_group.GroupMembers = ipv4
|
||||
@@ -225,6 +539,8 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
log.Error(err, "Could not update firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.IPV4Object.Name = firewall_group.Name
|
||||
firewallGroup.Status.ResourcesManaged.IPV4Object.ID = firewall_group.ID
|
||||
ipv4_done = true
|
||||
}
|
||||
if firewall_group.Name == ipv6_name+"-deleted" && len(ipv6) > 0 {
|
||||
@@ -236,8 +552,36 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
log.Error(err, "Could not update firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.IPV6Object.Name = firewall_group.Name
|
||||
firewallGroup.Status.ResourcesManaged.IPV6Object.ID = firewall_group.ID
|
||||
ipv6_done = true
|
||||
}
|
||||
if firewall_group.Name == tcpports_name+"-deleted" && len(tcpports) > 0 {
|
||||
firewall_group.Name = tcpports_name
|
||||
firewall_group.GroupMembers = tcpports
|
||||
log.Info(fmt.Sprintf("Creating %s (from previously deleted)", tcpports_name))
|
||||
_, err := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not update firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.TCPPortsObject.Name = firewall_group.Name
|
||||
firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID = firewall_group.ID
|
||||
tcpports_done = true
|
||||
}
|
||||
if firewall_group.Name == udpports_name+"-deleted" && len(udpports) > 0 {
|
||||
firewall_group.Name = udpports_name
|
||||
firewall_group.GroupMembers = udpports
|
||||
log.Info(fmt.Sprintf("Creating %s (from previously deleted)", udpports_name))
|
||||
_, err := r.UnifiClient.Client.UpdateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not update firewall group")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.UDPPortsObject.Name = firewall_group.Name
|
||||
firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID = firewall_group.ID
|
||||
udpports_done = true
|
||||
}
|
||||
}
|
||||
if len(ipv4) > 0 && !ipv4_done {
|
||||
log.Info(fmt.Sprintf("Creating %s", ipv4_name))
|
||||
@@ -246,11 +590,19 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
firewall_group.SiteID = r.UnifiClient.SiteID
|
||||
firewall_group.GroupMembers = ipv4
|
||||
firewall_group.GroupType = "address-group"
|
||||
_, err := r.UnifiClient.Client.CreateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
firewall_group_result, err := r.UnifiClient.Client.CreateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
log.Info(fmt.Sprintf("%+v", firewall_group_result))
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall group")
|
||||
return reconcile.Result{}, err
|
||||
} else {
|
||||
firewall_group = *firewall_group_result
|
||||
}
|
||||
|
||||
log.Info(fmt.Sprintf("ID and name: %s %s", firewall_group.ID, firewall_group.Name))
|
||||
log.Info(fmt.Sprintf("%+v", firewall_group))
|
||||
firewallGroup.Status.ResourcesManaged.IPV4Object.ID = firewall_group.ID
|
||||
firewallGroup.Status.ResourcesManaged.IPV4Object.Name = firewall_group.Name
|
||||
}
|
||||
if len(ipv6) > 0 && !ipv6_done {
|
||||
log.Info(fmt.Sprintf("Creating %s", ipv6_name))
|
||||
@@ -259,18 +611,62 @@ func (r *FirewallGroupReconciler) Reconcile(ctx context.Context, req reconcile.R
|
||||
firewall_group.SiteID = r.UnifiClient.SiteID
|
||||
firewall_group.GroupMembers = ipv6
|
||||
firewall_group.GroupType = "ipv6-address-group"
|
||||
_, err := r.UnifiClient.Client.CreateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
firewall_group_result, err := r.UnifiClient.Client.CreateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
log.Info(fmt.Sprintf("%+v", firewall_group_result))
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall group")
|
||||
return reconcile.Result{}, err
|
||||
} else {
|
||||
firewall_group = *firewall_group_result
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.IPV6Object.ID = firewall_group.ID
|
||||
firewallGroup.Status.ResourcesManaged.IPV6Object.Name = firewall_group.Name
|
||||
|
||||
}
|
||||
if err := r.Status().Update(ctx, &nwObj); err != nil {
|
||||
if len(tcpports) > 0 && !tcpports_done {
|
||||
log.Info(fmt.Sprintf("Creating %s", tcpports_name))
|
||||
var firewall_group goUnifi.FirewallGroup
|
||||
firewall_group.Name = tcpports_name
|
||||
firewall_group.SiteID = r.UnifiClient.SiteID
|
||||
firewall_group.GroupMembers = tcpports
|
||||
firewall_group.GroupType = "port-group"
|
||||
log.Info(fmt.Sprintf("Trying to apply: %+v", firewall_group))
|
||||
firewall_group_result, err := r.UnifiClient.Client.CreateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall group")
|
||||
return reconcile.Result{}, err
|
||||
} else {
|
||||
firewall_group = *firewall_group_result
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID = firewall_group.ID
|
||||
firewallGroup.Status.ResourcesManaged.TCPPortsObject.Name = firewall_group.Name
|
||||
}
|
||||
if len(udpports) > 0 && !udpports_done {
|
||||
log.Info(fmt.Sprintf("Creating %s", udpports_name))
|
||||
var firewall_group goUnifi.FirewallGroup
|
||||
firewall_group.Name = udpports_name
|
||||
firewall_group.SiteID = r.UnifiClient.SiteID
|
||||
firewall_group.GroupMembers = udpports
|
||||
firewall_group.GroupType = "port-group"
|
||||
log.Info(fmt.Sprintf("Trying to apply: %+v", firewall_group))
|
||||
firewall_group_result, err := r.UnifiClient.Client.CreateFirewallGroup(context.Background(), r.UnifiClient.SiteID, &firewall_group)
|
||||
log.Info(fmt.Sprintf("%+v", firewall_group_result))
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall group")
|
||||
return reconcile.Result{}, err
|
||||
} else {
|
||||
firewall_group = *firewall_group_result
|
||||
}
|
||||
firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID = firewall_group.ID
|
||||
firewallGroup.Status.ResourcesManaged.UDPPortsObject.Name = firewall_group.Name
|
||||
}
|
||||
log.Info(fmt.Sprintf("Updating status for %s: %+v", firewallGroup.Name, firewallGroup.Status))
|
||||
if err := r.Status().Update(ctx, &firewallGroup); err != nil {
|
||||
log.Error(err, "unable to update FirewallGroup status")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
|
||||
log.Info("Successfully updated FirewallGroup status with collected IP addresses")
|
||||
log.Info("Successfully updated FirewallGroup status with collected IP addresses and ports")
|
||||
|
||||
return reconcile.Result{}, nil
|
||||
}
|
||||
@@ -290,15 +686,15 @@ func (r *FirewallGroupReconciler) mapServiceToFirewallGroups(ctx context.Context
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, fwg := range allFirewallGroups.Items {
|
||||
if fwg.Spec.MatchServicesInAllNamespaces || fwg.Namespace == service.Namespace {
|
||||
for _, firewallGroup := range allFirewallGroups.Items {
|
||||
if firewallGroup.Spec.MatchServicesInAllNamespaces || firewallGroup.Namespace == service.Namespace {
|
||||
annotationKey := "unifi.engen.priv.no/firewall-group"
|
||||
annotationVal := fwg.Name
|
||||
annotationVal := firewallGroup.Name
|
||||
if val, ok := service.Annotations[annotationKey]; ok && (annotationVal == "" || val == annotationVal) {
|
||||
requests = append(requests, ctrl.Request{
|
||||
NamespacedName: types.NamespacedName{
|
||||
Name: fwg.Name,
|
||||
Namespace: fwg.Namespace,
|
||||
Name: firewallGroup.Name,
|
||||
Namespace: firewallGroup.Namespace,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -307,6 +703,7 @@ func (r *FirewallGroupReconciler) mapServiceToFirewallGroups(ctx context.Context
|
||||
|
||||
return requests
|
||||
}
|
||||
|
||||
// SetupWithManager sets up the controller with the Manager.
|
||||
func (r *FirewallGroupReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
|
||||
@@ -61,10 +61,10 @@ var _ = Describe("FirewallGroup Controller", func() {
|
||||
// TODO(user): Cleanup logic after each test, like removing the resource instance.
|
||||
resource := &unifiv1beta1.FirewallGroup{}
|
||||
err := k8sClient.Get(ctx, typeNamespacedName, resource)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
if err == nil {
|
||||
By("Cleanup the specific resource instance FirewallGroup")
|
||||
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
|
||||
}
|
||||
})
|
||||
It("should successfully reconcile the resource", func() {
|
||||
By("Reconciling the created resource")
|
||||
|
||||
887
internal/controller/firewallpolicy_controller.go
Normal file
887
internal/controller/firewallpolicy_controller.go
Normal file
@@ -0,0 +1,887 @@
|
||||
/*
|
||||
Copyright 2025 Vegard Engen.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
// "strings"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
"sigs.k8s.io/controller-runtime/pkg/handler"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
|
||||
goUnifi "gitea.engen.priv.no/klauvsteinen/go-unifi/unifi"
|
||||
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/config"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/unifi"
|
||||
)
|
||||
|
||||
// FirewallPolicyReconciler reconciles a FirewallPolicy object
|
||||
type FirewallPolicyReconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
UnifiClient *unifi.UnifiClient
|
||||
ConfigLoader *config.ConfigLoaderType
|
||||
}
|
||||
|
||||
const firewallPolicyFinalizer = "finalizer.unifi.engen.priv.no/firewallpolicy"
|
||||
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallpolicies,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallpolicies/status,verbs=get;update;patch
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallpolicies/finalizers,verbs=update
|
||||
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=list;get;watch
|
||||
// +kubebuilder:rbac:groups="",resources=services,verbs=list;get;watch
|
||||
|
||||
// Reconcile is part of the main kubernetes reconciliation loop which aims to
|
||||
// move the current state of the cluster closer to the desired state.
|
||||
// TODO(user): Modify the Reconcile function to compare the state specified by
|
||||
// the FirewallPolicy object against the actual cluster state, and then
|
||||
// perform operations to make the cluster state reflect the state specified by
|
||||
// the user.
|
||||
//
|
||||
// For more details, check Reconcile and its Result here:
|
||||
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.2/pkg/reconcile
|
||||
|
||||
func fillDefaultPolicy() goUnifi.FirewallPolicy {
|
||||
var firewallPolicy goUnifi.FirewallPolicy
|
||||
firewallPolicy.Action = "ALLOW"
|
||||
firewallPolicy.CreateAllowRespond = true
|
||||
firewallPolicy.ConnectionStateType = "ALL"
|
||||
firewallPolicy.ConnectionStates = []string{}
|
||||
firewallPolicy.Destination = goUnifi.FirewallDestination{
|
||||
MatchOppositePorts: false,
|
||||
MatchingTarget: "IP",
|
||||
MatchingTargetType: "OBJECT",
|
||||
}
|
||||
firewallPolicy.Enabled = true
|
||||
firewallPolicy.ICMPTypename = "ANY"
|
||||
firewallPolicy.ICMPV6Typename = "ANY"
|
||||
firewallPolicy.MatchIPSec = false
|
||||
firewallPolicy.MatchOppositeProtocol = false
|
||||
firewallPolicy.Predefined = false
|
||||
firewallPolicy.Schedule = goUnifi.FirewallSchedule{
|
||||
Mode: "ALWAYS",
|
||||
RepeatOnDays: []string{},
|
||||
TimeAllDay: false,
|
||||
}
|
||||
firewallPolicy.Source = goUnifi.FirewallSource{
|
||||
MatchMac: false,
|
||||
MatchOppositePorts: false,
|
||||
MatchOppositeNetworks: false,
|
||||
}
|
||||
|
||||
return firewallPolicy
|
||||
}
|
||||
|
||||
func (r *FirewallPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := log.FromContext(ctx)
|
||||
|
||||
cfg, err := r.ConfigLoader.GetConfig(ctx, "unifi-operator-config")
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
defaultNs := cfg.Data["defaultNamespace"]
|
||||
kubernetesZone := cfg.Data["kubernetesUnifiZone"]
|
||||
var kubernetesZoneID string
|
||||
log.Info(defaultNs)
|
||||
log.Info(kubernetesZone)
|
||||
|
||||
var firewallPolicy unifiv1beta1.FirewallPolicy
|
||||
|
||||
if err := r.Get(ctx, req.NamespacedName, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, client.IgnoreNotFound(err)
|
||||
}
|
||||
log.Info(firewallPolicy.Spec.Name)
|
||||
|
||||
if firewallPolicy.DeletionTimestamp != nil {
|
||||
if controllerutil.ContainsFinalizer(&firewallPolicy, firewallPolicyFinalizer) {
|
||||
err := r.UnifiClient.Reauthenticate()
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
log.Info("Running finalizer logic for FirewallPolicy", "name", firewallPolicy.Name)
|
||||
|
||||
if firewallPolicy.Status.ResourcesManaged != nil {
|
||||
if len(firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies) > 0 {
|
||||
for i, UnifiFirewallPolicy := range firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies {
|
||||
log.Info(fmt.Sprintf("From: %s to: %s TcpIpv4: %s UdpIpv4: %s TcpIpv6: %s UdpIpv6: %s", UnifiFirewallPolicy.From, UnifiFirewallPolicy.To, UnifiFirewallPolicy.TcpIpv4ID, UnifiFirewallPolicy.UdpIpv4ID, UnifiFirewallPolicy.TcpIpv6ID, UnifiFirewallPolicy.UdpIpv6ID))
|
||||
if len(UnifiFirewallPolicy.TcpIpv4ID) > 0 {
|
||||
err := r.UnifiClient.Client.DeleteFirewallPolicy(context.Background(), r.UnifiClient.SiteID, UnifiFirewallPolicy.TcpIpv4ID)
|
||||
if err != nil && !strings.Contains(err.Error(), "not found") {
|
||||
} else {
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[i].TcpIpv4ID = ""
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(UnifiFirewallPolicy.UdpIpv4ID) > 0 {
|
||||
err := r.UnifiClient.Client.DeleteFirewallPolicy(context.Background(), r.UnifiClient.SiteID, UnifiFirewallPolicy.UdpIpv4ID)
|
||||
if err != nil && !strings.Contains(err.Error(), "not found") {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
} else {
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[i].UdpIpv4ID = ""
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(UnifiFirewallPolicy.TcpIpv6ID) > 0 {
|
||||
err := r.UnifiClient.Client.DeleteFirewallPolicy(context.Background(), r.UnifiClient.SiteID, UnifiFirewallPolicy.TcpIpv6ID)
|
||||
if err != nil && !strings.Contains(err.Error(), "not found") {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
} else {
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[i].TcpIpv6ID = ""
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(UnifiFirewallPolicy.UdpIpv6ID) > 0 {
|
||||
err := r.UnifiClient.Client.DeleteFirewallPolicy(context.Background(), r.UnifiClient.SiteID, UnifiFirewallPolicy.UdpIpv6ID)
|
||||
if err != nil && !strings.Contains(err.Error(), "not found") {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
} else {
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[i].UdpIpv6ID = ""
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(firewallPolicy.Status.ResourcesManaged.FirewallGroups) > 0 {
|
||||
for i, firewallGroup := range firewallPolicy.Status.ResourcesManaged.FirewallGroups {
|
||||
var firewallGroupCRD unifiv1beta1.FirewallGroup
|
||||
if firewallGroup.Name != "" {
|
||||
if err := r.Get(ctx, types.NamespacedName{Name: firewallGroup.Name, Namespace: firewallGroup.Namespace}, &firewallGroupCRD); err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
if err := r.Delete(ctx, &firewallGroupCRD); err != nil {
|
||||
log.Error(err, "Could not delete firewall group")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.FirewallGroups[i].Name = ""
|
||||
firewallPolicy.Status.ResourcesManaged.FirewallGroups[i].Namespace = ""
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
controllerutil.RemoveFinalizer(&firewallPolicy, firewallPolicyFinalizer)
|
||||
if err := r.Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
log.Info("Successfully finalized FirewallGroup")
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
if !controllerutil.ContainsFinalizer(&firewallPolicy, firewallPolicyFinalizer) {
|
||||
controllerutil.AddFinalizer(&firewallPolicy, firewallPolicyFinalizer)
|
||||
if err := r.Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
// Create an index of already managed firewall policy entries, with source and destination as the key and placement in status field array as value. If no managed firewall policy
|
||||
// entries, this is a new policy and we will create an empty index and set empty lists in the status field of the firewallPolicy resource.
|
||||
|
||||
firewallpolicyindex := make(map[string]int)
|
||||
|
||||
nextFirewallPolicyIndex := 0
|
||||
if firewallPolicy.Status.ResourcesManaged == nil {
|
||||
firewallGroupsManaged := []unifiv1beta1.FirewallGroupEntry{}
|
||||
unifiFirewallPolicies := []unifiv1beta1.UnifiFirewallPolicyEntry{}
|
||||
firewallPolicy.Status.ResourcesManaged = &unifiv1beta1.FirewallPolicyResourcesManaged{
|
||||
UnifiFirewallPolicies: unifiFirewallPolicies,
|
||||
FirewallGroups: firewallGroupsManaged,
|
||||
}
|
||||
} else {
|
||||
for index, firewallPolicyEntry := range firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies {
|
||||
firewallpolicyindex[firewallPolicyEntry.From+"/"+firewallPolicyEntry.To] = index
|
||||
nextFirewallPolicyIndex = nextFirewallPolicyIndex + 1
|
||||
}
|
||||
}
|
||||
|
||||
err = r.UnifiClient.Reauthenticate()
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
var zoneCRDs unifiv1beta1.FirewallZoneList
|
||||
var networkCRDs unifiv1beta1.NetworkconfigurationList
|
||||
|
||||
err = r.List(ctx, &zoneCRDs)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not list firewall zones")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
|
||||
// Create an index of zones, with namespace/name as key and placement in zoneCRDs as value. This enables getting the zone properties from specified namespace/name in
|
||||
// the policy entries. If Namespace is not specified, default will be taken from the configmap.
|
||||
|
||||
zoneCRDNames := make(map[string]int)
|
||||
|
||||
for i, zoneCRD := range zoneCRDs.Items {
|
||||
namespace := defaultNs
|
||||
if len(zoneCRD.Namespace) > 0 {
|
||||
namespace = zoneCRD.Namespace
|
||||
}
|
||||
if kubernetesZone == zoneCRD.Name {
|
||||
kubernetesZoneID = zoneCRD.Spec.ID
|
||||
log.Info(fmt.Sprintf("Zone for kubernetes resources: %s with ID %s", kubernetesZone, kubernetesZoneID))
|
||||
}
|
||||
zoneCRDNames[namespace+"/"+zoneCRD.Name] = i
|
||||
}
|
||||
|
||||
err = r.List(ctx, &networkCRDs)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not list networks")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
|
||||
// Create an index of networks, with namespace/name as key and placement in networkCRDs as value. This enables getting the network properties from specified namespace/name in
|
||||
// the policy entries.
|
||||
|
||||
networkCRDNames := make(map[string]int)
|
||||
|
||||
for i, networkCRD := range networkCRDs.Items {
|
||||
namespace := defaultNs
|
||||
if len(networkCRD.Namespace) > 0 {
|
||||
namespace = networkCRD.Namespace
|
||||
}
|
||||
networkCRDNames[namespace+"/"+networkCRD.Name] = i
|
||||
}
|
||||
|
||||
destination_services := make(map[string]struct{})
|
||||
destination_groups := make(map[string]struct{})
|
||||
|
||||
// Run through the list of specified firewall groups destinations and service desitnations and create an index with namespace/name as key.
|
||||
// This will be used when running through all firewall groups and servics known, to see if a rule should be added.
|
||||
|
||||
for _, dest_group := range firewallPolicy.Spec.Destination.FirewallGroups {
|
||||
namespace := firewallPolicy.Namespace
|
||||
if len(dest_group.Namespace) > 0 {
|
||||
namespace = dest_group.Namespace
|
||||
}
|
||||
destination_groups[namespace+"/"+dest_group.Name] = struct{}{}
|
||||
}
|
||||
for _, dest_service := range firewallPolicy.Spec.Destination.Services {
|
||||
namespace := firewallPolicy.Namespace
|
||||
if len(dest_service.Namespace) > 0 {
|
||||
namespace = dest_service.Namespace
|
||||
}
|
||||
destination_services[namespace+"/"+dest_service.Name] = struct{}{}
|
||||
}
|
||||
|
||||
var firewallGroupCRDs unifiv1beta1.FirewallGroupList
|
||||
var myFirewallGroups []unifiv1beta1.FirewallGroup
|
||||
|
||||
if err = r.List(ctx, &firewallGroupCRDs); err != nil {
|
||||
log.Error(err, "Failed to list firewall groups")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
|
||||
// Run through all firewall groups. Add them to the myFirewallGroups list if they either have an annotations or is specified in the resource.
|
||||
|
||||
for _, firewallGroup := range firewallGroupCRDs.Items {
|
||||
if val, found := firewallGroup.Annotations["unifi.engen.priv.no/firewall-policy"]; found && ((strings.Contains(val, "/") && val == firewallPolicy.Namespace+"/"+firewallPolicy.Name) || (val == firewallPolicy.Name && firewallPolicy.Namespace == firewallGroup.Namespace)) {
|
||||
myFirewallGroups = append(myFirewallGroups, firewallGroup)
|
||||
} else if _, found := destination_groups[firewallGroup.Namespace+"/"+firewallGroup.Name]; found {
|
||||
myFirewallGroups = append(myFirewallGroups, firewallGroup)
|
||||
}
|
||||
}
|
||||
|
||||
// Create an index with namespace/name as value,
|
||||
|
||||
myFirewallGroupNames := make(map[string]struct{})
|
||||
for _, firewallGroup := range myFirewallGroups {
|
||||
myFirewallGroupNames[firewallGroup.Namespace+"/"+firewallGroup.Name] = struct{}{}
|
||||
}
|
||||
|
||||
var serviceCRDs corev1.ServiceList
|
||||
var myServices []corev1.Service
|
||||
if err = r.List(ctx, &serviceCRDs); err != nil {
|
||||
log.Error(err, "Failed to list services")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
|
||||
// Run through all services. Check if they are part of the manually specified services or have an annotation, and add it to the myServices list if found
|
||||
for _, service := range serviceCRDs.Items {
|
||||
skipService := false
|
||||
if val, found := service.Annotations["unifi.engen.priv.no/firewall-group"]; found {
|
||||
if _, found := myFirewallGroupNames[val]; found {
|
||||
|
||||
skipService = true
|
||||
}
|
||||
}
|
||||
if val, found := service.Annotations["unifi.engen.priv.no/firewall-policy"]; found && ((strings.Contains(val, "/") && val == firewallPolicy.Namespace+"/"+firewallPolicy.Name) || (val == firewallPolicy.Name && firewallPolicy.Namespace == service.Namespace)) && !skipService {
|
||||
myServices = append(myServices, service)
|
||||
} else if _, found := destination_services[service.Namespace+"/"+service.Name]; found && !skipService {
|
||||
myServices = append(myServices, service)
|
||||
}
|
||||
}
|
||||
|
||||
// Run through all services we should manage. Create a firewallgroup object for it, if it's not already created.
|
||||
// Add it to the list of managed unifiresources if it's created. Make sure to not add it twice.
|
||||
|
||||
for _, service := range myServices {
|
||||
log.Info(fmt.Sprintf("Should handle service %s", service.Name))
|
||||
var firewallGroupCRD unifiv1beta1.FirewallGroup
|
||||
|
||||
// Check if firewallgroup already exists. Add it to myFirewallGroups if it exists, create it if not.
|
||||
|
||||
if err := r.Get(ctx, types.NamespacedName{
|
||||
Name: toKubeName("k8s-auto" + "_" + service.Namespace + "/" + service.Name),
|
||||
Namespace: firewallPolicy.Namespace,
|
||||
}, &firewallGroupCRD); err == nil {
|
||||
myFirewallGroups = append(myFirewallGroups, firewallGroupCRD)
|
||||
} else {
|
||||
log.Info("Going to create firewall group")
|
||||
var manualServices []unifiv1beta1.ServiceEntry
|
||||
manualServices = append(manualServices, unifiv1beta1.ServiceEntry{
|
||||
Name: service.Name,
|
||||
Namespace: service.Namespace,
|
||||
})
|
||||
createdFirewallGroupCRD := &unifiv1beta1.FirewallGroup{
|
||||
ObjectMeta: ctrl.ObjectMeta{
|
||||
Name: toKubeName("k8s-auto" + "_" + service.Namespace + "/" + service.Name),
|
||||
Namespace: firewallPolicy.Namespace,
|
||||
},
|
||||
Spec: unifiv1beta1.FirewallGroupSpec{
|
||||
Name: "auto-" + service.Namespace + "/" + service.Name,
|
||||
AutoCreatedFrom: unifiv1beta1.FirewallPolicyEntry{
|
||||
Name: firewallPolicy.Name,
|
||||
Namespace: firewallPolicy.Namespace,
|
||||
},
|
||||
ManualServices: manualServices,
|
||||
MatchServicesInAllNamespaces: true,
|
||||
},
|
||||
}
|
||||
if err := r.Create(ctx, createdFirewallGroupCRD); err != nil {
|
||||
log.Error(err, fmt.Sprintf("Failed to create %s", createdFirewallGroupCRD.Name))
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
} else {
|
||||
// Give it time to be fully created. It doesn't need to be handled and expanded at this point, but it should be before using it later.
|
||||
time.Sleep(10 * time.Second)
|
||||
_ = r.Get(ctx, types.NamespacedName{Name: createdFirewallGroupCRD.Name, Namespace: createdFirewallGroupCRD.Namespace}, &firewallGroupCRD)
|
||||
}
|
||||
log.Info(fmt.Sprintf("Adding %+v", firewallGroupCRD))
|
||||
myFirewallGroups = append(myFirewallGroups, firewallGroupCRD)
|
||||
|
||||
// Run through list of already managed Unifi firewallgroups to check if it's already on the list, to avoid having it in list twice.
|
||||
|
||||
found := false
|
||||
for _, managedFirewallGroup := range firewallPolicy.Status.ResourcesManaged.FirewallGroups {
|
||||
if managedFirewallGroup.Name == firewallGroupCRD.Name && managedFirewallGroup.Namespace == firewallGroupCRD.Namespace {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
||||
// Add it to resource status field.
|
||||
if !found {
|
||||
firewallPolicy.Status.ResourcesManaged.FirewallGroups = append(firewallPolicy.Status.ResourcesManaged.FirewallGroups, unifiv1beta1.FirewallGroupEntry{Name: firewallGroupCRD.Name, Namespace: firewallGroupCRD.Namespace})
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
log.Error(err, "Failed to update status with added firewallgroup")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Finished listing destinations. Starting to handle source specifications.
|
||||
// Source can be either zones or networks managed by/known to the operator. Specified by namespace and name. Use default from configmap if namespace is not specified.
|
||||
|
||||
unifi_firewall_policies, err := r.UnifiClient.Client.ListFirewallPolicy(context.Background(), r.UnifiClient.SiteID)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not list firewall policies")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
// Create an index of Unifi firewall policy names.
|
||||
unifiFirewallpolicyNames := make(map[string]struct{})
|
||||
for _, unifi_firewall_policy := range unifi_firewall_policies {
|
||||
unifiFirewallpolicyNames[unifi_firewall_policy.Name] = struct{}{}
|
||||
}
|
||||
log.Info(fmt.Sprintf("Number of firewall policies: %d", len(unifi_firewall_policies)))
|
||||
|
||||
// Run through specified source zones and check if we should handle them.
|
||||
for _, zoneEntry := range firewallPolicy.Spec.Source.FirewallZones {
|
||||
namespace := defaultNs
|
||||
if len(zoneEntry.Namespace) > 0 {
|
||||
namespace = zoneEntry.Namespace
|
||||
}
|
||||
|
||||
if zoneIndex, found := zoneCRDNames[namespace+"/"+zoneEntry.Name]; found {
|
||||
// Should handle, so we create firewall policies.
|
||||
|
||||
log.Info(fmt.Sprintf("Creating firewallpolicies for %s", zoneCRDs.Items[zoneIndex].Name))
|
||||
|
||||
// Run through destination firewall groups and enumerate and create polices if they don't already exist.
|
||||
|
||||
for _, firewallGroup := range myFirewallGroups {
|
||||
found := false
|
||||
|
||||
index, found := firewallpolicyindex["zone:"+zoneCRDs.Items[zoneIndex].Name+"/"+firewallGroup.Name]
|
||||
|
||||
// Not found? We add an empty entry in status field.
|
||||
if !found {
|
||||
firewallPolicyEntry := unifiv1beta1.UnifiFirewallPolicyEntry{
|
||||
From: "zone:" + zoneCRDs.Items[zoneIndex].Name,
|
||||
To: firewallGroup.Name,
|
||||
TcpIpv4ID: "",
|
||||
UdpIpv4ID: "",
|
||||
TcpIpv6ID: "",
|
||||
UdpIpv6ID: "",
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies = append(firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies, firewallPolicyEntry)
|
||||
index = nextFirewallPolicyIndex
|
||||
nextFirewallPolicyIndex = nextFirewallPolicyIndex + 1
|
||||
}
|
||||
|
||||
// Create policies for all permutations of Ipversion and protocol.
|
||||
|
||||
if len(firewallGroup.Status.ResolvedIPV4Addresses) > 0 {
|
||||
if len(firewallGroup.Status.ResolvedTCPPorts) > 0 {
|
||||
policyname := "k8s-fw-" + firewallPolicy.Namespace + "/" + firewallPolicy.Name + "-" + "zone:" + zoneCRDs.Items[zoneIndex].Name + "-" + firewallGroup.Name + "-ipv4-tcp"
|
||||
if _, found := unifiFirewallpolicyNames[policyname]; !found {
|
||||
log.Info(fmt.Sprintf("Creating ipv4 tcp firewallpolicy for %s to %s: %s", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name, policyname))
|
||||
unifiFirewallPolicy := fillDefaultPolicy()
|
||||
unifiFirewallPolicy.Name = policyname
|
||||
unifiFirewallPolicy.Source.PortMatchingType = "ANY"
|
||||
unifiFirewallPolicy.Source.ZoneID = zoneCRDs.Items[zoneIndex].Spec.ID
|
||||
unifiFirewallPolicy.Source.MatchingTarget = "ANY"
|
||||
unifiFirewallPolicy.Protocol = "tcp"
|
||||
unifiFirewallPolicy.IPVersion = "IPV4"
|
||||
unifiFirewallPolicy.Description = fmt.Sprintf("Allow tcp IPV4 from %s to %s", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name)
|
||||
unifiFirewallPolicy.Destination.MatchingTargetType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.IPGroupID = firewallGroup.Status.ResourcesManaged.IPV4Object.ID
|
||||
unifiFirewallPolicy.Destination.MatchingTarget = "IP"
|
||||
unifiFirewallPolicy.Destination.PortMatchingType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.PortGroupID = firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID
|
||||
unifiFirewallPolicy.Destination.ZoneID = kubernetesZoneID
|
||||
|
||||
log.Info(fmt.Sprintf("Trying to create firewall policy from zone %s to %s: %+v", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name, unifiFirewallPolicy))
|
||||
pretty, _ := json.MarshalIndent(unifiFirewallPolicy, "", " ")
|
||||
log.Info(string(pretty))
|
||||
updatedPolicy, err := r.UnifiClient.Client.CreateFirewallPolicy(context.Background(), r.UnifiClient.SiteID, &unifiFirewallPolicy)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall policy")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[index].TcpIpv4ID = updatedPolicy.ID
|
||||
if err = r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("Firewall policy for ipv4 tcp %s to %s already exists", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name))
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResolvedUDPPorts) > 0 {
|
||||
policyname := "k8s-fw-" + firewallPolicy.Namespace + "/" + firewallPolicy.Name + "-" + "zone:" + zoneCRDs.Items[zoneIndex].Name + "-" + firewallGroup.Name + "-ipv4-udp"
|
||||
if _, found := unifiFirewallpolicyNames[policyname]; !found {
|
||||
log.Info(fmt.Sprintf("Creating ipv4 udp firewallpolicy for %s to %s: %s", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name, policyname))
|
||||
unifiFirewallPolicy := fillDefaultPolicy()
|
||||
unifiFirewallPolicy.Name = policyname
|
||||
unifiFirewallPolicy.Source.PortMatchingType = "ANY"
|
||||
unifiFirewallPolicy.Source.ZoneID = zoneCRDs.Items[zoneIndex].Spec.ID
|
||||
unifiFirewallPolicy.Source.MatchingTarget = "ANY"
|
||||
unifiFirewallPolicy.Protocol = "udp"
|
||||
unifiFirewallPolicy.IPVersion = "IPV4"
|
||||
unifiFirewallPolicy.Description = fmt.Sprintf("Allow udp IPV4 from %s to %s", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name)
|
||||
unifiFirewallPolicy.Destination.MatchingTargetType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.IPGroupID = firewallGroup.Status.ResourcesManaged.IPV4Object.ID
|
||||
unifiFirewallPolicy.Destination.MatchingTarget = "IP"
|
||||
unifiFirewallPolicy.Destination.PortMatchingType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.PortGroupID = firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID
|
||||
unifiFirewallPolicy.Destination.ZoneID = kubernetesZoneID
|
||||
|
||||
log.Info(fmt.Sprintf("Trying to create firewall policy from zone %s to %s: %+v", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name, unifiFirewallPolicy))
|
||||
pretty, _ := json.MarshalIndent(unifiFirewallPolicy, "", " ")
|
||||
log.Info(string(pretty))
|
||||
updatedPolicy, err := r.UnifiClient.Client.CreateFirewallPolicy(context.Background(), r.UnifiClient.SiteID, &unifiFirewallPolicy)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall policy")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[index].UdpIpv4ID = updatedPolicy.ID
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("Firewall policy for ipv4 udp %s to %s already exists", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name))
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResolvedIPV6Addresses) > 0 {
|
||||
if len(firewallGroup.Status.ResolvedTCPPorts) > 0 {
|
||||
policyname := "k8s-fw-" + firewallPolicy.Namespace + "/" + firewallPolicy.Name + "-" + "zone:" + zoneCRDs.Items[zoneIndex].Name + "-" + firewallGroup.Name + "-ipv6-tcp"
|
||||
if _, found := unifiFirewallpolicyNames[policyname]; !found {
|
||||
log.Info(fmt.Sprintf("Creating ipv6 tcp firewallpolicy for %s to %s: %s", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name, policyname))
|
||||
unifiFirewallPolicy := fillDefaultPolicy()
|
||||
unifiFirewallPolicy.Name = policyname
|
||||
unifiFirewallPolicy.Source.PortMatchingType = "ANY"
|
||||
unifiFirewallPolicy.Source.ZoneID = zoneCRDs.Items[zoneIndex].Spec.ID
|
||||
unifiFirewallPolicy.Source.MatchingTarget = "ANY"
|
||||
unifiFirewallPolicy.Protocol = "tcp"
|
||||
unifiFirewallPolicy.IPVersion = "IPV6"
|
||||
unifiFirewallPolicy.Description = fmt.Sprintf("Allow tcp IPV6 from %s to %s", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name)
|
||||
unifiFirewallPolicy.Destination.MatchingTargetType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.IPGroupID = firewallGroup.Status.ResourcesManaged.IPV6Object.ID
|
||||
unifiFirewallPolicy.Destination.MatchingTarget = "IP"
|
||||
unifiFirewallPolicy.Destination.PortMatchingType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.PortGroupID = firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID
|
||||
unifiFirewallPolicy.Destination.ZoneID = kubernetesZoneID
|
||||
|
||||
log.Info(fmt.Sprintf("Trying to create firewall policy from zone %s to %s: %+v", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name, unifiFirewallPolicy))
|
||||
pretty, _ := json.MarshalIndent(unifiFirewallPolicy, "", " ")
|
||||
log.Info(string(pretty))
|
||||
updatedPolicy, err := r.UnifiClient.Client.CreateFirewallPolicy(context.Background(), r.UnifiClient.SiteID, &unifiFirewallPolicy)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall policy")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[index].TcpIpv6ID = updatedPolicy.ID
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("Firewall policy for ipv6 tcp %s to %s already exists", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name))
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResolvedUDPPorts) > 0 {
|
||||
policyname := "k8s-fw-" + firewallPolicy.Namespace + "/" + firewallPolicy.Name + "-" + "zone:" + zoneCRDs.Items[zoneIndex].Name + "-" + firewallGroup.Name + "-ipv6-udp"
|
||||
if _, found := unifiFirewallpolicyNames[policyname]; !found {
|
||||
log.Info(fmt.Sprintf("Creating ipv6 udp firewallpolicy for %s to %s: %s", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name, policyname))
|
||||
unifiFirewallPolicy := fillDefaultPolicy()
|
||||
unifiFirewallPolicy.Name = policyname
|
||||
unifiFirewallPolicy.Source.PortMatchingType = "ANY"
|
||||
unifiFirewallPolicy.Source.ZoneID = zoneCRDs.Items[zoneIndex].Spec.ID
|
||||
unifiFirewallPolicy.Source.MatchingTarget = "ANY"
|
||||
unifiFirewallPolicy.Protocol = "udp"
|
||||
unifiFirewallPolicy.IPVersion = "IPV6"
|
||||
unifiFirewallPolicy.Description = fmt.Sprintf("Allow udp IPV6 from %s to %s", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name)
|
||||
unifiFirewallPolicy.Destination.MatchingTargetType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.IPGroupID = firewallGroup.Status.ResourcesManaged.IPV6Object.ID
|
||||
unifiFirewallPolicy.Destination.MatchingTarget = "IP"
|
||||
unifiFirewallPolicy.Destination.PortMatchingType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.PortGroupID = firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID
|
||||
unifiFirewallPolicy.Destination.ZoneID = kubernetesZoneID
|
||||
|
||||
log.Info(fmt.Sprintf("Trying to create firewall policy from zone %s to %s: %+v", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name, unifiFirewallPolicy))
|
||||
pretty, _ := json.MarshalIndent(unifiFirewallPolicy, "", " ")
|
||||
log.Info(string(pretty))
|
||||
updatedPolicy, err := r.UnifiClient.Client.CreateFirewallPolicy(context.Background(), r.UnifiClient.SiteID, &unifiFirewallPolicy)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall policy")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[index].UdpIpv6ID = updatedPolicy.ID
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("Firewall policy for ipv6 udp %s to %s already exists", zoneCRDs.Items[zoneIndex].Name, firewallGroup.Name))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, networkEntry := range firewallPolicy.Spec.Source.Networks {
|
||||
namespace := defaultNs
|
||||
if len(networkEntry.Namespace) > 0 {
|
||||
namespace = networkEntry.Namespace
|
||||
}
|
||||
if networkIndex, found := networkCRDNames[namespace+"/"+networkEntry.Name]; found {
|
||||
log.Info(fmt.Sprintf("Creating firewallpolicies for %s", networkCRDs.Items[networkIndex].Name))
|
||||
for _, firewallGroup := range myFirewallGroups {
|
||||
index, found := firewallpolicyindex["network:"+networkCRDs.Items[networkIndex].Name+"/"+firewallGroup.Name]
|
||||
if !found {
|
||||
firewallPolicyEntry := unifiv1beta1.UnifiFirewallPolicyEntry{
|
||||
From: "zone:" + networkCRDs.Items[networkIndex].Name,
|
||||
To: firewallGroup.Name,
|
||||
TcpIpv4ID: "",
|
||||
UdpIpv4ID: "",
|
||||
TcpIpv6ID: "",
|
||||
UdpIpv6ID: "",
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies = append(firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies, firewallPolicyEntry)
|
||||
index = nextFirewallPolicyIndex
|
||||
nextFirewallPolicyIndex = nextFirewallPolicyIndex + 1
|
||||
}
|
||||
if len(firewallGroup.Status.ResolvedIPV4Addresses) > 0 {
|
||||
if len(firewallGroup.Status.ResolvedTCPPorts) > 0 {
|
||||
policyname := "k8s-fw-" + firewallPolicy.Namespace + "/" + firewallPolicy.Name + "-" + "network:" + networkCRDs.Items[networkIndex].Name + "-" + firewallGroup.Name + "-ipv4-tcp"
|
||||
if _, found := unifiFirewallpolicyNames[policyname]; !found {
|
||||
log.Info(fmt.Sprintf("Creating ipv4 tcp firewallpolicy for %s to %s: %s", networkCRDs.Items[networkIndex].Name, firewallGroup.Name, policyname))
|
||||
unifiFirewallPolicy := fillDefaultPolicy()
|
||||
unifiFirewallPolicy.Name = policyname
|
||||
unifiFirewallPolicy.Source.NetworkIDs = []string{networkCRDs.Items[networkIndex].Spec.ID}
|
||||
unifiFirewallPolicy.Source.PortMatchingType = "ANY"
|
||||
unifiFirewallPolicy.Source.ZoneID = networkCRDs.Items[networkIndex].Status.FirewallZoneID
|
||||
unifiFirewallPolicy.Source.MatchingTarget = "NETWORK"
|
||||
unifiFirewallPolicy.Protocol = "tcp"
|
||||
unifiFirewallPolicy.IPVersion = "IPV4"
|
||||
unifiFirewallPolicy.Description = fmt.Sprintf("Allow tcp IPV4 from %s to %s", networkCRDs.Items[networkIndex].Name, firewallGroup.Name)
|
||||
unifiFirewallPolicy.Destination.MatchingTargetType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.IPGroupID = firewallGroup.Status.ResourcesManaged.IPV4Object.ID
|
||||
unifiFirewallPolicy.Destination.MatchingTarget = "IP"
|
||||
unifiFirewallPolicy.Destination.PortMatchingType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.PortGroupID = firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID
|
||||
unifiFirewallPolicy.Destination.ZoneID = kubernetesZoneID
|
||||
|
||||
log.Info(fmt.Sprintf("Trying to create firewall policy from network %s to %s: %+v", networkCRDs.Items[networkIndex].Name, firewallGroup.Name, unifiFirewallPolicy))
|
||||
pretty, _ := json.MarshalIndent(unifiFirewallPolicy, "", " ")
|
||||
log.Info(string(pretty))
|
||||
updatedPolicy, err := r.UnifiClient.Client.CreateFirewallPolicy(context.Background(), r.UnifiClient.SiteID, &unifiFirewallPolicy)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall policy")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[index].TcpIpv4ID = updatedPolicy.ID
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("Firewall policy for ipv4 tcp %s to %s already exists", networkCRDs.Items[networkIndex].Name, firewallGroup.Name))
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResolvedUDPPorts) > 0 {
|
||||
policyname := "k8s-fw-" + firewallPolicy.Namespace + "/" + firewallPolicy.Name + "-" + "network:" + networkCRDs.Items[networkIndex].Name + "-" + firewallGroup.Name + "-ipv4-udp"
|
||||
if _, found := unifiFirewallpolicyNames[policyname]; !found {
|
||||
log.Info(fmt.Sprintf("Creating ipv4 udp firewallpolicy for %s to %s: %s", networkCRDs.Items[networkIndex].Name, firewallGroup.Name, policyname))
|
||||
unifiFirewallPolicy := fillDefaultPolicy()
|
||||
unifiFirewallPolicy.Name = policyname
|
||||
unifiFirewallPolicy.Source.NetworkIDs = []string{networkCRDs.Items[networkIndex].Spec.ID}
|
||||
unifiFirewallPolicy.Source.PortMatchingType = "ANY"
|
||||
unifiFirewallPolicy.Source.ZoneID = networkCRDs.Items[networkIndex].Status.FirewallZoneID
|
||||
unifiFirewallPolicy.Source.MatchingTarget = "NETWORK"
|
||||
unifiFirewallPolicy.Protocol = "udp"
|
||||
unifiFirewallPolicy.IPVersion = "IPV4"
|
||||
unifiFirewallPolicy.Description = fmt.Sprintf("Allow udp IPV4 from %s to %s", networkCRDs.Items[networkIndex].Name, firewallGroup.Name)
|
||||
unifiFirewallPolicy.Destination.MatchingTargetType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.IPGroupID = firewallGroup.Status.ResourcesManaged.IPV4Object.ID
|
||||
unifiFirewallPolicy.Destination.MatchingTarget = "IP"
|
||||
unifiFirewallPolicy.Destination.PortMatchingType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.PortGroupID = firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID
|
||||
unifiFirewallPolicy.Destination.ZoneID = kubernetesZoneID
|
||||
|
||||
log.Info(fmt.Sprintf("Trying to create firewall policy from network %s to %s: %+v", networkCRDs.Items[networkIndex].Name, firewallGroup.Name, unifiFirewallPolicy))
|
||||
pretty, _ := json.MarshalIndent(unifiFirewallPolicy, "", " ")
|
||||
log.Info(string(pretty))
|
||||
updatedPolicy, err := r.UnifiClient.Client.CreateFirewallPolicy(context.Background(), r.UnifiClient.SiteID, &unifiFirewallPolicy)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall policy")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[index].UdpIpv4ID = updatedPolicy.ID
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("Firewall policy for ipv4 udp %s to %s already exists", networkCRDs.Items[networkIndex].Name, firewallGroup.Name))
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResolvedIPV6Addresses) > 0 {
|
||||
if len(firewallGroup.Status.ResolvedTCPPorts) > 0 {
|
||||
policyname := "k8s-fw-" + firewallPolicy.Namespace + "/" + firewallPolicy.Name + "-" + "network:" + networkCRDs.Items[networkIndex].Name + "-" + firewallGroup.Name + "-ipv6-tcp"
|
||||
if _, found := unifiFirewallpolicyNames[policyname]; !found {
|
||||
log.Info(fmt.Sprintf("Creating ipv6 tcp firewallpolicy for %s to %s: %s", networkCRDs.Items[networkIndex].Name, firewallGroup.Name, policyname))
|
||||
unifiFirewallPolicy := fillDefaultPolicy()
|
||||
unifiFirewallPolicy.Name = policyname
|
||||
unifiFirewallPolicy.Source.NetworkIDs = []string{networkCRDs.Items[networkIndex].Spec.ID}
|
||||
unifiFirewallPolicy.Source.PortMatchingType = "ANY"
|
||||
unifiFirewallPolicy.Source.ZoneID = networkCRDs.Items[networkIndex].Status.FirewallZoneID
|
||||
unifiFirewallPolicy.Source.MatchingTarget = "NETWORK"
|
||||
unifiFirewallPolicy.Protocol = "tcp"
|
||||
unifiFirewallPolicy.IPVersion = "IPV6"
|
||||
unifiFirewallPolicy.Description = fmt.Sprintf("Allow tcp IPV6 from %s to %s", networkCRDs.Items[networkIndex].Name, firewallGroup.Name)
|
||||
unifiFirewallPolicy.Destination.MatchingTargetType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.IPGroupID = firewallGroup.Status.ResourcesManaged.IPV6Object.ID
|
||||
unifiFirewallPolicy.Destination.MatchingTarget = "IP"
|
||||
unifiFirewallPolicy.Destination.PortMatchingType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.PortGroupID = firewallGroup.Status.ResourcesManaged.TCPPortsObject.ID
|
||||
unifiFirewallPolicy.Destination.ZoneID = kubernetesZoneID
|
||||
|
||||
log.Info(fmt.Sprintf("Trying to create firewall policy from network %s to %s: %+v", networkCRDs.Items[networkIndex].Name, firewallGroup.Name, unifiFirewallPolicy))
|
||||
pretty, _ := json.MarshalIndent(unifiFirewallPolicy, "", " ")
|
||||
log.Info(string(pretty))
|
||||
updatedPolicy, err := r.UnifiClient.Client.CreateFirewallPolicy(context.Background(), r.UnifiClient.SiteID, &unifiFirewallPolicy)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall policy")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[index].TcpIpv6ID = updatedPolicy.ID
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("Firewall policy for ipv6 tcp %s to %s already exists", networkCRDs.Items[networkIndex].Name, firewallGroup.Name))
|
||||
}
|
||||
}
|
||||
if len(firewallGroup.Status.ResolvedUDPPorts) > 0 {
|
||||
policyname := "k8s-fw-" + firewallPolicy.Namespace + "/" + firewallPolicy.Name + "-" + "network:" + networkCRDs.Items[networkIndex].Name + "-" + firewallGroup.Name + "-ipv6-udp"
|
||||
if _, found := unifiFirewallpolicyNames[policyname]; !found {
|
||||
log.Info(fmt.Sprintf("Creating ipv6 udp firewallpolicy for %s to %s: %s", networkCRDs.Items[networkIndex].Name, firewallGroup.Name, policyname))
|
||||
unifiFirewallPolicy := fillDefaultPolicy()
|
||||
unifiFirewallPolicy.Name = policyname
|
||||
unifiFirewallPolicy.Source.NetworkIDs = []string{networkCRDs.Items[networkIndex].Spec.ID}
|
||||
unifiFirewallPolicy.Source.PortMatchingType = "ANY"
|
||||
unifiFirewallPolicy.Source.ZoneID = networkCRDs.Items[networkIndex].Status.FirewallZoneID
|
||||
unifiFirewallPolicy.Source.MatchingTarget = "NETWORK"
|
||||
unifiFirewallPolicy.Protocol = "udp"
|
||||
unifiFirewallPolicy.IPVersion = "IPV6"
|
||||
unifiFirewallPolicy.Description = fmt.Sprintf("Allow udp IPV6 from %s to %s", networkCRDs.Items[networkIndex].Name, firewallGroup.Name)
|
||||
unifiFirewallPolicy.Destination.MatchingTargetType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.IPGroupID = firewallGroup.Status.ResourcesManaged.IPV6Object.ID
|
||||
unifiFirewallPolicy.Destination.MatchingTarget = "IP"
|
||||
unifiFirewallPolicy.Destination.PortMatchingType = "OBJECT"
|
||||
unifiFirewallPolicy.Destination.PortGroupID = firewallGroup.Status.ResourcesManaged.UDPPortsObject.ID
|
||||
unifiFirewallPolicy.Destination.ZoneID = kubernetesZoneID
|
||||
|
||||
log.Info(fmt.Sprintf("Trying to create firewall policy from network %s to %s: %+v", networkCRDs.Items[networkIndex].Name, firewallGroup.Name, unifiFirewallPolicy))
|
||||
pretty, _ := json.MarshalIndent(unifiFirewallPolicy, "", " ")
|
||||
log.Info(string(pretty))
|
||||
updatedPolicy, err := r.UnifiClient.Client.CreateFirewallPolicy(context.Background(), r.UnifiClient.SiteID, &unifiFirewallPolicy)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not create firewall policy")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
firewallPolicy.Status.ResourcesManaged.UnifiFirewallPolicies[index].UdpIpv6ID = updatedPolicy.ID
|
||||
if err := r.Status().Update(ctx, &firewallPolicy); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("Firewall policy for ipv6 udp %s to %s already exists", networkCRDs.Items[networkIndex].Name, firewallGroup.Name))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
func (r *FirewallPolicyReconciler) mapFirewallGroupToFirewallPolicies(ctx context.Context, obj client.Object) []ctrl.Request {
|
||||
var requests []ctrl.Request
|
||||
firewallGroup, ok := obj.(*unifiv1beta1.FirewallGroup)
|
||||
if !ok {
|
||||
return requests
|
||||
}
|
||||
|
||||
cfg, err := r.ConfigLoader.GetConfig(ctx, "unifi-operator-config")
|
||||
if err != nil {
|
||||
return requests
|
||||
}
|
||||
|
||||
defaultNs := cfg.Data["defaultNamespace"]
|
||||
|
||||
var allFirewallPolicies unifiv1beta1.FirewallPolicyList
|
||||
|
||||
if err := r.List(ctx, &allFirewallPolicies); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, policy := range allFirewallPolicies.Items {
|
||||
if policy.Spec.MatchFirewallGroupsInAllNamespaces || policy.Namespace == firewallGroup.Namespace {
|
||||
if val, found := firewallGroup.Annotations["unifi.engen.priv.no/firewall-policy"]; found && ((strings.Contains(val, "/") && val == policy.Namespace+"/"+policy.Name) || (val == policy.Name && policy.Namespace == defaultNs)) {
|
||||
requests = append(requests, ctrl.Request{
|
||||
NamespacedName: types.NamespacedName{
|
||||
Name: policy.Name,
|
||||
Namespace: policy.Namespace,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requests
|
||||
}
|
||||
|
||||
func (r *FirewallPolicyReconciler) mapServiceToFirewallPolicies(ctx context.Context, obj client.Object) []ctrl.Request {
|
||||
var requests []ctrl.Request
|
||||
service, ok := obj.(*corev1.Service)
|
||||
if !ok {
|
||||
return requests
|
||||
}
|
||||
|
||||
cfg, err := r.ConfigLoader.GetConfig(ctx, "unifi-operator-config")
|
||||
if err != nil {
|
||||
return requests
|
||||
}
|
||||
|
||||
defaultNs := cfg.Data["defaultNamespace"]
|
||||
|
||||
var allFirewallPolicies unifiv1beta1.FirewallPolicyList
|
||||
|
||||
if err := r.List(ctx, &allFirewallPolicies); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, policy := range allFirewallPolicies.Items {
|
||||
if policy.Spec.MatchServicesInAllNamespaces || policy.Namespace == service.Namespace {
|
||||
if val, found := service.Annotations["unifi.engen.priv.no/firewall-policy"]; found && ((strings.Contains(val, "/") && val == policy.Namespace+"/"+policy.Name) || (val == policy.Name && policy.Namespace == defaultNs)) {
|
||||
requests = append(requests, ctrl.Request{
|
||||
NamespacedName: types.NamespacedName{
|
||||
Name: policy.Name,
|
||||
Namespace: policy.Namespace,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requests
|
||||
}
|
||||
|
||||
// SetupWithManager sets up the controller with the Manager.
|
||||
func (r *FirewallPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
For(&unifiv1beta1.FirewallPolicy{}).
|
||||
Named("firewallpolicy").
|
||||
Watches(
|
||||
&corev1.Service{},
|
||||
handler.EnqueueRequestsFromMapFunc(r.mapServiceToFirewallPolicies),
|
||||
).
|
||||
Watches(
|
||||
&unifiv1beta1.FirewallGroup{},
|
||||
handler.EnqueueRequestsFromMapFunc(r.mapFirewallGroupToFirewallPolicies),
|
||||
).
|
||||
Complete(r)
|
||||
}
|
||||
84
internal/controller/firewallpolicy_controller_test.go
Normal file
84
internal/controller/firewallpolicy_controller_test.go
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright 2025 Vegard Engen.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
)
|
||||
|
||||
var _ = Describe("FirewallPolicy Controller", func() {
|
||||
Context("When reconciling a resource", func() {
|
||||
const resourceName = "test-resource"
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
typeNamespacedName := types.NamespacedName{
|
||||
Name: resourceName,
|
||||
Namespace: "default", // TODO(user):Modify as needed
|
||||
}
|
||||
firewallpolicy := &unifiv1beta1.FirewallPolicy{}
|
||||
|
||||
BeforeEach(func() {
|
||||
By("creating the custom resource for the Kind FirewallPolicy")
|
||||
err := k8sClient.Get(ctx, typeNamespacedName, firewallpolicy)
|
||||
if err != nil && errors.IsNotFound(err) {
|
||||
resource := &unifiv1beta1.FirewallPolicy{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: resourceName,
|
||||
Namespace: "default",
|
||||
},
|
||||
// TODO(user): Specify other spec details if needed.
|
||||
}
|
||||
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
|
||||
}
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
// TODO(user): Cleanup logic after each test, like removing the resource instance.
|
||||
resource := &unifiv1beta1.FirewallPolicy{}
|
||||
err := k8sClient.Get(ctx, typeNamespacedName, resource)
|
||||
if err == nil {
|
||||
By("Cleanup the specific resource instance FirewallPolicy")
|
||||
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
|
||||
}
|
||||
})
|
||||
It("should successfully reconcile the resource", func() {
|
||||
By("Reconciling the created resource")
|
||||
controllerReconciler := &FirewallPolicyReconciler{
|
||||
Client: k8sClient,
|
||||
Scheme: k8sClient.Scheme(),
|
||||
}
|
||||
|
||||
_, err := controllerReconciler.Reconcile(ctx, reconcile.Request{
|
||||
NamespacedName: typeNamespacedName,
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
// TODO(user): Add more specific assertions depending on your controller's reconciliation logic.
|
||||
// Example: If you expect a certain status condition after reconciliation, verify it here.
|
||||
})
|
||||
})
|
||||
})
|
||||
225
internal/controller/firewallzone_controller.go
Normal file
225
internal/controller/firewallzone_controller.go
Normal file
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
Copyright 2025 Vegard Engen.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
|
||||
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/config"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/unifi"
|
||||
)
|
||||
|
||||
// FirewallZoneReconciler reconciles a FirewallZone object
|
||||
type FirewallZoneReconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
UnifiClient *unifi.UnifiClient
|
||||
ConfigLoader *config.ConfigLoaderType
|
||||
}
|
||||
|
||||
func toKubeName(input string) string {
|
||||
// Lowercase the input
|
||||
name := strings.ToLower(input)
|
||||
|
||||
// Replace any non-alphanumeric characters with dashes
|
||||
re := regexp.MustCompile(`[^a-z0-9\-\.]+`)
|
||||
name = re.ReplaceAllString(name, "-")
|
||||
|
||||
// Trim leading and trailing non-alphanumerics
|
||||
name = strings.Trim(name, "-.")
|
||||
|
||||
// Ensure it's not empty and doesn't exceed 253 characters
|
||||
if len(name) == 0 {
|
||||
name = "default"
|
||||
} else if len(name) > 253 {
|
||||
name = name[:253]
|
||||
}
|
||||
|
||||
return name
|
||||
}
|
||||
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallzones,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallzones/status,verbs=get;update;patch
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=firewallzones/finalizers,verbs=update
|
||||
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=list;get;watch
|
||||
|
||||
// Reconcile is part of the main kubernetes reconciliation loop which aims to
|
||||
// move the current state of the cluster closer to the desired state.
|
||||
// TODO(user): Modify the Reconcile function to compare the state specified by
|
||||
// the FirewallZone object against the actual cluster state, and then
|
||||
// perform operations to make the cluster state reflect the state specified by
|
||||
// the user.
|
||||
//
|
||||
// For more details, check Reconcile and its Result here:
|
||||
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.2/pkg/reconcile
|
||||
func (r *FirewallZoneReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := log.FromContext(ctx)
|
||||
|
||||
cfg, err := r.ConfigLoader.GetConfig(ctx, "unifi-operator-config")
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
defaultNs := cfg.Data["defaultNamespace"]
|
||||
|
||||
err = r.UnifiClient.Reauthenticate()
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
fullSyncZone := "gateway"
|
||||
if cfg.Data["fullSyncZone"] != "" {
|
||||
fullSyncZone = cfg.Data["fullSyncZone"]
|
||||
}
|
||||
|
||||
fullSync := false
|
||||
var zoneObj unifiv1beta1.FirewallZone
|
||||
if err := r.Get(ctx, req.NamespacedName, &zoneObj); err != nil {
|
||||
return ctrl.Result{}, client.IgnoreNotFound(err)
|
||||
}
|
||||
|
||||
log.Info(fmt.Sprintf("fullSyncZone: %s Zone: %s", fullSyncZone, zoneObj.Name))
|
||||
if zoneObj.Name == fullSyncZone {
|
||||
fullSync = true
|
||||
log.Info("Going into fullsync mode")
|
||||
}
|
||||
|
||||
err = r.UnifiClient.Reauthenticate()
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
if !fullSync {
|
||||
firewallzones, err := r.UnifiClient.Client.ListFirewallZones(context.Background(), r.UnifiClient.SiteID)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not list firewall zones")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
found := false
|
||||
for _, unifizone := range firewallzones {
|
||||
if unifizone.Name == zoneObj.Spec.Name {
|
||||
found = true
|
||||
zoneSpec := unifiv1beta1.FirewallZoneSpec{
|
||||
Name: unifizone.Name,
|
||||
ID: unifizone.ID,
|
||||
DefaultZone: unifizone.DefaultZone,
|
||||
NetworkIDs: unifizone.NetworkIDs,
|
||||
}
|
||||
zoneObj.Spec = zoneSpec
|
||||
err := r.Update(ctx, &zoneObj)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
err := r.Delete(ctx, &zoneObj)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
log.Info("Starting fullsync mode")
|
||||
|
||||
var fwzCRDs unifiv1beta1.FirewallZoneList
|
||||
_ = r.List(ctx, &fwzCRDs, client.InNamespace(defaultNs))
|
||||
|
||||
firewall_zones, err := r.UnifiClient.Client.ListFirewallZones(context.Background(), r.UnifiClient.SiteID)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not list firewall zones")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
log.Info(fmt.Sprintf("Number of resources: %d Number of zones in Unifi: %d", len(fwzCRDs.Items), len(firewall_zones)))
|
||||
|
||||
firewallZoneNamesUnifi := make(map[string]struct{})
|
||||
for _, zone := range firewall_zones {
|
||||
firewallZoneNamesUnifi[zone.Name] = struct{}{}
|
||||
}
|
||||
|
||||
// Step 2: Collect zones in fwzCRDs that are NOT in firewall_zones
|
||||
for _, zone := range fwzCRDs.Items {
|
||||
if _, found := firewallZoneNamesUnifi[zone.Spec.Name]; !found {
|
||||
err := r.Delete(ctx, &zone)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
firewallZoneNamesCRDs := make(map[string]struct{})
|
||||
for _, zoneCRD := range fwzCRDs.Items {
|
||||
firewallZoneNamesCRDs[zoneCRD.Spec.Name] = struct{}{}
|
||||
}
|
||||
for _, unifizone := range firewall_zones {
|
||||
log.Info(fmt.Sprintf("%+v\n", unifizone))
|
||||
if _, found := firewallZoneNamesCRDs[unifizone.Name]; !found {
|
||||
zoneCRD := &unifiv1beta1.FirewallZone{
|
||||
ObjectMeta: ctrl.ObjectMeta{
|
||||
Name: toKubeName(unifizone.Name),
|
||||
Namespace: defaultNs,
|
||||
},
|
||||
Spec: unifiv1beta1.FirewallZoneSpec{
|
||||
Name: unifizone.Name,
|
||||
ID: unifizone.ID,
|
||||
DefaultZone: unifizone.DefaultZone,
|
||||
ZoneKey: unifizone.ZoneKey,
|
||||
NetworkIDs: unifizone.NetworkIDs,
|
||||
},
|
||||
}
|
||||
err := r.Create(ctx, zoneCRD)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
} else {
|
||||
for _, zoneCRD := range fwzCRDs.Items {
|
||||
if zoneCRD.Spec.Name == unifizone.Name {
|
||||
zoneCRD.Spec = unifiv1beta1.FirewallZoneSpec{
|
||||
Name: unifizone.Name,
|
||||
ID: unifizone.ID,
|
||||
DefaultZone: unifizone.DefaultZone,
|
||||
ZoneKey: unifizone.ZoneKey,
|
||||
NetworkIDs: unifizone.NetworkIDs,
|
||||
}
|
||||
err := r.Update(ctx, &zoneCRD)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, nil
|
||||
}
|
||||
|
||||
// SetupWithManager sets up the controller with the Manager.
|
||||
func (r *FirewallZoneReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
For(&unifiv1beta1.FirewallZone{}).
|
||||
Named("firewallzone").
|
||||
Complete(r)
|
||||
}
|
||||
84
internal/controller/firewallzone_controller_test.go
Normal file
84
internal/controller/firewallzone_controller_test.go
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright 2025 Vegard Engen.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
)
|
||||
|
||||
var _ = Describe("FirewallZone Controller", func() {
|
||||
Context("When reconciling a resource", func() {
|
||||
const resourceName = "test-resource"
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
typeNamespacedName := types.NamespacedName{
|
||||
Name: resourceName,
|
||||
Namespace: "default", // TODO(user):Modify as needed
|
||||
}
|
||||
firewallzone := &unifiv1beta1.FirewallZone{}
|
||||
|
||||
BeforeEach(func() {
|
||||
By("creating the custom resource for the Kind FirewallZone")
|
||||
err := k8sClient.Get(ctx, typeNamespacedName, firewallzone)
|
||||
if err != nil && errors.IsNotFound(err) {
|
||||
resource := &unifiv1beta1.FirewallZone{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: resourceName,
|
||||
Namespace: "default",
|
||||
},
|
||||
// TODO(user): Specify other spec details if needed.
|
||||
}
|
||||
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
|
||||
}
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
// TODO(user): Cleanup logic after each test, like removing the resource instance.
|
||||
resource := &unifiv1beta1.FirewallZone{}
|
||||
err := k8sClient.Get(ctx, typeNamespacedName, resource)
|
||||
if err == nil {
|
||||
By("Cleanup the specific resource instance FirewallZone")
|
||||
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
|
||||
}
|
||||
})
|
||||
It("should successfully reconcile the resource", func() {
|
||||
By("Reconciling the created resource")
|
||||
controllerReconciler := &FirewallZoneReconciler{
|
||||
Client: k8sClient,
|
||||
Scheme: k8sClient.Scheme(),
|
||||
}
|
||||
|
||||
_, err := controllerReconciler.Reconcile(ctx, reconcile.Request{
|
||||
NamespacedName: typeNamespacedName,
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
// TODO(user): Add more specific assertions depending on your controller's reconciliation logic.
|
||||
// Example: If you expect a certain status condition after reconciliation, verify it here.
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -19,13 +19,17 @@ package controller
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
|
||||
unifiv1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/config"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/unifi"
|
||||
)
|
||||
|
||||
@@ -34,11 +38,13 @@ type NetworkconfigurationReconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
UnifiClient *unifi.UnifiClient
|
||||
ConfigLoader *config.ConfigLoaderType
|
||||
}
|
||||
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=networkconfigurations,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=networkconfigurations/status,verbs=get;update;patch
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=networkconfigurations/finalizers,verbs=update
|
||||
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=list;get;watch
|
||||
|
||||
// Reconcile is part of the main kubernetes reconciliation loop which aims to
|
||||
// move the current state of the cluster closer to the desired state.
|
||||
@@ -51,38 +57,182 @@ type NetworkconfigurationReconciler struct {
|
||||
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.2/pkg/reconcile
|
||||
func (r *NetworkconfigurationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := log.FromContext(ctx)
|
||||
|
||||
var networkCRDs unifiv1.NetworkconfigurationList
|
||||
if err := r.List(ctx, &networkCRDs); err != nil {
|
||||
cfg, err := r.ConfigLoader.GetConfig(ctx, "unifi-operator-config")
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
k8sNetworks := make(map[string]*unifiv1.Networkconfiguration)
|
||||
for i := range networkCRDs.Items {
|
||||
log.Info(fmt.Sprintf("Inserting network %s\n", networkCRDs.Items[i].Spec.NetworkID))
|
||||
k8sNetworks[networkCRDs.Items[i].Spec.NetworkID] = &networkCRDs.Items[i]
|
||||
|
||||
defaultNs := cfg.Data["defaultNamespace"]
|
||||
log.Info(defaultNs)
|
||||
|
||||
fullSyncNetwork := "core"
|
||||
if cfg.Data["fullSyncNetwork"] != "" {
|
||||
fullSyncNetwork = cfg.Data["fullSyncNetwork"]
|
||||
}
|
||||
|
||||
fullSync := false
|
||||
var networkObj unifiv1.Networkconfiguration
|
||||
if err := r.Get(ctx, req.NamespacedName, &networkObj); err != nil {
|
||||
return ctrl.Result{}, client.IgnoreNotFound(err)
|
||||
}
|
||||
|
||||
log.Info(fmt.Sprintf("fullSyncNetwork: %s Network: %s", fullSyncNetwork, networkObj.Name))
|
||||
if networkObj.Name == fullSyncNetwork {
|
||||
fullSync = true
|
||||
log.Info("Going into fullsync mode")
|
||||
}
|
||||
|
||||
err = r.UnifiClient.Reauthenticate()
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
if !fullSync {
|
||||
networks, err := r.UnifiClient.Client.ListNetwork(context.Background(), r.UnifiClient.SiteID)
|
||||
if err != nil {
|
||||
log.Error(err, "Could not list netwrorks")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
found := false
|
||||
for _, unifinetwork := range networks {
|
||||
if unifinetwork.Name == networkObj.Spec.Name {
|
||||
found = true
|
||||
networkSpec := unifiv1.NetworkconfigurationSpec{
|
||||
Name: unifinetwork.Name,
|
||||
ID: unifinetwork.ID,
|
||||
IPSubnet: unifinetwork.IPSubnet,
|
||||
Ipv6InterfaceType: unifinetwork.IPV6InterfaceType,
|
||||
Ipv6PdAutoPrefixidEnabled: unifinetwork.IPV6PDAutoPrefixidEnabled,
|
||||
Ipv6RaEnabled: unifinetwork.IPV6RaEnabled,
|
||||
Ipv6SettingPreference: unifinetwork.IPV6SettingPreference,
|
||||
Ipv6Subnet: unifinetwork.IPV6Subnet,
|
||||
Purpose: unifinetwork.Purpose,
|
||||
Networkgroup: unifinetwork.NetworkGroup,
|
||||
SettingPreference: unifinetwork.SettingPreference,
|
||||
Vlan: int64(unifinetwork.VLAN),
|
||||
VlanEnabled: unifinetwork.VLANEnabled,
|
||||
}
|
||||
if !reflect.DeepEqual(networkObj.Spec, networkSpec) {
|
||||
networkObj.Spec = networkSpec
|
||||
err := r.Update(ctx, &networkObj)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
err := r.Delete(ctx, &networkObj)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
log.Info("Starting fullsync mode")
|
||||
var networkCRDs unifiv1.NetworkconfigurationList
|
||||
_ = r.List(ctx, &networkCRDs, client.InNamespace(defaultNs))
|
||||
|
||||
networks, err := r.UnifiClient.Client.ListNetwork(context.Background(), r.UnifiClient.SiteID)
|
||||
if err != nil {
|
||||
log.Error(err, "Failed to list Unifi Networks")
|
||||
return ctrl.Result{}, err
|
||||
log.Error(err, "Could not list netwrorks")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
log.Info(fmt.Sprintf("Number of resources: %d Number of networks in Unifi: %d", len(networkCRDs.Items), len(networks)))
|
||||
|
||||
var firewallZoneCRDs unifiv1.FirewallZoneList
|
||||
err = r.List(ctx, &firewallZoneCRDs, client.InNamespace(defaultNs))
|
||||
if err != nil {
|
||||
log.Error(err, "Could not list firewall zones")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
|
||||
seenNetworks := map[string]bool{}
|
||||
networkNamesUnifi := make(map[string]struct{})
|
||||
for _, unifinetwork := range networks {
|
||||
networkNamesUnifi[unifinetwork.Name] = struct{}{}
|
||||
}
|
||||
|
||||
for _, network := range networks {
|
||||
networkID := network.ID
|
||||
seenNetworks[networkID] = true
|
||||
log.Info(fmt.Sprintf("Searching for %s\n", networkID))
|
||||
|
||||
if existing, found := k8sNetworks[networkID]; found {
|
||||
log.Info(fmt.Sprintf("Found network match: %s/%s", existing.Spec.NetworkID, networkID))
|
||||
// Step 2: Collect zones in fwzCRDs that are NOT in firewall_zones
|
||||
for _, network := range networkCRDs.Items {
|
||||
if _, found := networkNamesUnifi[network.Spec.Name]; !found {
|
||||
err := r.Delete(ctx, &network)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
networkNamesCRDs := make(map[string]struct{})
|
||||
for _, networkCRD := range networkCRDs.Items {
|
||||
networkNamesCRDs[networkCRD.Spec.Name] = struct{}{}
|
||||
}
|
||||
for _, unifinetwork := range networks {
|
||||
if unifinetwork.Purpose == "corporate" {
|
||||
networkSpec := unifiv1.NetworkconfigurationSpec{
|
||||
Name: unifinetwork.Name,
|
||||
ID: unifinetwork.ID,
|
||||
IPSubnet: unifinetwork.IPSubnet,
|
||||
Ipv6InterfaceType: unifinetwork.IPV6InterfaceType,
|
||||
Ipv6PdAutoPrefixidEnabled: unifinetwork.IPV6PDAutoPrefixidEnabled,
|
||||
Ipv6RaEnabled: unifinetwork.IPV6RaEnabled,
|
||||
Ipv6SettingPreference: unifinetwork.IPV6SettingPreference,
|
||||
Ipv6Subnet: unifinetwork.IPV6Subnet,
|
||||
Purpose: unifinetwork.Purpose,
|
||||
Networkgroup: unifinetwork.NetworkGroup,
|
||||
SettingPreference: unifinetwork.SettingPreference,
|
||||
Vlan: int64(unifinetwork.VLAN),
|
||||
VlanEnabled: unifinetwork.VLANEnabled,
|
||||
}
|
||||
networkStatus := unifiv1.NetworkconfigurationStatus{
|
||||
FirewallZoneID: unifinetwork.FirewallZoneID,
|
||||
}
|
||||
log.Info(fmt.Sprintf("Network status %s: %+v", networkSpec.Name, networkStatus))
|
||||
if _, found := networkNamesCRDs[unifinetwork.Name]; !found {
|
||||
firewallZoneNamesCRDs := make(map[string]struct{})
|
||||
firewallZoneIdsCRDs := make(map[string]struct{})
|
||||
for _, firewallZoneCRD := range firewallZoneCRDs.Items {
|
||||
firewallZoneNamesCRDs[firewallZoneCRD.Spec.Name] = struct{}{}
|
||||
firewallZoneIdsCRDs[firewallZoneCRD.Spec.ID] = struct{}{}
|
||||
}
|
||||
networkCRD := &unifiv1.Networkconfiguration{
|
||||
ObjectMeta: ctrl.ObjectMeta{
|
||||
Name: toKubeName(unifinetwork.Name),
|
||||
Namespace: defaultNs,
|
||||
},
|
||||
Spec: networkSpec,
|
||||
Status: networkStatus,
|
||||
}
|
||||
err = r.Create(ctx, networkCRD)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
err = r.Get(ctx, types.NamespacedName{Name: networkCRD.Name, Namespace: networkCRD.Namespace}, networkCRD)
|
||||
networkCRD.Status = networkStatus
|
||||
if err = r.Status().Update(ctx, networkCRD); err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("New network: %s with ID %s", network.Name, network.ID))
|
||||
for _, networkCRD := range networkCRDs.Items {
|
||||
if networkCRD.Spec.Name == unifinetwork.Name {
|
||||
if !reflect.DeepEqual(networkCRD.Spec, networkSpec) {
|
||||
networkCRD.Spec = networkSpec
|
||||
err := r.Update(ctx, &networkCRD)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(networkCRD.Status, networkStatus) {
|
||||
networkCRD.Status = networkStatus
|
||||
if err = r.Status().Update(ctx, &networkCRD); err != nil {
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ctrl.Result{}, nil
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, nil
|
||||
}
|
||||
|
||||
// SetupWithManager sets up the controller with the Manager.
|
||||
|
||||
@@ -61,10 +61,10 @@ var _ = Describe("Networkconfiguration Controller", func() {
|
||||
// TODO(user): Cleanup logic after each test, like removing the resource instance.
|
||||
resource := &unifiv1beta1.Networkconfiguration{}
|
||||
err := k8sClient.Get(ctx, typeNamespacedName, resource)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
if err == nil {
|
||||
By("Cleanup the specific resource instance Networkconfiguration")
|
||||
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
|
||||
}
|
||||
})
|
||||
It("should successfully reconcile the resource", func() {
|
||||
By("Reconciling the created resource")
|
||||
|
||||
152
internal/controller/portforward_controller.go
Normal file
152
internal/controller/portforward_controller.go
Normal file
@@ -0,0 +1,152 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
// "k8s.io/apimachinery/pkg/types"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller"
|
||||
// "sigs.k8s.io/controller-runtime/pkg/handler"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
// "sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
// "sigs.k8s.io/controller-runtime/pkg/source"
|
||||
|
||||
goUnifi "gitea.engen.priv.no/klauvsteinen/go-unifi/unifi"
|
||||
// unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/config"
|
||||
"github.com/vegardengen/unifi-network-operator/internal/unifi"
|
||||
)
|
||||
|
||||
type PortForwardReconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
UnifiClient *unifi.UnifiClient
|
||||
ConfigLoader *config.ConfigLoaderType
|
||||
}
|
||||
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=portforwards,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=portforwards/status,verbs=get;update;patch
|
||||
// +kubebuilder:rbac:groups=unifi.engen.priv.no,resources=portforwards/finalizers,verbs=update
|
||||
// +kubebuilder:rbac:groups="",resources=services,verbs=list;get;watch
|
||||
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=list;get;watch
|
||||
|
||||
func (r *PortForwardReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := log.FromContext(ctx)
|
||||
|
||||
var svc corev1.Service
|
||||
if err := r.Get(ctx, req.NamespacedName, &svc); err != nil {
|
||||
return ctrl.Result{}, client.IgnoreNotFound(err)
|
||||
}
|
||||
|
||||
annotation := svc.Annotations["portforward.unifi.engen.priv.no/forward"]
|
||||
err := r.UnifiClient.Reauthenticate()
|
||||
if err != nil {
|
||||
log.Error(err, "Failed to authenticate to Unifi")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
|
||||
portforwards, err := r.UnifiClient.Client.ListPortForward(context.Background(), r.UnifiClient.SiteID)
|
||||
if err != nil {
|
||||
log.Error(err, "Failed to list PortForfards")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
portforwardnames := make(map[string]int)
|
||||
for i, portforward := range portforwards {
|
||||
portforwardnames[portforward.Name] = i
|
||||
}
|
||||
if annotation == "" {
|
||||
for _, port := range svc.Spec.Ports {
|
||||
portforwardname := "k8s-forward-" + svc.Name + "-" + port.Name
|
||||
if i, found := portforwardnames[portforwardname]; found {
|
||||
log.Info(fmt.Sprintf("Cleaning up old portfoward for service %s/%s", svc.Namespace, svc.Name))
|
||||
if err := r.UnifiClient.Client.DeletePortForward(context.Background(), r.UnifiClient.SiteID, portforwards[i].ID); err != nil {
|
||||
log.Error(err, "Could not delete portforward")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
portMap := make(map[string]int)
|
||||
entries := strings.Split(annotation, ";")
|
||||
for _, entry := range entries {
|
||||
entry = strings.TrimSpace(entry)
|
||||
if entry == "" {
|
||||
continue
|
||||
}
|
||||
parts := strings.Split(entry, ":")
|
||||
for _, port := range svc.Spec.Ports {
|
||||
if parts[0] == port.Name {
|
||||
if len(parts) == 1 {
|
||||
portMap[parts[0]] = int(port.Port)
|
||||
} else if len(parts) == 2 {
|
||||
extPort, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
log.Error(err, "Invalid external port", "entry", entry)
|
||||
continue
|
||||
}
|
||||
portMap[parts[0]] = extPort
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(svc.Status.LoadBalancer.Ingress) == 0 {
|
||||
log.Info("No LoadBalancer IP for Service", "service", svc.Name)
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
ip := svc.Status.LoadBalancer.Ingress[0].IP
|
||||
|
||||
for _, port := range svc.Spec.Ports {
|
||||
extPort, found := portMap[port.Name]
|
||||
|
||||
if found {
|
||||
|
||||
log.Info("Setting up port forward",
|
||||
"externalPort", extPort,
|
||||
"internalPort", port.Port,
|
||||
"ip", ip,
|
||||
"protocol", port.Protocol)
|
||||
}
|
||||
portforwardname := "k8s-forward-" + svc.Name + "-" + port.Name
|
||||
log.Info(fmt.Sprintf("Should handle %s", portforwardname))
|
||||
if portforwardindex, found := portforwardnames[portforwardname]; found {
|
||||
if portforwards[portforwardindex].DstPort == fmt.Sprintf("%d", portMap[port.Name]) && portforwards[portforwardindex].Fwd == ip && portforwards[portforwardindex].FwdPort == fmt.Sprintf("%d", port.Port) {
|
||||
log.Info("Portforward already exists and is correct")
|
||||
} else {
|
||||
log.Info("Exists, but need to update")
|
||||
portforwards[portforwardindex].DstPort = fmt.Sprintf("%d", portMap[port.Name])
|
||||
portforwards[portforwardindex].FwdPort = fmt.Sprintf("%d", port.Port)
|
||||
portforwards[portforwardindex].Fwd = ip
|
||||
if _, err := r.UnifiClient.Client.UpdatePortForward(context.Background(), r.UnifiClient.SiteID, &portforwards[portforwardindex]); err != nil {
|
||||
log.Error(err, fmt.Sprintf("Failed to update portforward %s", portforwardname))
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_, err := r.UnifiClient.Client.CreatePortForward(context.Background(), r.UnifiClient.SiteID, &goUnifi.PortForward{Name: portforwardname, PfwdInterface: "wan", Src: "any", Log: false, DestinationIPs: []goUnifi.PortForwardDestinationIPs{}, Enabled: true, Fwd: ip, DestinationIP: "any", Proto: "tcp", DstPort: fmt.Sprintf("%d", portMap[port.Name]), SiteID: r.UnifiClient.SiteID, FwdPort: fmt.Sprintf("%d", port.Port)})
|
||||
if err != nil {
|
||||
log.Error(err, "Portforward could not be created")
|
||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
func (r *PortForwardReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
For(&corev1.Service{}).
|
||||
WithOptions(controller.Options{MaxConcurrentReconciles: 1}).
|
||||
Complete(r)
|
||||
}
|
||||
84
internal/controller/portforward_controller_test.go
Normal file
84
internal/controller/portforward_controller_test.go
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright 2025 Vegard Engen.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
||||
)
|
||||
|
||||
var _ = Describe("PortForward Controller", func() {
|
||||
Context("When reconciling a resource", func() {
|
||||
const resourceName = "test-resource"
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
typeNamespacedName := types.NamespacedName{
|
||||
Name: resourceName,
|
||||
Namespace: "default", // TODO(user):Modify as needed
|
||||
}
|
||||
portforward := &unifiv1beta1.PortForward{}
|
||||
|
||||
BeforeEach(func() {
|
||||
By("creating the custom resource for the Kind PortForward")
|
||||
err := k8sClient.Get(ctx, typeNamespacedName, portforward)
|
||||
if err != nil && errors.IsNotFound(err) {
|
||||
resource := &unifiv1beta1.PortForward{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: resourceName,
|
||||
Namespace: "default",
|
||||
},
|
||||
// TODO(user): Specify other spec details if needed.
|
||||
}
|
||||
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
|
||||
}
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
// TODO(user): Cleanup logic after each test, like removing the resource instance.
|
||||
resource := &unifiv1beta1.PortForward{}
|
||||
err := k8sClient.Get(ctx, typeNamespacedName, resource)
|
||||
if err == nil {
|
||||
By("Cleanup the specific resource instance PortForward")
|
||||
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
|
||||
}
|
||||
})
|
||||
It("should successfully reconcile the resource", func() {
|
||||
By("Reconciling the created resource")
|
||||
controllerReconciler := &PortForwardReconciler{
|
||||
Client: k8sClient,
|
||||
Scheme: k8sClient.Scheme(),
|
||||
}
|
||||
|
||||
_, err := controllerReconciler.Reconcile(ctx, reconcile.Request{
|
||||
NamespacedName: typeNamespacedName,
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
// TODO(user): Add more specific assertions depending on your controller's reconciliation logic.
|
||||
// Example: If you expect a certain status condition after reconciliation, verify it here.
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -48,6 +48,10 @@ var (
|
||||
)
|
||||
|
||||
func TestControllers(t *testing.T) {
|
||||
if os.Getenv("SKIP_INTEGRATION_TESTS") == "true" {
|
||||
t.Skip("Skipping integration tests that require envtest")
|
||||
}
|
||||
|
||||
RegisterFailHandler(Fail)
|
||||
|
||||
RunSpecs(t, "Controller Suite")
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/vegardengen/go-unifi/unifi"
|
||||
"gitea.engen.priv.no/klauvsteinen/go-unifi/unifi"
|
||||
)
|
||||
|
||||
type UnifiClient struct {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/* https://github.com/clbx/kube-port-forward-controller */
|
||||
|
||||
package unifi_network_operator_utils
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func isIPv6(ip string) bool {
|
||||
return strings.Contains(ip, ":")
|
||||
}
|
||||
|
||||
func toKubeName(input string) string {
|
||||
// Lowercase the input
|
||||
name := strings.ToLower(input)
|
||||
|
||||
// Replace any non-alphanumeric characters with dashes
|
||||
re := regexp.MustCompile(`[^a-z0-9\-\.]+`)
|
||||
name = re.ReplaceAllString(name, "-")
|
||||
|
||||
// Trim leading and trailing non-alphanumerics
|
||||
name = strings.Trim(name, "-.")
|
||||
|
||||
// Ensure it's not empty and doesn't exceed 253 characters
|
||||
if len(name) == 0 {
|
||||
name = "default"
|
||||
} else if len(name) > 253 {
|
||||
name = name[:253]
|
||||
}
|
||||
|
||||
return name
|
||||
}
|
||||
7
ko.yaml
Normal file
7
ko.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
defaultBaseImage: cgr.dev/chainguard/static:latest
|
||||
|
||||
labels:
|
||||
org.opencontainers.image.authors: Vegard Engen <vegard@engen.priv.no>
|
||||
org.opencontainers.image.source: https://github.com/vegardengen/unifi-network-operator
|
||||
org.opencontainers.image.vendor: Klauvsteinen
|
||||
dev.chainguard.package.main: ""
|
||||
@@ -47,6 +47,10 @@ var (
|
||||
// The default setup requires Kind, builds/loads the Manager Docker image locally, and installs
|
||||
// CertManager.
|
||||
func TestE2E(t *testing.T) {
|
||||
if os.Getenv("SKIP_INTEGRATION_TESTS") == "true" {
|
||||
t.Skip("Skipping e2e tests that require Kubernetes cluster")
|
||||
}
|
||||
|
||||
RegisterFailHandler(Fail)
|
||||
_, _ = fmt.Fprintf(GinkgoWriter, "Starting unifi-network-operator integration test suite\n")
|
||||
RunSpecs(t, "e2e suite")
|
||||
|
||||
Reference in New Issue
Block a user