mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
feat(platform): package address-controller and its MetalLB driver (#3382)
## What this PR does Adds IP addresses as a first-class resource ([cozystack/community#35](https://github.com/cozystack/community/pull/35)) as two optional system packages, off by default and enabled through `bundles.enabledPackages`: - **`cozystack.address-controller`** — the class-agnostic core ([cozystack/address-controller](https://github.com/cozystack/address-controller)): `IPAddressClass` / `IPAddress` / `IPAddressClaim` in `local.sdn.cozystack.io`, the PVC/PV-binding analog. It owns claim–address binding, status and reclaim, and never allocates anything itself. - **`cozystack.metallb-iad`** — the per-class driver for addresses announced by MetalLB ([cozystack/metallb-iad](https://github.com/cozystack/metallb-iad)). A class names an existing `IPAddressPool` with `autoAssign: false` in `cozy-metallb`, which the admin provisions together with its advertisement. The driver holds reservations as placeholder Services in its own namespace, and attaches an address to a Service that names a claim with the `local.sdn.cozystack.io/ip-address-claim` annotation. ### Packaging Both are ordinary wrapper packages under `packages/system/`, sourced from the `cozystack-packages` artifact like every other package. The upstream chart is vendored verbatim under `charts/` by `make update` at a pinned commit, since neither project publishes a chart artifact: the `v0.2.0` release-preparation commits of [cozystack/address-controller#17](https://github.com/cozystack/address-controller/pull/17) and [cozystack/metallb-iad#11](https://github.com/cozystack/metallb-iad/pull/11). Each controller image is pinned by digest to a `main-<sha>` build carrying the same controller code: `address-controller:main-90e65ca`, whose commit differs from #17 only in chart version and docs, and `metallb-iad:main-1faf937`, whose commit differs from #11 only in chart version and the address-controller module pin, a purely additive API change the driver does not use. The pins move to the `v0.2.0` tags and images once both are released. The images live under `ghcr.io/cozystack/<name>`, outside the `ghcr.io/cozystack/cozystack/` repositories the release tooling owns, so promotion and the nightly mirror pass over them. The core installs its v1alpha1 CRDs with `upgradeCRDs: CreateReplace`. ### What the wrappers add - **Tenant access.** The upstream chart is Cozystack-agnostic and grants only the controller itself. `cozy:addresses`, `cozy:addresses:view` and `cozy:addresses:admin` aggregate into `cozy:tenant`, `cozy:tenant:view` and `cozy:tenant:admin` respectively, so a tenant can manage `IPAddressClaim`s in its own namespace, and the grant exists only while the package is installed. The cluster-scoped `IPAddress` and `IPAddressClass` are not granted: `cozy:tenant*` reaches a tenant through a per-namespace RoleBinding, so a rule for either would never be consulted. A tenant reads its address from the claim's `status.addresses[]`. - **The driver's admission policy, turned on for tenant namespaces.** MetalLB honours a pin or pool selector from any writer of a Service: the `metallb.io/` annotations, their `metallb.universe.tf/` predecessors and `spec.loadBalancerIP`. A tenant cluster's cloud provider copies a guest Service's annotations and `loadBalancerIP` onto the Service it creates in the tenant namespace. The upstream `metallb-iad-service-pins` policy reserves all of these, plus the sharing annotation, to the driver's ServiceAccount and the cluster-admin groups. An admission policy binds every principal regardless of RBAC, so the wrapper adds `cozystack-cluster-admin`, the group Cozystack's OIDC administrators authenticate as, to the chart's `system:masters` and `kubeadm:cluster-admins`. The wrapper enables it in `Deny` mode for namespaces carrying `namespace.cozystack.io/host`, which `tenant-root` and every tenant namespace have and nothing in `cozy-*` does. Unchanged values always pass, so the driver's pin on a tenant's own Service does not lock the rest of that Service. - **The driver's MetalLB namespace**, `cozy-metallb` instead of the upstream default `metallb-system`. ### Variant scoping `cozystack.metallb-iad` depends on `cozystack.address-controller`, which is opt-in, and on `cozystack.metallb`, which is absent on `isp-hosted`, on a slim variant that did not opt into it, and wherever `disabledPackages` names it. The driver is emitted from the `common-packages` helper only when the includes of MetalLB and of `cozystack.address-controller` both rendered a Package, so it cannot be enabled where it would sit in `DependenciesNotReady` forever, and it follows either dependency automatically if its rules change. The core carries no MetalLB dependency and remains available everywhere. ### Validation `helm unittest` covers the aggregation labels and rules on the tenant roles and the driver's emission, which requires both MetalLB and the address core. `hack/select-install.sh --validate` passes, and the selective-install fixture is regenerated from `hack/select-install.sh --disabled postgres`. The admission policy is upstream's and carries no render test here. ### Screenshots Not a UI change. ### Downstream repositories - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: [cozystack/website#810](https://github.com/cozystack/website/pull/810) (component cards), [cozystack/website#811](https://github.com/cozystack/website/pull/811) (operator guide) - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: The website is the one repository this change reaches: [cozystack/website#810](https://github.com/cozystack/website/pull/810) adds the two new platform components to `guides/platform-stack/_index.md` and `operations/configuration/licenses.md`, and [cozystack/website#811](https://github.com/cozystack/website/pull/811) adds an operator guide under `networking/`. The guide restates both image refs, so a repin here needs the same edit there. ### Release note ```release-note feat(platform): add IP addresses as a first-class resource as two optional system packages, `cozystack.address-controller` (IPAddressClass / IPAddress / IPAddressClaim) and its MetalLB driver `cozystack.metallb-iad`. Tenants can reserve an address with an IPAddressClaim. A LoadBalancer Service a tenant Kubernetes cluster creates can name that claim with the `local.sdn.cozystack.io/ip-address-claim` annotation, or draw one through auto-claim once an admin marks an auto-claim class. An admission policy reserves MetalLB's pool, pin and sharing inputs on tenant Services to the driver. The driver is only emitted where MetalLB and the address core are. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added address management for requesting and tracking IPv4, IPv6, or dual-stack addresses, with configurable address classes and lifecycle status. * Added the MetalLB IAD driver for address provisioning through MetalLB. It is included only when the required MetalLB and address-management components are enabled. * Added optional admission controls for address claims and protected MetalLB service settings. * Added optional address-controller metrics, monitoring, and alerting resources. * Added tenant access roles for viewing and managing address claims. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
32 files changed
+1706
-1
No files matched your search
@@ -0,0 +1,28 @@
|
||||
---
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: PackageSource
|
||||
metadata:
|
||||
name: cozystack.address-controller
|
||||
spec:
|
||||
sourceRef:
|
||||
kind: OCIRepository
|
||||
name: cozystack-packages
|
||||
namespace: cozy-system
|
||||
path: /
|
||||
variants:
|
||||
# IP addresses as a first-class resource (IPAddressClass / IPAddress /
|
||||
# IPAddressClaim, local.sdn.cozystack.io) — the PVC/PV-binding analog. The
|
||||
# core owns claim–address binding and reclaim; allocation belongs to
|
||||
# per-class drivers such as cozystack.metallb-iad.
|
||||
- name: default
|
||||
dependsOn:
|
||||
- cozystack.networking
|
||||
components:
|
||||
- name: address-controller
|
||||
path: system/address-controller
|
||||
install:
|
||||
namespace: cozy-address-controller
|
||||
releaseName: address-controller
|
||||
# The vendored chart ships its CRDs in crds/; they are v1alpha1 and
|
||||
# still evolving, so upgrades must be allowed to replace them.
|
||||
upgradeCRDs: CreateReplace
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: PackageSource
|
||||
metadata:
|
||||
name: cozystack.metallb-iad
|
||||
spec:
|
||||
sourceRef:
|
||||
kind: OCIRepository
|
||||
name: cozystack-packages
|
||||
namespace: cozy-system
|
||||
path: /
|
||||
variants:
|
||||
# The MetalLB IP Allocation Driver — the per-class driver implementing the
|
||||
# cozystack.address-controller contract for addresses announced by MetalLB.
|
||||
# It holds reservations as placeholder Services in its own namespace
|
||||
# (cozy-metallb-iad, which tenants must have no write access to) and needs
|
||||
# both the core CRDs/controller and MetalLB itself in place.
|
||||
- name: default
|
||||
dependsOn:
|
||||
- cozystack.address-controller
|
||||
- cozystack.metallb
|
||||
components:
|
||||
- name: metallb-iad
|
||||
path: system/metallb-iad
|
||||
install:
|
||||
namespace: cozy-metallb-iad
|
||||
releaseName: metallb-iad
|
||||
@@ -224,7 +224,15 @@ cozystack-scheduler (emitted with its own variant in both branches)
|
||||
{{include "cozystack.platform.package.default" (list "cozystack.kubeovn-plunger" $root) }}
|
||||
{{- end }}
|
||||
{{include "cozystack.platform.package.full.default" (list "cozystack.cozy-proxy" $root) }}
|
||||
{{include "cozystack.platform.package.full.default" (list "cozystack.metallb" $root) }}
|
||||
{{- $metallb := include "cozystack.platform.package.full.default" (list "cozystack.metallb" $root) }}
|
||||
{{ $metallb }}
|
||||
{{- /* Gated on its dependencies' own includes rendering a Package, so it
|
||||
follows their emission rules rather than restating them. The core is
|
||||
rendered here only for that test; bundles/system.yaml emits it. */ -}}
|
||||
{{- $addressController := include "cozystack.platform.package.optional.default" (list "cozystack.address-controller" $root) }}
|
||||
{{- if and (trim $metallb) (trim $addressController) }}
|
||||
{{include "cozystack.platform.package.optional.default" (list "cozystack.metallb-iad" $root) }}
|
||||
{{- end }}
|
||||
{{include "cozystack.platform.package.default" (list "cozystack.reloader" $root) }}
|
||||
{{include "cozystack.platform.package.default" (list "cozystack.linstor-scheduler" $root) }}
|
||||
{{include "cozystack.platform.package.default" (list "cozystack.snapshot-controller" $root) }}
|
||||
|
||||
@@ -397,5 +397,8 @@ variants and opt-in on the slim ones. */}}
|
||||
{{- end }}
|
||||
{{include "cozystack.platform.package.optional.default" (list "cozystack.hetzner-robotlb" $) }}
|
||||
{{include "cozystack.platform.package.optional.default" (list "cozystack.talos-log-collector" $) }}
|
||||
{{- /* Its MetalLB driver, cozystack.metallb-iad, is emitted from the
|
||||
common-packages helper. */}}
|
||||
{{include "cozystack.platform.package.optional.default" (list "cozystack.address-controller" $) }}
|
||||
|
||||
{{- end }}
|
||||
@@ -0,0 +1,142 @@
|
||||
suite: the MetalLB address driver is emitted only beside MetalLB and the address core
|
||||
templates:
|
||||
- templates/bundles/system.yaml
|
||||
release:
|
||||
name: cozystack
|
||||
namespace: cozy-system
|
||||
|
||||
tests:
|
||||
- it: emits the driver on isp-full when enabled
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
enabledPackages:
|
||||
- cozystack.address-controller
|
||||
- cozystack.metallb-iad
|
||||
asserts:
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.metallb-iad
|
||||
any: true
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.metallb
|
||||
any: true
|
||||
|
||||
- it: withholds the driver on isp-hosted even when enabled
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-hosted
|
||||
enabledPackages:
|
||||
- cozystack.address-controller
|
||||
- cozystack.metallb-iad
|
||||
asserts:
|
||||
# any: true is REQUIRED inside the matcher for the negative to search the
|
||||
# whole document set; without it containsDocument matches nothing and
|
||||
# `not: true` passes vacuously.
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.metallb-iad
|
||||
any: true
|
||||
not: true
|
||||
# The core carries no MetalLB dependency, so it is still available there.
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.address-controller
|
||||
any: true
|
||||
|
||||
- it: withholds the driver on a slim variant that did not opt into MetalLB
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-slim
|
||||
enabledPackages:
|
||||
- cozystack.address-controller
|
||||
- cozystack.metallb-iad
|
||||
asserts:
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.metallb-iad
|
||||
any: true
|
||||
not: true
|
||||
|
||||
- it: emits the driver on a slim variant that opted into MetalLB
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-slim
|
||||
enabledPackages:
|
||||
- cozystack.metallb
|
||||
- cozystack.address-controller
|
||||
- cozystack.metallb-iad
|
||||
asserts:
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.metallb-iad
|
||||
any: true
|
||||
|
||||
- it: withholds the driver where disabledPackages removes MetalLB
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
enabledPackages:
|
||||
- cozystack.address-controller
|
||||
- cozystack.metallb-iad
|
||||
disabledPackages:
|
||||
- cozystack.metallb
|
||||
asserts:
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.metallb-iad
|
||||
any: true
|
||||
not: true
|
||||
|
||||
- it: withholds the driver when the address core is not enabled
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
enabledPackages:
|
||||
- cozystack.metallb-iad
|
||||
asserts:
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.metallb-iad
|
||||
any: true
|
||||
not: true
|
||||
|
||||
- it: withholds the driver where disabledPackages removes the address core
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
enabledPackages:
|
||||
- cozystack.address-controller
|
||||
- cozystack.metallb-iad
|
||||
disabledPackages:
|
||||
- cozystack.address-controller
|
||||
asserts:
|
||||
- containsDocument:
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: Package
|
||||
name: cozystack.metallb-iad
|
||||
any: true
|
||||
not: true
|
||||
@@ -2,6 +2,7 @@
|
||||
# Regenerate after changing the PackageSource inventory or install baseline.
|
||||
bundles:
|
||||
disabledPackages:
|
||||
- cozystack.address-controller
|
||||
- cozystack.bootbox
|
||||
- cozystack.bootbox-application
|
||||
- cozystack.capi-provider-infra-proxmox
|
||||
@@ -37,6 +38,7 @@ bundles:
|
||||
- cozystack.local-storage
|
||||
- cozystack.mariadb-application
|
||||
- cozystack.mariadb-operator
|
||||
- cozystack.metallb-iad
|
||||
- cozystack.mongodb-application
|
||||
- cozystack.mongodb-operator
|
||||
- cozystack.monitoring
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
apiVersion: v2
|
||||
name: cozy-address-controller
|
||||
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
|
||||
@@ -0,0 +1,23 @@
|
||||
export NAME=address-controller
|
||||
export NAMESPACE=cozy-$(NAME)
|
||||
|
||||
include ../../../hack/package.mk
|
||||
|
||||
# Upstream publishes no chart artifact, so the chart is taken from the
|
||||
# repository at a pinned commit. Bump together with the image in values.yaml,
|
||||
# which must carry the same controller code: upstream's release job tags each
|
||||
# main build as main-<short sha>, and the digest is in that job's log or from
|
||||
# `crane digest`.
|
||||
ADDRESS_CONTROLLER_REPO ?= https://github.com/cozystack/address-controller.git
|
||||
ADDRESS_CONTROLLER_REF ?= 0ed4cc53de935ba108c012e43008fc456b806f79
|
||||
|
||||
test:
|
||||
helm unittest .
|
||||
|
||||
update:
|
||||
rm -rf charts tmp-repo
|
||||
git clone --filter=tree:0 --no-checkout $(ADDRESS_CONTROLLER_REPO) tmp-repo
|
||||
git -C tmp-repo checkout --quiet $(ADDRESS_CONTROLLER_REF)
|
||||
mkdir -p charts
|
||||
cp -r tmp-repo/chart/address-controller charts/
|
||||
rm -rf tmp-repo
|
||||
@@ -0,0 +1,9 @@
|
||||
# Patterns to ignore when building packages.
|
||||
.DS_Store
|
||||
.git/
|
||||
.gitignore
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*.orig
|
||||
*~
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v2
|
||||
name: address-controller
|
||||
description: Core controllers for IP addresses as a first-class resource — IPAddressClass, IPAddress, IPAddressClaim (local.sdn.cozystack.io)
|
||||
type: application
|
||||
version: 0.2.0
|
||||
appVersion: "0.2.0"
|
||||
# CEL validation rules on the CRDs (immutability, union exactness) need 1.29+.
|
||||
kubeVersion: ">=1.29.0-0"
|
||||
keywords:
|
||||
- ipam
|
||||
- networking
|
||||
- cozystack
|
||||
home: https://github.com/cozystack/address-controller
|
||||
sources:
|
||||
- https://github.com/cozystack/address-controller
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.1
|
||||
name: ipaddressclaims.local.sdn.cozystack.io
|
||||
spec:
|
||||
group: local.sdn.cozystack.io
|
||||
names:
|
||||
kind: IPAddressClaim
|
||||
listKind: IPAddressClaimList
|
||||
plural: ipaddressclaims
|
||||
singular: ipaddressclaim
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- additionalPrinterColumns:
|
||||
- jsonPath: .status.phase
|
||||
name: Phase
|
||||
type: string
|
||||
- jsonPath: .status.className
|
||||
name: Class
|
||||
type: string
|
||||
- jsonPath: .status.addresses[*].address
|
||||
name: Addresses
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
name: v1alpha1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: |-
|
||||
IPAddressClaim is a namespaced request for an address — the whole
|
||||
tenant-facing API, the PersistentVolumeClaim of the address model.
|
||||
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: IPAddressClaimSpec defines the desired state of IPAddressClaim.
|
||||
properties:
|
||||
addressName:
|
||||
description: |-
|
||||
addressName pins the claim to a specific Available IPAddress instead
|
||||
of letting the controller match or the driver provision one — the
|
||||
analogue of PersistentVolumeClaim.spec.volumeName. Only meaningful
|
||||
for single-family claims.
|
||||
type: string
|
||||
className:
|
||||
description: |-
|
||||
className names the IPAddressClass to draw from. Empty means the
|
||||
default class (the one annotated
|
||||
ipaddressclass.local.sdn.cozystack.io/is-default-class: "true").
|
||||
type: string
|
||||
family:
|
||||
default: IPv4
|
||||
description: family selects the IP families requested.
|
||||
enum:
|
||||
- IPv4
|
||||
- IPv6
|
||||
- Dual
|
||||
type: string
|
||||
type: object
|
||||
status:
|
||||
description: IPAddressClaimStatus defines the observed state of IPAddressClaim.
|
||||
properties:
|
||||
addresses:
|
||||
description: |-
|
||||
addresses lists the bound addresses. A list deliberately: a Dual
|
||||
claim binds a v4 and a v6 IPAddress and must report both. For a
|
||||
single-family claim the list has one entry.
|
||||
items:
|
||||
description: BoundAddress reports one IPAddress bound to the claim.
|
||||
properties:
|
||||
address:
|
||||
description: address is the IP itself — what the tenant reads
|
||||
and puts in DNS.
|
||||
type: string
|
||||
name:
|
||||
description: name of the bound IPAddress object.
|
||||
type: string
|
||||
required:
|
||||
- address
|
||||
- name
|
||||
type: object
|
||||
type: array
|
||||
className:
|
||||
description: |-
|
||||
className is the class the claim resolved to. For claims created
|
||||
without a className it records which default class was picked; the
|
||||
resolution is sticky.
|
||||
type: string
|
||||
conditions:
|
||||
description: |-
|
||||
conditions represent the latest available observations of the
|
||||
claim's state.
|
||||
items:
|
||||
description: Condition contains details for one aspect of the current
|
||||
state of this API Resource.
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
description: |-
|
||||
lastTransitionTime is the last time the condition transitioned from one status to another.
|
||||
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
|
||||
format: date-time
|
||||
type: string
|
||||
message:
|
||||
description: |-
|
||||
message is a human readable message indicating details about the transition.
|
||||
This may be an empty string.
|
||||
maxLength: 32768
|
||||
type: string
|
||||
observedGeneration:
|
||||
description: |-
|
||||
observedGeneration represents the .metadata.generation that the condition was set based upon.
|
||||
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
|
||||
with respect to the current state of the instance.
|
||||
format: int64
|
||||
minimum: 0
|
||||
type: integer
|
||||
reason:
|
||||
description: |-
|
||||
reason contains a programmatic identifier indicating the reason for the condition's last transition.
|
||||
Producers of specific condition types may define expected values and meanings for this field,
|
||||
and whether the values are considered a guaranteed API.
|
||||
The value should be a CamelCase string.
|
||||
This field may not be empty.
|
||||
maxLength: 1024
|
||||
minLength: 1
|
||||
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
|
||||
type: string
|
||||
status:
|
||||
description: status of the condition, one of True, False, Unknown.
|
||||
enum:
|
||||
- "True"
|
||||
- "False"
|
||||
- Unknown
|
||||
type: string
|
||||
type:
|
||||
description: type of condition in CamelCase or in foo.example.com/CamelCase.
|
||||
maxLength: 316
|
||||
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
|
||||
type: string
|
||||
required:
|
||||
- lastTransitionTime
|
||||
- message
|
||||
- reason
|
||||
- status
|
||||
- type
|
||||
type: object
|
||||
type: array
|
||||
x-kubernetes-list-map-keys:
|
||||
- type
|
||||
x-kubernetes-list-type: map
|
||||
phase:
|
||||
description: phase is the current lifecycle phase of the claim.
|
||||
enum:
|
||||
- Pending
|
||||
- Bound
|
||||
- Lost
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.1
|
||||
name: ipaddressclasses.local.sdn.cozystack.io
|
||||
spec:
|
||||
group: local.sdn.cozystack.io
|
||||
names:
|
||||
kind: IPAddressClass
|
||||
listKind: IPAddressClassList
|
||||
plural: ipaddressclasses
|
||||
singular: ipaddressclass
|
||||
scope: Cluster
|
||||
versions:
|
||||
- additionalPrinterColumns:
|
||||
- jsonPath: .spec.provisioner
|
||||
name: Provisioner
|
||||
type: string
|
||||
- jsonPath: .spec.reclaimPolicy
|
||||
name: ReclaimPolicy
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
name: v1alpha1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: |-
|
||||
IPAddressClass describes an address source: which pool, which driver.
|
||||
It is the StorageClass of the address model. Marking a class with the
|
||||
annotation ipaddressclass.local.sdn.cozystack.io/is-default-class: "true"
|
||||
makes it the class for claims that do not name one.
|
||||
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: IPAddressClassSpec defines the desired state of IPAddressClass.
|
||||
properties:
|
||||
parameters:
|
||||
description: |-
|
||||
parameters is an opaque, driver-specific configuration blob (for
|
||||
example the address ranges to carve from). The core controller never
|
||||
interprets it.
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
provisioner:
|
||||
description: |-
|
||||
provisioner names the per-class driver that fulfils claims of this
|
||||
class, exactly as StorageClass.provisioner names a CSI driver. The
|
||||
core controller never provisions addresses itself; it stamps this
|
||||
value onto pending claims so the named driver can pick them up.
|
||||
minLength: 1
|
||||
type: string
|
||||
x-kubernetes-validations:
|
||||
- message: provisioner is immutable
|
||||
rule: self == oldSelf
|
||||
reclaimPolicy:
|
||||
default: Retain
|
||||
description: |-
|
||||
reclaimPolicy is copied to IPAddress objects provisioned for this
|
||||
class and governs what happens to them when their claim is deleted.
|
||||
enum:
|
||||
- Retain
|
||||
- Delete
|
||||
type: string
|
||||
releaseDelay:
|
||||
description: |-
|
||||
releaseDelay, under reclaimPolicy Retain, returns a Released address
|
||||
of this class to Available once it has been Released this long: the
|
||||
core controller clears its claimRef. Unset keeps a Released address
|
||||
until an admin clears it. An address annotated
|
||||
ipaddress.local.sdn.cozystack.io/held: "true" is exempt.
|
||||
type: string
|
||||
required:
|
||||
- provisioner
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources: {}
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.17.1
|
||||
name: ipaddresses.local.sdn.cozystack.io
|
||||
spec:
|
||||
group: local.sdn.cozystack.io
|
||||
names:
|
||||
kind: IPAddress
|
||||
listKind: IPAddressList
|
||||
plural: ipaddresses
|
||||
singular: ipaddress
|
||||
scope: Cluster
|
||||
versions:
|
||||
- additionalPrinterColumns:
|
||||
- jsonPath: .spec.address
|
||||
name: Address
|
||||
type: string
|
||||
- jsonPath: .spec.className
|
||||
name: Class
|
||||
type: string
|
||||
- jsonPath: .status.phase
|
||||
name: Phase
|
||||
type: string
|
||||
- jsonPath: .spec.claimRef.namespace
|
||||
name: ClaimNamespace
|
||||
type: string
|
||||
- jsonPath: .spec.claimRef.name
|
||||
name: Claim
|
||||
type: string
|
||||
- jsonPath: .status.associatedTo.name
|
||||
name: AttachedTo
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
name: v1alpha1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: |-
|
||||
IPAddress is a concrete address the cluster owns — the inventory object,
|
||||
the PersistentVolume of the address model. Created by a per-class driver
|
||||
(or an admin, for static pre-provisioning), never by tenants.
|
||||
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: IPAddressSpec defines the desired state of IPAddress.
|
||||
properties:
|
||||
address:
|
||||
description: |-
|
||||
address is the IP address itself, in canonical textual form
|
||||
(e.g. "203.0.113.7" or "2001:db8::7").
|
||||
minLength: 1
|
||||
type: string
|
||||
x-kubernetes-validations:
|
||||
- message: address is immutable
|
||||
rule: self == oldSelf
|
||||
claimRef:
|
||||
description: |-
|
||||
claimRef binds this address to a claim. Set either by the driver at
|
||||
provisioning time (pre-bound) or by the core controller when it
|
||||
matches an Available address to a claim. An address with no claimRef
|
||||
is Available. After a Retain reclaim the field survives the claim
|
||||
(phase Released) until an admin clears it.
|
||||
properties:
|
||||
name:
|
||||
description: name of the claim.
|
||||
minLength: 1
|
||||
type: string
|
||||
namespace:
|
||||
description: namespace of the claim.
|
||||
minLength: 1
|
||||
type: string
|
||||
uid:
|
||||
description: |-
|
||||
uid of the claim. A driver pre-binding an address may leave it empty;
|
||||
the core controller completes it when it accepts the binding.
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- namespace
|
||||
type: object
|
||||
className:
|
||||
description: className names the IPAddressClass this address belongs
|
||||
to.
|
||||
minLength: 1
|
||||
type: string
|
||||
reclaimPolicy:
|
||||
default: Retain
|
||||
description: |-
|
||||
reclaimPolicy governs what happens to this object when its claim is
|
||||
deleted; copied from the class at provisioning time.
|
||||
enum:
|
||||
- Retain
|
||||
- Delete
|
||||
type: string
|
||||
source:
|
||||
description: source records where the address came from.
|
||||
properties:
|
||||
fromClass:
|
||||
description: fromClass marks the address as allocated from the
|
||||
class's range.
|
||||
type: object
|
||||
providerRef:
|
||||
description: |-
|
||||
providerRef marks the address as adopted from a provider-side
|
||||
reservation.
|
||||
properties:
|
||||
id:
|
||||
description: |-
|
||||
id is the provider-side stable handle of the reservation, for example
|
||||
an AWS allocation id ("eipalloc-0a1b...").
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
type: object
|
||||
x-kubernetes-validations:
|
||||
- message: exactly one of fromClass or providerRef must be set
|
||||
rule: '(has(self.fromClass) ? 1 : 0) + (has(self.providerRef) ?
|
||||
1 : 0) == 1'
|
||||
required:
|
||||
- address
|
||||
- className
|
||||
- source
|
||||
type: object
|
||||
status:
|
||||
description: IPAddressStatus defines the observed state of IPAddress.
|
||||
properties:
|
||||
associatedTo:
|
||||
description: |-
|
||||
associatedTo names the workload the address is currently announced
|
||||
for. Nil means reserved but inert. Maintained by the per-class
|
||||
driver, never by the core controller.
|
||||
properties:
|
||||
kind:
|
||||
description: kind of the associated object, e.g. "Service".
|
||||
minLength: 1
|
||||
type: string
|
||||
name:
|
||||
description: name of the associated object.
|
||||
minLength: 1
|
||||
type: string
|
||||
namespace:
|
||||
description: namespace of the associated object.
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- kind
|
||||
- name
|
||||
- namespace
|
||||
type: object
|
||||
conditions:
|
||||
description: |-
|
||||
conditions represent the latest available observations of the
|
||||
address's state.
|
||||
items:
|
||||
description: Condition contains details for one aspect of the current
|
||||
state of this API Resource.
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
description: |-
|
||||
lastTransitionTime is the last time the condition transitioned from one status to another.
|
||||
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
|
||||
format: date-time
|
||||
type: string
|
||||
message:
|
||||
description: |-
|
||||
message is a human readable message indicating details about the transition.
|
||||
This may be an empty string.
|
||||
maxLength: 32768
|
||||
type: string
|
||||
observedGeneration:
|
||||
description: |-
|
||||
observedGeneration represents the .metadata.generation that the condition was set based upon.
|
||||
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
|
||||
with respect to the current state of the instance.
|
||||
format: int64
|
||||
minimum: 0
|
||||
type: integer
|
||||
reason:
|
||||
description: |-
|
||||
reason contains a programmatic identifier indicating the reason for the condition's last transition.
|
||||
Producers of specific condition types may define expected values and meanings for this field,
|
||||
and whether the values are considered a guaranteed API.
|
||||
The value should be a CamelCase string.
|
||||
This field may not be empty.
|
||||
maxLength: 1024
|
||||
minLength: 1
|
||||
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
|
||||
type: string
|
||||
status:
|
||||
description: status of the condition, one of True, False, Unknown.
|
||||
enum:
|
||||
- "True"
|
||||
- "False"
|
||||
- Unknown
|
||||
type: string
|
||||
type:
|
||||
description: type of condition in CamelCase or in foo.example.com/CamelCase.
|
||||
maxLength: 316
|
||||
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
|
||||
type: string
|
||||
required:
|
||||
- lastTransitionTime
|
||||
- message
|
||||
- reason
|
||||
- status
|
||||
- type
|
||||
type: object
|
||||
type: array
|
||||
x-kubernetes-list-map-keys:
|
||||
- type
|
||||
x-kubernetes-list-type: map
|
||||
phase:
|
||||
description: phase is the current lifecycle phase of the address.
|
||||
enum:
|
||||
- Pending
|
||||
- Available
|
||||
- Bound
|
||||
- Released
|
||||
- Conflict
|
||||
- Lost
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -0,0 +1,15 @@
|
||||
{{/* Common metadata labels (not used as selectors — selectors stay stable). */}}
|
||||
{{- define "address-controller.labels" -}}
|
||||
app.kubernetes.io/name: address-controller
|
||||
app.kubernetes.io/part-of: address-controller
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
helm.sh/chart: {{ printf "address-controller-%s" .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* imagePullSecrets block, rendered only when set. Call with the root context. */}}
|
||||
{{- define "address-controller.imagePullSecrets" -}}
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
{{- /* Optional admission policy (proposal, Security: "spec.addressName cannot
|
||||
be checked in CEL"): only allowlisted principals may set, change or
|
||||
remove IPAddressClaim.spec.addressName, which binds one specific
|
||||
Available address and so lets its writer pick an address out of a
|
||||
class. Writes that leave the field as it was are always admitted. */ -}}
|
||||
{{- if .Values.admissionPolicy.enabled }}
|
||||
---
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: ValidatingAdmissionPolicy
|
||||
metadata:
|
||||
name: address-controller-claim-address-name
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
spec:
|
||||
failurePolicy: Fail
|
||||
matchConstraints:
|
||||
resourceRules:
|
||||
- apiGroups: ["local.sdn.cozystack.io"]
|
||||
apiVersions: ["v1alpha1"]
|
||||
operations: ["CREATE", "UPDATE"]
|
||||
resources: ["ipaddressclaims"]
|
||||
matchConditions:
|
||||
- name: not-allowlisted
|
||||
expression: >-
|
||||
!(request.userInfo.username in {{ toJson .Values.admissionPolicy.allowedUsernames }}) &&
|
||||
!(has(request.userInfo.groups) &&
|
||||
request.userInfo.groups.exists(g, g in {{ toJson .Values.admissionPolicy.allowedGroups }}))
|
||||
variables:
|
||||
- name: oldAddressName
|
||||
expression: >-
|
||||
request.operation == "UPDATE" && has(oldObject.spec.addressName)
|
||||
? oldObject.spec.addressName : ""
|
||||
- name: newAddressName
|
||||
expression: >-
|
||||
has(object.spec.addressName) ? object.spec.addressName : ""
|
||||
validations:
|
||||
- expression: variables.newAddressName == variables.oldAddressName
|
||||
message: >-
|
||||
spec.addressName is reserved to the platform; create the claim without it
|
||||
and the class assigns an address
|
||||
reason: Forbidden
|
||||
---
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: ValidatingAdmissionPolicyBinding
|
||||
metadata:
|
||||
name: address-controller-claim-address-name
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
spec:
|
||||
policyName: address-controller-claim-address-name
|
||||
validationActions: {{ toJson .Values.admissionPolicy.validationActions }}
|
||||
matchResources:
|
||||
namespaceSelector:
|
||||
{{- toYaml .Values.admissionPolicy.namespaceSelector | nindent 6 }}
|
||||
{{- end }}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
{{- /* The ClusterRole lives in templates/role.yaml, GENERATED by controller-gen
|
||||
from the +kubebuilder:rbac markers (make manifests). Everything
|
||||
deployment-shaped is hand-written here. */ -}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: address-controller
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: address-controller
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: address-controller
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: address-controller
|
||||
namespace: {{ .Release.Namespace }}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: address-controller
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: address-controller
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.controller.replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: address-controller
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: address-controller
|
||||
spec:
|
||||
serviceAccountName: address-controller
|
||||
{{- with .Values.controller.priorityClassName }}
|
||||
priorityClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- include "address-controller.imagePullSecrets" . | nindent 6 }}
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: controller
|
||||
image: {{ .Values.image }}
|
||||
imagePullPolicy: {{ .Values.imagePullPolicy }}
|
||||
args:
|
||||
- --leader-elect={{ .Values.controller.leaderElect }}
|
||||
- --metrics-bind-address={{ if .Values.metrics.enabled }}:8443{{ else }}{{ .Values.controller.metricsBindAddress }}{{ end }}
|
||||
- --health-probe-bind-address=:8081
|
||||
{{- if .Values.metrics.enabled }}
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 8443
|
||||
{{- end }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
resources:
|
||||
{{- toYaml .Values.controller.resources | nindent 12 }}
|
||||
livenessProbe:
|
||||
httpGet: { path: /healthz, port: 8081 }
|
||||
initialDelaySeconds: 10
|
||||
readinessProbe:
|
||||
httpGet: { path: /readyz, port: 8081 }
|
||||
@@ -0,0 +1,121 @@
|
||||
{{- if .Values.metrics.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: address-controller-metrics
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: address-controller-metrics
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
spec:
|
||||
selector:
|
||||
app: address-controller
|
||||
ports:
|
||||
- name: metrics
|
||||
port: 8443
|
||||
targetPort: metrics
|
||||
---
|
||||
# Lets the controller authenticate and authorize scrape requests.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: address-controller-metrics-auth
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups: ["authentication.k8s.io"]
|
||||
resources: ["tokenreviews"]
|
||||
verbs: ["create"]
|
||||
- apiGroups: ["authorization.k8s.io"]
|
||||
resources: ["subjectaccessreviews"]
|
||||
verbs: ["create"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: address-controller-metrics-auth
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: address-controller-metrics-auth
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: address-controller
|
||||
namespace: {{ .Release.Namespace }}
|
||||
---
|
||||
# Bind a scraper's identity to this role to let it read the metrics.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: address-controller-metrics-reader
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- nonResourceURLs: ["/metrics"]
|
||||
verbs: ["get"]
|
||||
{{- if and .Values.metrics.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor") }}
|
||||
---
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: address-controller
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
{{- with .Values.metrics.serviceMonitor.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: address-controller-metrics
|
||||
endpoints:
|
||||
- port: metrics
|
||||
scheme: https
|
||||
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
tlsConfig:
|
||||
# The controller serves a self-signed certificate.
|
||||
insecureSkipVerify: true
|
||||
{{- end }}
|
||||
{{- if and .Values.metrics.prometheusRule.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/PrometheusRule") }}
|
||||
---
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
name: address-controller
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "address-controller.labels" . | nindent 4 }}
|
||||
spec:
|
||||
groups:
|
||||
- name: address-controller
|
||||
rules:
|
||||
- alert: IPAddressConflict
|
||||
expr: sum by (class) (address_controller_ipaddresses{phase="Conflict"}) > 0
|
||||
for: 5m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: "{{ "{{ $value }}" }} IPAddress(es) of class {{ "{{ $labels.class }}" }} in Conflict"
|
||||
description: A Service holds an address that its binding does not authorize. kubectl get ipaddresses names the offender.
|
||||
- alert: IPAddressLost
|
||||
expr: sum by (class) (address_controller_ipaddresses{phase="Lost"}) > 0
|
||||
for: 5m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: "{{ "{{ $value }}" }} IPAddress(es) of class {{ "{{ $labels.class }}" }} Lost"
|
||||
description: The backend no longer holds a reserved address. Its claim reports Lost until the address is restored or deleted.
|
||||
- alert: IPAddressClaimPending
|
||||
expr: sum by (namespace, class) (address_controller_ipaddressclaims{phase="Pending"}) > 0
|
||||
for: 15m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: "{{ "{{ $value }}" }} IPAddressClaim(s) in {{ "{{ $labels.namespace }}" }} Pending for 15m"
|
||||
description: The claim's class may be exhausted, missing or refused by its driver. kubectl describe on the claim shows why.
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: address-controller
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- events
|
||||
verbs:
|
||||
- create
|
||||
- patch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- services
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- services/finalizers
|
||||
verbs:
|
||||
- update
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- local.sdn.cozystack.io
|
||||
resources:
|
||||
- ipaddressclaims
|
||||
verbs:
|
||||
- create
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- local.sdn.cozystack.io
|
||||
resources:
|
||||
- ipaddressclaims/finalizers
|
||||
- ipaddressclasses/finalizers
|
||||
- ipaddresses/finalizers
|
||||
verbs:
|
||||
- update
|
||||
- apiGroups:
|
||||
- local.sdn.cozystack.io
|
||||
resources:
|
||||
- ipaddressclaims/status
|
||||
- ipaddresses/status
|
||||
verbs:
|
||||
- get
|
||||
- patch
|
||||
- update
|
||||
- apiGroups:
|
||||
- local.sdn.cozystack.io
|
||||
resources:
|
||||
- ipaddressclasses
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- local.sdn.cozystack.io
|
||||
resources:
|
||||
- ipaddresses
|
||||
verbs:
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
@@ -0,0 +1,61 @@
|
||||
# Container image for the core controller.
|
||||
image: ghcr.io/cozystack/address-controller:main
|
||||
imagePullPolicy: IfNotPresent
|
||||
imagePullSecrets: []
|
||||
|
||||
controller:
|
||||
replicas: 1
|
||||
# Leader election matters once replicas > 1, but is on by default so scaling
|
||||
# up is safe without a config change.
|
||||
leaderElect: true
|
||||
# ":8443" (HTTPS) or ":8080" (HTTP) to expose controller-runtime metrics;
|
||||
# "0" disables the endpoint.
|
||||
metricsBindAddress: "0"
|
||||
priorityClassName: ""
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
memory: 128Mi
|
||||
|
||||
metrics:
|
||||
# Serve controller-runtime and inventory metrics (address_controller_*)
|
||||
# over HTTPS on 8443, behind the Service address-controller-metrics.
|
||||
# Requests are authenticated and authorized against the API server, so a
|
||||
# scraper needs GET on the /metrics non-resource URL: bind its identity
|
||||
# to the address-controller-metrics-reader ClusterRole. Overrides
|
||||
# controller.metricsBindAddress.
|
||||
enabled: false
|
||||
serviceMonitor:
|
||||
# A monitoring.coreos.com ServiceMonitor for the Service; rendered only
|
||||
# where that API exists. The scraping Prometheus's ServiceAccount still
|
||||
# needs a ClusterRoleBinding to address-controller-metrics-reader, which
|
||||
# the chart cannot create without knowing that ServiceAccount.
|
||||
enabled: false
|
||||
# Extra labels on the ServiceMonitor, e.g. to match a Prometheus
|
||||
# serviceMonitorSelector.
|
||||
labels: {}
|
||||
prometheusRule:
|
||||
# Alerts on Conflict and Lost addresses and on long-Pending claims;
|
||||
# rendered only where monitoring.coreos.com exists.
|
||||
enabled: false
|
||||
|
||||
# Optional ValidatingAdmissionPolicy reserving IPAddressClaim.spec.addressName,
|
||||
# which binds one specific Available address of a class, to the principals
|
||||
# below. Writes that leave the field as it was are always admitted. In a
|
||||
# brokered deployment, allowlist the machinery that moves addresses between
|
||||
# namespaces.
|
||||
admissionPolicy:
|
||||
enabled: false
|
||||
# [Deny], or e.g. [Warn, Audit] to observe what would be denied first.
|
||||
validationActions: [Deny]
|
||||
# Namespaces the policy applies to; scope it to tenant namespaces.
|
||||
namespaceSelector: {}
|
||||
# Admission policies bind system:masters too, so cluster admins must be
|
||||
# listed; kubeadm since 1.29 issues admin credentials in
|
||||
# kubeadm:cluster-admins instead.
|
||||
allowedUsernames: []
|
||||
allowedGroups:
|
||||
- system:masters
|
||||
- kubeadm:cluster-admins
|
||||
@@ -0,0 +1,44 @@
|
||||
{{- /* Only IPAddressClaim is granted. IPAddress and IPAddressClass are
|
||||
cluster-scoped and cozy:tenant* reaches a tenant through a per-namespace
|
||||
RoleBinding, so a rule for either would never be consulted; a tenant
|
||||
reads the address it was given from its own claim's status.addresses[]. */ -}}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: cozy:addresses
|
||||
labels:
|
||||
rbac.cozystack.io/aggregate-to-tenant: "true"
|
||||
rules:
|
||||
- apiGroups: ["local.sdn.cozystack.io"]
|
||||
resources: ["ipaddressclaims"]
|
||||
verbs: ['*']
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: cozy:addresses:view
|
||||
labels:
|
||||
rbac.cozystack.io/aggregate-to-tenant-view: "true"
|
||||
rules:
|
||||
- apiGroups: ["local.sdn.cozystack.io"]
|
||||
resources: ["ipaddressclaims"]
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: cozy:addresses:admin
|
||||
labels:
|
||||
rbac.cozystack.io/aggregate-to-tenant-admin: "true"
|
||||
rules:
|
||||
- apiGroups: ["local.sdn.cozystack.io"]
|
||||
resources: ["ipaddressclaims"]
|
||||
verbs:
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
@@ -0,0 +1,57 @@
|
||||
suite: address-controller tenant ClusterRoles aggregate into the cozystack base roles
|
||||
|
||||
templates:
|
||||
- templates/tenant-clusterroles.yaml
|
||||
|
||||
release:
|
||||
name: address-controller
|
||||
namespace: cozy-address-controller
|
||||
|
||||
# The aggregation label is the whole wiring: cozy:tenant, cozy:tenant:view and
|
||||
# cozy:tenant:admin carry an aggregationRule selecting these, so a typo in a
|
||||
# label silently grants a tenant nothing and nothing else fails.
|
||||
tests:
|
||||
- it: the tenant ServiceAccount role manages claims and aggregates to cozy:tenant
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozy:addresses
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["rbac.cozystack.io/aggregate-to-tenant"]
|
||||
value: "true"
|
||||
- contains:
|
||||
path: rules
|
||||
content:
|
||||
apiGroups: ["local.sdn.cozystack.io"]
|
||||
resources: ["ipaddressclaims"]
|
||||
verbs: ['*']
|
||||
|
||||
- it: the view role reads claims and aggregates to cozy:tenant:view
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozy:addresses:view
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["rbac.cozystack.io/aggregate-to-tenant-view"]
|
||||
value: "true"
|
||||
- contains:
|
||||
path: rules
|
||||
content:
|
||||
apiGroups: ["local.sdn.cozystack.io"]
|
||||
resources: ["ipaddressclaims"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
|
||||
- it: the admin role writes claims and aggregates to cozy:tenant:admin
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozy:addresses:admin
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["rbac.cozystack.io/aggregate-to-tenant-admin"]
|
||||
value: "true"
|
||||
- contains:
|
||||
path: rules
|
||||
content:
|
||||
apiGroups: ["local.sdn.cozystack.io"]
|
||||
resources: ["ipaddressclaims"]
|
||||
verbs: ["create", "update", "patch", "delete"]
|
||||
@@ -0,0 +1,6 @@
|
||||
address-controller:
|
||||
# The chart's own default is the floating `:main` tag, which would let the
|
||||
# running controller change with no change in this tree. Pinned here rather
|
||||
# than in charts/, which `make update` regenerates. Bump in lockstep with
|
||||
# ADDRESS_CONTROLLER_REF in the Makefile.
|
||||
image: ghcr.io/cozystack/address-controller:main-90e65ca@sha256:74e4c7cf63f730ebe61527fdcd2b06e1bca2c383a66522dd4734aab9e66a9331
|
||||
@@ -0,0 +1,3 @@
|
||||
apiVersion: v2
|
||||
name: cozy-metallb-iad
|
||||
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
|
||||
@@ -0,0 +1,16 @@
|
||||
export NAME=metallb-iad
|
||||
export NAMESPACE=cozy-$(NAME)
|
||||
|
||||
include ../../../hack/package.mk
|
||||
|
||||
# Same pinning story as packages/system/address-controller.
|
||||
METALLB_IAD_REPO ?= https://github.com/cozystack/metallb-iad.git
|
||||
METALLB_IAD_REF ?= 2f983b67ed6ab86d745922a6bff9d89f18fc681d
|
||||
|
||||
update:
|
||||
rm -rf charts tmp-repo
|
||||
git clone --filter=tree:0 --no-checkout $(METALLB_IAD_REPO) tmp-repo
|
||||
git -C tmp-repo checkout --quiet $(METALLB_IAD_REF)
|
||||
mkdir -p charts
|
||||
cp -r tmp-repo/chart/metallb-iad charts/
|
||||
rm -rf tmp-repo
|
||||
@@ -0,0 +1,9 @@
|
||||
# Patterns to ignore when building packages.
|
||||
.DS_Store
|
||||
.git/
|
||||
.gitignore
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*.orig
|
||||
*~
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v2
|
||||
name: metallb-iad
|
||||
description: MetalLB IP Allocation Driver — the reference per-class driver for the address-controller core (local.sdn.cozystack.io)
|
||||
type: application
|
||||
version: 0.2.0
|
||||
appVersion: "0.2.0"
|
||||
kubeVersion: ">=1.29.0-0"
|
||||
keywords:
|
||||
- ipam
|
||||
- metallb
|
||||
- networking
|
||||
- cozystack
|
||||
home: https://github.com/cozystack/metallb-iad
|
||||
sources:
|
||||
- https://github.com/cozystack/metallb-iad
|
||||
@@ -0,0 +1,20 @@
|
||||
{{/* Common metadata labels (not used as selectors — selectors stay stable). */}}
|
||||
{{- define "metallb-iad.labels" -}}
|
||||
app.kubernetes.io/name: metallb-iad
|
||||
app.kubernetes.io/part-of: metallb-iad
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
helm.sh/chart: {{ printf "metallb-iad-%s" .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* The namespace reservation placeholders live in (defaults to the release namespace). */}}
|
||||
{{- define "metallb-iad.placeholderNamespace" -}}
|
||||
{{- default .Release.Namespace .Values.placeholderNamespace -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* imagePullSecrets block, rendered only when set. Call with the root context. */}}
|
||||
{{- define "metallb-iad.imagePullSecrets" -}}
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,85 @@
|
||||
{{- /* Optional admission layer (design doc §8): only the driver and allowlisted
|
||||
principals may set, change or remove the Service fields that steer
|
||||
MetalLB at a specific address or pool, or the driver's own markers.
|
||||
Writes that leave those fields as they were are always admitted. */ -}}
|
||||
{{- if .Values.admissionPolicy.enabled }}
|
||||
{{- $users := append .Values.admissionPolicy.allowedUsernames (printf "system:serviceaccount:%s:metallb-iad" .Release.Namespace) }}
|
||||
{{- $groups := .Values.admissionPolicy.allowedGroups }}
|
||||
---
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: ValidatingAdmissionPolicy
|
||||
metadata:
|
||||
name: metallb-iad-service-pins
|
||||
labels:
|
||||
{{- include "metallb-iad.labels" . | nindent 4 }}
|
||||
spec:
|
||||
failurePolicy: Fail
|
||||
matchConstraints:
|
||||
resourceRules:
|
||||
- apiGroups: [""]
|
||||
apiVersions: ["v1"]
|
||||
operations: ["CREATE", "UPDATE"]
|
||||
resources: ["services"]
|
||||
matchConditions:
|
||||
- name: not-allowlisted
|
||||
expression: >-
|
||||
!(request.userInfo.username in {{ toJson $users }}) &&
|
||||
!(has(request.userInfo.groups) &&
|
||||
request.userInfo.groups.exists(g, g in {{ toJson $groups }}))
|
||||
variables:
|
||||
- name: protectedKeys
|
||||
expression: >-
|
||||
[
|
||||
"metallb.io/loadBalancerIPs",
|
||||
"metallb.io/address-pool",
|
||||
"metallb.io/allow-shared-ip",
|
||||
"metallb.universe.tf/loadBalancerIPs",
|
||||
"metallb.universe.tf/address-pool",
|
||||
"metallb.universe.tf/allow-shared-ip",
|
||||
"metallb.drivers.local.sdn.cozystack.io/pinned"
|
||||
]
|
||||
- name: oldAnnotations
|
||||
expression: >-
|
||||
request.operation == "UPDATE" && has(oldObject.metadata.annotations)
|
||||
? oldObject.metadata.annotations : {}
|
||||
- name: newAnnotations
|
||||
expression: >-
|
||||
has(object.metadata.annotations) ? object.metadata.annotations : {}
|
||||
- name: changedKeys
|
||||
expression: >-
|
||||
variables.protectedKeys.filter(k,
|
||||
(k in variables.newAnnotations) != (k in variables.oldAnnotations) ||
|
||||
(k in variables.newAnnotations && variables.newAnnotations[k] != variables.oldAnnotations[k]))
|
||||
- name: oldLoadBalancerIP
|
||||
expression: >-
|
||||
request.operation == "UPDATE" && has(oldObject.spec.loadBalancerIP)
|
||||
? oldObject.spec.loadBalancerIP : ""
|
||||
- name: newLoadBalancerIP
|
||||
expression: >-
|
||||
has(object.spec.loadBalancerIP) ? object.spec.loadBalancerIP : ""
|
||||
validations:
|
||||
- expression: size(variables.changedKeys) == 0
|
||||
messageExpression: >-
|
||||
"Service annotations " + variables.changedKeys.join(", ") +
|
||||
" are reserved to the address driver; reserve an IPAddressClaim and name it" +
|
||||
" with local.sdn.cozystack.io/ip-address-claim instead"
|
||||
reason: Forbidden
|
||||
- expression: variables.newLoadBalancerIP == variables.oldLoadBalancerIP
|
||||
message: >-
|
||||
spec.loadBalancerIP is reserved to the address driver; reserve an
|
||||
IPAddressClaim and name it with local.sdn.cozystack.io/ip-address-claim instead
|
||||
reason: Forbidden
|
||||
---
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: ValidatingAdmissionPolicyBinding
|
||||
metadata:
|
||||
name: metallb-iad-service-pins
|
||||
labels:
|
||||
{{- include "metallb-iad.labels" . | nindent 4 }}
|
||||
spec:
|
||||
policyName: metallb-iad-service-pins
|
||||
validationActions: {{ toJson .Values.admissionPolicy.validationActions }}
|
||||
matchResources:
|
||||
namespaceSelector:
|
||||
{{- toYaml .Values.admissionPolicy.namespaceSelector | nindent 6 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,86 @@
|
||||
{{- /* The ClusterRole lives in templates/role.yaml, GENERATED by controller-gen
|
||||
from the +kubebuilder:rbac markers (make manifests). Everything
|
||||
deployment-shaped is hand-written here. */ -}}
|
||||
{{- if ne (include "metallb-iad.placeholderNamespace" .) .Release.Namespace }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: {{ include "metallb-iad.placeholderNamespace" . }}
|
||||
labels:
|
||||
{{- include "metallb-iad.labels" . | nindent 4 }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: metallb-iad
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "metallb-iad.labels" . | nindent 4 }}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: metallb-iad
|
||||
labels:
|
||||
{{- include "metallb-iad.labels" . | nindent 4 }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: metallb-iad
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: metallb-iad
|
||||
namespace: {{ .Release.Namespace }}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: metallb-iad
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: metallb-iad
|
||||
{{- include "metallb-iad.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.controller.replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: metallb-iad
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: metallb-iad
|
||||
spec:
|
||||
serviceAccountName: metallb-iad
|
||||
{{- with .Values.controller.priorityClassName }}
|
||||
priorityClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- include "metallb-iad.imagePullSecrets" . | nindent 6 }}
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: driver
|
||||
image: {{ .Values.image }}
|
||||
imagePullPolicy: {{ .Values.imagePullPolicy }}
|
||||
args:
|
||||
- --metallb-namespace={{ .Values.metallbNamespace }}
|
||||
- --placeholder-namespace={{ include "metallb-iad.placeholderNamespace" . }}
|
||||
- --lb-class={{ .Values.loadBalancerClass }}
|
||||
- --leader-elect={{ .Values.controller.leaderElect }}
|
||||
- --metrics-bind-address={{ .Values.controller.metricsBindAddress }}
|
||||
- --health-probe-bind-address=:8081
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
resources:
|
||||
{{- toYaml .Values.controller.resources | nindent 12 }}
|
||||
livenessProbe:
|
||||
httpGet: { path: /healthz, port: 8081 }
|
||||
initialDelaySeconds: 10
|
||||
readinessProbe:
|
||||
httpGet: { path: /readyz, port: 8081 }
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: metallb-iad
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- events
|
||||
verbs:
|
||||
- create
|
||||
- patch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- services
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- local.sdn.cozystack.io
|
||||
resources:
|
||||
- ipaddressclaims
|
||||
- ipaddressclasses
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- local.sdn.cozystack.io
|
||||
resources:
|
||||
- ipaddresses
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- local.sdn.cozystack.io
|
||||
resources:
|
||||
- ipaddresses/status
|
||||
verbs:
|
||||
- get
|
||||
- patch
|
||||
- update
|
||||
- apiGroups:
|
||||
- metallb.io
|
||||
resources:
|
||||
- ipaddresspools
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
@@ -0,0 +1,59 @@
|
||||
# Container image for the driver.
|
||||
image: ghcr.io/cozystack/metallb-iad:main
|
||||
imagePullPolicy: IfNotPresent
|
||||
imagePullSecrets: []
|
||||
|
||||
# Namespace MetalLB is installed in. The IPAddressPools that classes name
|
||||
# (parameters.pool) are looked up here.
|
||||
metallbNamespace: metallb-system
|
||||
|
||||
# The --lb-class of the MetalLB instance this driver fronts. Empty for a
|
||||
# MetalLB that serves Services without a loadBalancerClass, the cluster
|
||||
# default. Placeholders carry it as spec.loadBalancerClass.
|
||||
loadBalancerClass: ""
|
||||
|
||||
# Namespace the reservation placeholder Services live in. Empty means the
|
||||
# release namespace. Tenants must have no write access to it: a Service
|
||||
# carrying the placeholder label is exempt from conflict detection only
|
||||
# inside this namespace, so whoever can create Services there can hold
|
||||
# addresses. Setting it to anything other than the release namespace renders
|
||||
# a Namespace object as part of the chart.
|
||||
placeholderNamespace: ""
|
||||
|
||||
controller:
|
||||
replicas: 1
|
||||
# Leader election matters once replicas > 1, but is on by default so scaling
|
||||
# up is safe without a config change.
|
||||
leaderElect: true
|
||||
# ":8443" (HTTPS) or ":8080" (HTTP) to expose controller-runtime metrics;
|
||||
# "0" disables the endpoint.
|
||||
metricsBindAddress: "0"
|
||||
priorityClassName: ""
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
memory: 128Mi
|
||||
|
||||
# Optional ValidatingAdmissionPolicy reserving the Service fields that steer
|
||||
# MetalLB at a specific address or pool — the metallb.io/ (and legacy
|
||||
# metallb.universe.tf/) loadBalancerIPs, address-pool and allow-shared-ip
|
||||
# annotations, spec.loadBalancerIP — and the driver's own pinned marker.
|
||||
# Only the driver's ServiceAccount and the principals below may set, change
|
||||
# or remove them; writes that leave them as they were are always admitted.
|
||||
admissionPolicy:
|
||||
enabled: false
|
||||
# [Deny], or e.g. [Warn, Audit] to observe what would be denied first.
|
||||
validationActions: [Deny]
|
||||
# Namespaces the policy applies to. Scope it to tenant namespaces when
|
||||
# platform components elsewhere set these annotations themselves.
|
||||
namespaceSelector: {}
|
||||
# Usernames and groups exempt in addition to the driver's ServiceAccount.
|
||||
# Admission policies bind system:masters too, so cluster admins must be
|
||||
# listed; kubeadm since 1.29 issues admin credentials in
|
||||
# kubeadm:cluster-admins instead.
|
||||
allowedUsernames: []
|
||||
allowedGroups:
|
||||
- system:masters
|
||||
- kubeadm:cluster-admins
|
||||
@@ -0,0 +1,23 @@
|
||||
metallb-iad:
|
||||
# Cozystack runs MetalLB in cozy-metallb, not the chart's upstream default of
|
||||
# metallb-system; classes name their IPAddressPool in this namespace.
|
||||
metallbNamespace: cozy-metallb
|
||||
# Same digest pin as packages/system/address-controller; bump in lockstep
|
||||
# with METALLB_IAD_REF in the Makefile.
|
||||
image: ghcr.io/cozystack/metallb-iad:main-1faf937@sha256:a2a8b05a887f9f28927d75f8b57e264be40e8770d0177798b4f06a0f69c3e793
|
||||
# Reserve MetalLB's pool, pin and sharing inputs on tenant Services to the
|
||||
# driver. A tenant that could set them could steer MetalLB at an address
|
||||
# reserved for someone else. Every tenant namespace, tenant-root included,
|
||||
# and nothing else carries namespace.cozystack.io/host, so platform
|
||||
# components that set these fields in cozy-* namespaces are unaffected.
|
||||
admissionPolicy:
|
||||
enabled: true
|
||||
namespaceSelector:
|
||||
matchExpressions:
|
||||
- key: namespace.cozystack.io/host
|
||||
operator: Exists
|
||||
# A values list replaces the chart's defaults rather than extending them.
|
||||
allowedGroups:
|
||||
- system:masters
|
||||
- kubeadm:cluster-admins
|
||||
- cozystack-cluster-admin
|
||||
Reference in new issue
Block a user