diff --git a/api/apps/v1alpha1/harbor/types.go b/api/apps/v1alpha1/harbor/types.go index d5638214e..def139016 100644 --- a/api/apps/v1alpha1/harbor/types.go +++ b/api/apps/v1alpha1/harbor/types.go @@ -27,6 +27,12 @@ type ConfigSpec struct { // +kubebuilder:default:="" // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="storageClass is immutable" StorageClass string `json:"storageClass"` + // Entry-point proxy configuration. + // +kubebuilder:default:={} + Nginx Nginx `json:"nginx"` + // Web portal configuration. + // +kubebuilder:default:={} + Portal Portal `json:"portal"` // Core API server configuration. // +kubebuilder:default:={} Core Core `json:"core"` @@ -48,6 +54,11 @@ type ConfigSpec struct { } type Core struct { + // Number of core replicas, which issue the token every pull and push needs. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. + // +kubebuilder:default:=1 + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=2.147483647e+09 + Replicas int `json:"replicas,omitempty"` // Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. // +kubebuilder:default:={} Resources Resources `json:"resources,omitempty"` @@ -57,7 +68,7 @@ type Core struct { } type Database struct { - // Number of database instances. + // Number of database instances. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset. // +kubebuilder:default:=2 Replicas int `json:"replicas"` // Persistent Volume size for database storage. @@ -74,8 +85,24 @@ type Jobservice struct { ResourcesPreset ResourcesPreset `json:"resourcesPreset,omitempty"` } +type Nginx struct { + // Number of replicas of the proxy every `docker login`, pull and push goes through. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. + // +kubebuilder:default:=1 + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=2.147483647e+09 + Replicas int `json:"replicas,omitempty"` +} + +type Portal struct { + // Number of web portal replicas. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. + // +kubebuilder:default:=1 + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=2.147483647e+09 + Replicas int `json:"replicas,omitempty"` +} + type Redis struct { - // Number of Redis replicas. + // Number of Redis replicas. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset; the three sentinels always are. // +kubebuilder:default:=2 Replicas int `json:"replicas"` // Persistent Volume size for cache storage. @@ -84,6 +111,11 @@ type Redis struct { } type Registry struct { + // Number of registry replicas; they share the S3 bucket and no local state. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. + // +kubebuilder:default:=1 + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=2.147483647e+09 + Replicas int `json:"replicas,omitempty"` // Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. // +kubebuilder:default:={} Resources Resources `json:"resources,omitempty"` diff --git a/api/apps/v1alpha1/harbor/zz_generated.deepcopy.go b/api/apps/v1alpha1/harbor/zz_generated.deepcopy.go index 8ff615ac2..c500a9c27 100644 --- a/api/apps/v1alpha1/harbor/zz_generated.deepcopy.go +++ b/api/apps/v1alpha1/harbor/zz_generated.deepcopy.go @@ -58,6 +58,8 @@ func (in *ConfigSpec) DeepCopyInto(out *ConfigSpec) { *out = make([]string, len(*in)) copy(*out, *in) } + out.Nginx = in.Nginx + out.Portal = in.Portal in.Core.DeepCopyInto(&out.Core) in.Registry.DeepCopyInto(&out.Registry) in.Jobservice.DeepCopyInto(&out.Jobservice) @@ -124,6 +126,36 @@ func (in *Jobservice) DeepCopy() *Jobservice { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Nginx) DeepCopyInto(out *Nginx) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Nginx. +func (in *Nginx) DeepCopy() *Nginx { + if in == nil { + return nil + } + out := new(Nginx) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Portal) DeepCopyInto(out *Portal) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Portal. +func (in *Portal) DeepCopy() *Portal { + if in == nil { + return nil + } + out := new(Portal) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Redis) DeepCopyInto(out *Redis) { *out = *in diff --git a/packages/apps/harbor/README.md b/packages/apps/harbor/README.md index 10d6e5a04..313beab44 100644 --- a/packages/apps/harbor/README.md +++ b/packages/apps/harbor/README.md @@ -29,34 +29,40 @@ Without object storage in the tenant chain, Harbor cannot provision its registry ### Component configuration -| Name | Description | Type | Value | -| ----------------------------- | -------------------------------------------------------------------------------------------------------- | ---------- | ---------- | -| `core` | Core API server configuration. | `object` | `{}` | -| `core.resources` | Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` | -| `core.resources.cpu` | Number of CPU cores allocated. | `quantity` | `""` | -| `core.resources.memory` | Amount of memory allocated. | `quantity` | `""` | -| `core.resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.small` | -| `registry` | Container image registry configuration. | `object` | `{}` | -| `registry.resources` | Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` | -| `registry.resources.cpu` | Number of CPU cores allocated. | `quantity` | `""` | -| `registry.resources.memory` | Amount of memory allocated. | `quantity` | `""` | -| `registry.resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.small` | -| `jobservice` | Background job service configuration. | `object` | `{}` | -| `jobservice.resources` | Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` | -| `jobservice.resources.cpu` | Number of CPU cores allocated. | `quantity` | `""` | -| `jobservice.resources.memory` | Amount of memory allocated. | `quantity` | `""` | -| `jobservice.resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.nano` | -| `trivy` | Trivy vulnerability scanner configuration. | `object` | `{}` | -| `trivy.enabled` | Enable or disable the vulnerability scanner. | `bool` | `true` | -| `trivy.size` | Persistent Volume size for vulnerability database cache. | `quantity` | `5Gi` | -| `trivy.resources` | Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` | -| `trivy.resources.cpu` | Number of CPU cores allocated. | `quantity` | `""` | -| `trivy.resources.memory` | Amount of memory allocated. | `quantity` | `""` | -| `trivy.resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.nano` | -| `database` | PostgreSQL database configuration. | `object` | `{}` | -| `database.size` | Persistent Volume size for database storage. | `quantity` | `5Gi` | -| `database.replicas` | Number of database instances. | `int` | `2` | -| `redis` | Redis cache configuration. | `object` | `{}` | -| `redis.size` | Persistent Volume size for cache storage. | `quantity` | `1Gi` | -| `redis.replicas` | Number of Redis replicas. | `int` | `2` | +| Name | Description | Type | Value | +| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------- | +| `nginx` | Entry-point proxy configuration. | `object` | `{}` | +| `nginx.replicas` | Number of replicas of the proxy every `docker login`, pull and push goes through. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. | `int` | `1` | +| `portal` | Web portal configuration. | `object` | `{}` | +| `portal.replicas` | Number of web portal replicas. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. | `int` | `1` | +| `core` | Core API server configuration. | `object` | `{}` | +| `core.replicas` | Number of core replicas, which issue the token every pull and push needs. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. | `int` | `1` | +| `core.resources` | Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` | +| `core.resources.cpu` | Number of CPU cores allocated. | `quantity` | `""` | +| `core.resources.memory` | Amount of memory allocated. | `quantity` | `""` | +| `core.resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.small` | +| `registry` | Container image registry configuration. | `object` | `{}` | +| `registry.replicas` | Number of registry replicas; they share the S3 bucket and no local state. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. | `int` | `1` | +| `registry.resources` | Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` | +| `registry.resources.cpu` | Number of CPU cores allocated. | `quantity` | `""` | +| `registry.resources.memory` | Amount of memory allocated. | `quantity` | `""` | +| `registry.resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.small` | +| `jobservice` | Background job service configuration. | `object` | `{}` | +| `jobservice.resources` | Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` | +| `jobservice.resources.cpu` | Number of CPU cores allocated. | `quantity` | `""` | +| `jobservice.resources.memory` | Amount of memory allocated. | `quantity` | `""` | +| `jobservice.resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.nano` | +| `trivy` | Trivy vulnerability scanner configuration. | `object` | `{}` | +| `trivy.enabled` | Enable or disable the vulnerability scanner. | `bool` | `true` | +| `trivy.size` | Persistent Volume size for vulnerability database cache. | `quantity` | `5Gi` | +| `trivy.resources` | Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` | +| `trivy.resources.cpu` | Number of CPU cores allocated. | `quantity` | `""` | +| `trivy.resources.memory` | Amount of memory allocated. | `quantity` | `""` | +| `trivy.resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.nano` | +| `database` | PostgreSQL database configuration. | `object` | `{}` | +| `database.size` | Persistent Volume size for database storage. | `quantity` | `5Gi` | +| `database.replicas` | Number of database instances. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset. | `int` | `2` | +| `redis` | Redis cache configuration. | `object` | `{}` | +| `redis.size` | Persistent Volume size for cache storage. | `quantity` | `1Gi` | +| `redis.replicas` | Number of Redis replicas. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset; the three sentinels always are. | `int` | `2` | diff --git a/packages/apps/harbor/templates/_helpers.tpl b/packages/apps/harbor/templates/_helpers.tpl new file mode 100644 index 000000000..391db84d3 --- /dev/null +++ b/packages/apps/harbor/templates/_helpers.tpl @@ -0,0 +1,45 @@ +{{- /* + Spread for the request-path components: the cluster-wide + scheduling.globalAppTopologySpreadConstraints when the platform sets one, as + the other applications do, otherwise a soft zone and node spread. Any + labelSelector is dropped because the upstream chart appends its own + release/app/component selector to every entry, and a second one would be a + duplicate key in the rendered Deployment. +*/}} +{{- define "harbor.topologySpreadConstraints" -}} +{{- $raw := dig "scheduling" "globalAppTopologySpreadConstraints" "" (.Values._cluster | default dict) }} +{{- $constraints := list }} +{{- if $raw }} +{{- range (get ($raw | fromYaml) "topologySpreadConstraints" | default list) }} +{{- $constraints = append $constraints (omit . "labelSelector") }} +{{- end }} +{{- end }} +{{- if not $constraints }} +{{- $constraints = list + (dict "maxSkew" 1 "topologyKey" "topology.kubernetes.io/zone" "whenUnsatisfiable" "ScheduleAnyway") + (dict "maxSkew" 1 "topologyKey" "kubernetes.io/hostname" "whenUnsatisfiable" "ScheduleAnyway") }} +{{- end }} +{{- toYaml $constraints }} +{{- end }} + +{{- /* + Replica count and placement for one stateless component of the upstream chart. + Nothing beyond `replicas` is rendered for a single replica, so an install that + keeps the default renders the same pod template as before. + + Upstream defaults podDisruptionBudget.minAvailable to 1 and renders whichever + of minAvailable and maxUnavailable is truthy; the API server rejects a PDB + carrying both, so minAvailable is zeroed to leave maxUnavailable alone. +*/}} +{{- define "harbor.replicaPlacement" -}} +{{- $replicas := int (default 1 (index . 0)) }} +replicas: {{ $replicas }} +{{- if gt $replicas 1 }} +podDisruptionBudget: + enabled: true + minAvailable: 0 + maxUnavailable: 1 +topologySpreadConstraints: +{{- include "harbor.topologySpreadConstraints" (index . 1) | nindent 0 }} +{{- end }} +{{- end }} diff --git a/packages/apps/harbor/templates/harbor.yaml b/packages/apps/harbor/templates/harbor.yaml index 453ef2253..5d699adfa 100644 --- a/packages/apps/harbor/templates/harbor.yaml +++ b/packages/apps/harbor/templates/harbor.yaml @@ -1,3 +1,6 @@ +{{- $componentDefaults := dict "resourcesPreset" "t1.small" }} +{{- $core := .Values.core | default $componentDefaults }} +{{- $registry := .Values.registry | default $componentDefaults }} {{- $host := include "cozy-lib.ns-host-required" . }} {{- $harborHost := .Values.host | default (printf "%s.%s" .Release.Name $host) }} @@ -192,20 +195,24 @@ spec: {{- end }} {{- end }} nginx: + {{- include "harbor.replicaPlacement" (list (.Values.nginx).replicas $) | nindent 8 }} resources: {{- include "cozy-lib.resources.defaultingSanitize" (list "t1.small" (dict) $) | nindent 10 }} portal: + {{- include "harbor.replicaPlacement" (list (.Values.portal).replicas $) | nindent 8 }} resources: {{- include "cozy-lib.resources.defaultingSanitize" (list "t1.micro" (dict) $) | nindent 10 }} core: + {{- include "harbor.replicaPlacement" (list $core.replicas $) | nindent 8 }} {{- if and $tokenKey $tokenCert }} tokenKey: {{ $tokenKey | quote }} tokenCert: {{ $tokenCert | quote }} {{- end }} - resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.core.resourcesPreset .Values.core.resources $) | nindent 10 }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list $core.resourcesPreset $core.resources $) | nindent 10 }} registry: + {{- include "harbor.replicaPlacement" (list $registry.replicas $) | nindent 8 }} registry: - resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.registry.resourcesPreset .Values.registry.resources $) | nindent 12 }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list $registry.resourcesPreset $registry.resources $) | nindent 12 }} controller: - resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.registry.resourcesPreset .Values.registry.resources $) | nindent 12 }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list $registry.resourcesPreset $registry.resources $) | nindent 12 }} jobservice: resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.jobservice.resourcesPreset .Values.jobservice.resources $) | nindent 10 }} trivy: @@ -243,9 +250,9 @@ kind: WorkloadMonitor metadata: name: {{ $.Release.Name }}-core labels: - workloads.cozystack.io/resource-preset: {{ .Values.core.resourcesPreset | quote }} + workloads.cozystack.io/resource-preset: {{ $core.resourcesPreset | quote }} spec: - replicas: 1 + replicas: {{ default 1 $core.replicas }} minReplicas: 1 kind: harbor type: core @@ -261,9 +268,9 @@ kind: WorkloadMonitor metadata: name: {{ $.Release.Name }}-registry labels: - workloads.cozystack.io/resource-preset: {{ .Values.registry.resourcesPreset | quote }} + workloads.cozystack.io/resource-preset: {{ $registry.resourcesPreset | quote }} spec: - replicas: 1 + replicas: {{ default 1 $registry.replicas }} minReplicas: 1 kind: harbor type: registry @@ -279,7 +286,7 @@ kind: WorkloadMonitor metadata: name: {{ $.Release.Name }}-portal spec: - replicas: 1 + replicas: {{ default 1 (.Values.portal).replicas }} minReplicas: 1 kind: harbor type: portal diff --git a/packages/apps/harbor/tests/replica_placement_test.yaml b/packages/apps/harbor/tests/replica_placement_test.yaml new file mode 100644 index 000000000..a04d943bd --- /dev/null +++ b/packages/apps/harbor/tests/replica_placement_test.yaml @@ -0,0 +1,372 @@ +suite: request-path replicas and placement + +release: + name: harbor + namespace: tenant-test + +# nginx, core and registry sit on every docker login, pull and push, and portal +# serves the UI. Their replica count is forwarded to the upstream chart, and only +# above one replica does the wrapper add a PodDisruptionBudget and a soft zone and +# node spread, so an install on the default keeps rendering the pod template it had. +# +# The release is selected by kind rather than by document index: the template also +# renders a Secret and three WorkloadMonitors. +set: + _namespace: + host: example.org + ingress: nginx + gateway: "" + seaweedfs: seaweedfs + _cluster: + solver: http01 + +tests: + - it: keeps a single replica and adds no placement by default + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + asserts: + - equal: + path: spec.values.harbor.nginx.replicas + value: 1 + - equal: + path: spec.values.harbor.portal.replicas + value: 1 + - equal: + path: spec.values.harbor.core.replicas + value: 1 + - equal: + path: spec.values.harbor.registry.replicas + value: 1 + - notExists: + path: spec.values.harbor.nginx.podDisruptionBudget + - notExists: + path: spec.values.harbor.nginx.topologySpreadConstraints + - notExists: + path: spec.values.harbor.portal.podDisruptionBudget + - notExists: + path: spec.values.harbor.portal.topologySpreadConstraints + - notExists: + path: spec.values.harbor.core.podDisruptionBudget + - notExists: + path: spec.values.harbor.core.topologySpreadConstraints + - notExists: + path: spec.values.harbor.registry.podDisruptionBudget + - notExists: + path: spec.values.harbor.registry.topologySpreadConstraints + + - it: adds a PodDisruptionBudget and a soft zone and node spread above one replica + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + set: + nginx: + replicas: 2 + asserts: + - equal: + path: spec.values.harbor.nginx.replicas + value: 2 + # Upstream defaults minAvailable to 1; left in place it would sit next to + # maxUnavailable and the API server would reject the PDB. + - equal: + path: spec.values.harbor.nginx.podDisruptionBudget + value: + enabled: true + minAvailable: 0 + maxUnavailable: 1 + - equal: + path: spec.values.harbor.nginx.topologySpreadConstraints + value: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: ScheduleAnyway + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: ScheduleAnyway + + - it: scales each component independently + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + set: + core: + replicas: 3 + asserts: + - equal: + path: spec.values.harbor.core.replicas + value: 3 + - exists: + path: spec.values.harbor.core.podDisruptionBudget + - equal: + path: spec.values.harbor.nginx.replicas + value: 1 + - notExists: + path: spec.values.harbor.nginx.podDisruptionBudget + - notExists: + path: spec.values.harbor.registry.podDisruptionBudget + + # The upstream chart reads registry.replicas, not registry.registry.replicas, + # which is where the registry container's resources live. + - it: places registry replicas at the Deployment level of the upstream values + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + set: + registry: + replicas: 2 + asserts: + - equal: + path: spec.values.harbor.registry.replicas + value: 2 + - exists: + path: spec.values.harbor.registry.topologySpreadConstraints + - notExists: + path: spec.values.harbor.registry.registry.replicas + + - it: portal follows its own replica count + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + set: + portal: + replicas: 2 + asserts: + - equal: + path: spec.values.harbor.portal.replicas + value: 2 + - exists: + path: spec.values.harbor.portal.podDisruptionBudget + + - it: core WorkloadMonitor expects the configured replica count + template: templates/harbor.yaml + documentSelector: + path: metadata.name + value: harbor-core + set: + core: + replicas: 3 + asserts: + - isKind: + of: WorkloadMonitor + - equal: + path: spec.replicas + value: 3 + - equal: + path: spec.minReplicas + value: 1 + + - it: registry WorkloadMonitor expects the configured replica count + template: templates/harbor.yaml + documentSelector: + path: metadata.name + value: harbor-registry + set: + registry: + replicas: 2 + asserts: + - isKind: + of: WorkloadMonitor + - equal: + path: spec.replicas + value: 2 + + - it: portal WorkloadMonitor expects the configured replica count + template: templates/harbor.yaml + documentSelector: + path: metadata.name + value: harbor-portal + set: + portal: + replicas: 2 + asserts: + - isKind: + of: WorkloadMonitor + - equal: + path: spec.replicas + value: 2 + + # The platform-wide policy is authored as a block under a top-level + # `topologySpreadConstraints:` key, the shape the other applications read. + # It replaces the built-in spread, and any labelSelector it carries is + # dropped because the upstream chart appends its own to every entry. + - it: follows the cluster-wide spread policy when the platform sets one + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + set: + _cluster: + solver: http01 + scheduling: + globalAppTopologySpreadConstraints: | + topologySpreadConstraints: + - maxSkew: 2 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + foo: bar + core: + replicas: 2 + asserts: + - equal: + path: spec.values.harbor.core.topologySpreadConstraints + value: + - maxSkew: 2 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule + - exists: + path: spec.values.harbor.core.podDisruptionBudget + + - it: ignores the cluster-wide spread policy at a single replica + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + set: + _cluster: + solver: http01 + scheduling: + globalAppTopologySpreadConstraints: | + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule + asserts: + - notExists: + path: spec.values.harbor.core.topologySpreadConstraints + + # Zero would scale the request path away, and a negative count would fail the + # nested HelmRelease at the apiserver; the schema refuses both up front. + - it: rejects zero nginx replicas + template: templates/harbor.yaml + set: + nginx: + replicas: 0 + asserts: + - failedTemplate: + errorPattern: "/nginx/replicas.: minimum: got 0, want 1" + + - it: rejects zero portal replicas + template: templates/harbor.yaml + set: + portal: + replicas: 0 + asserts: + - failedTemplate: + errorPattern: "/portal/replicas.: minimum: got 0, want 1" + + - it: rejects zero core replicas + template: templates/harbor.yaml + set: + core: + replicas: 0 + asserts: + - failedTemplate: + errorPattern: "/core/replicas.: minimum: got 0, want 1" + + - it: rejects negative registry replicas + template: templates/harbor.yaml + set: + registry: + replicas: -1 + asserts: + - failedTemplate: + errorPattern: "/registry/replicas.: minimum: got -1, want 1" + + - it: keeps the request path available when replica counts are cleared + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + set: + nginx.replicas: null + portal.replicas: null + core.replicas: null + registry.replicas: null + asserts: + - equal: + path: spec.values.harbor.nginx.replicas + value: 1 + - equal: + path: spec.values.harbor.portal.replicas + value: 1 + - equal: + path: spec.values.harbor.core.replicas + value: 1 + - equal: + path: spec.values.harbor.registry.replicas + value: 1 + + - it: the core monitor follows the default after replicas are cleared + template: templates/harbor.yaml + documentSelector: + path: metadata.name + value: harbor-core + set: + core.replicas: null + asserts: + - equal: + path: spec.replicas + value: 1 + + - it: the registry monitor follows the default after replicas are cleared + template: templates/harbor.yaml + documentSelector: + path: metadata.name + value: harbor-registry + set: + registry.replicas: null + asserts: + - equal: + path: spec.replicas + value: 1 + + - it: the portal monitor follows the default after replicas are cleared + template: templates/harbor.yaml + documentSelector: + path: metadata.name + value: harbor-portal + set: + portal.replicas: null + asserts: + - equal: + path: spec.replicas + value: 1 + + - it: rejects a count above the Deployment int32 limit + template: templates/harbor.yaml + set: + core.replicas: 2147483648 + asserts: + - failedTemplate: + errorPattern: "/core/replicas.: maximum:" + + - it: restores the request-path defaults when entire optional blocks are cleared + template: templates/harbor.yaml + documentSelector: + path: kind + value: HelmRelease + set: + nginx: null + portal: null + core: null + registry: null + asserts: + - equal: + path: spec.values.harbor.nginx.replicas + value: 1 + - equal: + path: spec.values.harbor.portal.replicas + value: 1 + - equal: + path: spec.values.harbor.core.replicas + value: 1 + - equal: + path: spec.values.harbor.registry.replicas + value: 1 diff --git a/packages/apps/harbor/values.schema.json b/packages/apps/harbor/values.schema.json index 5427370ec..32adc4983 100644 --- a/packages/apps/harbor/values.schema.json +++ b/packages/apps/harbor/values.schema.json @@ -29,11 +29,46 @@ "source": "storageclass" } }, + "nginx": { + "description": "Entry-point proxy configuration.", + "type": "object", + "default": {}, + "properties": { + "replicas": { + "description": "Number of replicas of the proxy every `docker login`, pull and push goes through. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset.", + "type": "integer", + "default": 1, + "maximum": 2147483647, + "minimum": 1 + } + } + }, + "portal": { + "description": "Web portal configuration.", + "type": "object", + "default": {}, + "properties": { + "replicas": { + "description": "Number of web portal replicas. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset.", + "type": "integer", + "default": 1, + "maximum": 2147483647, + "minimum": 1 + } + } + }, "core": { "description": "Core API server configuration.", "type": "object", "default": {}, "properties": { + "replicas": { + "description": "Number of core replicas, which issue the token every pull and push needs. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset.", + "type": "integer", + "default": 1, + "maximum": 2147483647, + "minimum": 1 + }, "resources": { "description": "Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.", "type": "object", @@ -128,6 +163,13 @@ "type": "object", "default": {}, "properties": { + "replicas": { + "description": "Number of registry replicas; they share the S3 bucket and no local state. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset.", + "type": "integer", + "default": 1, + "maximum": 2147483647, + "minimum": 1 + }, "resources": { "description": "Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.", "type": "object", @@ -438,7 +480,7 @@ ], "properties": { "replicas": { - "description": "Number of database instances.", + "description": "Number of database instances. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset.", "type": "integer", "default": 2 }, @@ -468,7 +510,7 @@ ], "properties": { "replicas": { - "description": "Number of Redis replicas.", + "description": "Number of Redis replicas. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset; the three sentinels always are.", "type": "integer", "default": 2 }, diff --git a/packages/apps/harbor/values.yaml b/packages/apps/harbor/values.yaml index 364871884..448c2bc2d 100644 --- a/packages/apps/harbor/values.yaml +++ b/packages/apps/harbor/values.yaml @@ -70,21 +70,47 @@ storageClass: "" ## @value xlarge ## @value 2xlarge +## @typedef {struct} Nginx - Entry-point proxy configuration. +## @field {int} [replicas] - Number of replicas of the proxy every `docker login`, pull and push goes through. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. +## @minimum 1 +## @maximum 2147483647 + +## @param {Nginx} nginx - Entry-point proxy configuration. +nginx: + replicas: 1 + +## @typedef {struct} Portal - Web portal configuration. +## @field {int} [replicas] - Number of web portal replicas. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. +## @minimum 1 +## @maximum 2147483647 + +## @param {Portal} portal - Web portal configuration. +portal: + replicas: 1 + ## @typedef {struct} Core - Core API server configuration. +## @field {int} [replicas] - Number of core replicas, which issue the token every pull and push needs. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. +## @minimum 1 +## @maximum 2147483647 ## @field {Resources} [resources] - Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. ## @field {ResourcesPreset} [resourcesPreset] - Default sizing preset used when `resources` is omitted. ## @param {Core} core - Core API server configuration. core: + replicas: 1 resources: {} resourcesPreset: "t1.small" ## @typedef {struct} Registry - Container image registry configuration. +## @field {int} [replicas] - Number of registry replicas; they share the S3 bucket and no local state. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset. +## @minimum 1 +## @maximum 2147483647 ## @field {Resources} [resources] - Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied. ## @field {ResourcesPreset} [resourcesPreset] - Default sizing preset used when `resources` is omitted. ## @param {Registry} registry - Container image registry configuration. registry: + replicas: 1 resources: {} resourcesPreset: "t1.small" @@ -112,7 +138,7 @@ trivy: ## @typedef {struct} Database - PostgreSQL database configuration (provisioned via CloudNativePG). ## @field {quantity} size - Persistent Volume size for database storage. -## @field {int} replicas - Number of database instances. +## @field {int} replicas - Number of database instances. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset. ## @param {Database} database - PostgreSQL database configuration. database: @@ -121,7 +147,7 @@ database: ## @typedef {struct} Redis - Redis cache configuration (provisioned via redis-operator). ## @field {quantity} size - Persistent Volume size for cache storage. -## @field {int} replicas - Number of Redis replicas. +## @field {int} replicas - Number of Redis replicas. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset; the three sentinels always are. ## @param {Redis} redis - Redis cache configuration. redis: diff --git a/packages/system/harbor-rd/cozyrds/harbor.yaml b/packages/system/harbor-rd/cozyrds/harbor.yaml index 32913a044..c48ac4faf 100644 --- a/packages/system/harbor-rd/cozyrds/harbor.yaml +++ b/packages/system/harbor-rd/cozyrds/harbor.yaml @@ -8,7 +8,7 @@ spec: singular: harbor plural: harbors openAPISchema: |- - {"title":"Chart Values","type":"object","properties":{"host":{"description":"Hostname for external access to Harbor (defaults to 'harbor' subdomain for the tenant host).","type":"string","default":""},"managementWhitelist":{"description":"IP addresses or CIDR ranges allowed to reach the Harbor web portal and API. `/v2/` and `/service/token`, which `docker login`, image pulls and pushes use, are not restricted by this list. For the portal and API it replaces the tenant ingress `whitelist` rather than narrowing it, and it is matched against the client address the ingress controller sees, which is a proxy or a forwarded header rather than the real client when something in front of the controller rewrites it. Empty allows every address. Requires Ingress publishing; rejected when the tenant publishes through Gateway API.","type":"array","default":[],"items":{"type":"string"}},"storageClass":{"description":"StorageClass used to store the data.","type":"string","default":"","x-kubernetes-validations":[{"rule":"self == oldSelf","message":"storageClass is immutable"}],"x-cozystack-options":{"source":"storageclass"}},"core":{"description":"Core API server configuration.","type":"object","default":{},"properties":{"resources":{"description":"Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"Number of CPU cores allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Amount of memory allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.small","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]}}},"registry":{"description":"Container image registry configuration.","type":"object","default":{},"properties":{"resources":{"description":"Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"Number of CPU cores allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Amount of memory allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.small","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]}}},"jobservice":{"description":"Background job service configuration.","type":"object","default":{},"properties":{"resources":{"description":"Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"Number of CPU cores allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Amount of memory allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.nano","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]}}},"trivy":{"description":"Trivy vulnerability scanner configuration.","type":"object","default":{},"required":["enabled","size"],"properties":{"enabled":{"description":"Enable or disable the vulnerability scanner.","type":"boolean","default":true},"resources":{"description":"Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"Number of CPU cores allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Amount of memory allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.nano","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]},"size":{"description":"Persistent Volume size for vulnerability database cache.","default":"5Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"database":{"description":"PostgreSQL database configuration.","type":"object","default":{},"required":["replicas","size"],"properties":{"replicas":{"description":"Number of database instances.","type":"integer","default":2},"size":{"description":"Persistent Volume size for database storage.","default":"5Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"redis":{"description":"Redis cache configuration.","type":"object","default":{},"required":["replicas","size"],"properties":{"replicas":{"description":"Number of Redis replicas.","type":"integer","default":2},"size":{"description":"Persistent Volume size for cache storage.","default":"1Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}}}} + {"title":"Chart Values","type":"object","properties":{"host":{"description":"Hostname for external access to Harbor (defaults to 'harbor' subdomain for the tenant host).","type":"string","default":""},"managementWhitelist":{"description":"IP addresses or CIDR ranges allowed to reach the Harbor web portal and API. `/v2/` and `/service/token`, which `docker login`, image pulls and pushes use, are not restricted by this list. For the portal and API it replaces the tenant ingress `whitelist` rather than narrowing it, and it is matched against the client address the ingress controller sees, which is a proxy or a forwarded header rather than the real client when something in front of the controller rewrites it. Empty allows every address. Requires Ingress publishing; rejected when the tenant publishes through Gateway API.","type":"array","default":[],"items":{"type":"string"}},"storageClass":{"description":"StorageClass used to store the data.","type":"string","default":"","x-kubernetes-validations":[{"rule":"self == oldSelf","message":"storageClass is immutable"}],"x-cozystack-options":{"source":"storageclass"}},"nginx":{"description":"Entry-point proxy configuration.","type":"object","default":{},"properties":{"replicas":{"description":"Number of replicas of the proxy every `docker login`, pull and push goes through. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset.","type":"integer","default":1,"maximum":2147483647,"minimum":1}}},"portal":{"description":"Web portal configuration.","type":"object","default":{},"properties":{"replicas":{"description":"Number of web portal replicas. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset.","type":"integer","default":1,"maximum":2147483647,"minimum":1}}},"core":{"description":"Core API server configuration.","type":"object","default":{},"properties":{"replicas":{"description":"Number of core replicas, which issue the token every pull and push needs. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset.","type":"integer","default":1,"maximum":2147483647,"minimum":1},"resources":{"description":"Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"Number of CPU cores allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Amount of memory allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.small","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]}}},"registry":{"description":"Container image registry configuration.","type":"object","default":{},"properties":{"replicas":{"description":"Number of registry replicas; they share the S3 bucket and no local state. Above 1, adds a PodDisruptionBudget and spreads the replicas by the platform's `globalAppTopologySpreadConstraints`, or softly across zones and nodes when it is unset.","type":"integer","default":1,"maximum":2147483647,"minimum":1},"resources":{"description":"Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"Number of CPU cores allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Amount of memory allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.small","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]}}},"jobservice":{"description":"Background job service configuration.","type":"object","default":{},"properties":{"resources":{"description":"Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"Number of CPU cores allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Amount of memory allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.nano","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]}}},"trivy":{"description":"Trivy vulnerability scanner configuration.","type":"object","default":{},"required":["enabled","size"],"properties":{"enabled":{"description":"Enable or disable the vulnerability scanner.","type":"boolean","default":true},"resources":{"description":"Explicit CPU and memory configuration. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"Number of CPU cores allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Amount of memory allocated.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.nano","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]},"size":{"description":"Persistent Volume size for vulnerability database cache.","default":"5Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"database":{"description":"PostgreSQL database configuration.","type":"object","default":{},"required":["replicas","size"],"properties":{"replicas":{"description":"Number of database instances. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset.","type":"integer","default":2},"size":{"description":"Persistent Volume size for database storage.","default":"5Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"redis":{"description":"Redis cache configuration.","type":"object","default":{},"required":["replicas","size"],"properties":{"replicas":{"description":"Number of Redis replicas. Above 1, they are spread by the platform's `globalAppTopologySpreadConstraints`, or softly across zones when it is unset; the three sentinels always are.","type":"integer","default":2},"size":{"description":"Persistent Volume size for cache storage.","default":"1Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}}}} release: prefix: "harbor-" labels: @@ -27,7 +27,7 @@ spec: - registry - container icon: "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHJvbGU9ImltZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHZpZXdCb3g9IjEuMDUgLTEuOTUgMzU5LjQxIDM2MS42NiI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJsaW5lYXItZ3JhZGllbnQiIHgxPSIyNjQuNzkiIHgyPSIyNjcuMjciIHkxPSI5NTIuMzkiIHkyPSI5NTIuMzkiIGdyYWRpZW50VHJhbnNmb3JtPSJtYXRyaXgoMzAuNDMgMCAwIC0zMC40MyAtNzk1NS4yMiAyOTI4NS43NSkiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiM2MGI5MzIiLz48c3RvcCBvZmZzZXQ9Ii4yOCIgc3RvcC1jb2xvcj0iIzYwYjkzMiIvPjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzM2N2MzNCIvPjwvbGluZWFyR3JhZGllbnQ+PGxpbmVhckdyYWRpZW50IGlkPSJsaW5lYXItZ3JhZGllbnQtMiIgeDE9IjI2My43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OTIgMTUybDE0Mi00LjgzIDMyLjUtMS4xMWMtLjQ4LTIuNTEtMS01LTEuNTYtNy40OCIvPjwvZz48L2c+PC9nPjwvc3ZnPg==" - keysOrder: [["apiVersion"], ["appVersion"], ["kind"], ["metadata"], ["metadata", "name"], ["spec", "host"], ["spec", "managementWhitelist"], ["spec", "storageClass"], ["spec", "core"], ["spec", "core", "resources"], ["spec", "core", "resourcesPreset"], ["spec", "registry"], ["spec", "registry", "resources"], ["spec", "registry", "resourcesPreset"], ["spec", "jobservice"], ["spec", "jobservice", "resources"], ["spec", "jobservice", "resourcesPreset"], ["spec", "trivy"], ["spec", "trivy", "enabled"], ["spec", "trivy", "size"], ["spec", "trivy", "resources"], ["spec", "trivy", "resourcesPreset"], ["spec", "database"], ["spec", "database", "size"], ["spec", "database", "replicas"], ["spec", "redis"], ["spec", "redis", "size"], ["spec", "redis", "replicas"]] + keysOrder: [["apiVersion"], ["appVersion"], ["kind"], ["metadata"], ["metadata", "name"], ["spec", "host"], ["spec", "managementWhitelist"], ["spec", "storageClass"], ["spec", "nginx"], ["spec", "nginx", "replicas"], ["spec", "portal"], ["spec", "portal", "replicas"], ["spec", "core"], ["spec", "core", "replicas"], ["spec", "core", "resources"], ["spec", "core", "resourcesPreset"], ["spec", "registry"], ["spec", "registry", "replicas"], ["spec", "registry", "resources"], ["spec", "registry", "resourcesPreset"], ["spec", "jobservice"], ["spec", "jobservice", "resources"], ["spec", "jobservice", "resourcesPreset"], ["spec", "trivy"], ["spec", "trivy", "enabled"], ["spec", "trivy", "size"], ["spec", "trivy", "resources"], ["spec", "trivy", "resourcesPreset"], ["spec", "database"], ["spec", "database", "size"], ["spec", "database", "replicas"], ["spec", "redis"], ["spec", "redis", "size"], ["spec", "redis", "replicas"]] secrets: exclude: [] include: diff --git a/packages/system/harbor/templates/_helpers.tpl b/packages/system/harbor/templates/_helpers.tpl new file mode 100644 index 000000000..111f7585e --- /dev/null +++ b/packages/system/harbor/templates/_helpers.tpl @@ -0,0 +1,29 @@ +{{- /* + Spread for the data tier: the cluster-wide + scheduling.globalAppTopologySpreadConstraints when the platform sets one, as + the other applications do, otherwise a soft zone spread. Per-node spreading + is left to the anti-affinity CloudNativePG and the Redis operator apply by + default. Every entry is scoped to the given pod labels. + + Takes (list ). +*/}} +{{- define "harbor.topologySpreadConstraints" -}} +{{- $root := index . 0 }} +{{- $selector := dict "matchLabels" (index . 1) }} +{{- $raw := dig "scheduling" "globalAppTopologySpreadConstraints" "" ($root.Values._cluster | default dict) }} +{{- $constraints := list }} +{{- if $raw }} +{{- range (get ($raw | fromYaml) "topologySpreadConstraints" | default list) }} +{{- $constraints = append $constraints (omit . "labelSelector") }} +{{- end }} +{{- end }} +{{- if not $constraints }} +{{- $constraints = list (dict "maxSkew" 1 "topologyKey" "topology.kubernetes.io/zone" "whenUnsatisfiable" "ScheduleAnyway") }} +{{- end }} +{{- $scoped := list }} +{{- range $constraints }} +{{- $scoped = append $scoped (merge (dict "labelSelector" $selector) .) }} +{{- end }} +{{- toYaml $scoped }} +{{- end }} + diff --git a/packages/system/harbor/templates/database.yaml b/packages/system/harbor/templates/database.yaml index 9a9486017..8b0c81beb 100644 --- a/packages/system/harbor/templates/database.yaml +++ b/packages/system/harbor/templates/database.yaml @@ -8,6 +8,13 @@ spec: {{- $existingCluster := lookup "postgresql.cnpg.io/v1" "Cluster" .Release.Namespace (printf "%s-db" .Values.harbor.fullnameOverride) }} {{- $image := dig "spec" "imageName" "ghcr.io/cloudnative-pg/postgresql:17.7-standard-trixie" $existingCluster }} imageName: {{ if regexMatch ":17\\." $image }}ghcr.io/cloudnative-pg/postgresql:17.7-standard-trixie{{ else if regexMatch ":[0-9]+\\.[0-9]+$" $image }}{{ printf "%s-standard-trixie" $image }}{{ else }}{{ $image }}{{ end }} + {{- /* CloudNativePG's default anti-affinity is per node only. Spreading across + zones on top of it, rather than moving its topologyKey to the zone, keeps + instances off a shared node on a cluster that carries no zone labels. */}} + {{- if gt (int .Values.db.replicas) 1 }} + topologySpreadConstraints: + {{- include "harbor.topologySpreadConstraints" (list . (dict "cnpg.io/cluster" (printf "%s-db" .Values.harbor.fullnameOverride) "cnpg.io/podRole" "instance")) | nindent 2 }} + {{- end }} storage: size: {{ .Values.db.size }} {{- with .Values.db.storageClass }} diff --git a/packages/system/harbor/templates/redis.yaml b/packages/system/harbor/templates/redis.yaml index b781e42f2..217b537f6 100644 --- a/packages/system/harbor/templates/redis.yaml +++ b/packages/system/harbor/templates/redis.yaml @@ -27,6 +27,13 @@ spec: # bump it as a deliberate, separate change. image: redis:6.2.6-alpine replicas: 3 + {{- /* Setting affinity would replace the operator's default per-node + anti-affinity, so the zone spread goes through + topologySpreadConstraints instead and the two add up. The selector + leaves out redisfailovers-role, which flips between master and + slave at runtime. */}} + topologySpreadConstraints: + {{- include "harbor.topologySpreadConstraints" (list . (dict "app.kubernetes.io/name" (printf "%s-redis" .Values.harbor.fullnameOverride) "app.kubernetes.io/component" "sentinel")) | nindent 4 }} resources: limits: cpu: 250m @@ -39,6 +46,10 @@ spec: # Harbor's dump.rdb into a 7.x format a platform rollback can no longer load. image: redis:6.2.6-alpine replicas: {{ .Values.redis.replicas }} + {{- if gt (int .Values.redis.replicas) 1 }} + topologySpreadConstraints: + {{- include "harbor.topologySpreadConstraints" (list . (dict "app.kubernetes.io/name" (printf "%s-redis" .Values.harbor.fullnameOverride) "app.kubernetes.io/component" "redis")) | nindent 4 }} + {{- end }} resources: limits: cpu: "1" diff --git a/packages/system/harbor/tests/zone_spread_test.yaml b/packages/system/harbor/tests/zone_spread_test.yaml new file mode 100644 index 000000000..74f7922e1 --- /dev/null +++ b/packages/system/harbor/tests/zone_spread_test.yaml @@ -0,0 +1,218 @@ +suite: zone spread of the data tier and the request path + +release: + name: harbor-system + namespace: tenant-test + +# Both operators already keep replicas off a shared node. The spread follows +# the platform's globalAppTopologySpreadConstraints when one is set, and is a +# soft zone spread otherwise. It goes through topologySpreadConstraints so the +# operators' per-node default survives: +# overriding affinity on the RedisFailover, or moving CloudNativePG's +# topologyKey to the zone, would drop it on a cluster without zone labels. +set: + harbor: + fullnameOverride: harbor + expose: + type: clusterIP + tls: + enabled: false + +tests: + - it: spreads database instances across zones + template: templates/database.yaml + set: + db: + replicas: 3 + asserts: + - equal: + path: spec.topologySpreadConstraints + value: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: ScheduleAnyway + labelSelector: + matchLabels: + cnpg.io/cluster: harbor-db + cnpg.io/podRole: instance + - notExists: + path: spec.affinity + + - it: leaves a single database instance unconstrained + template: templates/database.yaml + set: + db: + replicas: 1 + asserts: + - notExists: + path: spec.topologySpreadConstraints + + - it: spreads redis replicas across zones without replacing the operator's affinity + template: templates/redis.yaml + documentSelector: + path: kind + value: RedisFailover + set: + redis: + replicas: 3 + asserts: + - equal: + path: spec.redis.topologySpreadConstraints + value: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: ScheduleAnyway + labelSelector: + matchLabels: + app.kubernetes.io/name: harbor-redis + app.kubernetes.io/component: redis + - notExists: + path: spec.redis.affinity + + - it: leaves a single redis replica unconstrained + template: templates/redis.yaml + documentSelector: + path: kind + value: RedisFailover + set: + redis: + replicas: 1 + asserts: + - notExists: + path: spec.redis.topologySpreadConstraints + + - it: always spreads the three sentinels across zones + template: templates/redis.yaml + documentSelector: + path: kind + value: RedisFailover + set: + redis: + replicas: 1 + asserts: + - equal: + path: spec.sentinel.topologySpreadConstraints + value: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: ScheduleAnyway + labelSelector: + matchLabels: + app.kubernetes.io/name: harbor-redis + app.kubernetes.io/component: sentinel + - notExists: + path: spec.sentinel.affinity + + - it: follows the cluster-wide spread policy for the database + template: templates/database.yaml + set: + db: + replicas: 3 + _cluster: + scheduling: + globalAppTopologySpreadConstraints: | + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + - maxSkew: 2 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: ScheduleAnyway + asserts: + - equal: + path: spec.topologySpreadConstraints + value: + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + cnpg.io/cluster: harbor-db + cnpg.io/podRole: instance + - maxSkew: 2 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: ScheduleAnyway + labelSelector: + matchLabels: + cnpg.io/cluster: harbor-db + cnpg.io/podRole: instance + + # A selector written into the platform-wide policy cannot know this + # release's pods, so it is replaced rather than kept. + - it: scopes the cluster-wide spread policy to the sentinels + template: templates/redis.yaml + documentSelector: + path: kind + value: RedisFailover + set: + _cluster: + scheduling: + globalAppTopologySpreadConstraints: | + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + foo: bar + asserts: + - equal: + path: spec.sentinel.topologySpreadConstraints + value: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + app.kubernetes.io/name: harbor-redis + app.kubernetes.io/component: sentinel + + # The values below are what packages/apps/harbor forwards for nginx.replicas: 2. + # The API server rejects a PDB that sets both minAvailable and maxUnavailable, + # and upstream defaults minAvailable to 1, so the forwarded zero has to reach + # the rendered object as an absent field. + - it: renders the upstream PodDisruptionBudget with maxUnavailable alone + template: charts/harbor/templates/nginx/nginx-pdb.yaml + set: + harbor: + nginx: + replicas: 2 + podDisruptionBudget: + enabled: true + minAvailable: 0 + maxUnavailable: 1 + asserts: + - isKind: + of: PodDisruptionBudget + - equal: + path: spec.maxUnavailable + value: 1 + - notExists: + path: spec.minAvailable + + - it: scopes the forwarded spread to the component's own pods + template: charts/harbor/templates/core/core-dpl.yaml + set: + harbor: + core: + replicas: 2 + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: ScheduleAnyway + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: ScheduleAnyway + asserts: + - equal: + path: spec.replicas + value: 2 + - equal: + path: spec.template.spec.topologySpreadConstraints[0].labelSelector.matchLabels.component + value: core + - equal: + path: spec.template.spec.topologySpreadConstraints[1].labelSelector.matchLabels.component + value: core + - equal: + path: spec.template.spec.topologySpreadConstraints[1].labelSelector.matchLabels.release + value: harbor-system