mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
refactor(kubernetes): drop unused helpers and correct stale comments
kubernetes.fullname, its fullnameOverride read, kubernetes.positiveDuration and the Bitnami resources.preset in _resources.tpl have no caller: the first is a helm-create leftover, the duration check moved with the worker pools to the kubernetes-nodes chart, which carries its own copy because a named template does not cross releases, and resource presets come from cozy-lib. A reader who finds them assumes they are in use. The template and test comments described the pre-split chart: phases of a rollout, worker objects at document indices this chart no longer renders, cross-references to files that live in the other chart, and a claim that the cluster CIDRs are kept in one place while the pool chart and the CoreDNS release carry copies. Only Helm comments and test comments change; the chart renders the same bytes for its test values, and the pinned bootstrap-token Job hash is unchanged. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
11 files changed
+36
-126
No files matched your search
@@ -5,24 +5,6 @@ Expand the name of the chart.
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "kubernetes.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
@@ -185,29 +167,6 @@ never boots.
|
||||
{{- printf "has(claims.groups) && dyn(claims.groups).exists(g, g in [\"%s-view\", \"%s-use\", \"%s-admin\", \"%s-super-admin\"])" $ns $ns $ns $ns -}}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
Validates and returns a duration destined for a consumer that does not reject
|
||||
a bad value: the cluster-autoscaler parses its annotation with
|
||||
time.ParseDuration and silently falls back to its built-in default on a value
|
||||
it cannot parse, and the CAPI webhook does not validate unhealthyConditions
|
||||
timeouts at all, so a zero or negative one applies and remediates a Machine the
|
||||
moment its condition flips. The values schema types these fields as strings and
|
||||
stops there, which lets "30" and "-5m" reach the template. The accepted shape
|
||||
is narrower than Go's duration grammar on purpose, because that grammar also
|
||||
admits a value large enough to overflow the parser -- the silent fallback again
|
||||
-- and a fraction small enough to round to zero. The first segment must be
|
||||
positive; later segments may be zero, so the canonical rendering of a duration
|
||||
("20m0s", "1h0m0s" -- what metav1.Duration serializes to) round-trips. Every
|
||||
string this admits parses to a positive duration.
|
||||
*/ -}}
|
||||
{{- define "kubernetes.positiveDuration" -}}
|
||||
{{- $value := toString .value -}}
|
||||
{{- if not (regexMatch "^[1-9][0-9]{0,4}[smh]([0-9]{1,5}[smh]){0,2}$" $value) -}}
|
||||
{{- fail (printf "%s must be a whole number of s, m or h (e.g. 30m, 1h30m), got %q" .field $value) -}}
|
||||
{{- end -}}
|
||||
{{- $value -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
The two kube-apiserver flags the tenant control plane owns that have a
|
||||
KamajiControlPlane field it renders them from, keyed to that field.
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
{{/*
|
||||
Copyright Broadcom, Inc. All Rights Reserved.
|
||||
SPDX-License-Identifier: APACHE-2.0
|
||||
*/}}
|
||||
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{/*
|
||||
Return a resource request/limit object based on a given preset.
|
||||
These presets are for basic testing and not meant to be used in production
|
||||
{{ include "resources.preset" (dict "type" "nano") -}}
|
||||
*/}}
|
||||
{{- define "resources.preset" -}}
|
||||
{{- $presets := dict
|
||||
"nano" (dict
|
||||
"requests" (dict "cpu" "100m" "memory" "128Mi" "ephemeral-storage" "50Mi")
|
||||
"limits" (dict "memory" "128Mi" "ephemeral-storage" "2Gi")
|
||||
)
|
||||
"micro" (dict
|
||||
"requests" (dict "cpu" "250m" "memory" "256Mi" "ephemeral-storage" "50Mi")
|
||||
"limits" (dict "memory" "256Mi" "ephemeral-storage" "2Gi")
|
||||
)
|
||||
"small" (dict
|
||||
"requests" (dict "cpu" "500m" "memory" "512Mi" "ephemeral-storage" "50Mi")
|
||||
"limits" (dict "memory" "512Mi" "ephemeral-storage" "2Gi")
|
||||
)
|
||||
"medium" (dict
|
||||
"requests" (dict "cpu" "500m" "memory" "1Gi" "ephemeral-storage" "50Mi")
|
||||
"limits" (dict "memory" "1Gi" "ephemeral-storage" "2Gi")
|
||||
)
|
||||
"large" (dict
|
||||
"requests" (dict "cpu" "1" "memory" "2Gi" "ephemeral-storage" "50Mi")
|
||||
"limits" (dict "memory" "2Gi" "ephemeral-storage" "2Gi")
|
||||
)
|
||||
"xlarge" (dict
|
||||
"requests" (dict "cpu" "2" "memory" "4Gi" "ephemeral-storage" "50Mi")
|
||||
"limits" (dict "memory" "4Gi" "ephemeral-storage" "2Gi")
|
||||
)
|
||||
"2xlarge" (dict
|
||||
"requests" (dict "cpu" "4" "memory" "8Gi" "ephemeral-storage" "50Mi")
|
||||
"limits" (dict "memory" "8Gi" "ephemeral-storage" "2Gi")
|
||||
)
|
||||
}}
|
||||
{{- if hasKey $presets .type -}}
|
||||
{{- index $presets .type | toYaml -}}
|
||||
{{- else -}}
|
||||
{{- printf "ERROR: Preset key '%s' invalid. Allowed values are %s" .type (join "," (keys $presets)) | fail -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -40,20 +40,23 @@
|
||||
*/}}
|
||||
{{- /* Worker node pools (KubevirtMachineTemplate, MachineDeployment,
|
||||
MachineHealthCheck, worker WorkloadMonitor) and the Talos
|
||||
reconcile Job that produces each pool's TalosConfigTemplate now
|
||||
live in the separate `kubernetes-nodes` chart (one HelmRelease
|
||||
per pool). This chart renders the control plane only. The
|
||||
reconcile Job in the kubernetes-nodes release still re-patches
|
||||
this KamajiControlPlane's apiserver-Service ClusterIP-SAN and
|
||||
owns each TalosConfigTemplate via an ownerReference to this KCP,
|
||||
so garbage collection on control-plane uninstall is unchanged. */}}
|
||||
reconcile Job that produces each pool's TalosConfigTemplate are
|
||||
rendered by the `kubernetes-nodes` chart (one HelmRelease per
|
||||
pool). This chart renders the control plane only. The reconcile
|
||||
Job in the kubernetes-nodes release re-patches this
|
||||
KamajiControlPlane's apiserver-Service ClusterIP-SAN and owns
|
||||
each TalosConfigTemplate via an ownerReference to this KCP, so
|
||||
uninstalling the control plane garbage-collects them. */}}
|
||||
{{- /*
|
||||
Cluster pod/service CIDRs MUST match between the CAPI Cluster
|
||||
spec.clusterNetwork below and the Talos worker machineconfig's
|
||||
cluster.network — Talos surfaces overlaps against the host pod CIDR
|
||||
as a diagnostic at boot, and divergence between CAPI and Talos would
|
||||
manifest as silently broken kube-proxy / Cilium routing. Keep them
|
||||
in one place here.
|
||||
manifest as silently broken kube-proxy / Cilium routing. The worker
|
||||
side is a copy of these two literals in
|
||||
packages/apps/kubernetes-nodes/templates/_talosconfigtemplate.tpl, and
|
||||
templates/helmreleases/coredns.yaml pins the DNS Service IP inside the
|
||||
service CIDR, so a change here is a change in all three places.
|
||||
*/}}
|
||||
{{- $podCIDR := "10.243.0.0/16" }}
|
||||
{{- $serviceCIDR := "10.95.0.0/16" }}
|
||||
@@ -78,7 +81,7 @@ data:
|
||||
to reconcile - this HelmRelease will pick up the DataStore on its next
|
||||
5m reconcile loop and provision the cluster.
|
||||
{{- else }}
|
||||
{{- /* Phase 2 worker-pool adoption guard. Worker pools now live in per-pool
|
||||
{{- /* Worker-pool adoption guard. Worker pools live in per-pool
|
||||
kubernetes-nodes releases; the platform migration adopts each pre-split
|
||||
pool's live objects onto its child release (re-annotating
|
||||
meta.helm.sh/release-name, pinning helm.sh/resource-policy=keep) as a
|
||||
|
||||
@@ -23,9 +23,8 @@ ingress-nginx:
|
||||
{{- if and .Values.addons.ingressNginx.enabled .Values._namespace.etcd }}
|
||||
{{- /* The ingress-nginx controller DaemonSet pins itself to nodes labelled
|
||||
node-role.kubernetes.io/ingress-nginx (see cozystack.defaultIngressValues
|
||||
nodeSelector). Since Phase 2 moved worker pools into the separate
|
||||
kubernetes-nodes chart, that label is produced by a KubernetesNodes pool
|
||||
with roles: [ingress-nginx]. If no such pool exists the DaemonSet simply
|
||||
nodeSelector). That label is produced by a KubernetesNodes pool with
|
||||
roles: [ingress-nginx]. If no such pool exists the DaemonSet simply
|
||||
schedules nothing (degraded, not failed) — the requirement is documented
|
||||
in NOTES.txt and the release note rather than enforced at render time, so
|
||||
an existing cluster is never flipped from Ready to Failed on upgrade. */}}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
/etc/kubernetes/authentication-config/config.yaml and consumed via
|
||||
--authentication-config=. Compared to the legacy `--oidc-*` flags,
|
||||
the file form supports multiple issuers (the `jwt` block is a list)
|
||||
and inline private-CA PEM, so future BYO and Phase-2 issuers extend
|
||||
the same Secret instead of fighting the chart shape.
|
||||
and inline private-CA PEM, so further issuers extend the same Secret
|
||||
instead of fighting the chart shape.
|
||||
|
||||
System mode:
|
||||
Single JWT entry built from `_cluster.root-host` (the cozy realm
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{- /*
|
||||
Phase 1 — System mode: render one per-cluster Keycloak client and a
|
||||
System mode: render one per-cluster Keycloak client and a
|
||||
per-cluster audience client scope inside the platform `cozy` realm.
|
||||
|
||||
The clientId is namespace-prefixed so it is globally unique across the
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
kube-system, which the management cluster can only reach via the
|
||||
Kamaji-issued admin kubeconfig stored as <release>-admin-kubeconfig.
|
||||
|
||||
Why a main-phase resource and not a Helm post-install/post-upgrade hook
|
||||
(the earlier shape): the hook is unreliable on the very failure it was
|
||||
meant to cover. This release carries
|
||||
release.cozystack.io/helm-install-disable-wait: "true" (cozystack-api
|
||||
Why a main-phase resource and not a Helm post-install/post-upgrade hook:
|
||||
the hook is unreliable on the very failure it was meant to cover. This
|
||||
release carries release.cozystack.io/helm-install-disable-wait: "true" (cozystack-api
|
||||
sets it on both Install.DisableWait and Upgrade.DisableWait), so there
|
||||
is NO main-resource wait phase in front of the hooks — a post-install
|
||||
hook is not gated on MachineDeployment Ready and does fire on a fresh
|
||||
@@ -25,9 +24,9 @@
|
||||
<release>-admin-kubeconfig (materialised by Kamaji after the
|
||||
KamajiControlPlane is applied) is not yet available.
|
||||
|
||||
As an ordinary main-phase resource (mirroring talos-reconcile-job.yaml)
|
||||
the Job is applied on every install and every reconcile regardless of
|
||||
hook phase. It lands together with the KamajiControlPlane and
|
||||
As an ordinary main-phase resource (like talos-reconcile-job.yaml in the
|
||||
kubernetes-nodes chart) the Job is applied on every install and every
|
||||
reconcile regardless of hook phase. It lands together with the KamajiControlPlane and
|
||||
talos-secrets; a wait-for-kubeconfig init container holds the Pod until
|
||||
Kamaji publishes the admin kubeconfig Secret (the Secret volume is
|
||||
optional so kubelet does not FailedMount in the meantime), then the
|
||||
@@ -40,9 +39,9 @@
|
||||
upgrade that lands while the Job is live (or inside
|
||||
ttlSecondsAfterFinished) with `spec.template: field is immutable`, and
|
||||
RetryOnFailure would loop on it. The Job therefore carries a
|
||||
content-hash name suffix over its whole rendered spec (mirrors
|
||||
talos-reconcile-job.yaml and the KubevirtMachineTemplate idiom in
|
||||
cluster.yaml): an identical render keeps the name and Helm no-ops it;
|
||||
content-hash name suffix over its whole rendered spec (the idiom of
|
||||
talos-reconcile-job.yaml and the KubevirtMachineTemplate name in the
|
||||
kubernetes-nodes chart): an identical render keeps the name and Helm no-ops it;
|
||||
any change that flows into the spec — notably a new images/kubectl.tag —
|
||||
yields a new name so a fresh Job runs and Helm prunes the old one. The
|
||||
hash also folds in the looked-up bootstrap token — both halves,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
suite: control-plane-only cluster.yaml render (worker pools moved to kubernetes-nodes)
|
||||
suite: control-plane-only cluster.yaml render (worker pools are kubernetes-nodes releases)
|
||||
|
||||
# Phase 2 moved the worker node pools (KubevirtMachineTemplate, MachineDeployment,
|
||||
# The worker node pools (KubevirtMachineTemplate, MachineDeployment,
|
||||
# MachineHealthCheck, worker WorkloadMonitor) and the per-pool talos-reconcile Job
|
||||
# into the separate kubernetes-nodes chart. cluster.yaml now renders the control
|
||||
# are rendered by the kubernetes-nodes chart. cluster.yaml renders the control
|
||||
# plane only, in source order: Cluster (0), KamajiControlPlane (1), the
|
||||
# control-plane WorkloadMonitor (2), KubevirtCluster (3). This suite pins that
|
||||
# surface so a regression that re-introduces pool objects into the parent chart
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
suite: tenant kube-apiserver OIDC (Phase 1)
|
||||
suite: tenant kube-apiserver OIDC
|
||||
|
||||
values:
|
||||
- values/common.yaml
|
||||
|
||||
# In cluster.yaml the KamajiControlPlane is document index 1
|
||||
# (0: Cluster, 1: KamajiControlPlane, 2: WorkloadMonitor, 3: KubevirtCluster, ...).
|
||||
# Documents at higher indices are KubevirtMachineTemplate, MachineDeployment,
|
||||
# MachineHealthCheck, WorkloadMonitor per node group.
|
||||
# (0: Cluster, 1: KamajiControlPlane, 2: WorkloadMonitor, 3: KubevirtCluster);
|
||||
# tests/control_plane_only_test.yaml pins that there are no others.
|
||||
|
||||
tests:
|
||||
###############################################
|
||||
|
||||
@@ -19,5 +19,5 @@ controlPlane:
|
||||
server:
|
||||
resources: {}
|
||||
resourcesPreset: "micro"
|
||||
# Worker pools are managed via KubernetesNodes resources since the Phase 2 split;
|
||||
# the kubernetes chart renders the control plane only.
|
||||
# Worker pools are KubernetesNodes resources; the kubernetes chart renders the
|
||||
# control plane only.
|
||||
@@ -1,4 +1,4 @@
|
||||
suite: Phase 2 worker-pool adoption guard
|
||||
suite: worker-pool adoption guard
|
||||
|
||||
# The guard in templates/cluster.yaml refuses to render the control-plane-only
|
||||
# chart when a live worker MachineDeployment for this cluster is NOT owned by
|
||||
|
||||
Reference in new issue
Block a user