mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
feat(cluster-api)!: update Cluster API to v1.14.4 (#4902)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, security (a fix that comes through a security advisory), docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list. Pick the most specific scope for the change. - Breaking changes: append `!` after type/scope or add a `BREAKING CHANGE:` footer. - If it is a work in progress, consider creating this PR as a draft. - Ask for opinion and review in the community chats when needed. - Fixes merged to main reach supported release lines through the backport batch automatically. Do not open backport PRs by hand. --> ## What this PR does Updates the Cluster API stack with an automatic intermediate upgrade for existing v1.10 providers. The core chart upgrades them through v1.13.8 before Helm applies the final manifests. The hook fails on API errors, conflicting changes or timeouts. The hook image goes through cozy-lib. The core chart's PackageSource declares that library, otherwise the packaged chart can't render the hook. Fresh installations skip the intermediate providers. Helm keeps the intermediate ConfigMaps, so they stay in the cluster after the next change of the intermediate version, and that bump has to remove them. Each provider now selects exactly one repository. The bridge and final ConfigMaps carry `provider.cluster.x-k8s.io/version` with the full version, including the role suffix, and the core and kubeadm selectors include it. The operator's finalize step hashes every ConfigMap the selector matches and rejects more than one. During an upgrade it also checks the selector of every other installed provider. So the bridge ConfigMaps carry only the version label, and the v1.10 selectors, which have no version, never match them. The hook switches the version and the selector in one guarded patch and selects a bridge by that label alone. It also narrows an existing bridge selector to that label. A provider whose first installation never finished takes the fresh-install path. Kamaji, CAPK, capmox and IPAM keep their existing pins and temporary v1beta1 compatibility. The autoscaler keeps its explicit v1beta1 selection. An infrastructure provider's v1beta1 `failureReason` no longer immediately fails a Machine or triggers remediation. The provider conditions still show the cause. The vendored operator chart gets six local patches, and `make update` reapplies them. The core components get a startup probe patch. The sync-period patch from main stays. I kept the one-minute resync setting until restart recovery is tested. CAPI Bats, the bootstrap and platform Helm suites and the rendering checks pass locally. On envtest against cluster-api-operator v0.30.0, legacy v1.10 core and kubeadm providers go through v1.13.8 to v1.14.4 with these ConfigMaps. With the old bridge labels core stayed on v1.10. I have not run a live upgrade, restart or eviction test on this revision. The [earlier Proxmox report](https://github.com/cozystack/cozystack/pull/4902#pullrequestreview-5510737333) covers the v1.13 candidate only. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> Not a UI change. ### Downstream repositories <!-- Cozystack is upstream for repositories that are not kept in sync automatically. Check the trigger map in docs/agents/contributing.md against the diff. Keep every checkbox. Tick an affected repository only after linking an existing or newly opened follow-up. Do not claim no downstream impact when it is unknown. --> - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#751 - [ ] [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 existing website follow-up needs the management-cluster minimum updated to v1.33. No tenant API fields, version enums, installer values or platform variants change. ### Release note ```release-note feat(cluster-api)!: update Cluster API core and kubeadm bootstrap to v1.14.4, cluster-api-operator to v0.30.0 and Talos bootstrap to v0.6.13. Legacy core and kubeadm installations are upgraded through v1.13.8 before the final manifests are applied. The core and kubeadm bootstrap charts reject management Kubernetes older than v1.33. The upgrade is one-way: Cluster and Machine CRDs use v1beta2 storage and downgrades are not supported. The preferred Cluster API version becomes v1beta2. Clients relying on v1beta1 fields must select that version explicitly. The operator no longer serves operator.cluster.x-k8s.io/v1alpha1. The autoscaler stays on the v1beta1 Cluster API. ```
This commit is contained in:
71 files changed
+21010
-17385
No files matched your search
@@ -3,3 +3,7 @@ packages/system/capi-providers-infraprovider/images/cluster-api-provider-kubevir
|
|||||||
packages/system/cilium/images/cilium-operator/patches/*.diff -whitespace
|
packages/system/cilium/images/cilium-operator/patches/*.diff -whitespace
|
||||||
packages/system/seaweedfs/images/seaweedfs/patches/*.diff -whitespace
|
packages/system/seaweedfs/images/seaweedfs/patches/*.diff -whitespace
|
||||||
packages/system/kamaji/images/kamaji/patches/*.diff -whitespace
|
packages/system/kamaji/images/kamaji/patches/*.diff -whitespace
|
||||||
|
packages/system/capi-operator/charts/** linguist-vendored
|
||||||
|
packages/system/capi-operator/files/bridge-*.yaml linguist-generated
|
||||||
|
packages/system/capi-providers-core/files/*-components*.yaml linguist-generated
|
||||||
|
packages/system/capi-providers-bootstrap/files/*-components*.yaml linguist-generated
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#!/usr/bin/env bats
|
|
||||||
# capi-providers-core ships the Cluster API core manifests twice: as
|
|
||||||
# files/core-components.yaml, which a reviewer reads, and as files/components.gz,
|
|
||||||
# which the chart mounts into the cluster. Both are edited by hand; this package
|
|
||||||
# has no `make components`. An edit to the YAML alone reviews cleanly and changes
|
|
||||||
# nothing in a cluster, which is how the startupProbe from #2946 stayed out of
|
|
||||||
# the shipped manager. This holds the two files to the same bytes.
|
|
||||||
#
|
|
||||||
# The comparison is on the decompressed bytes, so the gzip header plays no part
|
|
||||||
# in it. `gzip -n` is still the flag to regenerate with: without it the header
|
|
||||||
# carries a timestamp and every regeneration rewrites the committed blob even
|
|
||||||
# when the input has not changed.
|
|
||||||
|
|
||||||
load test_helper
|
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
|
|
||||||
FILES="$REPO_ROOT/packages/system/capi-providers-core/files"
|
|
||||||
|
|
||||||
@test "core provider components.gz matches core-components.yaml" {
|
|
||||||
[ -f "$FILES/core-components.yaml" ] || { echo "missing core-components.yaml" >&2; return 1; }
|
|
||||||
[ -f "$FILES/components.gz" ] || { echo "missing components.gz" >&2; return 1; }
|
|
||||||
|
|
||||||
local work; work="$(mktemp -d)"
|
|
||||||
gzip -dc "$FILES/components.gz" > "$work/decompressed.yaml"
|
|
||||||
if ! cmp -s "$work/decompressed.yaml" "$FILES/core-components.yaml"; then
|
|
||||||
echo "components.gz does not match core-components.yaml" >&2
|
|
||||||
echo "the chart mounts the blob, so the cluster would run what the YAML does not say" >&2
|
|
||||||
echo "regenerate: gzip -9 -n -c files/core-components.yaml > files/components.gz" >&2
|
|
||||||
diff "$work/decompressed.yaml" "$FILES/core-components.yaml" | head -20 >&2 || true
|
|
||||||
rm -rf "$work"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
rm -rf "$work"
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,20 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
# The operator's resync period is what bounds the stale-Ready window after an
|
# values.yaml keeps a one-minute resync period until restart recovery on the
|
||||||
# operator restart (kubernetes-sigs/cluster-api-operator#1031): about two
|
# current operator is measured; the v0.19 operator needed it for
|
||||||
# periods. It reaches the manager only through patches/sync-period.diff, which
|
# kubernetes-sigs/cluster-api-operator#1031. It reaches the manager only through
|
||||||
# `make update` has to reapply on every re-vendor, and through the value in
|
# patches/sync-period.diff, which `make update` has to reapply on every
|
||||||
# values.yaml. Losing either silently returns the window to about 20 minutes,
|
# re-vendor, and through the value in values.yaml. Losing either drops the
|
||||||
# so this checks the argument the rendered Deployment actually carries.
|
# setting silently, so this checks the argument the rendered Deployment carries.
|
||||||
|
|
||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
|
||||||
OPERATOR="$REPO_ROOT/packages/system/capi-operator"
|
OPERATOR="$REPO_ROOT/packages/system/capi-operator"
|
||||||
|
|
||||||
|
@test "the operator chart declares its vendored dependencies" {
|
||||||
|
helm lint "$OPERATOR"
|
||||||
|
}
|
||||||
|
|
||||||
@test "the operator manager runs with a one-minute resync period" {
|
@test "the operator manager runs with a one-minute resync period" {
|
||||||
local rendered args
|
local rendered args
|
||||||
rendered="$BATS_TEST_TMPDIR/operator.yaml"
|
rendered="$BATS_TEST_TMPDIR/operator.yaml"
|
||||||
@@ -23,3 +27,473 @@ OPERATOR="$REPO_ROOT/packages/system/capi-operator"
|
|||||||
esac
|
esac
|
||||||
printf '%s\n' "$args" | grep -qx -- '--sync-period=1m' || { echo "manager args: $args" >&2; return 1; }
|
printf '%s\n' "$args" | grep -qx -- '--sync-period=1m' || { echo "manager args: $args" >&2; return 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_feature_gate() {
|
||||||
|
local expected="$1" mode="$2" group provider legacy kind rendered actual failed=0
|
||||||
|
local -a flags
|
||||||
|
for entry in 'core cluster-api core CoreProvider' \
|
||||||
|
'controlPlane kubeadm kubeadm ControlPlaneProvider' \
|
||||||
|
'infrastructure docker docker InfrastructureProvider' \
|
||||||
|
'ipam in-cluster in-cluster IPAMProvider'; do
|
||||||
|
read -r group provider legacy kind <<< "$entry"
|
||||||
|
flags=(--set "cluster-api-operator.$group.$provider.version=v1.13.7")
|
||||||
|
case "$mode" in
|
||||||
|
global)
|
||||||
|
flags+=(--set "cluster-api-operator.manager.featureGates.$legacy.ClusterTopology=true")
|
||||||
|
;;
|
||||||
|
provider)
|
||||||
|
flags+=(--set "cluster-api-operator.$group.$provider.manager.featureGates.ClusterTopology=true")
|
||||||
|
;;
|
||||||
|
false)
|
||||||
|
flags+=(--set "cluster-api-operator.manager.featureGates.$legacy.ClusterTopology=true"
|
||||||
|
--set "cluster-api-operator.$group.$provider.manager.featureGates.ClusterTopology=false")
|
||||||
|
;;
|
||||||
|
empty)
|
||||||
|
flags+=(--set "cluster-api-operator.manager.featureGates.$legacy.ClusterTopology=true"
|
||||||
|
--set-json "cluster-api-operator.$group.$provider.manager.featureGates={}")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
rendered="$BATS_TEST_TMPDIR/$kind.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api "${flags[@]}" > "$rendered"
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.manager.featureGates.ClusterTopology" "$rendered")"
|
||||||
|
[ "$actual" = "$expected" ] || {
|
||||||
|
echo "$kind $mode: expected $expected, got $actual" >&2
|
||||||
|
failed=1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
[ "$failed" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "legacy global feature gates remain effective for provider kinds" {
|
||||||
|
check_feature_gate true global
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "provider feature gates work without a legacy global value" {
|
||||||
|
check_feature_gate true provider
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an explicit false provider gate overrides the global gate" {
|
||||||
|
check_feature_gate false false
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an explicitly empty provider gate map replaces global gates" {
|
||||||
|
check_feature_gate null empty
|
||||||
|
}
|
||||||
|
|
||||||
|
check_auto_kubeadm_gate() {
|
||||||
|
local expected="$1" rendered actual
|
||||||
|
shift
|
||||||
|
rendered="$BATS_TEST_TMPDIR/automatic-control-plane.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set cluster-api-operator.infrastructure.docker.version=v1.13.7 \
|
||||||
|
--set cluster-api-operator.configSecret.name=provider-config \
|
||||||
|
"$@" > "$rendered"
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "ControlPlaneProvider") | .spec.manager.featureGates.ClusterTopology' "$rendered")"
|
||||||
|
[ "$actual" = "$expected" ] || {
|
||||||
|
echo "automatic kubeadm gate: expected $expected, got $actual" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "automatic kubeadm control plane retains the legacy global gate" {
|
||||||
|
check_auto_kubeadm_gate true \
|
||||||
|
--set cluster-api-operator.manager.featureGates.kubeadm.ClusterTopology=true
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "automatic kubeadm control plane does not manufacture a feature gate" {
|
||||||
|
check_auto_kubeadm_gate null
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "explicit kubeadm false gate supersedes automatic global defaults" {
|
||||||
|
check_auto_kubeadm_gate false \
|
||||||
|
--set cluster-api-operator.manager.featureGates.kubeadm.ClusterTopology=true \
|
||||||
|
--set cluster-api-operator.controlPlane.kubeadm.version=v1.13.7 \
|
||||||
|
--set cluster-api-operator.controlPlane.kubeadm.manager.featureGates.ClusterTopology=false
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "explicit kubeadm empty gate map supersedes automatic global defaults" {
|
||||||
|
check_auto_kubeadm_gate null \
|
||||||
|
--set cluster-api-operator.manager.featureGates.kubeadm.ClusterTopology=true \
|
||||||
|
--set cluster-api-operator.controlPlane.kubeadm.version=v1.13.7 \
|
||||||
|
--set-json 'cluster-api-operator.controlPlane.kubeadm.manager.featureGates={}'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "automatic core and bootstrap keep their existing gate-free defaults" {
|
||||||
|
local rendered actual
|
||||||
|
rendered="$BATS_TEST_TMPDIR/automatic-defaults.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set cluster-api-operator.infrastructure.docker.version=v1.13.7 \
|
||||||
|
--set cluster-api-operator.configSecret.name=provider-config \
|
||||||
|
--set cluster-api-operator.manager.featureGates.core.ClusterTopology=true \
|
||||||
|
--set cluster-api-operator.manager.featureGates.kubeadm.ClusterTopology=true > "$rendered"
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "CoreProvider") | .spec.manager.featureGates' "$rendered")"
|
||||||
|
[ "$actual" = null ]
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "BootstrapProvider") | .spec.manager.featureGates' "$rendered")"
|
||||||
|
[ "$actual" = null ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "explicit bootstrap retains its own manager gate" {
|
||||||
|
local rendered actual
|
||||||
|
rendered="$BATS_TEST_TMPDIR/bootstrap.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set cluster-api-operator.bootstrap.kubeadm.version=v1.13.7 \
|
||||||
|
--set cluster-api-operator.bootstrap.kubeadm.manager.featureGates.ClusterTopology=true > "$rendered"
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "BootstrapProvider") | .spec.manager.featureGates.ClusterTopology' "$rendered")"
|
||||||
|
[ "$actual" = true ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "addon retains its supported manager metrics without a legacy gate" {
|
||||||
|
local rendered actual
|
||||||
|
rendered="$BATS_TEST_TMPDIR/addon.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set cluster-api-operator.addon.example.version=v1.13.7 \
|
||||||
|
--set cluster-api-operator.addon.example.manager.metrics.diagnosticsAddress=:8443 \
|
||||||
|
--set cluster-api-operator.manager.featureGates.example.ClusterTopology=true > "$rendered"
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "AddonProvider") | .spec.manager.metrics.diagnosticsAddress' "$rendered")"
|
||||||
|
[ "$actual" = ':8443' ]
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "AddonProvider") | .spec.manager.featureGates' "$rendered")"
|
||||||
|
[ "$actual" = null ]
|
||||||
|
}
|
||||||
|
|
||||||
|
check_provider_spec_field() {
|
||||||
|
local field="$1" group provider kind entry rendered actual expected path failed=0
|
||||||
|
local -a flags
|
||||||
|
for entry in 'core cluster-api CoreProvider' 'bootstrap kubeadm BootstrapProvider' \
|
||||||
|
'controlPlane kubeadm ControlPlaneProvider' 'infrastructure docker InfrastructureProvider' \
|
||||||
|
'ipam in-cluster IPAMProvider' 'addon example AddonProvider'; do
|
||||||
|
read -r group provider kind <<< "$entry"
|
||||||
|
flags=(--set "cluster-api-operator.$group.$provider.createNamespace=false")
|
||||||
|
case "$field" in
|
||||||
|
fetchConfig)
|
||||||
|
flags+=(--set-string "cluster-api-operator.$group.$provider.fetchConfig.selector.matchLabels.example=manifests")
|
||||||
|
path='.spec.fetchConfig.selector.matchLabels.example'
|
||||||
|
expected=manifests
|
||||||
|
;;
|
||||||
|
manifestPatches)
|
||||||
|
flags+=(--set-json "cluster-api-operator.$group.$provider.manifestPatches=[\"kind: Deployment\"]")
|
||||||
|
path='.spec.manifestPatches[0]'
|
||||||
|
expected='kind: Deployment'
|
||||||
|
;;
|
||||||
|
additionalManifests)
|
||||||
|
flags+=(--set-json "cluster-api-operator.$group.$provider.additionalManifests={\"name\":\"extra-manifests\",\"manifests\":\"kind: ConfigMap\"}")
|
||||||
|
path='.spec.additionalManifests.name'
|
||||||
|
expected=extra-manifests
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
path='.spec'
|
||||||
|
expected=null
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
rendered="$BATS_TEST_TMPDIR/$kind-$field.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api "${flags[@]}" > "$rendered"
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | $path" "$rendered")"
|
||||||
|
[ "$actual" = "$expected" ] || {
|
||||||
|
echo "$kind $field: expected $expected in spec, got $actual" >&2
|
||||||
|
failed=1
|
||||||
|
}
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .metadata.$field" "$rendered")"
|
||||||
|
[ "$actual" = null ] || {
|
||||||
|
echo "$kind leaked $field into metadata" >&2
|
||||||
|
failed=1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
[ "$failed" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "fetch configuration alone belongs to every provider spec" {
|
||||||
|
check_provider_spec_field fetchConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "manifest patches alone belong to every provider spec" {
|
||||||
|
check_provider_spec_field manifestPatches
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "additional manifests alone belong to every provider spec" {
|
||||||
|
check_provider_spec_field additionalManifests
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "provider namespace options alone do not manufacture spec fields" {
|
||||||
|
check_provider_spec_field absent
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "legacy global fetch configuration alone stays inside matching provider specs" {
|
||||||
|
local group provider kind entry rendered actual
|
||||||
|
for entry in 'infrastructure docker InfrastructureProvider' 'ipam in-cluster IPAMProvider'; do
|
||||||
|
read -r group provider kind <<< "$entry"
|
||||||
|
rendered="$BATS_TEST_TMPDIR/$kind-global-fetch.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set "cluster-api-operator.$group.$provider.createNamespace=false" \
|
||||||
|
--set-string "cluster-api-operator.fetchConfig.$provider.url=https://example.test/components.yaml" > "$rendered"
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig.url" "$rendered")"
|
||||||
|
[ "$actual" = 'https://example.test/components.yaml' ]
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .metadata.fetchConfig" "$rendered")"
|
||||||
|
[ "$actual" = null ]
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "another provider's global fetch configuration does not create a spec" {
|
||||||
|
local rendered actual
|
||||||
|
rendered="$BATS_TEST_TMPDIR/unmatched-fetch.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set cluster-api-operator.infrastructure.docker.createNamespace=false \
|
||||||
|
--set-string cluster-api-operator.fetchConfig.other.url=https://example.test/components.yaml > "$rendered"
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "InfrastructureProvider") | .spec' "$rendered")"
|
||||||
|
[ "$actual" = null ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "infrastructure patches alone belong to the provider spec" {
|
||||||
|
local rendered actual
|
||||||
|
rendered="$BATS_TEST_TMPDIR/infrastructure-patches.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set-string 'cluster-api-operator.infrastructure.docker.patches[0].patch=kind: Deployment' > "$rendered"
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "InfrastructureProvider") | .spec.patches[0].patch' "$rendered")"
|
||||||
|
[ "$actual" = 'kind: Deployment' ]
|
||||||
|
actual="$(yq --no-doc 'select(.kind == "InfrastructureProvider") | .metadata.patches' "$rendered")"
|
||||||
|
[ "$actual" = null ]
|
||||||
|
}
|
||||||
|
|
||||||
|
check_fetch_overlap() {
|
||||||
|
local mode="$1" group provider kind template entry rendered actual expected failed=0
|
||||||
|
local -a flags
|
||||||
|
for entry in 'infrastructure docker InfrastructureProvider infra.yaml' \
|
||||||
|
'ipam in-cluster IPAMProvider ipam.yaml'; do
|
||||||
|
read -r group provider kind template <<< "$entry"
|
||||||
|
flags=(--set "cluster-api-operator.$group.$provider.createNamespace=false"
|
||||||
|
--set-string "cluster-api-operator.fetchConfig.$provider.url=https://legacy.example/components.yaml")
|
||||||
|
case "$mode" in
|
||||||
|
override)
|
||||||
|
flags+=(--set-string "cluster-api-operator.$group.$provider.fetchConfig.url=https://provider.example/components.yaml")
|
||||||
|
expected=https://provider.example/components.yaml
|
||||||
|
;;
|
||||||
|
empty)
|
||||||
|
flags+=(--set-json "cluster-api-operator.$group.$provider.fetchConfig={}")
|
||||||
|
expected=https://legacy.example/components.yaml
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
rendered="$BATS_TEST_TMPDIR/$kind-overlap-$mode.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api "${flags[@]}" \
|
||||||
|
--show-only "charts/cluster-api-operator/templates/$template" > "$rendered"
|
||||||
|
[ "$(grep -c '^ fetchConfig:' "$rendered")" -eq 1 ] || {
|
||||||
|
echo "$kind $mode must emit exactly one fetchConfig key" >&2
|
||||||
|
failed=1
|
||||||
|
}
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig.url" "$rendered")"
|
||||||
|
[ "$actual" = "$expected" ] || {
|
||||||
|
echo "$kind $mode expected $expected, got $actual" >&2
|
||||||
|
failed=1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
[ "$failed" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "nonempty provider fetch configuration overrides global input with one key" {
|
||||||
|
check_fetch_overlap override
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "empty provider fetch configuration retains the legacy global fallback" {
|
||||||
|
check_fetch_overlap empty
|
||||||
|
}
|
||||||
|
|
||||||
|
check_profiling_flags() {
|
||||||
|
local rendered
|
||||||
|
rendered="$BATS_TEST_TMPDIR/profiling.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set cluster-api-operator.profilerAddress=:6061 \
|
||||||
|
--set cluster-api-operator.contentionProfiling=true "$@" > "$rendered"
|
||||||
|
grep -q -- '--profiler-address=localhost:6061' "$rendered"
|
||||||
|
grep -q -- '--contention-profiling=true' "$rendered"
|
||||||
|
grep -q '^[[:space:]]*- containerPort: 6061$' "$rendered"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "profiling flags remain effective when leader election is disabled" {
|
||||||
|
check_profiling_flags --set cluster-api-operator.leaderElection.enabled=false
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "profiling flags remain effective when the optional leader election block is absent" {
|
||||||
|
check_profiling_flags --set-json cluster-api-operator.leaderElection=null
|
||||||
|
}
|
||||||
|
|
||||||
|
check_global_fetch_type() {
|
||||||
|
local mode="$1" group provider kind template entry rendered actual failed=0
|
||||||
|
local -a flags
|
||||||
|
for entry in 'infrastructure docker InfrastructureProvider infra.yaml' \
|
||||||
|
'ipam in-cluster IPAMProvider ipam.yaml'; do
|
||||||
|
read -r group provider kind template <<< "$entry"
|
||||||
|
flags=(--set "cluster-api-operator.$group.$provider.createNamespace=false")
|
||||||
|
case "$mode" in
|
||||||
|
selector)
|
||||||
|
flags+=(--set-json "cluster-api-operator.fetchConfig.$provider.selector={\"matchLabels\":{\"example\":\"manifests\"},\"matchExpressions\":[{\"key\":\"release\",\"operator\":\"In\",\"values\":[\"v1\"]}]}")
|
||||||
|
;;
|
||||||
|
empty)
|
||||||
|
flags+=(--set-json "cluster-api-operator.fetchConfig.$provider.selector={}")
|
||||||
|
;;
|
||||||
|
oci)
|
||||||
|
flags+=(--set-string "cluster-api-operator.fetchConfig.$provider.oci=oci://registry.example/provider:v1")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
rendered="$BATS_TEST_TMPDIR/$kind-fetch-type-$mode.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api "${flags[@]}" \
|
||||||
|
--show-only "charts/cluster-api-operator/templates/$template" > "$rendered"
|
||||||
|
[ "$(grep -c '^ fetchConfig:' "$rendered")" -eq 1 ]
|
||||||
|
if [ "$mode" = oci ]; then
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig.oci" "$rendered")"
|
||||||
|
[ "$actual" = 'oci://registry.example/provider:v1' ]
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig.selector | tag" "$rendered")"
|
||||||
|
if [ "$actual" != '!!map' ]; then
|
||||||
|
echo "$kind $mode selector must be an object, got $actual" >&2
|
||||||
|
failed=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "$mode" = selector ]; then
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig.selector.matchLabels.example" "$rendered")"
|
||||||
|
[ "$actual" = manifests ]
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig.selector.matchExpressions[0].key" "$rendered")"
|
||||||
|
[ "$actual" = release ]
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig.selector.matchExpressions[0].operator" "$rendered")"
|
||||||
|
[ "$actual" = In ]
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig.selector.matchExpressions[0].values[0]" "$rendered")"
|
||||||
|
[ "$actual" = v1 ]
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ "$failed" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "global fetch selectors preserve nested label and expression objects" {
|
||||||
|
check_global_fetch_type selector
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "empty global fetch selectors remain objects rather than strings" {
|
||||||
|
check_global_fetch_type empty
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "global OCI fetch configuration remains a string source" {
|
||||||
|
check_global_fetch_type oci
|
||||||
|
}
|
||||||
|
|
||||||
|
check_global_fetch_entry() {
|
||||||
|
local value="$1" expected="$2" group provider kind template entry rendered actual failed=0
|
||||||
|
for entry in 'infrastructure docker InfrastructureProvider infra.yaml' \
|
||||||
|
'ipam in-cluster IPAMProvider ipam.yaml'; do
|
||||||
|
read -r group provider kind template <<< "$entry"
|
||||||
|
rendered="$BATS_TEST_TMPDIR/$kind-entry.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set "cluster-api-operator.$group.$provider.version=v1.13.7" \
|
||||||
|
--set-json "cluster-api-operator.fetchConfig.$provider=$value" \
|
||||||
|
--show-only "charts/cluster-api-operator/templates/$template" > "$rendered"
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.fetchConfig | tag" "$rendered")"
|
||||||
|
[ "$actual" = "$expected" ] || {
|
||||||
|
echo "$kind global entry $value: expected $expected, got $actual" >&2
|
||||||
|
failed=1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
[ "$failed" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "empty global fetch entries preserve default source selection" {
|
||||||
|
check_global_fetch_entry '{}' '!!null'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "null global fetch entries preserve default source selection" {
|
||||||
|
check_global_fetch_entry null '!!null'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "malformed global fetch primitives are not silently replaced by a default source" {
|
||||||
|
check_global_fetch_entry false '!!bool'
|
||||||
|
check_global_fetch_entry 0 '!!int'
|
||||||
|
check_global_fetch_entry '"invalid"' '!!str'
|
||||||
|
check_global_fetch_entry '[]' '!!seq'
|
||||||
|
}
|
||||||
|
|
||||||
|
check_provider_scalar_types() {
|
||||||
|
local mode="$1" metrics="$2" name="$3" namespace="$4" expected="$5"
|
||||||
|
local group provider kind entry rendered path actual failed=0
|
||||||
|
local -a flags
|
||||||
|
for entry in 'core cluster-api CoreProvider' 'bootstrap kubeadm BootstrapProvider' \
|
||||||
|
'controlPlane kubeadm ControlPlaneProvider' 'infrastructure docker InfrastructureProvider' \
|
||||||
|
'ipam in-cluster IPAMProvider' 'addon example AddonProvider'; do
|
||||||
|
read -r group provider kind <<< "$entry"
|
||||||
|
flags=("--set-$mode" "cluster-api-operator.$group.$provider.manager.metrics.diagnosticsAddress=$metrics"
|
||||||
|
"--set-$mode" "cluster-api-operator.$group.$provider.configSecret.name=$name"
|
||||||
|
"--set-$mode" "cluster-api-operator.$group.$provider.configSecret.namespace=$namespace")
|
||||||
|
rendered="$BATS_TEST_TMPDIR/$kind-scalars-$mode.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api "${flags[@]}" > "$rendered"
|
||||||
|
for path in manager.metrics.diagnosticsAddress configSecret.name configSecret.namespace; do
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.$path | tag" "$rendered")"
|
||||||
|
[ "$actual" = "$expected" ] || {
|
||||||
|
echo "$kind $path: expected YAML type $expected, got $actual" >&2
|
||||||
|
failed=1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.manager.metrics.diagnosticsAddress" "$rendered")"
|
||||||
|
[ "$actual" = "$metrics" ]
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.configSecret.name" "$rendered")"
|
||||||
|
[ "$actual" = "$name" ]
|
||||||
|
actual="$(yq --no-doc "select(.kind == \"$kind\") | .spec.configSecret.namespace" "$rendered")"
|
||||||
|
[ "$actual" = "$namespace" ]
|
||||||
|
done
|
||||||
|
[ "$failed" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "provider metric disable values and numeric secret identifiers stay strings" {
|
||||||
|
check_provider_scalar_types string 0 123 456 '!!str'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "provider secret identifiers that resemble YAML keywords stay strings" {
|
||||||
|
check_provider_scalar_types string 0 true null '!!str'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "invalid numeric provider string inputs are not coerced into valid strings" {
|
||||||
|
check_provider_scalar_types json 123 123 456 '!!int'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "invalid boolean provider string inputs are not coerced into valid strings" {
|
||||||
|
check_provider_scalar_types json true true true '!!bool'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "provider config Secrets override global defaults" {
|
||||||
|
local group provider kind rendered entry
|
||||||
|
for entry in 'core cluster-api CoreProvider' 'bootstrap kubeadm BootstrapProvider' \
|
||||||
|
'controlPlane kubeadm ControlPlaneProvider' 'infrastructure docker InfrastructureProvider' \
|
||||||
|
'ipam in-cluster IPAMProvider' 'addon example AddonProvider'; do
|
||||||
|
read -r group provider kind <<< "$entry"
|
||||||
|
rendered="$BATS_TEST_TMPDIR/$kind-secret-precedence.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" \
|
||||||
|
--set cluster-api-operator.configSecret.name=global-config \
|
||||||
|
--set cluster-api-operator.configSecret.namespace=global-namespace \
|
||||||
|
--set "cluster-api-operator.$group.$provider.configSecret.name=provider-config" \
|
||||||
|
--set "cluster-api-operator.$group.$provider.configSecret.namespace=provider-namespace" > "$rendered"
|
||||||
|
[ "$(yq --no-doc "select(.kind == \"$kind\") | .spec.configSecret.name" "$rendered")" = provider-config ]
|
||||||
|
[ "$(yq --no-doc "select(.kind == \"$kind\") | .spec.configSecret.namespace" "$rendered")" = provider-namespace ]
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "operator profiling preserves an explicit host address" {
|
||||||
|
local rendered="$BATS_TEST_TMPDIR/profiler-host.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" \
|
||||||
|
--set cluster-api-operator.profilerAddress=127.0.0.1:6061 > "$rendered"
|
||||||
|
grep --quiet --fixed-strings -- '--profiler-address=127.0.0.1:6061' "$rendered"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "operator ports retain port-only addresses" {
|
||||||
|
local rendered
|
||||||
|
rendered="$BATS_TEST_TMPDIR/operator.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set cluster-api-operator.healthAddr=:9440 \
|
||||||
|
--set cluster-api-operator.diagnosticsAddress=:8443 > "$rendered"
|
||||||
|
[ "$(grep -c '^[[:space:]]*port: 9440$' "$rendered")" -eq 2 ]
|
||||||
|
grep -q '^[[:space:]]*- containerPort: 8443$' "$rendered"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "operator ports preserve explicit IPv4 host addresses" {
|
||||||
|
local rendered
|
||||||
|
rendered="$BATS_TEST_TMPDIR/operator.yaml"
|
||||||
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api \
|
||||||
|
--set cluster-api-operator.healthAddr=0.0.0.0:9440 \
|
||||||
|
--set cluster-api-operator.diagnosticsAddress=0.0.0.0:8443 > "$rendered"
|
||||||
|
[ "$(grep -c '^[[:space:]]*port: 9440$' "$rendered")" -eq 2 ]
|
||||||
|
grep -q '^[[:space:]]*- containerPort: 8443$' "$rendered"
|
||||||
|
grep -q -- '--health-addr=0.0.0.0:9440' "$rendered"
|
||||||
|
grep -q -- '--diagnostics-address=0.0.0.0:8443' "$rendered"
|
||||||
|
}
|
||||||
@@ -18,22 +18,22 @@ load test_helper
|
|||||||
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
|
||||||
|
|
||||||
check_pair() {
|
check_pair() {
|
||||||
local pkg="$1" yaml="$2"
|
local pkg="$1" yaml="$2" blob="${3:-components.gz}"
|
||||||
local dir="$REPO_ROOT/packages/system/$pkg/files"
|
local dir="$REPO_ROOT/packages/system/$pkg/files"
|
||||||
|
|
||||||
[ -f "$dir/$yaml" ] || { echo "missing $pkg/files/$yaml" >&2; return 1; }
|
[ -f "$dir/$yaml" ] || { echo "missing $pkg/files/$yaml" >&2; return 1; }
|
||||||
[ -f "$dir/components.gz" ] || { echo "missing $pkg/files/components.gz" >&2; return 1; }
|
[ -f "$dir/$blob" ] || { echo "missing $pkg/files/$blob" >&2; return 1; }
|
||||||
|
|
||||||
local work; work="$(mktemp -d)"
|
local work; work="$(mktemp -d)"
|
||||||
gzip -dc "$dir/components.gz" > "$work/decompressed.yaml"
|
gzip -dc "$dir/$blob" > "$work/decompressed.yaml"
|
||||||
|
|
||||||
if ! cmp -s "$work/decompressed.yaml" "$dir/$yaml"; then
|
if ! cmp -s "$work/decompressed.yaml" "$dir/$yaml"; then
|
||||||
echo "$pkg: components.gz does not match $yaml" >&2
|
echo "$pkg: $blob does not match $yaml" >&2
|
||||||
echo "the chart mounts the blob, so the cluster would run what the YAML does not say" >&2
|
echo "the chart mounts the blob, so the cluster would run what the YAML does not say" >&2
|
||||||
if grep -q '^components:' "$REPO_ROOT/packages/system/$pkg/Makefile" 2>/dev/null; then
|
if [ "$blob" = components.gz ] && grep -q '^components:' "$REPO_ROOT/packages/system/$pkg/Makefile" 2>/dev/null; then
|
||||||
echo "run: make -C packages/system/$pkg components" >&2
|
echo "run: make -C packages/system/$pkg components" >&2
|
||||||
else
|
else
|
||||||
echo "regenerate: gzip -9 -n -c files/$yaml > files/components.gz" >&2
|
echo "regenerate: gzip -9 -n -c files/$yaml > files/$blob" >&2
|
||||||
fi
|
fi
|
||||||
head -40 "$work/decompressed.yaml" > "$work/a"
|
head -40 "$work/decompressed.yaml" > "$work/a"
|
||||||
head -40 "$dir/$yaml" > "$work/b"
|
head -40 "$dir/$yaml" > "$work/b"
|
||||||
@@ -66,9 +66,10 @@ check_version() {
|
|||||||
version="$(sed -n "s/^${makefile_var}=//p" "$dir/Makefile")"
|
version="$(sed -n "s/^${makefile_var}=//p" "$dir/Makefile")"
|
||||||
[ -n "$version" ] || { echo "$pkg: no $makefile_var in Makefile" >&2; return 1; }
|
[ -n "$version" ] || { echo "$pkg: no $makefile_var in Makefile" >&2; return 1; }
|
||||||
|
|
||||||
local cm_name provider_version
|
local cm_name provider_version rendered="$BATS_TEST_TMPDIR/$pkg.yaml"
|
||||||
cm_name="$(sed -n 's/^ name: //p' "$dir/templates/configmaps.yaml")"
|
helm template provider "$dir" --kube-version 1.33.0 > "$rendered"
|
||||||
provider_version="$(sed -n 's/^ version: //p' "$dir/templates/providers.yaml")"
|
provider_version="$(yq --no-doc 'select(.apiVersion == "operator.cluster.x-k8s.io/v1alpha2") | .spec.version' "$rendered")"
|
||||||
|
cm_name="$(PROVIDER_VERSION="$provider_version" yq --no-doc 'select(.kind == "ConfigMap" and .metadata.name == strenv(PROVIDER_VERSION)) | .metadata.name' "$rendered")"
|
||||||
|
|
||||||
if [ "$cm_name" != "$provider_version" ]; then
|
if [ "$cm_name" != "$provider_version" ]; then
|
||||||
echo "$pkg: ConfigMap name '$cm_name' and spec.version '$provider_version' differ" >&2
|
echo "$pkg: ConfigMap name '$cm_name' and spec.version '$provider_version' differ" >&2
|
||||||
@@ -100,16 +101,24 @@ check_version() {
|
|||||||
# vendored file edited by hand, or a sum bumped without the file, both show up
|
# vendored file edited by hand, or a sum bumped without the file, both show up
|
||||||
# without anyone running the refresh target.
|
# without anyone running the refresh target.
|
||||||
check_sums() {
|
check_sums() {
|
||||||
local pkg="$1" makefile_var="$2" yaml="$3"
|
local pkg="$1" makefile_var="$2" yaml="$3" metadata="${4:-metadata.yaml}"
|
||||||
|
local metadata_var="${5:-${makefile_var}_SHA256_METADATA}"
|
||||||
local dir="$REPO_ROOT/packages/system/$pkg"
|
local dir="$REPO_ROOT/packages/system/$pkg"
|
||||||
|
|
||||||
local sum_components sum_metadata
|
local sum_components sum_metadata
|
||||||
sum_components="$(sed -n "s/^${makefile_var}_SHA256_COMPONENTS=//p" "$dir/Makefile")"
|
sum_components="$(sed -n "s/^${makefile_var}_SHA256_COMPONENTS=//p" "$dir/Makefile")"
|
||||||
sum_metadata="$(sed -n "s/^${makefile_var}_SHA256_METADATA=//p" "$dir/Makefile")"
|
sum_metadata="$(sed --quiet "s/^${metadata_var}=//p" "$dir/Makefile")"
|
||||||
[ -n "$sum_components" ] && [ -n "$sum_metadata" ] \
|
[ -n "$sum_components" ] && [ -n "$sum_metadata" ] \
|
||||||
|| { echo "$pkg: Makefile pins no ${makefile_var}_SHA256_* sums" >&2; return 1; }
|
|| { echo "$pkg: Makefile pins no ${makefile_var}_SHA256_* sums" >&2; return 1; }
|
||||||
|
|
||||||
if ! printf '%s %s\n%s %s\n' "$sum_components" "$dir/files/$yaml" "$sum_metadata" "$dir/files/metadata.yaml" \
|
local components="$dir/files/$yaml"
|
||||||
|
case "$yaml" in
|
||||||
|
*.gz)
|
||||||
|
components="$BATS_TEST_TMPDIR/$makefile_var.yaml"
|
||||||
|
gzip --decompress --stdout "$dir/files/$yaml" > "$components" || return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if ! printf '%s %s\n%s %s\n' "$sum_components" "$components" "$sum_metadata" "$dir/files/$metadata" \
|
||||||
| sha256sum -c - >/dev/null 2>&1; then
|
| sha256sum -c - >/dev/null 2>&1; then
|
||||||
echo "$pkg: a vendored file does not match the sum its Makefile pins" >&2
|
echo "$pkg: a vendored file does not match the sum its Makefile pins" >&2
|
||||||
echo "either the file was edited without a refresh, or the sum moved without the file" >&2
|
echo "either the file was edited without a refresh, or the sum moved without the file" >&2
|
||||||
@@ -117,6 +126,46 @@ check_sums() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Packages that carry patches/ vendor a file that differs from the release
|
||||||
|
# asset, so its sum cannot be pinned directly. Reverting the patches recovers
|
||||||
|
# the asset, and that is checked against the pinned sum instead: a hand edit of
|
||||||
|
# the vendored file, a patch changed without a refresh, or a sum moved without
|
||||||
|
# the file all show up here.
|
||||||
|
check_patched_sums() {
|
||||||
|
local pkg="$1" makefile_var="$2" yaml="$3" metadata="${4:-metadata.yaml}"
|
||||||
|
local metadata_var="${5:-${makefile_var}_SHA256_METADATA}"
|
||||||
|
local dir="$REPO_ROOT/packages/system/$pkg"
|
||||||
|
|
||||||
|
local sum_components sum_metadata
|
||||||
|
sum_components="$(sed -n "s/^${makefile_var}_SHA256_COMPONENTS=//p" "$dir/Makefile")"
|
||||||
|
sum_metadata="$(sed --quiet "s/^${metadata_var}=//p" "$dir/Makefile")"
|
||||||
|
[ -n "$sum_components" ] && [ -n "$sum_metadata" ] \
|
||||||
|
|| { echo "$pkg: Makefile pins no ${makefile_var}_SHA256_* sums" >&2; return 1; }
|
||||||
|
|
||||||
|
local work; work="$(mktemp -d)"
|
||||||
|
case "$yaml" in
|
||||||
|
*.gz) gzip --decompress --stdout "$dir/files/$yaml" > "$work/asset.yaml" || return ;;
|
||||||
|
*) cp "$dir/files/$yaml" "$work/asset.yaml" ;;
|
||||||
|
esac
|
||||||
|
local patches=() i
|
||||||
|
local patches_dir="${6:-$dir/patches}"
|
||||||
|
for i in "$patches_dir"/*.diff; do
|
||||||
|
[ -e "$i" ] && patches+=("$i")
|
||||||
|
done
|
||||||
|
for (( i = ${#patches[@]} - 1; i >= 0; i-- )); do
|
||||||
|
patch -s -f -R "$work/asset.yaml" < "${patches[$i]}" \
|
||||||
|
|| { echo "$pkg: $(basename "${patches[$i]}") does not revert cleanly from files/$yaml" >&2; rm -rf "$work"; return 1; }
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! printf '%s %s\n%s %s\n' "$sum_components" "$work/asset.yaml" "$sum_metadata" "$dir/files/$metadata" \
|
||||||
|
| sha256sum -c - >/dev/null 2>&1; then
|
||||||
|
echo "$pkg: files/$yaml without patches/, or files/$metadata, does not match the sum its Makefile pins" >&2
|
||||||
|
rm -rf "$work"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
rm -rf "$work"
|
||||||
|
}
|
||||||
|
|
||||||
@test "capmox vendored files match the sums its Makefile pins" {
|
@test "capmox vendored files match the sums its Makefile pins" {
|
||||||
check_sums capi-providers-infraprovider-proxmox CAPMOX infrastructure-components.yaml
|
check_sums capi-providers-infraprovider-proxmox CAPMOX infrastructure-components.yaml
|
||||||
}
|
}
|
||||||
@@ -124,3 +173,147 @@ check_sums() {
|
|||||||
@test "in-cluster IPAM vendored files match the sums its Makefile pins" {
|
@test "in-cluster IPAM vendored files match the sums its Makefile pins" {
|
||||||
check_sums capi-providers-ipam-in-cluster CAIP ipam-components.yaml
|
check_sums capi-providers-ipam-in-cluster CAIP ipam-components.yaml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "CAPI core components.gz matches the vendored core-components.yaml" {
|
||||||
|
check_pair capi-providers-core core-components.yaml
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "CAPI core vendored files match the sums its Makefile pins" {
|
||||||
|
check_patched_sums capi-providers-core CAPI core-components.yaml
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "CAPI core ships the version its Makefile vendored" {
|
||||||
|
check_version capi-providers-core CAPI_VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
# capi-providers-bootstrap ships two providers, kubeadm and Talos, each with its
|
||||||
|
# own ConfigMap and BootstrapProvider, so the single-provider check above does
|
||||||
|
# not fit it. This asserts that the ConfigMap and the provider object for one of
|
||||||
|
# them both carry <Makefile version>-<suffix>.
|
||||||
|
check_bootstrap_version() {
|
||||||
|
local makefile_var="$1" suffix="$2"
|
||||||
|
local dir="${3:-$REPO_ROOT/packages/system/capi-providers-bootstrap}"
|
||||||
|
|
||||||
|
local version
|
||||||
|
version="$(sed -n "s/^${makefile_var} *= *//p" "$dir/Makefile")"
|
||||||
|
[ -n "$version" ] || { echo "capi-providers-bootstrap: no $makefile_var in Makefile" >&2; return 1; }
|
||||||
|
|
||||||
|
local want="$version-$suffix" rendered="$BATS_TEST_TMPDIR/$suffix.yaml" provider
|
||||||
|
case "$suffix" in
|
||||||
|
bootstrap) provider=kubeadm ;;
|
||||||
|
bootstrap-talos) provider=talos ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
helm template provider "$dir" --kube-version 1.33.0 > "$rendered"
|
||||||
|
[ "$(WANT="$want" yq --no-doc 'select(.kind == "ConfigMap" and .metadata.name == strenv(WANT)) | .metadata.name' "$rendered")" = "$want" ] \
|
||||||
|
|| { echo "capi-providers-bootstrap: no ConfigMap named $want" >&2; return 1; }
|
||||||
|
[ "$(PROVIDER="$provider" yq --no-doc 'select(.kind == "BootstrapProvider" and .metadata.name == strenv(PROVIDER)) | .spec.version' "$rendered")" = "$want" ] \
|
||||||
|
|| { echo "capi-providers-bootstrap: no BootstrapProvider at version $want" >&2; return 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
# A version carries dots, which a pattern match would take for any character.
|
||||||
|
@test "the bootstrap version check compares the version literally" {
|
||||||
|
local fx="$BATS_TEST_TMPDIR/bootstrap"
|
||||||
|
mkdir -p "$fx/templates"
|
||||||
|
printf 'CAPI_VERSION=v1.13.7\n' > "$fx/Makefile"
|
||||||
|
printf 'apiVersion: v2\nname: example\nversion: 0.0.0\n' > "$fx/Chart.yaml"
|
||||||
|
printf 'apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: v1x13x7-bootstrap\n' > "$fx/templates/configmaps.yaml"
|
||||||
|
printf 'apiVersion: operator.cluster.x-k8s.io/v1alpha2\nkind: BootstrapProvider\nmetadata:\n name: kubeadm\nspec:\n version: v1x13x7-bootstrap\n' > "$fx/templates/providers.yaml"
|
||||||
|
run check_bootstrap_version CAPI_VERSION bootstrap "$fx"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "kubeadm bootstrap ships the version its Makefile vendored" {
|
||||||
|
check_bootstrap_version CAPI_VERSION bootstrap
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Talos bootstrap ships the version its Makefile vendored" {
|
||||||
|
check_bootstrap_version CABPT_UPSTREAM_VERSION bootstrap-talos
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Talos bootstrap components-talos.gz matches the vendored bootstrap-components-talos.yaml" {
|
||||||
|
check_pair capi-providers-bootstrap bootstrap-components-talos.yaml components-talos.gz
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Talos bootstrap vendored files match the sums its Makefile pins" {
|
||||||
|
check_patched_sums capi-providers-bootstrap CABPT bootstrap-components-talos.yaml metadata-talos.yaml
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Talos bootstrap keeps a dedicated service account and matching bindings" {
|
||||||
|
local file="$REPO_ROOT/packages/system/capi-providers-bootstrap/files/bootstrap-components-talos.yaml" accounts
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "Deployment") | .spec.template.spec.serviceAccountName' "$file")" = cabpt-manager ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "ServiceAccount") | .metadata.name' "$file")" = cabpt-manager ]
|
||||||
|
accounts="$(yq --no-doc 'select(.kind == "RoleBinding" or .kind == "ClusterRoleBinding") | .subjects[] | select(.kind == "ServiceAccount") | .name' "$file")"
|
||||||
|
[ -n "$accounts" ]
|
||||||
|
while IFS= read -r account; do
|
||||||
|
[ "$account" = cabpt-manager ]
|
||||||
|
done <<< "$accounts"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "kubeadm bootstrap components.gz matches the vendored bootstrap-components.yaml" {
|
||||||
|
check_pair capi-providers-bootstrap bootstrap-components.yaml
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "kubeadm bootstrap vendored files match the sums its Makefile pins" {
|
||||||
|
check_sums capi-providers-bootstrap CAPI bootstrap-components.yaml
|
||||||
|
}
|
||||||
|
|
||||||
|
# The core and the kubeadm bootstrap provider are cut from one Cluster API
|
||||||
|
# release; running them at different versions is not a combination upstream
|
||||||
|
# tests.
|
||||||
|
@test "CAPI core and kubeadm bootstrap vendor the same Cluster API release" {
|
||||||
|
local core boot
|
||||||
|
core="$(sed -n 's/^CAPI_VERSION=//p' "$REPO_ROOT/packages/system/capi-providers-core/Makefile")"
|
||||||
|
boot="$(sed -n 's/^CAPI_VERSION=//p' "$REPO_ROOT/packages/system/capi-providers-bootstrap/Makefile")"
|
||||||
|
[ -n "$core" ] && [ "$core" = "$boot" ] \
|
||||||
|
|| { echo "core vendors '$core', kubeadm bootstrap vendors '$boot'" >&2; return 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "CAPI charts reject management Kubernetes below the supported minimum" {
|
||||||
|
local pkg
|
||||||
|
for pkg in capi-providers-core capi-providers-bootstrap; do
|
||||||
|
run helm template "$pkg" "$REPO_ROOT/packages/system/$pkg" --kube-version 1.32.9
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"requires kubeVersion"* ]]
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "CAPI charts render on the minimum supported management Kubernetes" {
|
||||||
|
local pkg
|
||||||
|
for pkg in capi-providers-core capi-providers-bootstrap; do
|
||||||
|
run helm template "$pkg" "$REPO_ROOT/packages/system/$pkg" --kube-version 1.33.0
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[[ "$output" == *"kind: ConfigMap"* ]]
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "intermediate core bundle recovers the pinned upstream release" {
|
||||||
|
check_patched_sums capi-operator CAPI_BRIDGE_CORE bridge-core-components.gz bridge-metadata.yaml CAPI_BRIDGE_SHA256_METADATA "$REPO_ROOT/packages/system/capi-providers-core/patches"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "intermediate kubeadm bundle matches the pinned upstream release" {
|
||||||
|
check_sums capi-operator CAPI_BRIDGE_BOOTSTRAP bridge-bootstrap-components.gz bridge-metadata.yaml CAPI_BRIDGE_SHA256_METADATA
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a changed compressed bootstrap bundle fails the pinned checksum" {
|
||||||
|
local fixture="$BATS_TEST_TMPDIR/fixture" source="$REPO_ROOT/packages/system/capi-operator"
|
||||||
|
mkdir "$fixture" "$fixture/packages" "$fixture/packages/system" "$fixture/packages/system/capi-operator" "$fixture/packages/system/capi-operator/files"
|
||||||
|
cp "$source/Makefile" "$fixture/packages/system/capi-operator/Makefile"
|
||||||
|
cp "$source/files/bridge-metadata.yaml" "$fixture/packages/system/capi-operator/files/bridge-metadata.yaml"
|
||||||
|
gzip --decompress --stdout "$source/files/bridge-bootstrap-components.gz" > "$BATS_TEST_TMPDIR/modified.yaml"
|
||||||
|
printf '\n# changed\n' >> "$BATS_TEST_TMPDIR/modified.yaml"
|
||||||
|
gzip --no-name --stdout "$BATS_TEST_TMPDIR/modified.yaml" > "$fixture/packages/system/capi-operator/files/bridge-bootstrap-components.gz"
|
||||||
|
REPO_ROOT="$fixture" run check_sums capi-operator CAPI_BRIDGE_BOOTSTRAP bridge-bootstrap-components.gz bridge-metadata.yaml CAPI_BRIDGE_SHA256_METADATA
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"does not match the sum"* ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "both core bundles retain the certificate provisioning startup budget" {
|
||||||
|
local file probe manifest="$BATS_TEST_TMPDIR/core-components.yaml"
|
||||||
|
for file in capi-providers-core/files/components.gz capi-operator/files/bridge-core-components.gz; do
|
||||||
|
gzip --decompress --stdout "$REPO_ROOT/packages/system/$file" > "$manifest"
|
||||||
|
probe="$(yq --output-format=json --no-doc 'select(.kind == "Deployment" and .metadata.name == "capi-controller-manager") | .spec.template.spec.containers[] | select(.name == "manager") | .startupProbe' "$manifest")"
|
||||||
|
[ -n "$probe" ]
|
||||||
|
jq --exit-status '.httpGet.path == "/healthz" and .httpGet.port == "healthz" and .failureThreshold * .periodSeconds >= 300' <<< "$probe"
|
||||||
|
done
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
|
||||||
|
CORE="$REPO_ROOT/packages/system/capi-providers-core"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
strict_setup
|
||||||
|
RENDERED="$BATS_TEST_TMPDIR/core.yaml"
|
||||||
|
helm template capi-providers-core "$CORE" --namespace test-capi --kube-version 1.33.0 > "$RENDERED"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the intermediate upgrade runs before Helm applies final provider manifests" {
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "Job") | .metadata.annotations."helm.sh/hook"' "$RENDERED")" = pre-install,pre-upgrade ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "Job") | .spec.backoffLimit' "$RENDERED")" = 0 ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.restartPolicy' "$RENDERED")" = Never ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "CoreProvider") | .metadata.annotations."helm.sh/hook"' "$RENDERED")" = null ]
|
||||||
|
local provider target
|
||||||
|
provider="$(yq --no-doc 'select(.kind == "CoreProvider") | .spec.version' "$RENDERED")"
|
||||||
|
target="$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].env[] | select(.name == "TARGET_VERSION") | .value' "$RENDERED")"
|
||||||
|
[ "$provider" = "$target-core" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the upgrade Job is kept until the next attempt, after a success too" {
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "Job") | .metadata.annotations."helm.sh/hook-delete-policy"' "$RENDERED")" = before-hook-creation ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind != "Job" and .metadata.annotations."helm.sh/hook" != null) | .metadata.annotations."helm.sh/hook-delete-policy"' "$RENDERED" | sort --unique)" = before-hook-creation,hook-succeeded ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the operator retains intermediate bundles independently of migration hooks" {
|
||||||
|
local name bridge policy rendered="$BATS_TEST_TMPDIR/operator.yaml"
|
||||||
|
bridge="$(< "$CORE/files/bridge-version")"
|
||||||
|
[ "$bridge" = "$(< "$REPO_ROOT/packages/system/capi-operator/files/bridge-version")" ]
|
||||||
|
helm template capi-operator "$REPO_ROOT/packages/system/capi-operator" --namespace test-capi > "$rendered"
|
||||||
|
for name in "$bridge-core" "$bridge-bootstrap"; do
|
||||||
|
policy="$(NAME="$name" yq --no-doc 'select(.kind == "ConfigMap" and .metadata.name == strenv(NAME)) | .metadata.annotations."helm.sh/resource-policy"' "$rendered")"
|
||||||
|
[ "$policy" = keep ]
|
||||||
|
[ "$(NAME="$name" yq --no-doc 'select(.kind == "ConfigMap" and .metadata.name == strenv(NAME)) | .metadata.annotations."helm.sh/hook"' "$rendered")" = null ]
|
||||||
|
[ "$(NAME="$name" yq --no-doc 'select(.kind == "ConfigMap" and .metadata.name == strenv(NAME)) | .metadata.annotations."provider.cluster.x-k8s.io/compressed"' "$rendered")" = true ]
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "intermediate bundles carry no label a legacy version-less selector matches" {
|
||||||
|
local rendered="$BATS_TEST_TMPDIR/operator.yaml"
|
||||||
|
helm template capi-operator "$REPO_ROOT/packages/system/capi-operator" --namespace test-capi > "$rendered"
|
||||||
|
yq --output-format=json --no-doc 'select(.kind == "ConfigMap" and .metadata.annotations."helm.sh/resource-policy" == "keep")' "$rendered" |
|
||||||
|
jq --slurp --exit-status 'length == 2 and all(.[]; .metadata.labels == {"provider.cluster.x-k8s.io/version": .metadata.name})'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the hook image follows the cluster images registry" {
|
||||||
|
local image mirrored
|
||||||
|
image="$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].image' "$RENDERED")"
|
||||||
|
[ "$image" = "$(yq '.upgrade.image' "$CORE/values.yaml")" ]
|
||||||
|
mirrored="$(helm template capi-providers-core "$CORE" --namespace test-capi --kube-version 1.33.0 --set-string '_cluster.images-registry=registry.example.test' |
|
||||||
|
yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].image')"
|
||||||
|
[ "$mirrored" = "registry.example.test/$image" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the packaged chart ships the cozy-lib subchart its templates include" {
|
||||||
|
local source="$REPO_ROOT/packages/core/platform/sources/capi-provider-core.yaml"
|
||||||
|
[ "$(yq '.spec.variants[] | select(.name == "default") | .libraries[] | select(.name == "cozy-lib") | .path' "$source")" = library/cozy-lib ]
|
||||||
|
[ "$(yq '.spec.variants[] | select(.name == "default") | .components[] | select(.name == "capi-providers-core") | .libraries[] | select(. == "cozy-lib")' "$source")" = cozy-lib ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the hook has no cluster-wide or secret permissions" {
|
||||||
|
local roles
|
||||||
|
roles="$(yq --output-format=json --no-doc 'select(.kind == "Role") | .rules' "$RENDERED")"
|
||||||
|
[ -n "$roles" ]
|
||||||
|
jq --exit-status 'length == 3 and all(.[];
|
||||||
|
(.verbs - ["get", "patch"] | length == 0) and
|
||||||
|
(.resourceNames | length > 0) and
|
||||||
|
(.resources - ["coreproviders", "bootstrapproviders", "deployments"] | length == 0)
|
||||||
|
)' <<< "$roles"
|
||||||
|
[ -z "$(yq --no-doc 'select(.kind == "ClusterRole" or .kind == "ClusterRoleBinding") | .kind' "$RENDERED")" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the hook mounts its script and uses an explicit in-cluster kubeconfig" {
|
||||||
|
local script image
|
||||||
|
script="$(yq --no-doc 'select(.kind == "ConfigMap" and .metadata.name == "capi-providers-core-upgrade") | .data."upgrade-providers.sh"' "$RENDERED")"
|
||||||
|
[ -n "$script" ]
|
||||||
|
[ "$script" = "$(< "$CORE/files/upgrade-providers.sh")" ]
|
||||||
|
[ "$(yq --output-format=json --indent 0 --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].command' "$RENDERED")" = '["bash","/scripts/upgrade-providers.sh"]' ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.volumes[] | select(.name == "scripts") | .configMap.name' "$RENDERED")" = capi-providers-core-upgrade ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].volumeMounts[] | select(.name == "scripts") | .mountPath' "$RENDERED")" = /scripts ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].env[] | select(.name == "KUBE_CONTEXT") | .value' "$RENDERED")" = capi-upgrade ]
|
||||||
|
image="$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].image' "$RENDERED")"
|
||||||
|
[[ "$image" =~ @sha256:[0-9a-f]{64}$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "hook RoleBinding namespace remains a string for YAML keyword names" {
|
||||||
|
local rendered="$BATS_TEST_TMPDIR/keyword-namespace.yaml"
|
||||||
|
helm template capi-providers-core "$CORE" --namespace true --kube-version 1.33.0 > "$rendered"
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "RoleBinding") | .subjects[0].namespace | tag' "$rendered")" = '!!str' ]
|
||||||
|
[ "$(yq --no-doc 'select(.kind == "RoleBinding") | .subjects[0].namespace' "$rendered")" = true ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the job deadline leaves room beyond the script deadline" {
|
||||||
|
local outer inner
|
||||||
|
outer="$(yq --no-doc 'select(.kind == "Job") | .spec.activeDeadlineSeconds' "$RENDERED")"
|
||||||
|
inner="$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].env[] | select(.name == "CAPI_UPGRADE_TIMEOUT_SECONDS") | .value' "$RENDERED")"
|
||||||
|
[ "$outer" -gt "$((inner + 10))" ]
|
||||||
|
[ "$outer" -lt 600 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "CAPI releases leave headroom for Helm Secret storage" {
|
||||||
|
local package chart manifest size budget=$((900 * 1024))
|
||||||
|
for package in capi-operator capi-providers-core; do
|
||||||
|
chart="$REPO_ROOT/packages/system/$package"
|
||||||
|
manifest="$BATS_TEST_TMPDIR/$package-manifest.yaml"
|
||||||
|
helm template "$package" "$chart" --namespace test-capi --kube-version 1.33.0 > "$manifest"
|
||||||
|
size="$(python3 -I "$REPO_ROOT/hack/helm-release-size.py" "$chart" < "$manifest")"
|
||||||
|
if [ "$size" -ge "$budget" ]; then
|
||||||
|
printf '%s: %s bytes exceeds storage budget %s\n' "$package" "$size" "$budget" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "every bootstrap variant waits for the core package migration" {
|
||||||
|
local variants
|
||||||
|
variants="$(yq --output-format=json '.spec.variants' "$REPO_ROOT/packages/core/platform/sources/capi-provider-bootstrap-kubeadm.yaml")"
|
||||||
|
[ -n "$variants" ]
|
||||||
|
jq --exit-status 'length > 0 and all(.[]; .dependsOn | index("cozystack.capi-provider-core") != null)' <<< "$variants"
|
||||||
|
}
|
||||||
|
|
||||||
|
render_repositories() {
|
||||||
|
local package
|
||||||
|
for package in capi-operator capi-providers-core capi-providers-bootstrap; do
|
||||||
|
helm template "$package" "$REPO_ROOT/packages/system/$package" --namespace test-capi --kube-version 1.33.0
|
||||||
|
printf '\n---\n'
|
||||||
|
done | yq --output-format=json --no-doc '.' | jq --slurp '.' > "$BATS_TEST_TMPDIR/repositories.json"
|
||||||
|
}
|
||||||
|
|
||||||
|
repository_matches_request() {
|
||||||
|
jq --exit-status --argjson count "${1:-2}" '
|
||||||
|
. as $objects | [.[] | select(.kind == "CoreProvider" or (.kind == "BootstrapProvider" and .metadata.name == "kubeadm"))] |
|
||||||
|
length == $count and all(.[]; . as $provider |
|
||||||
|
[$objects[] | select(.kind == "ConfigMap") | select(.metadata.labels as $labels |
|
||||||
|
$provider.spec.fetchConfig.selector.matchLabels | to_entries | all(.[]; $labels[.key] == .value))] |
|
||||||
|
length == 1 and ((.[0].metadata.labels["provider.cluster.x-k8s.io/version"] // .[0].metadata.name) == $provider.spec.version))
|
||||||
|
' "$BATS_TEST_TMPDIR/repositories.json"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "combined final repositories select one ConfigMap at the requested effective version" {
|
||||||
|
render_repositories
|
||||||
|
repository_matches_request
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "combined bridge repositories select one ConfigMap at the requested effective version" {
|
||||||
|
render_repositories
|
||||||
|
local bridge
|
||||||
|
bridge="$(< "$CORE/files/bridge-version")"
|
||||||
|
jq --arg bridge "$bridge" 'map(if .kind == "CoreProvider" or (.kind == "BootstrapProvider" and .metadata.name == "kubeadm") then
|
||||||
|
.spec.version = ($bridge + (if .kind == "CoreProvider" then "-core" else "-bootstrap" end)) |
|
||||||
|
.spec.fetchConfig.selector.matchLabels = {"provider.cluster.x-k8s.io/version": .spec.version}
|
||||||
|
else . end)' "$BATS_TEST_TMPDIR/repositories.json" > "$BATS_TEST_TMPDIR/bridge.json"
|
||||||
|
mv "$BATS_TEST_TMPDIR/bridge.json" "$BATS_TEST_TMPDIR/repositories.json"
|
||||||
|
repository_matches_request
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a unique repository with an unsuffixed native version is rejected" {
|
||||||
|
render_repositories
|
||||||
|
jq 'map(select(.kind != "BootstrapProvider") | if (.kind == "CoreProvider") then
|
||||||
|
.spec.fetchConfig.selector.matchLabels = {"core-components": "cozy", "provider.cluster.x-k8s.io/version": "v1.14.4"}
|
||||||
|
elif (.kind == "ConfigMap" and .metadata.name == "v1.14.4-core") then
|
||||||
|
.metadata.labels["provider.cluster.x-k8s.io/version"] = "v1.14.4"
|
||||||
|
else . end)' "$BATS_TEST_TMPDIR/repositories.json" > "$BATS_TEST_TMPDIR/negative.json"
|
||||||
|
mv "$BATS_TEST_TMPDIR/negative.json" "$BATS_TEST_TMPDIR/repositories.json"
|
||||||
|
jq --exit-status '[.[] | select(.kind == "ConfigMap" and .metadata.labels["core-components"] == "cozy" and .metadata.labels["provider.cluster.x-k8s.io/version"] == "v1.14.4")] | length == 1' "$BATS_TEST_TMPDIR/repositories.json"
|
||||||
|
run repository_matches_request 1
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Helm final restoration changes the bridge version and selector together" {
|
||||||
|
render_repositories
|
||||||
|
jq --exit-status '[.[] | select(.kind == "CoreProvider" or (.kind == "BootstrapProvider" and .metadata.name == "kubeadm"))] |
|
||||||
|
length == 2 and all(.[]; .spec.version == .spec.fetchConfig.selector.matchLabels["provider.cluster.x-k8s.io/version"])' "$BATS_TEST_TMPDIR/repositories.json"
|
||||||
|
}
|
||||||
@@ -0,0 +1,400 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
|
||||||
|
UPGRADE_SCRIPT="$REPO_ROOT/packages/system/capi-providers-core/files/upgrade-providers.sh"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
strict_setup
|
||||||
|
mkdir "$BATS_TEST_TMPDIR/bin"
|
||||||
|
cp "$REPO_ROOT/hack/testdata/capi-upgrade/kubectl" "$BATS_TEST_TMPDIR/bin/kubectl"
|
||||||
|
chmod +x "$BATS_TEST_TMPDIR/bin/kubectl"
|
||||||
|
export PATH="$BATS_TEST_TMPDIR/bin:$PATH"
|
||||||
|
export KUBECONFIG=/dev/null KUBE_CONTEXT=fixture NAMESPACE=test-capi
|
||||||
|
export BRIDGE_VERSION=v1.13.8 TARGET_VERSION=v1.14.4
|
||||||
|
export CAPI_UPGRADE_TIMEOUT_SECONDS=60 CAPI_UPGRADE_POLL_SECONDS=0
|
||||||
|
export CAPI_TEST_CLOCK_JUMP="${CAPI_TEST_CLOCK_JUMP:-5}"
|
||||||
|
export BASH_ENV="$REPO_ROOT/hack/testdata/capi-upgrade/clock.bash"
|
||||||
|
export CAPI_TEST_STATE="$BATS_TEST_TMPDIR/state.json" CAPI_TEST_LOG="$BATS_TEST_TMPDIR/calls.jsonl"
|
||||||
|
: > "$CAPI_TEST_LOG"
|
||||||
|
jq --null-input --argjson bridge "$(rendered_configmaps capi-operator templates/upgrade-bundles.yaml)" '
|
||||||
|
def provider($name; $suffix): {
|
||||||
|
metadata: {name: $name, uid: $name, generation: 1},
|
||||||
|
spec: {version: ("v1.10.1-" + $suffix), fetchConfig: {selector: {matchLabels: ({($suffix + "-components"): "cozy"} + if $suffix == "bootstrap" then {"bootstrap-provider": "kubeadm"} else {} end)}}},
|
||||||
|
status: {installedVersion: ("v1.10.1-" + $suffix), observedGeneration: 1, conditions: [{type: "Ready", status: "True"}]}
|
||||||
|
};
|
||||||
|
def deployment: {
|
||||||
|
metadata: {generation: 1}, spec: {replicas: 1},
|
||||||
|
status: {observedGeneration: 1, replicas: 1, updatedReplicas: 1, readyReplicas: 1, availableReplicas: 1}
|
||||||
|
};
|
||||||
|
{
|
||||||
|
providers: {"cluster-api": provider("cluster-api"; "core"), kubeadm: provider("kubeadm"; "bootstrap")},
|
||||||
|
deployments: {"capi-controller-manager": deployment, "capi-kubeadm-bootstrap-controller-manager": deployment},
|
||||||
|
configmaps: ([
|
||||||
|
{name: "v1.10.1-core", labels: {"core-components": "cozy"}},
|
||||||
|
{name: "v1.10.1-bootstrap", labels: {"bootstrap-components": "cozy", "bootstrap-provider": "kubeadm"}}
|
||||||
|
] + $bridge)
|
||||||
|
}' > "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
rendered_configmaps() {
|
||||||
|
helm template "$1" "$REPO_ROOT/packages/system/$1" --namespace test-capi --kube-version 1.33.0 --show-only "$2" |
|
||||||
|
yq --output-format=json --no-doc 'select(.kind == "ConfigMap") | {"name": .metadata.name, "labels": .metadata.labels}' |
|
||||||
|
jq --slurp --compact-output '.'
|
||||||
|
}
|
||||||
|
|
||||||
|
fixture() {
|
||||||
|
jq "$1" "$CAPI_TEST_STATE" > "$BATS_TEST_TMPDIR/next.json"
|
||||||
|
mv "$BATS_TEST_TMPDIR/next.json" "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
accepted_patches() {
|
||||||
|
jq --slurp --compact-output '[.[] | select(.accepted == true) | {name, version: (.patch[] | select(.path == "/spec/version" and .op == "replace") | .value)}]' "$CAPI_TEST_LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "fresh installations do not create or patch providers" {
|
||||||
|
fixture '.providers = {}'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "providers within the supported upgrade window are unchanged" {
|
||||||
|
fixture '.providers["cluster-api"].spec.version = "v1.13.7-core" | .providers["cluster-api"].status.installedVersion = "v1.13.7-core" | .providers.kubeadm.spec.version = "v1.13.7-bootstrap" | .providers.kubeadm.status.installedVersion = "v1.13.7-bootstrap"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "legacy core and kubeadm converge on the intermediate release in order" {
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"},{"name":"kubeadm","version":"v1.13.8-bootstrap"}]' ]
|
||||||
|
[ "$(jq --raw-output '.providers.kubeadm.status.installedVersion' "$CAPI_TEST_STATE")" = v1.13.8-bootstrap ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "bootstrap waits for the intermediate core deployment rollout" {
|
||||||
|
fixture '.lagRollout = true'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(jq --raw-output '.deployments["capi-controller-manager"].status.readyReplicas' "$CAPI_TEST_STATE")" = 1 ]
|
||||||
|
[ "$(jq --raw-output '.deployments["capi-kubeadm-bootstrap-controller-manager"].status.readyReplicas' "$CAPI_TEST_STATE")" = 1 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an interrupted transition resumes without downgrading core" {
|
||||||
|
fixture '.providers["cluster-api"].spec.version = "v1.13.8-core" | .providers["cluster-api"].spec.fetchConfig.selector.matchLabels = {"provider.cluster.x-k8s.io/version": "v1.13.8-core"} | .providers["cluster-api"].status.installedVersion = "v1.13.8-core"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"kubeadm","version":"v1.13.8-bootstrap"}]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a final core upgrade already in progress is not reset to the bridge" {
|
||||||
|
fixture ".configmaps += $(rendered_configmaps capi-providers-core templates/configmaps.yaml)"
|
||||||
|
fixture '.providers["cluster-api"].spec.version = "v1.14.4-core" | .providers["cluster-api"].status.installedVersion = "v1.13.8-core" | .pending = {"cluster-api": 2} | .providers["cluster-api"].spec.fetchConfig.selector.matchLabels["provider.cluster.x-k8s.io/version"] = "v1.14.4-core"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"kubeadm","version":"v1.13.8-bootstrap"}]' ]
|
||||||
|
[ "$(jq --raw-output '.providers["cluster-api"].status.installedVersion' "$CAPI_TEST_STATE")" = v1.14.4-core ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a core upgrade stalls while another installed provider selects two repositories" {
|
||||||
|
fixture '.configmaps += [{name: "v1.10.2-bootstrap", labels: {"bootstrap-components": "cozy", "bootstrap-provider": "kubeadm"}}]'
|
||||||
|
export CAPI_TEST_CLOCK_JUMP=61
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"cluster-api timed out"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the live legacy kubeadm selector matches only its own repository during the core step" {
|
||||||
|
jq --exit-status '.providers.kubeadm.spec.fetchConfig.selector.matchLabels as $s |
|
||||||
|
[.configmaps[] | select(.labels as $l | $s | to_entries | all(.[]; $l[.key] == .value))] | map(.name) == ["v1.10.1-bootstrap"]' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an API process cannot outlive the upgrade deadline" {
|
||||||
|
fixture '.readDelay = 3'
|
||||||
|
export CAPI_UPGRADE_TIMEOUT_SECONDS=1
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"timed out"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
[ "$(jq --raw-output '.delayedReadCompleted // false' "$CAPI_TEST_STATE")" = false ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a rollback of the requested core version resumes the installed bridge" {
|
||||||
|
fixture '.providers["cluster-api"].status.installedVersion = "v1.13.8-core"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"},{"name":"kubeadm","version":"v1.13.8-bootstrap"}]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a missing kubeadm provider is not installed by the migration" {
|
||||||
|
fixture 'del(.providers.kubeadm)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an API read failure aborts before any mutation" {
|
||||||
|
fixture '.failGet = "cluster-api"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"API unavailable"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a rejected patch aborts rather than reporting an upgraded provider" {
|
||||||
|
fixture '.failPatch = "cluster-api"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"patch refused"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "replacing a provider between read and patch fails the UID precondition" {
|
||||||
|
fixture '.replaceUIDOnPatch = "cluster-api"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"JSON patch test failed"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a competing requested version is not overwritten by the migration" {
|
||||||
|
fixture '.replaceVersionOnPatch = "cluster-api"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"JSON patch test failed"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
[ "$(jq --raw-output '.providers["cluster-api"].spec.version' "$CAPI_TEST_STATE")" = v1.12.4-core ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a newer installed minor cannot be downgraded by the chart" {
|
||||||
|
fixture '.providers["cluster-api"].spec.version = "v1.15.0-core" | .providers["cluster-api"].status.installedVersion = "v1.15.0-core"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"downgrades are not supported"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a newer installed patch cannot be downgraded by the chart" {
|
||||||
|
fixture '.providers["cluster-api"].spec.version = "v1.14.5-core" | .providers["cluster-api"].status.installedVersion = "v1.14.5-core"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"downgrades are not supported"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "malformed installed versions fail before either provider is changed" {
|
||||||
|
fixture '.providers.kubeadm.status.installedVersion = "invalid"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"invalid installed version"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "providers that never finished installing take the fresh installation path" {
|
||||||
|
fixture 'del(.providers[].status.installedVersion)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a kubeadm installation completing during the core upgrade is staged to the bridge" {
|
||||||
|
fixture '.bootstrapAfterCore = .providers.kubeadm | del(.providers.kubeadm.status.installedVersion)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"},{"name":"kubeadm","version":"v1.13.8-bootstrap"}]' ]
|
||||||
|
[ "$(jq --raw-output '.providers.kubeadm.status.installedVersion' "$CAPI_TEST_STATE")" = v1.13.8-bootstrap ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an unfinished kubeadm installation at an old requested version is staged to the bridge" {
|
||||||
|
fixture 'del(.providers.kubeadm.status.installedVersion)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"},{"name":"kubeadm","version":"v1.13.8-bootstrap"}]' ]
|
||||||
|
[ "$(jq --raw-output '.providers.kubeadm.status.installedVersion' "$CAPI_TEST_STATE")" = v1.13.8-bootstrap ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an unfinished kubeadm target request does not wait for the final bootstrap chart" {
|
||||||
|
fixture 'del(.providers.kubeadm.status.installedVersion) | .providers.kubeadm.spec.version = "v1.14.4-bootstrap" | .providers.kubeadm.spec.fetchConfig.selector.matchLabels = {"provider.cluster.x-k8s.io/version": "v1.14.4-bootstrap"}'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
|
||||||
|
jq --exit-status '.providers.kubeadm | .spec.version == "v1.14.4-bootstrap" and (.status | has("installedVersion") | not)' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an unfinished kubeadm request within the upgrade window is left to the final manifests" {
|
||||||
|
fixture 'del(.providers.kubeadm.status.installedVersion) | .providers.kubeadm.spec.version = "v1.13.7-bootstrap"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
|
||||||
|
jq --exit-status '.providers.kubeadm | .spec.version == "v1.13.7-bootstrap" and (.status | has("installedVersion") | not)' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an unfinished kubeadm installation with a malformed request is rejected" {
|
||||||
|
fixture 'del(.providers.kubeadm.status.installedVersion) | .providers.kubeadm.spec.version = "invalid"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"invalid requested version: invalid"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an unfinished kubeadm installation with no requested version is rejected" {
|
||||||
|
fixture 'del(.providers.kubeadm.status.installedVersion, .providers.kubeadm.spec.version)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"invalid requested version:"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a kubeadm replacement during the core upgrade is not adopted" {
|
||||||
|
fixture '.bootstrapAfterCore = (.providers.kubeadm | .metadata.uid = "replacement") | del(.providers.kubeadm.status.installedVersion)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"kubeadm was replaced during the upgrade"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a kubeadm version installed during the core upgrade is revalidated" {
|
||||||
|
fixture '.bootstrapAfterCore = (.providers.kubeadm | .status.installedVersion = "v1.14.5-bootstrap") | del(.providers.kubeadm.status.installedVersion)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"bootstrap provider downgrades are not supported"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "an installed kubeadm without an installed core provider is refused" {
|
||||||
|
fixture 'del(.providers["cluster-api"].status.installedVersion)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"kubeadm is installed without an installed core provider"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a malformed requested version is reported as the requested one" {
|
||||||
|
fixture '.providers["cluster-api"].spec.version = "invalid"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"invalid requested version: invalid"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a malformed target release is not reported as an installed version" {
|
||||||
|
export TARGET_VERSION=invalid
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"invalid target version: invalid"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "versions outside the intermediate upgrade window are rejected" {
|
||||||
|
fixture '.providers["cluster-api"].status.installedVersion = "v1.9.0-core" | .providers["cluster-api"].spec.version = "v1.9.0-core"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"outside the intermediate upgrade window"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a different requested upgrade is not overwritten" {
|
||||||
|
fixture '.providers["cluster-api"].spec.version = "v1.12.4-core"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"another upgrade is in progress"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a stalled intermediate rollout reaches a hard deadline" {
|
||||||
|
fixture '.stalled = true'
|
||||||
|
export CAPI_TEST_CLOCK_JUMP=61
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"timed out"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "bridge selection changes version and repository selector in one guarded patch" {
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
jq --slurp --exit-status 'all(.[] | select(.accepted); . as $call |
|
||||||
|
any(.patch[]; .op == "test" and .path == "/metadata/uid") and
|
||||||
|
any(.patch[]; .op == "test" and .path == "/spec/version") and
|
||||||
|
any(.patch[]; .op == "test" and .path == "/spec/fetchConfig") and
|
||||||
|
any(.patch[]; .path == "/spec/fetchConfig" and .op == "replace" and
|
||||||
|
.value.selector.matchLabels == {"provider.cluster.x-k8s.io/version":
|
||||||
|
(if $call.name == "cluster-api" then "v1.13.8-core" else "v1.13.8-bootstrap" end)}))' "$CAPI_TEST_LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "already selected bridges repair stale selectors inside the supported window" {
|
||||||
|
fixture '.providers |= with_entries(.value.spec.version = ("v1.13.8-" + (if .key == "cluster-api" then "core" else "bootstrap" end)) | .value.status.installedVersion = .value.spec.version)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
jq --exit-status 'all(.providers[]; .spec.fetchConfig.selector.matchLabels == {"provider.cluster.x-k8s.io/version": .spec.version})' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a bridge selector that keeps legacy labels is narrowed to the version label" {
|
||||||
|
fixture '.providers |= with_entries(.value.spec.version = ("v1.13.8-" + (if .key == "cluster-api" then "core" else "bootstrap" end)) | .value.status.installedVersion = .value.spec.version | .value.spec.fetchConfig.selector.matchLabels["provider.cluster.x-k8s.io/version"] = .value.spec.version)'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
jq --exit-status 'all(.providers[]; .spec.fetchConfig.selector.matchLabels == {"provider.cluster.x-k8s.io/version": .spec.version})' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a bridge selector with extra expressions is narrowed to the version label" {
|
||||||
|
fixture '.providers |= with_entries(.value.spec.version = ("v1.13.8-" + (if .key == "cluster-api" then "core" else "bootstrap" end)) | .value.status.installedVersion = .value.spec.version | .value.spec.fetchConfig.selector = {matchLabels: {"provider.cluster.x-k8s.io/version": .value.spec.version}, matchExpressions: [{key: "core-components", operator: "Exists"}]})'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
jq --exit-status 'all(.providers[]; .spec.fetchConfig.selector == {matchLabels: {"provider.cluster.x-k8s.io/version": .spec.version}})' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "already selected bridges repair missing fetchConfig without changing other spec fields" {
|
||||||
|
fixture '.providers |= with_entries(.value.spec.version = ("v1.13.8-" + (if .key == "cluster-api" then "core" else "bootstrap" end)) | .value.status.installedVersion = .value.spec.version | .value.spec.deployment = {replicas: 2} | del(.value.spec.fetchConfig))'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
jq --exit-status 'all(.providers[]; .spec.deployment.replicas == 2 and .spec.fetchConfig.selector.matchLabels == {"provider.cluster.x-k8s.io/version": .spec.version})' "$CAPI_TEST_STATE"
|
||||||
|
jq --slurp --exit-status 'all(.[] | select(.accepted); any(.patch[]; .op == "test" and .path == "/spec") and any(.patch[]; .op == "add" and .path == "/spec/fetchConfig"))' "$CAPI_TEST_LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a matching bridge selector is an idempotent no-op" {
|
||||||
|
fixture '.providers |= with_entries(.value.spec.version = ("v1.13.8-" + (if .key == "cluster-api" then "core" else "bootstrap" end)) | .value.status.installedVersion = .value.spec.version | .value.spec.fetchConfig.selector.matchLabels = {"provider.cluster.x-k8s.io/version": .value.spec.version})'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a concurrent fetchConfig replacement rejects the whole version transition" {
|
||||||
|
fixture '.replaceFetchConfigOnPatch = "cluster-api"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"JSON patch test failed"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
jq --exit-status '.providers["cluster-api"].spec | .version == "v1.10.1-core" and .fetchConfig.selector.matchLabels == {competing: "repository"}' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a concurrent fetchConfig creation rejects a stale add" {
|
||||||
|
fixture 'del(.providers["cluster-api"].spec.fetchConfig) | .replaceFetchConfigOnPatch = "cluster-api"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "$output" == *"JSON patch test failed"* ]]
|
||||||
|
[ "$(accepted_patches)" = '[]' ]
|
||||||
|
jq --exit-status '.providers["cluster-api"].spec | .version == "v1.10.1-core" and .fetchConfig.selector.matchLabels == {competing: "repository"}' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a status-only concurrent update does not conflict with bridge selection" {
|
||||||
|
fixture '.statusOnlyOnPatch = "cluster-api"'
|
||||||
|
run bash "$UPGRADE_SCRIPT"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(jq --raw-output '.providers["cluster-api"].metadata.resourceVersion' "$CAPI_TEST_STATE")" = 2 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the fake applies JSON Patch atomically when a later precondition fails" {
|
||||||
|
run kubectl --context fixture --namespace test-capi --request-timeout=10s patch coreproviders.operator.cluster.x-k8s.io cluster-api --type=json --patch '[{"op":"replace","path":"/spec/version","value":"v1.13.8-core"},{"op":"test","path":"/metadata/uid","value":"wrong"}]'
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[ "$(jq --raw-output '.providers["cluster-api"].spec.version' "$CAPI_TEST_STATE")" = v1.10.1-core ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the fake does not repair a stale selector or synthesize readiness" {
|
||||||
|
fixture '.pending = {"cluster-api": 0} | .providers["cluster-api"].spec.version = "v1.13.8-core" | .providers["cluster-api"].status.conditions = [{type: "Ready", status: "False"}]'
|
||||||
|
run kubectl --context fixture --namespace test-capi --request-timeout=10s get coreproviders.operator.cluster.x-k8s.io cluster-api --output json
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
jq --exit-status '.providers["cluster-api"] | .status.installedVersion == "v1.10.1-core" and .status.conditions[0].status == "False" and (.spec.fetchConfig.selector.matchLabels | has("provider.cluster.x-k8s.io/version") | not)' "$CAPI_TEST_STATE"
|
||||||
|
}
|
||||||
@@ -6407,7 +6407,10 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Wait for all machine deployment replicas to be ready (timeout after 10 minutes)
|
# Wait for all machine deployment replicas to be ready (timeout after 10 minutes)
|
||||||
kubectl wait machinedeployment kubernetes-${test_name}-md0 -n tenant-test --timeout=10m --for=jsonpath='{.status.v1beta2.readyReplicas}'=2
|
# Named at v1beta1: status.v1beta2.readyReplicas exists only there, and a bare
|
||||||
|
# resource name follows whichever version the cluster prefers, which is
|
||||||
|
# v1beta2 from Cluster API v1.11. v1beta1 is served until v1.16.
|
||||||
|
kubectl wait machinedeployments.v1beta1.cluster.x-k8s.io kubernetes-${test_name}-md0 -n tenant-test --timeout=10m --for=jsonpath='{.status.v1beta2.readyReplicas}'=2
|
||||||
|
|
||||||
for component in cilium coredns csi vsnap-crd; do
|
for component in cilium coredns csi vsnap-crd; do
|
||||||
kubectl wait hr "kubernetes-${test_name}-${component}" -n tenant-test --timeout=5m --for=condition=ready
|
kubectl wait hr "kubernetes-${test_name}-${component}" -n tenant-test --timeout=5m --for=condition=ready
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
sleep() {
|
||||||
|
if [[ -n "${CAPI_TEST_CLOCK_JUMP:-}" ]]; then
|
||||||
|
SECONDS=$((SECONDS + CAPI_TEST_CLOCK_JUMP))
|
||||||
|
else
|
||||||
|
command sleep "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
Vendored
+154
@@ -0,0 +1,154 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import copy
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
state_path = Path(os.environ["CAPI_TEST_STATE"])
|
||||||
|
log_path = Path(os.environ["CAPI_TEST_LOG"])
|
||||||
|
state = json.loads(state_path.read_text())
|
||||||
|
args = sys.argv[1:]
|
||||||
|
expected = ["--context", "fixture", "--namespace", "test-capi", "--request-timeout=10s"]
|
||||||
|
if args[:len(expected)] != expected:
|
||||||
|
sys.exit("unexpected kubectl context or namespace")
|
||||||
|
args = args[len(expected):]
|
||||||
|
verb, resource, name = args[:3]
|
||||||
|
resources = {
|
||||||
|
"coreproviders.operator.cluster.x-k8s.io": "providers",
|
||||||
|
"bootstrapproviders.operator.cluster.x-k8s.io": "providers",
|
||||||
|
"deployments.apps": "deployments",
|
||||||
|
}
|
||||||
|
if resource not in resources or name not in (
|
||||||
|
"cluster-api", "kubeadm", "capi-controller-manager", "capi-kubeadm-bootstrap-controller-manager"
|
||||||
|
):
|
||||||
|
sys.exit("unexpected resource")
|
||||||
|
entry = {"verb": verb, "resource": resource, "name": name}
|
||||||
|
|
||||||
|
|
||||||
|
def selected(selector):
|
||||||
|
return [cm for cm in state.get("configmaps", []) if all(cm["labels"].get(k) == v for k, v in selector.items())]
|
||||||
|
|
||||||
|
|
||||||
|
def repository_ready(name, obj):
|
||||||
|
own = selected(obj["spec"].get("fetchConfig", {}).get("selector", {}).get("matchLabels", {}))
|
||||||
|
if len(own) != 1 or own[0]["labels"].get("provider.cluster.x-k8s.io/version", own[0]["name"]) != obj["spec"]["version"]:
|
||||||
|
return False
|
||||||
|
# A version change makes cluster-api-operator resolve the repository of every
|
||||||
|
# other installed provider, refusing a selector that matches more than one ConfigMap.
|
||||||
|
return obj["status"].get("installedVersion") == obj["spec"]["version"] or all(
|
||||||
|
len(selected(other["spec"].get("fetchConfig", {}).get("selector", {}).get("matchLabels", {}))) == 1
|
||||||
|
for other_name, other in state["providers"].items()
|
||||||
|
if other_name != name and other["status"].get("installedVersion")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def save():
|
||||||
|
state_path.write_text(json.dumps(state))
|
||||||
|
|
||||||
|
|
||||||
|
def log():
|
||||||
|
with log_path.open("a") as stream:
|
||||||
|
stream.write(json.dumps(entry) + "\n")
|
||||||
|
|
||||||
|
|
||||||
|
if verb == "get":
|
||||||
|
log()
|
||||||
|
time.sleep(state.get("readDelay", 0))
|
||||||
|
if state.get("readDelay"):
|
||||||
|
state["delayedReadCompleted"] = True
|
||||||
|
save()
|
||||||
|
if state.get("failGet") == name:
|
||||||
|
sys.exit("API unavailable")
|
||||||
|
obj = state[resources[resource]].get(name)
|
||||||
|
if obj is None:
|
||||||
|
if "--ignore-not-found" not in args:
|
||||||
|
sys.exit("NotFound")
|
||||||
|
sys.exit(0)
|
||||||
|
if resource != "deployments.apps" and name in state.get("pending", {}):
|
||||||
|
pending = state["pending"][name]
|
||||||
|
if pending > 0:
|
||||||
|
state["pending"][name] -= 1
|
||||||
|
elif not state.get("stalled") and repository_ready(name, obj):
|
||||||
|
obj["status"]["installedVersion"] = obj["spec"]["version"]
|
||||||
|
obj["status"]["observedGeneration"] = obj["metadata"]["generation"]
|
||||||
|
obj["status"]["conditions"] = [{"type": "Ready", "status": "True"}]
|
||||||
|
deployment_name = "capi-controller-manager" if name == "cluster-api" else "capi-kubeadm-bootstrap-controller-manager"
|
||||||
|
deployment = state["deployments"][deployment_name]
|
||||||
|
deployment["metadata"]["generation"] += 1
|
||||||
|
deployment["status"]["observedGeneration"] = deployment["metadata"]["generation"]
|
||||||
|
deployment["status"]["updatedReplicas"] = 1
|
||||||
|
deployment["status"]["replicas"] = 1
|
||||||
|
deployment["status"]["readyReplicas"] = 0 if state.get("lagRollout") else 1
|
||||||
|
deployment["status"]["availableReplicas"] = deployment["status"]["readyReplicas"]
|
||||||
|
if state.get("lagRollout"):
|
||||||
|
state.setdefault("rolloutReads", {})[deployment_name] = 1
|
||||||
|
del state["pending"][name]
|
||||||
|
if resource == "deployments.apps" and name in state.get("rolloutReads", {}):
|
||||||
|
if state["rolloutReads"][name] > 0:
|
||||||
|
state["rolloutReads"][name] -= 1
|
||||||
|
else:
|
||||||
|
obj["status"]["readyReplicas"] = 1
|
||||||
|
obj["status"]["availableReplicas"] = 1
|
||||||
|
del state["rolloutReads"][name]
|
||||||
|
if name == "capi-controller-manager" and "bootstrapAfterCore" in state and obj["status"]["readyReplicas"] == 1:
|
||||||
|
state["providers"]["kubeadm"] = state.pop("bootstrapAfterCore")
|
||||||
|
save()
|
||||||
|
print(json.dumps(obj))
|
||||||
|
elif verb == "patch":
|
||||||
|
if resource == "deployments.apps" or "--type=json" not in args:
|
||||||
|
sys.exit("unexpected write")
|
||||||
|
patch = json.loads(args[args.index("--patch") + 1])
|
||||||
|
entry["patch"] = patch
|
||||||
|
if state.get("failPatch") == name:
|
||||||
|
log()
|
||||||
|
sys.exit("patch refused")
|
||||||
|
obj = state["providers"][name]
|
||||||
|
if state.get("replaceUIDOnPatch") == name:
|
||||||
|
obj["metadata"]["uid"] = "replacement"
|
||||||
|
save()
|
||||||
|
if state.get("replaceVersionOnPatch") == name:
|
||||||
|
obj["spec"]["version"] = "v1.12.4-core"
|
||||||
|
save()
|
||||||
|
if state.get("replaceFetchConfigOnPatch") == name:
|
||||||
|
obj["spec"]["fetchConfig"] = {"selector": {"matchLabels": {"competing": "repository"}}}
|
||||||
|
save()
|
||||||
|
if state.get("statusOnlyOnPatch") == name:
|
||||||
|
obj["metadata"]["resourceVersion"] = "2"
|
||||||
|
obj["status"]["conditions"] = [{"type": "Ready", "status": "False"}]
|
||||||
|
save()
|
||||||
|
candidate = copy.deepcopy(obj)
|
||||||
|
for operation in patch:
|
||||||
|
keys = [key.replace("~1", "/").replace("~0", "~") for key in operation["path"].strip("/").split("/")]
|
||||||
|
parent = candidate
|
||||||
|
for key in keys[:-1]:
|
||||||
|
parent = parent[key]
|
||||||
|
key = keys[-1]
|
||||||
|
if operation["op"] == "test":
|
||||||
|
if key not in parent or parent[key] != operation["value"]:
|
||||||
|
log()
|
||||||
|
sys.exit("JSON patch test failed")
|
||||||
|
elif operation["op"] in ("replace", "add") and operation["path"] in ("/spec/version", "/spec/fetchConfig"):
|
||||||
|
if operation["op"] == "replace" and key not in parent:
|
||||||
|
sys.exit("JSON patch replace target missing")
|
||||||
|
if name == "kubeadm":
|
||||||
|
core = state["providers"]["cluster-api"]
|
||||||
|
deployment = state["deployments"]["capi-controller-manager"]
|
||||||
|
if core["status"]["installedVersion"] == "v1.10.1-core" or deployment["status"]["readyReplicas"] != 1:
|
||||||
|
log()
|
||||||
|
sys.exit("bootstrap upgrade started before core was ready")
|
||||||
|
parent[key] = operation["value"]
|
||||||
|
else:
|
||||||
|
sys.exit("unexpected patch operation")
|
||||||
|
obj = candidate
|
||||||
|
state["providers"][name] = obj
|
||||||
|
obj["metadata"]["generation"] += 1
|
||||||
|
obj["status"]["conditions"] = [{"type": "Ready", "status": "False"}]
|
||||||
|
state.setdefault("pending", {})[name] = 1
|
||||||
|
entry["accepted"] = True
|
||||||
|
save()
|
||||||
|
log()
|
||||||
|
print(json.dumps(obj))
|
||||||
|
else:
|
||||||
|
sys.exit("unexpected kubectl operation")
|
||||||
@@ -46,6 +46,15 @@ spec:
|
|||||||
requests:
|
requests:
|
||||||
cpu: 125m
|
cpu: 125m
|
||||||
memory: 128Mi
|
memory: 128Mi
|
||||||
|
{{- /* Without CAPI_VERSION the autoscaler reads the newest Cluster API
|
||||||
|
version the management cluster serves, which is v1beta2 from
|
||||||
|
Cluster API v1.11. The 1.32 build lacks the fixes for reading
|
||||||
|
v1beta2 (kubernetes/autoscaler#8410 for scale from zero, #9458
|
||||||
|
for infrastructure references), so it stays on v1beta1, served
|
||||||
|
until Cluster API v1.16, until the image moves past them. */}}
|
||||||
|
env:
|
||||||
|
- name: CAPI_VERSION
|
||||||
|
value: v1beta1
|
||||||
command:
|
command:
|
||||||
- /cluster-autoscaler
|
- /cluster-autoscaler
|
||||||
args:
|
args:
|
||||||
|
|||||||
@@ -36,3 +36,14 @@ tests:
|
|||||||
- notContains:
|
- notContains:
|
||||||
path: spec.template.spec.containers[0].args
|
path: spec.template.spec.containers[0].args
|
||||||
content: --force-delete-unregistered-nodes=true
|
content: --force-delete-unregistered-nodes=true
|
||||||
|
|
||||||
|
- it: pins the Cluster API version the autoscaler reads to v1beta1
|
||||||
|
documentSelector:
|
||||||
|
path: kind
|
||||||
|
value: Deployment
|
||||||
|
asserts:
|
||||||
|
- contains:
|
||||||
|
path: spec.template.spec.containers[0].env
|
||||||
|
content:
|
||||||
|
name: CAPI_VERSION
|
||||||
|
value: v1beta1
|
||||||
@@ -14,6 +14,7 @@ spec:
|
|||||||
dependsOn:
|
dependsOn:
|
||||||
- cozystack.networking
|
- cozystack.networking
|
||||||
- cozystack.capi-operator
|
- cozystack.capi-operator
|
||||||
|
- cozystack.capi-provider-core
|
||||||
components:
|
components:
|
||||||
- name: capi-providers-bootstrap
|
- name: capi-providers-bootstrap
|
||||||
path: system/capi-providers-bootstrap
|
path: system/capi-providers-bootstrap
|
||||||
@@ -25,6 +26,7 @@ spec:
|
|||||||
dependsOn:
|
dependsOn:
|
||||||
- cozystack.networking
|
- cozystack.networking
|
||||||
- cozystack.capi-operator
|
- cozystack.capi-operator
|
||||||
|
- cozystack.capi-provider-core
|
||||||
components:
|
components:
|
||||||
- name: capi-providers-bootstrap
|
- name: capi-providers-bootstrap
|
||||||
path: system/capi-providers-bootstrap
|
path: system/capi-providers-bootstrap
|
||||||
|
|||||||
@@ -14,9 +14,13 @@ spec:
|
|||||||
dependsOn:
|
dependsOn:
|
||||||
- cozystack.networking
|
- cozystack.networking
|
||||||
- cozystack.capi-operator
|
- cozystack.capi-operator
|
||||||
|
libraries:
|
||||||
|
- name: cozy-lib
|
||||||
|
path: library/cozy-lib
|
||||||
components:
|
components:
|
||||||
- name: capi-providers-core
|
- name: capi-providers-core
|
||||||
path: system/capi-providers-core
|
path: system/capi-providers-core
|
||||||
|
libraries: ["cozy-lib"]
|
||||||
install:
|
install:
|
||||||
privileged: true
|
privileged: true
|
||||||
namespace: cozy-cluster-api
|
namespace: cozy-cluster-api
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
images
|
images
|
||||||
hack
|
hack
|
||||||
.gitkeep
|
.gitkeep
|
||||||
|
files/*-components.yaml
|
||||||
|
patches/
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: cozy-capi-operator
|
name: cozy-capi-operator
|
||||||
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
|
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
|
||||||
|
dependencies:
|
||||||
|
- name: cluster-api-operator
|
||||||
|
version: "*"
|
||||||
|
repository: "file://charts/cluster-api-operator"
|
||||||
@@ -3,7 +3,13 @@ export NAMESPACE=cozy-cluster-api
|
|||||||
export REPO_NAME=capi-operator
|
export REPO_NAME=capi-operator
|
||||||
export REPO_URL=https://kubernetes-sigs.github.io/cluster-api-operator
|
export REPO_URL=https://kubernetes-sigs.github.io/cluster-api-operator
|
||||||
export CHART_NAME=cluster-api-operator
|
export CHART_NAME=cluster-api-operator
|
||||||
export CHART_VERSION=^0.19
|
export CHART_VERSION=0.30.0
|
||||||
|
|
||||||
|
CAPI_BRIDGE_VERSION=v1.13.8
|
||||||
|
CAPI_BRIDGE_URL=https://github.com/kubernetes-sigs/cluster-api/releases/download/$(CAPI_BRIDGE_VERSION)
|
||||||
|
CAPI_BRIDGE_CORE_SHA256_COMPONENTS=f28647b6c20956d56fd8a678bf477821036bea71f1a1318d9cacdc413c779957
|
||||||
|
CAPI_BRIDGE_BOOTSTRAP_SHA256_COMPONENTS=775ebb39516fcf17eccaa6f2d157fa763f90d7349f274520c5320cb693d88726
|
||||||
|
CAPI_BRIDGE_SHA256_METADATA=20ffd682bfc50ab5193aa14ba55222ba390f9204ccf6a0dd2d52c4a3c4fb004f
|
||||||
|
|
||||||
include ../../../hack/package.mk
|
include ../../../hack/package.mk
|
||||||
|
|
||||||
@@ -12,3 +18,26 @@ update: clean capi-operator-update
|
|||||||
# The upstream chart has no value for --sync-period; values.yaml explains
|
# The upstream chart has no value for --sync-period; values.yaml explains
|
||||||
# why we set it.
|
# why we set it.
|
||||||
patch -p1 < patches/sync-period.diff
|
patch -p1 < patches/sync-period.diff
|
||||||
|
patch -p1 < patches/legacy-feature-gates.diff
|
||||||
|
patch -p1 < patches/provider-spec-guards.diff
|
||||||
|
patch -p1 < patches/fetch-config-precedence.diff
|
||||||
|
patch -p1 < patches/profiling-independent.diff
|
||||||
|
patch -p1 < patches/fetch-config-types.diff
|
||||||
|
patch -p1 < patches/provider-string-types.diff
|
||||||
|
|
||||||
|
.PHONY: bridge-components
|
||||||
|
bridge-components:
|
||||||
|
rm -rf .bridge-tmp
|
||||||
|
mkdir .bridge-tmp
|
||||||
|
curl --fail --location --output .bridge-tmp/core-components.yaml $(CAPI_BRIDGE_URL)/core-components.yaml
|
||||||
|
curl --fail --location --output .bridge-tmp/bootstrap-components.yaml $(CAPI_BRIDGE_URL)/bootstrap-components.yaml
|
||||||
|
curl --fail --location --output .bridge-tmp/metadata.yaml $(CAPI_BRIDGE_URL)/metadata.yaml
|
||||||
|
printf '%s .bridge-tmp/core-components.yaml\n%s .bridge-tmp/bootstrap-components.yaml\n%s .bridge-tmp/metadata.yaml\n' $(CAPI_BRIDGE_CORE_SHA256_COMPONENTS) $(CAPI_BRIDGE_BOOTSTRAP_SHA256_COMPONENTS) $(CAPI_BRIDGE_SHA256_METADATA) | sha256sum --check -
|
||||||
|
patch --batch .bridge-tmp/core-components.yaml < ../capi-providers-core/patches/0001-add-startup-probe.diff
|
||||||
|
mv .bridge-tmp/metadata.yaml files/bridge-metadata.yaml
|
||||||
|
gzip --best --no-name --stdout .bridge-tmp/core-components.yaml > files/bridge-core-components.gz
|
||||||
|
gzip --best --no-name --stdout .bridge-tmp/bootstrap-components.yaml > files/bridge-bootstrap-components.gz
|
||||||
|
rm .bridge-tmp/core-components.yaml .bridge-tmp/bootstrap-components.yaml
|
||||||
|
printf '%s\n' $(CAPI_BRIDGE_VERSION) | tee files/bridge-version ../capi-providers-core/files/bridge-version >/dev/null
|
||||||
|
if [ -f .bridge-tmp/core-components.yaml.orig ]; then rm .bridge-tmp/core-components.yaml.orig; fi
|
||||||
|
rmdir .bridge-tmp
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
appVersion: 0.19.0
|
appVersion: 0.30.0
|
||||||
description: Cluster API Operator
|
description: Cluster API Operator
|
||||||
name: cluster-api-operator
|
name: cluster-api-operator
|
||||||
type: application
|
type: application
|
||||||
version: 0.19.0
|
version: 0.30.0
|
||||||
+10
@@ -22,3 +22,13 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "capi-operator.configSecret" -}}
|
||||||
|
{{- $ := .ROOT -}}
|
||||||
|
{{- $arg := .ARGUMENT -}}
|
||||||
|
configSecret:
|
||||||
|
name: {{ default (($.Values).configSecret).name (($arg).configSecret).name | toYaml }}
|
||||||
|
{{- if (default (($.Values).configSecret).namespace (($arg).configSecret).namespace) }}
|
||||||
|
namespace: {{ default (($.Values).configSecret).namespace (($arg).configSecret).namespace | toYaml }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
+24
-1
@@ -3,6 +3,7 @@
|
|||||||
{{- $addonNamespace := default ( printf "%s-%s" $name "addon-system" ) (get $addon "namespace") }}
|
{{- $addonNamespace := default ( printf "%s-%s" $name "addon-system" ) (get $addon "namespace") }}
|
||||||
{{- $addonName := $name }}
|
{{- $addonName := $name }}
|
||||||
{{- $addonVersion := get $addon "version" }}
|
{{- $addonVersion := get $addon "version" }}
|
||||||
|
{{- if ne $addon.createNamespace false }}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
@@ -14,6 +15,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "1"
|
"argocd.argoproj.io/sync-wave": "1"
|
||||||
name: {{ $addonNamespace }}
|
name: {{ $addonNamespace }}
|
||||||
|
{{- end }}
|
||||||
---
|
---
|
||||||
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
kind: AddonProvider
|
kind: AddonProvider
|
||||||
@@ -26,12 +28,30 @@ metadata:
|
|||||||
"helm.sh/hook-weight": "2"
|
"helm.sh/hook-weight": "2"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "2"
|
"argocd.argoproj.io/sync-wave": "2"
|
||||||
{{- if or $addonVersion $.Values.secretName }}
|
{{- if or $addonVersion $.Values.secretName $.Values.secretNamespace $.Values.configSecret.name $addon.manager $addon.deployment (($addon).configSecret).name $addon.fetchConfig $addon.manifestPatches $addon.additionalManifests }}
|
||||||
spec:
|
spec:
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
{{- if $addon.deployment }}
|
||||||
|
deployment: {{ toYaml $addon.deployment | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $addon.manager }}
|
||||||
|
manager:
|
||||||
|
{{- if $addon.manager.metrics }}
|
||||||
|
metrics:
|
||||||
|
{{- if $addon.manager.metrics.insecureDiagnostics }}
|
||||||
|
insecureDiagnostics: {{ $addon.manager.metrics.insecureDiagnostics }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $addon.manager.metrics.diagnosticsAddress }}
|
||||||
|
diagnosticsAddress: {{ $addon.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
{{- if $addonVersion }}
|
{{- if $addonVersion }}
|
||||||
version: {{ $addonVersion }}
|
version: {{ $addonVersion }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if (default (($addon).configSecret).name (($.Values).configSecret).name) }}
|
||||||
|
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $addon) | nindent 2 }}
|
||||||
|
{{- end }}
|
||||||
{{- if $.Values.secretName }}
|
{{- if $.Values.secretName }}
|
||||||
secretName: {{ $.Values.secretName }}
|
secretName: {{ $.Values.secretName }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -41,6 +61,9 @@ spec:
|
|||||||
{{- if $addon.manifestPatches }}
|
{{- if $addon.manifestPatches }}
|
||||||
manifestPatches: {{ toYaml $addon.manifestPatches | nindent 4 }}
|
manifestPatches: {{ toYaml $addon.manifestPatches | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $addon.fetchConfig }}
|
||||||
|
fetchConfig: {{ toYaml $addon.fetchConfig | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
{{- if $addon.additionalManifests }}
|
{{- if $addon.additionalManifests }}
|
||||||
additionalManifests:
|
additionalManifests:
|
||||||
name: {{ $addon.additionalManifests.name }}
|
name: {{ $addon.additionalManifests.name }}
|
||||||
|
|||||||
+29
-7
@@ -3,6 +3,7 @@
|
|||||||
{{- $bootstrapNamespace := default ( printf "%s-%s" $name "bootstrap-system" ) (get $bootstrap "namespace") }}
|
{{- $bootstrapNamespace := default ( printf "%s-%s" $name "bootstrap-system" ) (get $bootstrap "namespace") }}
|
||||||
{{- $bootstrapName := $name }}
|
{{- $bootstrapName := $name }}
|
||||||
{{- $bootstrapVersion := get $bootstrap "version" }}
|
{{- $bootstrapVersion := get $bootstrap "version" }}
|
||||||
|
{{- if ne $bootstrap.createNamespace false }}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
@@ -14,6 +15,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "1"
|
"argocd.argoproj.io/sync-wave": "1"
|
||||||
name: {{ $bootstrapNamespace }}
|
name: {{ $bootstrapNamespace }}
|
||||||
|
{{- end }}
|
||||||
---
|
---
|
||||||
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
kind: BootstrapProvider
|
kind: BootstrapProvider
|
||||||
@@ -26,22 +28,42 @@ metadata:
|
|||||||
"helm.sh/hook-weight": "2"
|
"helm.sh/hook-weight": "2"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "2"
|
"argocd.argoproj.io/sync-wave": "2"
|
||||||
{{- if or $bootstrapVersion $.Values.configSecret.name }}
|
{{- if or $bootstrapVersion $.Values.configSecret.name $bootstrap.manager $bootstrap.deployment (($bootstrap).configSecret).name $bootstrap.fetchConfig $bootstrap.manifestPatches $bootstrap.additionalManifests }}
|
||||||
spec:
|
spec:
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
{{- if $bootstrap.deployment }}
|
||||||
|
deployment: {{ toYaml $bootstrap.deployment | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $bootstrap.manager }}
|
||||||
|
manager:
|
||||||
|
{{- if $bootstrap.manager.featureGates }}
|
||||||
|
featureGates:
|
||||||
|
{{- range $key, $value := $bootstrap.manager.featureGates }}
|
||||||
|
{{ $key }}: {{ $value }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $bootstrap.manager.metrics }}
|
||||||
|
metrics:
|
||||||
|
{{- if $bootstrap.manager.metrics.insecureDiagnostics }}
|
||||||
|
insecureDiagnostics: {{ $bootstrap.manager.metrics.insecureDiagnostics }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $bootstrap.manager.metrics.diagnosticsAddress }}
|
||||||
|
diagnosticsAddress: {{ $bootstrap.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
{{- if $bootstrapVersion }}
|
{{- if $bootstrapVersion }}
|
||||||
version: {{ $bootstrapVersion }}
|
version: {{ $bootstrapVersion }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $.Values.configSecret.name }}
|
{{- if (default (($bootstrap).configSecret).name (($.Values).configSecret).name) }}
|
||||||
configSecret:
|
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $bootstrap) | nindent 2 }}
|
||||||
name: {{ $.Values.configSecret.name }}
|
|
||||||
{{- if $.Values.configSecret.namespace }}
|
|
||||||
namespace: {{ $.Values.configSecret.namespace }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $bootstrap.manifestPatches }}
|
{{- if $bootstrap.manifestPatches }}
|
||||||
manifestPatches: {{ toYaml $bootstrap.manifestPatches | nindent 4 }}
|
manifestPatches: {{ toYaml $bootstrap.manifestPatches | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $bootstrap.fetchConfig }}
|
||||||
|
fetchConfig: {{ toYaml $bootstrap.fetchConfig | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
{{- if $bootstrap.additionalManifests }}
|
{{- if $bootstrap.additionalManifests }}
|
||||||
additionalManifests:
|
additionalManifests:
|
||||||
name: {{ $bootstrap.additionalManifests.name }}
|
name: {{ $bootstrap.additionalManifests.name }}
|
||||||
|
|||||||
+25
-15
@@ -1,8 +1,10 @@
|
|||||||
# Control plane provider
|
# Control plane provider
|
||||||
{{- range $name, $controlPlane := $.Values.controlPlane }}
|
{{- range $name, $controlPlane := $.Values.controlPlane }}
|
||||||
|
{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $controlPlane "key" $name) }}
|
||||||
{{- $controlPlaneNamespace := default ( printf "%s-%s" $name "control-plane-system" ) (get $controlPlane "namespace") }}
|
{{- $controlPlaneNamespace := default ( printf "%s-%s" $name "control-plane-system" ) (get $controlPlane "namespace") }}
|
||||||
{{- $controlPlaneName := $name }}
|
{{- $controlPlaneName := $name }}
|
||||||
{{- $controlPlaneVersion := get $controlPlane "version" }}
|
{{- $controlPlaneVersion := get $controlPlane "version" }}
|
||||||
|
{{- if ne $controlPlane.createNamespace false }}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
@@ -14,6 +16,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "1"
|
"argocd.argoproj.io/sync-wave": "1"
|
||||||
name: {{ $controlPlaneNamespace }}
|
name: {{ $controlPlaneNamespace }}
|
||||||
|
{{- end }}
|
||||||
---
|
---
|
||||||
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
kind: ControlPlaneProvider
|
kind: ControlPlaneProvider
|
||||||
@@ -26,35 +29,42 @@ metadata:
|
|||||||
"helm.sh/hook-weight": "2"
|
"helm.sh/hook-weight": "2"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "2"
|
"argocd.argoproj.io/sync-wave": "2"
|
||||||
{{- if or $controlPlaneVersion $.Values.configSecret.name $.Values.manager }}
|
{{- if or $controlPlaneVersion $.Values.configSecret.name $controlPlane.manager $controlPlane.deployment (($controlPlane).configSecret).name $controlPlane.fetchConfig $controlPlane.manifestPatches $controlPlane.additionalManifests }}
|
||||||
spec:
|
spec:
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{- if $controlPlaneVersion }}
|
{{- if $controlPlaneVersion }}
|
||||||
version: {{ $controlPlaneVersion }}
|
version: {{ $controlPlaneVersion }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $.Values.manager }}
|
{{- if $controlPlane.deployment }}
|
||||||
{{- if hasKey $.Values.manager.featureGates $controlPlaneName }}
|
deployment: {{ toYaml $controlPlane.deployment | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $controlPlane.manager }}
|
||||||
manager:
|
manager:
|
||||||
{{- range $key, $value := $.Values.manager.featureGates }}
|
{{- if $controlPlane.manager.featureGates }}
|
||||||
{{- if eq $key $controlPlaneName }}
|
|
||||||
featureGates:
|
featureGates:
|
||||||
{{- range $k, $v := $value }}
|
{{- range $key, $value := $controlPlane.manager.featureGates }}
|
||||||
{{ $k }}: {{ $v }}
|
{{ $key }}: {{ $value }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $controlPlane.manager.metrics }}
|
||||||
|
metrics:
|
||||||
|
{{- if $controlPlane.manager.metrics.insecureDiagnostics }}
|
||||||
|
insecureDiagnostics: {{ $controlPlane.manager.metrics.insecureDiagnostics }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $controlPlane.manager.metrics.diagnosticsAddress }}
|
||||||
|
diagnosticsAddress: {{ $controlPlane.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- if (default (($controlPlane).configSecret).name (($.Values).configSecret).name) }}
|
||||||
{{- end }}
|
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $controlPlane) | nindent 2 }}
|
||||||
{{- if $.Values.configSecret.name }}
|
|
||||||
configSecret:
|
|
||||||
name: {{ $.Values.configSecret.name }}
|
|
||||||
{{- if $.Values.configSecret.namespace }}
|
|
||||||
namespace: {{ $.Values.configSecret.namespace }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $controlPlane.manifestPatches }}
|
{{- if $controlPlane.manifestPatches }}
|
||||||
manifestPatches: {{ toYaml $controlPlane.manifestPatches | nindent 4 }}
|
manifestPatches: {{ toYaml $controlPlane.manifestPatches | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $controlPlane.fetchConfig }}
|
||||||
|
fetchConfig: {{ toYaml $controlPlane.fetchConfig | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
{{- if $controlPlane.additionalManifests }}
|
{{- if $controlPlane.additionalManifests }}
|
||||||
additionalManifests:
|
additionalManifests:
|
||||||
name: {{ $controlPlane.additionalManifests.name }}
|
name: {{ $controlPlane.additionalManifests.name }}
|
||||||
|
|||||||
+25
-11
@@ -1,8 +1,10 @@
|
|||||||
# Core provider
|
# Core provider
|
||||||
{{- range $name, $core := $.Values.core }}
|
{{- range $name, $core := $.Values.core }}
|
||||||
|
{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $core "key" "core") }}
|
||||||
{{- $coreNamespace := default "capi-system" (get $core "namespace") }}
|
{{- $coreNamespace := default "capi-system" (get $core "namespace") }}
|
||||||
{{- $coreName := $name }}
|
{{- $coreName := $name }}
|
||||||
{{- $coreVersion := get $core "version" }}
|
{{- $coreVersion := get $core "version" }}
|
||||||
|
{{- if ne $core.createNamespace false }}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
@@ -14,6 +16,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "1"
|
"argocd.argoproj.io/sync-wave": "1"
|
||||||
name: {{ $coreNamespace }}
|
name: {{ $coreNamespace }}
|
||||||
|
{{- end }}
|
||||||
---
|
---
|
||||||
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
kind: CoreProvider
|
kind: CoreProvider
|
||||||
@@ -26,31 +29,42 @@ metadata:
|
|||||||
"helm.sh/hook-weight": "2"
|
"helm.sh/hook-weight": "2"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "2"
|
"argocd.argoproj.io/sync-wave": "2"
|
||||||
{{- if or $coreVersion $.Values.configSecret.name $.Values.manager }}
|
{{- if or $coreVersion $.Values.configSecret.name $core.manager $core.deployment (($core).configSecret).name $core.fetchConfig $core.manifestPatches $core.additionalManifests }}
|
||||||
spec:
|
spec:
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{- if $coreVersion }}
|
{{- if $coreVersion }}
|
||||||
version: {{ $coreVersion }}
|
version: {{ $coreVersion }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $.Values.manager }}
|
{{- if $core.deployment }}
|
||||||
{{- if and $.Values.manager.featureGates $.Values.manager.featureGates.core }}
|
deployment: {{ toYaml $core.deployment | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $core.manager }}
|
||||||
manager:
|
manager:
|
||||||
|
{{- if $core.manager.featureGates }}
|
||||||
featureGates:
|
featureGates:
|
||||||
{{- range $key, $value := $.Values.manager.featureGates.core }}
|
{{- range $key, $value := $core.manager.featureGates }}
|
||||||
{{ $key }}: {{ $value }}
|
{{ $key }}: {{ $value }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- if $core.manager.metrics }}
|
||||||
{{- if $.Values.configSecret.name }}
|
metrics:
|
||||||
configSecret:
|
{{- if $core.manager.metrics.insecureDiagnostics }}
|
||||||
name: {{ $.Values.configSecret.name }}
|
insecureDiagnostics: {{ $core.manager.metrics.insecureDiagnostics }}
|
||||||
{{- if $.Values.configSecret.namespace }}
|
|
||||||
namespace: {{ $.Values.configSecret.namespace }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $core.manager.metrics.diagnosticsAddress }}
|
||||||
|
diagnosticsAddress: {{ $core.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if (default (($core).configSecret).name (($.Values).configSecret).name) }}
|
||||||
|
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $core) | nindent 2 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $core.manifestPatches }}
|
{{- if $core.manifestPatches }}
|
||||||
manifestPatches: {{ toYaml $core.manifestPatches | nindent 4 }}
|
manifestPatches: {{ toYaml $core.manifestPatches | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $core.fetchConfig }}
|
||||||
|
fetchConfig: {{ toYaml $core.fetchConfig | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
{{- if $core.additionalManifests }}
|
{{- if $core.additionalManifests }}
|
||||||
additionalManifests:
|
additionalManifests:
|
||||||
name: {{ $core.additionalManifests.name }}
|
name: {{ $core.additionalManifests.name }}
|
||||||
|
|||||||
+25
-13
@@ -74,6 +74,9 @@ spec:
|
|||||||
{{- if .Values.watchConfigSecret }}
|
{{- if .Values.watchConfigSecret }}
|
||||||
- --watch-configsecret
|
- --watch-configsecret
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if .Values.watchConfigMap }}
|
||||||
|
- --watch-configmap
|
||||||
|
{{- end }}
|
||||||
{{- with .Values.leaderElection }}
|
{{- with .Values.leaderElection }}
|
||||||
- --leader-elect={{ .enabled }}
|
- --leader-elect={{ .enabled }}
|
||||||
{{- if .leaseDuration }}
|
{{- if .leaseDuration }}
|
||||||
@@ -86,6 +89,12 @@ spec:
|
|||||||
- --leader-elect-retry-period={{ .retryPeriod }}
|
- --leader-elect-retry-period={{ .retryPeriod }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $.Values.profilerAddress }}
|
||||||
|
- --profiler-address={{ if hasPrefix ":" ($.Values.profilerAddress | toString) }}localhost{{ end }}{{ $.Values.profilerAddress }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $.Values.contentionProfiling }}
|
||||||
|
- --contention-profiling={{ $.Values.contentionProfiling }}
|
||||||
|
{{- end }}
|
||||||
{{- with .Values.syncPeriod }}
|
{{- with .Values.syncPeriod }}
|
||||||
- --sync-period={{ . }}
|
- --sync-period={{ . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -97,18 +106,21 @@ spec:
|
|||||||
imagePullPolicy: {{ .Values.image.manager.pullPolicy }}
|
imagePullPolicy: {{ .Values.image.manager.pullPolicy }}
|
||||||
name: manager
|
name: manager
|
||||||
ports:
|
ports:
|
||||||
|
{{- if $.Values.profilerAddress }}
|
||||||
|
{{- $profilerPort := $.Values.profilerAddress | toString | splitList ":" | last | int }}
|
||||||
|
- containerPort: {{ $profilerPort }}
|
||||||
|
name: profiler
|
||||||
|
protocol: TCP
|
||||||
|
{{- end }}
|
||||||
- containerPort: 9443
|
- containerPort: 9443
|
||||||
name: webhook-server
|
name: webhook-server
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
{{- if $.Values.diagnosticsAddress }}
|
{{- if .Values.diagnosticsAddress }}
|
||||||
{{- $diagnosticsPort := $.Values.diagnosticsAddress }}
|
{{- $diagnosticsPort := .Values.diagnosticsAddress | toString | splitList ":" | last | int }}
|
||||||
{{- if contains ":" $diagnosticsPort -}}
|
- containerPort: {{ $diagnosticsPort }}
|
||||||
{{ $diagnosticsPort = ( split ":" $.Values.diagnosticsAddress)._1 | int }}
|
name: diagnostics
|
||||||
{{- end }}
|
|
||||||
- containerPort: {{ $diagnosticsPort | int }}
|
|
||||||
name: metrics
|
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with .Values.resources.manager }}
|
{{- with .Values.resources.manager }}
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml . | nindent 12 }}
|
{{- toYaml . | nindent 12 }}
|
||||||
@@ -126,15 +138,15 @@ spec:
|
|||||||
{{- toYaml . | nindent 12 }}
|
{{- toYaml . | nindent 12 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
terminationMessagePolicy: FallbackToLogsOnError
|
terminationMessagePolicy: FallbackToLogsOnError
|
||||||
{{- $healthAddr := $.Values.healthAddr }}
|
{{- $healthPort := 9440 }}
|
||||||
{{- if contains ":" $healthAddr -}}
|
{{- if .Values.healthAddr }}
|
||||||
{{ $healthAddr = ( split ":" $.Values.healthAddr)._1 | int }}
|
{{- $healthPort = .Values.healthAddr | toString | splitList ":" | last | int }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
failureThreshold: 3
|
failureThreshold: 3
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /healthz
|
path: /healthz
|
||||||
port: {{ $healthAddr | default 9440 }}
|
port: {{ $healthPort }}
|
||||||
scheme: HTTP
|
scheme: HTTP
|
||||||
initialDelaySeconds: 15
|
initialDelaySeconds: 15
|
||||||
periodSeconds: 20
|
periodSeconds: 20
|
||||||
@@ -144,7 +156,7 @@ spec:
|
|||||||
failureThreshold: 3
|
failureThreshold: 3
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /readyz
|
path: /readyz
|
||||||
port: {{ $healthAddr | default 9440 }}
|
port: {{ $healthPort }}
|
||||||
scheme: HTTP
|
scheme: HTTP
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
periodSeconds: 10
|
periodSeconds: 10
|
||||||
|
|||||||
+4
-7
@@ -61,14 +61,11 @@ metadata:
|
|||||||
"argocd.argoproj.io/sync-wave": "2"
|
"argocd.argoproj.io/sync-wave": "2"
|
||||||
{{- with .Values.configSecret }}
|
{{- with .Values.configSecret }}
|
||||||
spec:
|
spec:
|
||||||
{{- if $.Values.manager }}
|
{{- $controlPlane := dict }}
|
||||||
{{- if and $.Values.manager.featureGates $.Values.manager.featureGates.kubeadm }}
|
{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $controlPlane "key" "kubeadm") }}
|
||||||
|
{{- with $controlPlane.manager }}
|
||||||
manager:
|
manager:
|
||||||
featureGates:
|
{{- toYaml . | nindent 4 }}
|
||||||
{{- range $key, $value := $.Values.manager.featureGates.kubeadm }}
|
|
||||||
{{ $key }}: {{ $value }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
configSecret:
|
configSecret:
|
||||||
name: {{ .name }}
|
name: {{ .name }}
|
||||||
|
|||||||
+32
-20
@@ -1,8 +1,10 @@
|
|||||||
# Infrastructure providers
|
# Infrastructure providers
|
||||||
{{- range $name, $infra := $.Values.infrastructure }}
|
{{- range $name, $infra := $.Values.infrastructure }}
|
||||||
|
{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $infra "key" $name) }}
|
||||||
{{- $infrastructureNamespace := default ( printf "%s-%s" $name "infrastructure-system" ) (get $infra "namespace") }}
|
{{- $infrastructureNamespace := default ( printf "%s-%s" $name "infrastructure-system" ) (get $infra "namespace") }}
|
||||||
{{- $infrastructureName := $name }}
|
{{- $infrastructureName := $name }}
|
||||||
{{- $infrastructureVersion := get $infra "version" }}
|
{{- $infrastructureVersion := get $infra "version" }}
|
||||||
|
{{- if ne $infra.createNamespace false }}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
@@ -14,6 +16,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "1"
|
"argocd.argoproj.io/sync-wave": "1"
|
||||||
name: {{ $infrastructureNamespace }}
|
name: {{ $infrastructureNamespace }}
|
||||||
|
{{- end }}
|
||||||
---
|
---
|
||||||
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
kind: InfrastructureProvider
|
kind: InfrastructureProvider
|
||||||
@@ -26,41 +29,44 @@ metadata:
|
|||||||
"helm.sh/hook-weight": "2"
|
"helm.sh/hook-weight": "2"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "2"
|
"argocd.argoproj.io/sync-wave": "2"
|
||||||
{{- if or $infrastructureVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments }}
|
{{- if or $infrastructureVersion $.Values.configSecret.name $infra.manager $infra.deployment $.Values.additionalDeployments (($infra).configSecret).name $infra.fetchConfig $infra.patches $infra.manifestPatches $infra.additionalManifests (and (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $infrastructureName)) }}
|
||||||
spec:
|
spec:
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $infrastructureVersion }}
|
{{- if $infrastructureVersion }}
|
||||||
version: {{ $infrastructureVersion }}
|
version: {{ $infrastructureVersion }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $.Values.manager }}
|
{{- if $infra.deployment }}
|
||||||
{{- if and (kindIs "map" $.Values.manager.featureGates) (hasKey $.Values.manager.featureGates $infrastructureName) }}
|
deployment: {{ toYaml $infra.deployment | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $infra.manager }}
|
||||||
manager:
|
manager:
|
||||||
{{- range $key, $value := $.Values.manager.featureGates }}
|
{{- if $infra.manager.featureGates }}
|
||||||
{{- if eq $key $infrastructureName }}
|
|
||||||
featureGates:
|
featureGates:
|
||||||
{{- range $k, $v := $value }}
|
{{- range $key, $value := $infra.manager.featureGates }}
|
||||||
{{ $k }}: {{ $v }}
|
{{ $key }}: {{ $value }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $infra.manager.metrics }}
|
||||||
|
metrics:
|
||||||
|
{{- if $infra.manager.metrics.insecureDiagnostics }}
|
||||||
|
insecureDiagnostics: {{ $infra.manager.metrics.insecureDiagnostics }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $infra.manager.metrics.diagnosticsAddress }}
|
||||||
|
diagnosticsAddress: {{ $infra.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- if and (not $infra.fetchConfig) (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $infrastructureName) }}
|
||||||
{{- end }}
|
|
||||||
{{- if and (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $infrastructureName) }}
|
|
||||||
{{- range $key, $value := $.Values.fetchConfig }}
|
{{- range $key, $value := $.Values.fetchConfig }}
|
||||||
{{- if eq $key $infrastructureName }}
|
{{- if eq $key $infrastructureName }}
|
||||||
fetchConfig:
|
{{- if not (or (kindIs "invalid" $value) (and (kindIs "map" $value) (empty $value))) }}
|
||||||
{{- range $k, $v := $value }}
|
fetchConfig: {{- toYaml $value | nindent 4 }}
|
||||||
{{ $k }}: {{ $v }}
|
{{- end }}
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $.Values.configSecret.name }}
|
{{- if (default (($infra).configSecret).name (($.Values).configSecret).name) }}
|
||||||
configSecret:
|
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $infra) | nindent 2 }}
|
||||||
name: {{ $.Values.configSecret.name }}
|
|
||||||
{{- if $.Values.configSecret.namespace }}
|
|
||||||
namespace: {{ $.Values.configSecret.namespace }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $.Values.additionalDeployments }}
|
{{- if $.Values.additionalDeployments }}
|
||||||
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
|
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
|
||||||
@@ -68,6 +74,12 @@ spec:
|
|||||||
{{- if $infra.manifestPatches }}
|
{{- if $infra.manifestPatches }}
|
||||||
manifestPatches: {{- toYaml $infra.manifestPatches | nindent 4 }}
|
manifestPatches: {{- toYaml $infra.manifestPatches | nindent 4 }}
|
||||||
{{- end }} {{/* if $infra.manifestPatches */}}
|
{{- end }} {{/* if $infra.manifestPatches */}}
|
||||||
|
{{- if $infra.patches }}
|
||||||
|
patches: {{ toYaml $infra.patches | nindent 4 }}
|
||||||
|
{{- end }} {{/* if $infra.patches */}}
|
||||||
|
{{- if $infra.fetchConfig }}
|
||||||
|
fetchConfig: {{ toYaml $infra.fetchConfig | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
{{- if $infra.additionalManifests }}
|
{{- if $infra.additionalManifests }}
|
||||||
additionalManifests:
|
additionalManifests:
|
||||||
name: {{ $infra.additionalManifests.name }}
|
name: {{ $infra.additionalManifests.name }}
|
||||||
|
|||||||
+32
-13
@@ -1,8 +1,10 @@
|
|||||||
# IPAM providers
|
# IPAM providers
|
||||||
{{- range $name, $ipam := $.Values.ipam }}
|
{{- range $name, $ipam := $.Values.ipam }}
|
||||||
|
{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $ipam "key" $name) }}
|
||||||
{{- $ipamNamespace := default ( printf "%s-%s" $name "ipam-system" ) (get $ipam "namespace") }}
|
{{- $ipamNamespace := default ( printf "%s-%s" $name "ipam-system" ) (get $ipam "namespace") }}
|
||||||
{{- $ipamName := $name }}
|
{{- $ipamName := $name }}
|
||||||
{{- $ipamVersion := get $ipam "version" }}
|
{{- $ipamVersion := get $ipam "version" }}
|
||||||
|
{{- if ne $ipam.createNamespace false }}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
@@ -14,6 +16,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "1"
|
"argocd.argoproj.io/sync-wave": "1"
|
||||||
name: {{ $ipamNamespace }}
|
name: {{ $ipamNamespace }}
|
||||||
|
{{- end }}
|
||||||
---
|
---
|
||||||
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
kind: IPAMProvider
|
kind: IPAMProvider
|
||||||
@@ -26,35 +29,51 @@ metadata:
|
|||||||
"helm.sh/hook-weight": "2"
|
"helm.sh/hook-weight": "2"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
"argocd.argoproj.io/sync-wave": "2"
|
"argocd.argoproj.io/sync-wave": "2"
|
||||||
{{- if or $ipamVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments }}
|
{{- if or $ipamVersion $.Values.configSecret.name $ipam.manager $ipam.deployment $.Values.additionalDeployments (($ipam).configSecret).name $ipam.fetchConfig $ipam.manifestPatches $ipam.additionalManifests (and (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $ipamName)) }}
|
||||||
spec:
|
spec:
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $ipamVersion }}
|
{{- if $ipamVersion }}
|
||||||
version: {{ $ipamVersion }}
|
version: {{ $ipamVersion }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $.Values.manager }}
|
{{- if $ipam.deployment }}
|
||||||
{{- if and (kindIs "map" $.Values.manager.featureGates) (hasKey $.Values.manager.featureGates $ipamName) }}
|
deployment: {{ toYaml $ipam.deployment | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $ipam.manager }}
|
||||||
manager:
|
manager:
|
||||||
{{- range $key, $value := $.Values.manager.featureGates }}
|
{{- if $ipam.manager.featureGates }}
|
||||||
{{- if eq $key $ipamName }}
|
|
||||||
featureGates:
|
featureGates:
|
||||||
{{- range $k, $v := $value }}
|
{{- range $key, $value := $ipam.manager.featureGates }}
|
||||||
{{ $k }}: {{ $v }}
|
{{ $key }}: {{ $value }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $ipam.manager.metrics }}
|
||||||
|
metrics:
|
||||||
|
{{- if $ipam.manager.metrics.insecureDiagnostics }}
|
||||||
|
insecureDiagnostics: {{ $ipam.manager.metrics.insecureDiagnostics }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $ipam.manager.metrics.diagnosticsAddress }}
|
||||||
|
diagnosticsAddress: {{ $ipam.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if and (not $ipam.fetchConfig) (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $ipamName) }}
|
||||||
|
{{- range $key, $value := $.Values.fetchConfig }}
|
||||||
|
{{- if eq $key $ipamName }}
|
||||||
|
{{- if not (or (kindIs "invalid" $value) (and (kindIs "map" $value) (empty $value))) }}
|
||||||
|
fetchConfig: {{- toYaml $value | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $.Values.configSecret.name }}
|
{{- if (default (($ipam).configSecret).name (($.Values).configSecret).name) }}
|
||||||
configSecret:
|
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $ipam) | nindent 2 }}
|
||||||
name: {{ $.Values.configSecret.name }}
|
|
||||||
{{- if $.Values.configSecret.namespace }}
|
|
||||||
namespace: {{ $.Values.configSecret.namespace }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $ipam.manifestPatches }}
|
{{- if $ipam.manifestPatches }}
|
||||||
manifestPatches: {{ toYaml $ipam.manifestPatches | nindent 4 }}
|
manifestPatches: {{ toYaml $ipam.manifestPatches | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $ipam.fetchConfig }}
|
||||||
|
fetchConfig: {{ toYaml $ipam.fetchConfig | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
{{- if $.Values.additionalDeployments }}
|
{{- if $.Values.additionalDeployments }}
|
||||||
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
|
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
Vendored
+1337
-6942
File diff suppressed because it is too large.
Load diff
+6
-1
@@ -1,7 +1,12 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "https://json-schema.org/draft/2020-12/schema#",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"fetchConfig": {
|
||||||
|
"type": "object",
|
||||||
|
"deprecated": true,
|
||||||
|
"description": "This field is deprecated and will be removed in future versions. Prefer declaring fetchConfig under the individual providers instead."
|
||||||
|
},
|
||||||
"core": {
|
"core": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{ "type": "object" },
|
{ "type": "object" },
|
||||||
|
|||||||
@@ -2,30 +2,118 @@
|
|||||||
# ---
|
# ---
|
||||||
# Cluster API provider options
|
# Cluster API provider options
|
||||||
core: {}
|
core: {}
|
||||||
# cluster-api: {} # Name, required
|
# cluster-api: {} # Name, required
|
||||||
# namespace: "" # Optional
|
# namespace: "" # Optional
|
||||||
# version: "" # Optional
|
# version: "" # Optional
|
||||||
|
# createNamespace: true # Optional
|
||||||
|
# deployment: # Optional
|
||||||
|
# replicas: 1
|
||||||
|
# nodeSelector: {}
|
||||||
|
# tolerations: []
|
||||||
|
# affinity: {}
|
||||||
|
# containers: []
|
||||||
|
# serviceAccountName: ""
|
||||||
|
# imagePullSecrets: []
|
||||||
|
# manager: # Optional
|
||||||
|
# featureGates:
|
||||||
|
# ClusterTopology: true
|
||||||
|
# metrics:
|
||||||
|
# insecureDiagnostics: true
|
||||||
|
# diagnosticsAddress: localhost:8080
|
||||||
bootstrap: {}
|
bootstrap: {}
|
||||||
# kubeadm: {} # Name, required
|
# kubeadm: {} # Name, required
|
||||||
# namespace: "" # Optional
|
# namespace: "" # Optional
|
||||||
# version: "" # Optional
|
# version: "" # Optional
|
||||||
|
# createNamespace: true # Optional
|
||||||
|
# deployment: # Optional
|
||||||
|
# replicas: 1
|
||||||
|
# nodeSelector: {}
|
||||||
|
# tolerations: []
|
||||||
|
# affinity: {}
|
||||||
|
# containers: []
|
||||||
|
# serviceAccountName: ""
|
||||||
|
# imagePullSecrets: []
|
||||||
|
# manager: # Optional
|
||||||
|
# featureGates:
|
||||||
|
# ClusterTopology: true
|
||||||
|
# MachinePool: true
|
||||||
|
# metrics:
|
||||||
|
# insecureDiagnostics: true
|
||||||
|
# diagnosticsAddress: localhost:8080
|
||||||
controlPlane: {}
|
controlPlane: {}
|
||||||
# kubeadm: {} # Name, required
|
# kubeadm: {} # Name, required
|
||||||
# namespace: "" # Optional
|
# namespace: "" # Optional
|
||||||
# version: "" # Optional
|
# version: "" # Optional
|
||||||
|
# createNamespace: true # Optional
|
||||||
|
# deployment: # Optional
|
||||||
|
# replicas: 1
|
||||||
|
# nodeSelector: {}
|
||||||
|
# tolerations: []
|
||||||
|
# affinity: {}
|
||||||
|
# containers: []
|
||||||
|
# serviceAccountName: ""
|
||||||
|
# imagePullSecrets: []
|
||||||
|
# manager: # Optional
|
||||||
|
# featureGates:
|
||||||
|
# ClusterTopology: true
|
||||||
|
# metrics:
|
||||||
|
# insecureDiagnostics: true
|
||||||
|
# diagnosticsAddress: localhost:8080
|
||||||
infrastructure: {}
|
infrastructure: {}
|
||||||
# docker: {} # Name, required
|
# docker: {} # Name, required
|
||||||
# namespace: "" # Optional
|
# namespace: "" # Optional
|
||||||
# version: "" # Optional
|
# version: "" # Optional
|
||||||
|
# createNamespace: true # Optional
|
||||||
|
# deployment: # Optional
|
||||||
|
# replicas: 1
|
||||||
|
# nodeSelector: {}
|
||||||
|
# tolerations: []
|
||||||
|
# affinity: {}
|
||||||
|
# containers: []
|
||||||
|
# serviceAccountName: ""
|
||||||
|
# imagePullSecrets: []
|
||||||
|
# manager: # Optional
|
||||||
|
# featureGates:
|
||||||
|
# ClusterTopology: true
|
||||||
|
# metrics:
|
||||||
|
# insecureDiagnostics: true
|
||||||
|
# diagnosticsAddress: localhost:8080
|
||||||
addon: {}
|
addon: {}
|
||||||
# helm: {} # Name, required
|
# helm: {} # Name, required
|
||||||
# namespace: "" # Optional
|
# namespace: "" # Optional
|
||||||
# version: "" # Optional
|
# version: "" # Optional
|
||||||
|
# createNamespace: true # Optional
|
||||||
|
# deployment: # Optional
|
||||||
|
# replicas: 1
|
||||||
|
# nodeSelector: {}
|
||||||
|
# tolerations: []
|
||||||
|
# affinity: {}
|
||||||
|
# containers: []
|
||||||
|
# serviceAccountName: ""
|
||||||
|
# imagePullSecrets: []
|
||||||
|
# manager: # Optional
|
||||||
|
# metrics:
|
||||||
|
# insecureDiagnostics: true
|
||||||
|
# diagnosticsAddress: localhost:8080
|
||||||
ipam: {}
|
ipam: {}
|
||||||
# in-cluster: {} # Name, required
|
# in-cluster: {} # Name, required
|
||||||
# namespace: "" # Optional
|
# namespace: "" # Optional
|
||||||
# version: "" # Optional
|
# version: "" # Optional
|
||||||
manager.featureGates: {}
|
# createNamespace: true # Optional
|
||||||
|
# deployment: # Optional
|
||||||
|
# replicas: 1
|
||||||
|
# nodeSelector: {}
|
||||||
|
# tolerations: []
|
||||||
|
# affinity: {}
|
||||||
|
# containers: []
|
||||||
|
# serviceAccountName: ""
|
||||||
|
# imagePullSecrets: []
|
||||||
|
# manager: # Optional
|
||||||
|
# featureGates:
|
||||||
|
# ClusterTopology: true
|
||||||
|
# metrics:
|
||||||
|
# insecureDiagnostics: true
|
||||||
|
# diagnosticsAddress: localhost:8080
|
||||||
fetchConfig: {}
|
fetchConfig: {}
|
||||||
# ---
|
# ---
|
||||||
# Common configuration secret options
|
# Common configuration secret options
|
||||||
@@ -39,20 +127,23 @@ leaderElection:
|
|||||||
image:
|
image:
|
||||||
manager:
|
manager:
|
||||||
repository: registry.k8s.io/capi-operator/cluster-api-operator
|
repository: registry.k8s.io/capi-operator/cluster-api-operator
|
||||||
tag: v0.19.0
|
tag: v0.30.0
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
env:
|
env:
|
||||||
manager: []
|
manager: []
|
||||||
diagnosticsAddress: ":8443"
|
diagnosticsAddress: ":8443"
|
||||||
healthAddr: ":9440"
|
healthAddr: ":9440"
|
||||||
|
profilerAddress: ":6060"
|
||||||
|
contentionProfiling: false
|
||||||
insecureDiagnostics: false
|
insecureDiagnostics: false
|
||||||
watchConfigSecret: false
|
watchConfigSecret: false
|
||||||
|
watchConfigMap: false
|
||||||
imagePullSecrets: {}
|
imagePullSecrets: {}
|
||||||
resources:
|
resources:
|
||||||
manager:
|
manager:
|
||||||
limits:
|
limits:
|
||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 150Mi
|
memory: 300Mi
|
||||||
requests:
|
requests:
|
||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 100Mi
|
memory: 100Mi
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,50 @@
|
|||||||
|
# maps release series of major.minor to cluster-api contract version
|
||||||
|
# the contract version may change between minor or major versions, but *not*
|
||||||
|
# between patch versions.
|
||||||
|
#
|
||||||
|
# update this file only when a new major or minor version is released
|
||||||
|
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
|
||||||
|
kind: Metadata
|
||||||
|
releaseSeries:
|
||||||
|
- major: 1
|
||||||
|
minor: 13
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 12
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 11
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 10
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 9
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 8
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 7
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 6
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 5
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 4
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 3
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 2
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 1
|
||||||
|
contract: v1beta1
|
||||||
|
- major: 1
|
||||||
|
minor: 0
|
||||||
|
contract: v1beta1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
v1.13.8
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
--- a/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
@@ -59,1 +59,1 @@
|
||||||
|
-{{- if and (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $infrastructureName) }}
|
||||||
|
+{{- if and (not $infra.fetchConfig) (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $infrastructureName) }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
@@ -59,1 +59,1 @@
|
||||||
|
-{{- if and (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $ipamName) }}
|
||||||
|
+{{- if and (not $ipam.fetchConfig) (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $ipamName) }}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
--- a/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
@@ -62,4 +62,3 @@
|
||||||
|
- fetchConfig:
|
||||||
|
- {{- range $k, $v := $value }}
|
||||||
|
- {{ $k }}: {{ $v }}
|
||||||
|
- {{- end }}
|
||||||
|
+{{- if not (or (kindIs "invalid" $value) (and (kindIs "map" $value) (empty $value))) }}
|
||||||
|
+ fetchConfig: {{- toYaml $value | nindent 4 }}
|
||||||
|
+{{- end }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
@@ -62,4 +62,3 @@
|
||||||
|
- fetchConfig:
|
||||||
|
- {{- range $k, $v := $value }}
|
||||||
|
- {{ $k }}: {{ $v }}
|
||||||
|
- {{- end }}
|
||||||
|
+{{- if not (or (kindIs "invalid" $value) (and (kindIs "map" $value) (empty $value))) }}
|
||||||
|
+ fetchConfig: {{- toYaml $value | nindent 4 }}
|
||||||
|
+{{- end }}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
--- a/charts/cluster-api-operator/templates/core.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/core.yaml
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
# Core provider
|
||||||
|
{{- range $name, $core := $.Values.core }}
|
||||||
|
+{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $core "key" "core") }}
|
||||||
|
{{- $coreNamespace := default "capi-system" (get $core "namespace") }}
|
||||||
|
{{- $coreName := $name }}
|
||||||
|
{{- $coreVersion := get $core "version" }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/control-plane.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/control-plane.yaml
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
# Control plane provider
|
||||||
|
{{- range $name, $controlPlane := $.Values.controlPlane }}
|
||||||
|
+{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $controlPlane "key" $name) }}
|
||||||
|
{{- $controlPlaneNamespace := default ( printf "%s-%s" $name "control-plane-system" ) (get $controlPlane "namespace") }}
|
||||||
|
{{- $controlPlaneName := $name }}
|
||||||
|
{{- $controlPlaneVersion := get $controlPlane "version" }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
# Infrastructure providers
|
||||||
|
{{- range $name, $infra := $.Values.infrastructure }}
|
||||||
|
+{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $infra "key" $name) }}
|
||||||
|
{{- $infrastructureNamespace := default ( printf "%s-%s" $name "infrastructure-system" ) (get $infra "namespace") }}
|
||||||
|
{{- $infrastructureName := $name }}
|
||||||
|
{{- $infrastructureVersion := get $infra "version" }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
# IPAM providers
|
||||||
|
{{- range $name, $ipam := $.Values.ipam }}
|
||||||
|
+{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $ipam "key" $name) }}
|
||||||
|
{{- $ipamNamespace := default ( printf "%s-%s" $name "ipam-system" ) (get $ipam "namespace") }}
|
||||||
|
{{- $ipamName := $name }}
|
||||||
|
{{- $ipamVersion := get $ipam "version" }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/infra-conditions.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/infra-conditions.yaml
|
||||||
|
@@ -61,6 +61,12 @@
|
||||||
|
"argocd.argoproj.io/sync-wave": "2"
|
||||||
|
{{- with .Values.configSecret }}
|
||||||
|
spec:
|
||||||
|
+{{- $controlPlane := dict }}
|
||||||
|
+{{- include "cozystack.capi-operator.legacyFeatureGates" (dict "root" $ "provider" $controlPlane "key" "kubeadm") }}
|
||||||
|
+{{- with $controlPlane.manager }}
|
||||||
|
+ manager:
|
||||||
|
+ {{- toYaml . | nindent 4 }}
|
||||||
|
+{{- end }}
|
||||||
|
configSecret:
|
||||||
|
name: {{ .name }}
|
||||||
|
{{- if .namespace }}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--- a/charts/cluster-api-operator/templates/deployment.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/deployment.yaml
|
||||||
|
@@ -87,14 +87,14 @@
|
||||||
|
{{- end }}
|
||||||
|
{{- if .retryPeriod }}
|
||||||
|
- --leader-elect-retry-period={{ .retryPeriod }}
|
||||||
|
{{- end }}
|
||||||
|
+ {{- end }}
|
||||||
|
{{- if $.Values.profilerAddress }}
|
||||||
|
- --profiler-address={{ if hasPrefix ":" ($.Values.profilerAddress | toString) }}localhost{{ end }}{{ $.Values.profilerAddress }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $.Values.contentionProfiling }}
|
||||||
|
- --contention-profiling={{ $.Values.contentionProfiling }}
|
||||||
|
{{- end }}
|
||||||
|
- {{- end }}
|
||||||
|
{{- with .Values.syncPeriod }}
|
||||||
|
- --sync-period={{ . }}
|
||||||
|
{{- end }}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
--- a/charts/cluster-api-operator/templates/core.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/core.yaml
|
||||||
|
@@ -32,1 +32,1 @@
|
||||||
|
-{{- if or $coreVersion $.Values.configSecret.name $core.manager $core.deployment (($core).configSecret).name }}
|
||||||
|
+{{- if or $coreVersion $.Values.configSecret.name $core.manager $core.deployment (($core).configSecret).name $core.fetchConfig $core.manifestPatches $core.additionalManifests }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/bootstrap.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/bootstrap.yaml
|
||||||
|
@@ -31,1 +31,1 @@
|
||||||
|
-{{- if or $bootstrapVersion $.Values.configSecret.name $bootstrap.manager $bootstrap.deployment (($bootstrap).configSecret).name }}
|
||||||
|
+{{- if or $bootstrapVersion $.Values.configSecret.name $bootstrap.manager $bootstrap.deployment (($bootstrap).configSecret).name $bootstrap.fetchConfig $bootstrap.manifestPatches $bootstrap.additionalManifests }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/control-plane.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/control-plane.yaml
|
||||||
|
@@ -32,1 +32,1 @@
|
||||||
|
-{{- if or $controlPlaneVersion $.Values.configSecret.name $controlPlane.manager $controlPlane.deployment (($controlPlane).configSecret).name }}
|
||||||
|
+{{- if or $controlPlaneVersion $.Values.configSecret.name $controlPlane.manager $controlPlane.deployment (($controlPlane).configSecret).name $controlPlane.fetchConfig $controlPlane.manifestPatches $controlPlane.additionalManifests }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
@@ -32,1 +32,1 @@
|
||||||
|
-{{- if or $infrastructureVersion $.Values.configSecret.name $infra.manager $infra.deployment $.Values.additionalDeployments (($infra).configSecret).name }}
|
||||||
|
+{{- if or $infrastructureVersion $.Values.configSecret.name $infra.manager $infra.deployment $.Values.additionalDeployments (($infra).configSecret).name $infra.fetchConfig $infra.patches $infra.manifestPatches $infra.additionalManifests (and (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $infrastructureName)) }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
@@ -32,1 +32,1 @@
|
||||||
|
-{{- if or $ipamVersion $.Values.configSecret.name $ipam.manager $ipam.deployment $.Values.additionalDeployments (($ipam).configSecret).name }}
|
||||||
|
+{{- if or $ipamVersion $.Values.configSecret.name $ipam.manager $ipam.deployment $.Values.additionalDeployments (($ipam).configSecret).name $ipam.fetchConfig $ipam.manifestPatches $ipam.additionalManifests (and (kindIs "map" $.Values.fetchConfig) (hasKey $.Values.fetchConfig $ipamName)) }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/addon.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/addon.yaml
|
||||||
|
@@ -31,1 +31,1 @@
|
||||||
|
-{{- if or $addonVersion $.Values.secretName $.Values.configSecret.name $addon.manager $addon.deployment (($addon).configSecret).name }}
|
||||||
|
+{{- if or $addonVersion $.Values.secretName $.Values.secretNamespace $.Values.configSecret.name $addon.manager $addon.deployment (($addon).configSecret).name $addon.fetchConfig $addon.manifestPatches $addon.additionalManifests }}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
--- a/charts/cluster-api-operator/templates/core.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/core.yaml
|
||||||
|
@@ -55,1 +55,1 @@
|
||||||
|
- diagnosticsAddress: {{ $core.manager.metrics.diagnosticsAddress }}
|
||||||
|
+ diagnosticsAddress: {{ $core.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/bootstrap.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/bootstrap.yaml
|
||||||
|
@@ -51,1 +51,1 @@
|
||||||
|
- diagnosticsAddress: {{ $bootstrap.manager.metrics.diagnosticsAddress }}
|
||||||
|
+ diagnosticsAddress: {{ $bootstrap.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/control-plane.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/control-plane.yaml
|
||||||
|
@@ -55,1 +55,1 @@
|
||||||
|
- diagnosticsAddress: {{ $controlPlane.manager.metrics.diagnosticsAddress }}
|
||||||
|
+ diagnosticsAddress: {{ $controlPlane.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/infra.yaml
|
||||||
|
@@ -55,1 +55,1 @@
|
||||||
|
- diagnosticsAddress: {{ $infra.manager.metrics.diagnosticsAddress }}
|
||||||
|
+ diagnosticsAddress: {{ $infra.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/ipam.yaml
|
||||||
|
@@ -55,1 +55,1 @@
|
||||||
|
- diagnosticsAddress: {{ $ipam.manager.metrics.diagnosticsAddress }}
|
||||||
|
+ diagnosticsAddress: {{ $ipam.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/addon.yaml
|
||||||
|
+++ b/charts/cluster-api-operator/templates/addon.yaml
|
||||||
|
@@ -45,1 +45,1 @@
|
||||||
|
- diagnosticsAddress: {{ $addon.manager.metrics.diagnosticsAddress }}
|
||||||
|
+ diagnosticsAddress: {{ $addon.manager.metrics.diagnosticsAddress | toYaml }}
|
||||||
|
--- a/charts/cluster-api-operator/templates/_helpers.tpl
|
||||||
|
+++ b/charts/cluster-api-operator/templates/_helpers.tpl
|
||||||
|
@@ -30,1 +30,1 @@
|
||||||
|
- name: {{ default (($.Values).configSecret).name (($arg).configSecret).name }}
|
||||||
|
+ name: {{ default (($.Values).configSecret).name (($arg).configSecret).name | toYaml }}
|
||||||
|
@@ -32,1 +32,1 @@
|
||||||
|
- namespace: {{ default (($.Values).configSecret).namespace (($arg).configSecret).namespace }}
|
||||||
|
+ namespace: {{ default (($.Values).configSecret).namespace (($arg).configSecret).namespace | toYaml }}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
--- a/charts/cluster-api-operator/templates/deployment.yaml
|
--- a/charts/cluster-api-operator/templates/deployment.yaml
|
||||||
+++ b/charts/cluster-api-operator/templates/deployment.yaml
|
+++ b/charts/cluster-api-operator/templates/deployment.yaml
|
||||||
@@ -86,6 +86,9 @@
|
@@ -95,6 +95,9 @@
|
||||||
- --leader-elect-retry-period={{ .retryPeriod }}
|
- --contention-profiling={{ $.Values.contentionProfiling }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
+ {{- with .Values.syncPeriod }}
|
+ {{- with .Values.syncPeriod }}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{{- define "cozystack.capi-operator.legacyFeatureGates" -}}
|
||||||
|
{{- $manager := deepCopy (.provider.manager | default dict) -}}
|
||||||
|
{{- $legacy := dig "featureGates" .key (dict) (.root.Values.manager | default dict) -}}
|
||||||
|
{{- if and (not (hasKey $manager "featureGates")) $legacy -}}
|
||||||
|
{{- $_ := set $manager "featureGates" (deepCopy $legacy) -}}
|
||||||
|
{{- $_ := set .provider "manager" $manager -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{{- $bridge := required "intermediate provider version is missing" (.Files.Get "files/bridge-version" | trim) -}}
|
||||||
|
{{/* Keep repositories available for providers left at the intermediate version.
|
||||||
|
Only the version label: a live v1.10 selector has none, and the operator fails every
|
||||||
|
provider upgrade while any installed provider's selector matches two ConfigMaps. */}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ $bridge }}-core
|
||||||
|
labels:
|
||||||
|
provider.cluster.x-k8s.io/version: {{ $bridge }}-core
|
||||||
|
annotations:
|
||||||
|
provider.cluster.x-k8s.io/compressed: "true"
|
||||||
|
helm.sh/resource-policy: keep
|
||||||
|
binaryData:
|
||||||
|
components: {{ required "intermediate core bundle is missing" (.Files.Get "files/bridge-core-components.gz") | b64enc | quote }}
|
||||||
|
data:
|
||||||
|
metadata: {{ required "intermediate provider metadata is missing" (.Files.Get "files/bridge-metadata.yaml") | quote }}
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ $bridge }}-bootstrap
|
||||||
|
labels:
|
||||||
|
provider.cluster.x-k8s.io/version: {{ $bridge }}-bootstrap
|
||||||
|
annotations:
|
||||||
|
provider.cluster.x-k8s.io/compressed: "true"
|
||||||
|
helm.sh/resource-policy: keep
|
||||||
|
binaryData:
|
||||||
|
components: {{ required "intermediate kubeadm bundle is missing" (.Files.Get "files/bridge-bootstrap-components.gz") | b64enc | quote }}
|
||||||
|
data:
|
||||||
|
metadata: {{ required "intermediate provider metadata is missing" (.Files.Get "files/bridge-metadata.yaml") | quote }}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
cluster-api-operator:
|
cluster-api-operator:
|
||||||
# A restarted v0.19 operator ignores the provider Deployments it finds
|
# A restarted v0.19 operator ignored the provider Deployments it found
|
||||||
# running (kubernetes-sigs/cluster-api-operator#1031), so a stale
|
# running (kubernetes-sigs/cluster-api-operator#1031), so a stale
|
||||||
# Ready=False on a provider clears only at the first informer resync,
|
# Ready=False on a provider cleared only at the first informer resync,
|
||||||
# two periods after the restart: ~20 min at the 10m default, ~2 min at
|
# two periods after the restart: ~20 min at the 10m default, ~2 min at
|
||||||
# 1m (both measured). A resync is served from the cache and changes
|
# 1m (both measured). v0.30 carries the upstream fix, but restart
|
||||||
# nothing when providers are in sync, so the short period costs no API
|
# recovery on it has not been measured, so the short period stays until
|
||||||
# writes. Applied through patches/sync-period.diff.
|
# it is. A resync is served from the cache and changes nothing when
|
||||||
|
# providers are in sync, so it costs no API writes. Applied through
|
||||||
|
# patches/sync-period.diff.
|
||||||
syncPeriod: 1m
|
syncPeriod: 1m
|
||||||
resources:
|
resources:
|
||||||
manager:
|
manager:
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
files/.*-components.yaml
|
files/*-components*.yaml
|
||||||
|
patches/
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: cozy-capi-providers-bootstrap
|
name: cozy-capi-providers-bootstrap
|
||||||
|
appVersion: "v1.14.4"
|
||||||
|
kubeVersion: ">=1.33.0-0"
|
||||||
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
|
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
|
||||||
@@ -1,37 +1,59 @@
|
|||||||
export NAME=capi-providers-bootstrap
|
export NAME=capi-providers-bootstrap
|
||||||
export NAMESPACE=cozy-cluster-api
|
export NAMESPACE=cozy-cluster-api
|
||||||
|
|
||||||
|
CAPI_VERSION=v1.14.4
|
||||||
|
CAPI_URL=https://github.com/kubernetes-sigs/cluster-api/releases/download/$(CAPI_VERSION)
|
||||||
|
# SHA-256 of the kubeadm bootstrap provider's two release assets at
|
||||||
|
# CAPI_VERSION. A release tag can be moved; these cannot. Keep CAPI_VERSION
|
||||||
|
# equal to the one in capi-providers-core/Makefile.
|
||||||
|
CAPI_SHA256_COMPONENTS=cf805775f24d197581b06e938bcd0eb9a9ed49d675f67e0f689ce7b71e5e397c
|
||||||
|
CAPI_SHA256_METADATA=c470906f551ac3e3e9aedc9a3e733b5a5994428693df43e95f65ea67c035f9fe
|
||||||
|
|
||||||
include ../../../hack/package.mk
|
include ../../../hack/package.mk
|
||||||
|
|
||||||
.PHONY: update
|
.PHONY: update components test
|
||||||
|
|
||||||
|
test:
|
||||||
|
helm unittest .
|
||||||
|
|
||||||
# Upstream Talos bootstrap provider (CABPT) release pinned by tag. Keep
|
# Upstream Talos bootstrap provider (CABPT) release pinned by tag. Keep
|
||||||
# in lockstep with templates/providers.yaml (BootstrapProvider spec.version)
|
# in lockstep with templates/providers.yaml (BootstrapProvider spec.version)
|
||||||
# and templates/configmaps.yaml (ConfigMap name) — clusterctl matches the
|
# and templates/configmaps.yaml (ConfigMap name) — clusterctl matches the
|
||||||
# bundle by tag.
|
# bundle by tag.
|
||||||
CABPT_UPSTREAM_VERSION = v0.6.12
|
CABPT_UPSTREAM_VERSION = v0.6.13
|
||||||
|
CABPT_URL=https://github.com/siderolabs/cluster-api-bootstrap-provider-talos/releases/download/$(CABPT_UPSTREAM_VERSION)
|
||||||
|
# SHA-256 of the two CABPT release assets at CABPT_UPSTREAM_VERSION, as
|
||||||
|
# downloaded, before patches/ is applied.
|
||||||
|
CABPT_SHA256_COMPONENTS=1e721ad294bdd5c8994aa957017cb94ad6e0cfd4ba52a52b45ed456d93efd4f8
|
||||||
|
CABPT_SHA256_METADATA=f2069963ae63593a795a7d134bb35999e372fd36240219a539f123c9387507ed
|
||||||
|
|
||||||
# Refreshes files/bootstrap-components-talos.yaml + files/components-talos.gz
|
# Providers share a namespace. Keep CABPT's permissions off that namespace's
|
||||||
# from upstream CABPT release artifacts at CABPT_UPSTREAM_VERSION with
|
# default service account by retaining its dedicated account and bindings.
|
||||||
# patches/ applied (the cozystack-side rename of the default ServiceAccount
|
|
||||||
# to cabpt-manager so capi-operator does not rewrite the SA namespace —
|
|
||||||
# see PR #2610 for the full rationale). Mirrors the symmetric update
|
|
||||||
# target in packages/system/capi-providers-cpprovider/Makefile.
|
|
||||||
#
|
|
||||||
# Run when bumping CABPT_UPSTREAM_VERSION or editing patches/. The
|
|
||||||
# metadata-talos.yaml file is checked in as-is from upstream and is not
|
|
||||||
# refreshed here (it changes far less often and a manual curl+diff is
|
|
||||||
# enough when CABPT cuts a new release series).
|
|
||||||
update:
|
update:
|
||||||
@command -v patch >/dev/null || { echo "patch(1) required"; exit 1; }
|
@command -v patch >/dev/null || { echo "patch(1) required"; exit 1; }
|
||||||
rm -rf .update-tmp
|
rm -rf .update-tmp
|
||||||
mkdir .update-tmp
|
mkdir .update-tmp
|
||||||
curl -sSL "https://github.com/siderolabs/cluster-api-bootstrap-provider-talos/releases/download/$(CABPT_UPSTREAM_VERSION)/bootstrap-components.yaml" \
|
curl -fL -o .update-tmp/bootstrap-components.yaml $(CABPT_URL)/bootstrap-components.yaml
|
||||||
-o .update-tmp/bootstrap-components.yaml
|
curl -fL -o .update-tmp/metadata.yaml $(CABPT_URL)/metadata.yaml
|
||||||
|
printf '%s .update-tmp/bootstrap-components.yaml\n%s .update-tmp/metadata.yaml\n' $(CABPT_SHA256_COMPONENTS) $(CABPT_SHA256_METADATA) | sha256sum -c -
|
||||||
for p in patches/*.diff; do \
|
for p in patches/*.diff; do \
|
||||||
[ -e "$$p" ] || continue; \
|
[ -e "$$p" ] || continue; \
|
||||||
(cd .update-tmp && patch bootstrap-components.yaml < ../$$p) || exit 1; \
|
(cd .update-tmp && patch bootstrap-components.yaml < ../$$p) || exit 1; \
|
||||||
done
|
done
|
||||||
mv .update-tmp/bootstrap-components.yaml files/bootstrap-components-talos.yaml
|
mv .update-tmp/bootstrap-components.yaml files/bootstrap-components-talos.yaml
|
||||||
gzip -nc files/bootstrap-components-talos.yaml > files/components-talos.gz
|
mv .update-tmp/metadata.yaml files/metadata-talos.yaml
|
||||||
|
gzip -9 -n -c files/bootstrap-components-talos.yaml > files/components-talos.gz
|
||||||
rm -rf .update-tmp
|
rm -rf .update-tmp
|
||||||
|
|
||||||
|
# Keep Chart.yaml appVersion equal to CAPI_VERSION: it selects the kubeadm
|
||||||
|
# version and ConfigMap that the operator installs.
|
||||||
|
components:
|
||||||
|
rm -rf .components-tmp
|
||||||
|
mkdir .components-tmp
|
||||||
|
curl -fL -o .components-tmp/bootstrap-components.yaml $(CAPI_URL)/bootstrap-components.yaml
|
||||||
|
curl -fL -o .components-tmp/metadata.yaml $(CAPI_URL)/metadata.yaml
|
||||||
|
printf '%s .components-tmp/bootstrap-components.yaml\n%s .components-tmp/metadata.yaml\n' $(CAPI_SHA256_COMPONENTS) $(CAPI_SHA256_METADATA) | sha256sum -c -
|
||||||
|
mv .components-tmp/bootstrap-components.yaml files/bootstrap-components.yaml
|
||||||
|
mv .components-tmp/metadata.yaml files/metadata.yaml
|
||||||
|
gzip -9 -n -c files/bootstrap-components.yaml > files/components.gz
|
||||||
|
rm -rf .components-tmp
|
||||||
+1
-1
@@ -699,7 +699,7 @@ spec:
|
|||||||
- --insecure-diagnostics=${CAPI_INSECURE_DIAGNOSTICS:=false}
|
- --insecure-diagnostics=${CAPI_INSECURE_DIAGNOSTICS:=false}
|
||||||
command:
|
command:
|
||||||
- /manager
|
- /manager
|
||||||
image: ghcr.io/siderolabs/cluster-api-talos-controller:v0.6.12
|
image: ghcr.io/siderolabs/cluster-api-talos-controller:v0.6.13
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
|
|||||||
+5597
-3965
File diff suppressed because it is too large.
Load diff
Binary file not shown.
Binary file not shown.
@@ -6,6 +6,18 @@
|
|||||||
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
|
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
|
||||||
kind: Metadata
|
kind: Metadata
|
||||||
releaseSeries:
|
releaseSeries:
|
||||||
|
- major: 1
|
||||||
|
minor: 14
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 13
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 12
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 11
|
||||||
|
contract: v1beta2
|
||||||
- major: 1
|
- major: 1
|
||||||
minor: 10
|
minor: 10
|
||||||
contract: v1beta1
|
contract: v1beta1
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{{- define "capi-providers-bootstrap.assertUpgradeWindow" -}}
|
||||||
|
{{- if .Capabilities.APIVersions.Has "operator.cluster.x-k8s.io/v1alpha2" -}}
|
||||||
|
{{- $provider := lookup "operator.cluster.x-k8s.io/v1alpha2" "BootstrapProvider" .Release.Namespace "kubeadm" -}}
|
||||||
|
{{- $installed := dig "status" "installedVersion" "" ($provider | default dict) -}}
|
||||||
|
{{- if and (kindIs "string" $installed) (ne $installed "") -}}
|
||||||
|
{{- $current := semver $installed -}}
|
||||||
|
{{- $target := semver .Chart.AppVersion -}}
|
||||||
|
{{- if or (gt $current.Major $target.Major) (and (eq $current.Major $target.Major) (gt $current.Minor $target.Minor)) (and (eq $current.Major $target.Major) (eq $current.Minor $target.Minor) (gt $current.Patch $target.Patch)) -}}
|
||||||
|
{{- fail "Cluster API provider downgrades are not supported" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if or (ne $current.Major $target.Major) (gt (sub $target.Minor $current.Minor) 3) -}}
|
||||||
|
{{- fail "kubeadm provider cannot skip more than three minor versions; upgrade the core provider package first to run the intermediate migration" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: v1.10.1-bootstrap
|
name: {{ .Chart.AppVersion }}-bootstrap
|
||||||
labels:
|
labels:
|
||||||
|
provider.cluster.x-k8s.io/version: {{ .Chart.AppVersion }}-bootstrap
|
||||||
bootstrap-components: cozy
|
bootstrap-components: cozy
|
||||||
bootstrap-provider: kubeadm
|
bootstrap-provider: kubeadm
|
||||||
annotations:
|
annotations:
|
||||||
@@ -15,7 +16,7 @@ data:
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: v0.6.12-bootstrap-talos
|
name: v0.6.13-bootstrap-talos
|
||||||
labels:
|
labels:
|
||||||
bootstrap-components: cozy
|
bootstrap-components: cozy
|
||||||
bootstrap-provider: talos
|
bootstrap-provider: talos
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
|
{{- include "capi-providers-bootstrap.assertUpgradeWindow" . }}
|
||||||
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
kind: BootstrapProvider
|
kind: BootstrapProvider
|
||||||
metadata:
|
metadata:
|
||||||
name: kubeadm
|
name: kubeadm
|
||||||
spec:
|
spec:
|
||||||
# https://github.com/kubernetes-sigs/cluster-api
|
# https://github.com/kubernetes-sigs/cluster-api
|
||||||
version: v1.10.1-bootstrap
|
version: {{ .Chart.AppVersion }}-bootstrap
|
||||||
fetchConfig:
|
fetchConfig:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
|
provider.cluster.x-k8s.io/version: {{ .Chart.AppVersion }}-bootstrap
|
||||||
bootstrap-components: cozy
|
bootstrap-components: cozy
|
||||||
bootstrap-provider: kubeadm
|
bootstrap-provider: kubeadm
|
||||||
deployment:
|
deployment:
|
||||||
@@ -27,7 +29,7 @@ metadata:
|
|||||||
name: talos
|
name: talos
|
||||||
spec:
|
spec:
|
||||||
# https://github.com/siderolabs/cluster-api-bootstrap-provider-talos
|
# https://github.com/siderolabs/cluster-api-bootstrap-provider-talos
|
||||||
version: v0.6.12-bootstrap-talos
|
version: v0.6.13-bootstrap-talos
|
||||||
fetchConfig:
|
fetchConfig:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
|
|||||||
@@ -0,0 +1,144 @@
|
|||||||
|
suite: kubeadm provider upgrade window
|
||||||
|
templates:
|
||||||
|
- templates/providers.yaml
|
||||||
|
release:
|
||||||
|
name: capi-providers-bootstrap
|
||||||
|
namespace: test-capi
|
||||||
|
capabilities:
|
||||||
|
majorVersion: 1
|
||||||
|
minorVersion: 33
|
||||||
|
apiVersions:
|
||||||
|
- operator.cluster.x-k8s.io/v1alpha2
|
||||||
|
tests:
|
||||||
|
- it: allows a fresh installation
|
||||||
|
kubernetesProvider:
|
||||||
|
scheme: &scheme
|
||||||
|
operator.cluster.x-k8s.io/v1alpha2/BootstrapProvider:
|
||||||
|
gvr:
|
||||||
|
group: operator.cluster.x-k8s.io
|
||||||
|
version: v1alpha2
|
||||||
|
resource: bootstrapproviders
|
||||||
|
namespaced: true
|
||||||
|
objects:
|
||||||
|
- &other
|
||||||
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
|
kind: BootstrapProvider
|
||||||
|
metadata:
|
||||||
|
name: other
|
||||||
|
namespace: other
|
||||||
|
documentSelector:
|
||||||
|
path: metadata.name
|
||||||
|
value: kubeadm
|
||||||
|
asserts:
|
||||||
|
- isKind:
|
||||||
|
of: BootstrapProvider
|
||||||
|
|
||||||
|
- it: rejects the legacy installed version before the core migration
|
||||||
|
kubernetesProvider:
|
||||||
|
scheme: *scheme
|
||||||
|
objects:
|
||||||
|
- &legacy
|
||||||
|
apiVersion: operator.cluster.x-k8s.io/v1alpha2
|
||||||
|
kind: BootstrapProvider
|
||||||
|
metadata:
|
||||||
|
name: kubeadm
|
||||||
|
namespace: test-capi
|
||||||
|
spec:
|
||||||
|
version: v1.10.1-bootstrap
|
||||||
|
status:
|
||||||
|
installedVersion: v1.10.1-bootstrap
|
||||||
|
asserts:
|
||||||
|
- failedTemplate:
|
||||||
|
errorPattern: "upgrade the core provider package first"
|
||||||
|
|
||||||
|
- it: does not confuse a requested bridge version with an installed one
|
||||||
|
kubernetesProvider:
|
||||||
|
scheme: *scheme
|
||||||
|
objects:
|
||||||
|
- <<: *legacy
|
||||||
|
spec:
|
||||||
|
version: v1.13.8-bootstrap
|
||||||
|
asserts:
|
||||||
|
- failedTemplate:
|
||||||
|
errorPattern: "upgrade the core provider package first"
|
||||||
|
|
||||||
|
- it: accepts the installed intermediate release
|
||||||
|
kubernetesProvider:
|
||||||
|
scheme: *scheme
|
||||||
|
objects:
|
||||||
|
- <<: *legacy
|
||||||
|
spec:
|
||||||
|
version: v1.13.8-bootstrap
|
||||||
|
status:
|
||||||
|
installedVersion: v1.13.8-bootstrap
|
||||||
|
documentSelector:
|
||||||
|
path: metadata.name
|
||||||
|
value: kubeadm
|
||||||
|
asserts:
|
||||||
|
- isKind:
|
||||||
|
of: BootstrapProvider
|
||||||
|
|
||||||
|
- it: accepts the oldest supported minor despite the provider suffix
|
||||||
|
kubernetesProvider:
|
||||||
|
scheme: *scheme
|
||||||
|
objects:
|
||||||
|
- <<: *legacy
|
||||||
|
spec:
|
||||||
|
version: v1.11.0-bootstrap
|
||||||
|
status:
|
||||||
|
installedVersion: v1.11.0-bootstrap
|
||||||
|
documentSelector:
|
||||||
|
path: metadata.name
|
||||||
|
value: kubeadm
|
||||||
|
asserts:
|
||||||
|
- isKind:
|
||||||
|
of: BootstrapProvider
|
||||||
|
|
||||||
|
- it: treats a provider that never finished installing as a fresh installation
|
||||||
|
kubernetesProvider:
|
||||||
|
scheme: *scheme
|
||||||
|
objects:
|
||||||
|
- <<: *legacy
|
||||||
|
status: {}
|
||||||
|
documentSelector:
|
||||||
|
path: metadata.name
|
||||||
|
value: kubeadm
|
||||||
|
asserts:
|
||||||
|
- isKind:
|
||||||
|
of: BootstrapProvider
|
||||||
|
|
||||||
|
- it: refuses a downgrade
|
||||||
|
kubernetesProvider:
|
||||||
|
scheme: *scheme
|
||||||
|
objects:
|
||||||
|
- <<: *legacy
|
||||||
|
spec:
|
||||||
|
version: v1.15.0-bootstrap
|
||||||
|
status:
|
||||||
|
installedVersion: v1.15.0-bootstrap
|
||||||
|
asserts:
|
||||||
|
- failedTemplate:
|
||||||
|
errorPattern: "downgrades are not supported"
|
||||||
|
|
||||||
|
- it: refuses a patch downgrade
|
||||||
|
kubernetesProvider:
|
||||||
|
scheme: *scheme
|
||||||
|
objects:
|
||||||
|
- <<: *legacy
|
||||||
|
spec:
|
||||||
|
version: v1.14.5-bootstrap
|
||||||
|
status:
|
||||||
|
installedVersion: v1.14.5-bootstrap
|
||||||
|
asserts:
|
||||||
|
- failedTemplate:
|
||||||
|
errorPattern: "downgrades are not supported"
|
||||||
|
|
||||||
|
- it: renders offline when the provider API is not served
|
||||||
|
capabilities:
|
||||||
|
apiVersions: []
|
||||||
|
documentSelector:
|
||||||
|
path: metadata.name
|
||||||
|
value: kubeadm
|
||||||
|
asserts:
|
||||||
|
- isKind:
|
||||||
|
of: BootstrapProvider
|
||||||
@@ -1 +1,2 @@
|
|||||||
files/*-components.yaml
|
files/*-components.yaml
|
||||||
|
patches/
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: cozy-capi-providers-core
|
name: cozy-capi-providers-core
|
||||||
|
appVersion: "v1.14.4"
|
||||||
|
kubeVersion: ">=1.33.0-0"
|
||||||
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
|
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
|
||||||
@@ -1,4 +1,33 @@
|
|||||||
export NAME=capi-providers-core
|
export NAME=capi-providers-core
|
||||||
export NAMESPACE=cozy-cluster-api
|
export NAMESPACE=cozy-cluster-api
|
||||||
|
|
||||||
|
CAPI_VERSION=v1.14.4
|
||||||
|
CAPI_URL=https://github.com/kubernetes-sigs/cluster-api/releases/download/$(CAPI_VERSION)
|
||||||
|
# SHA-256 of the two release assets at CAPI_VERSION, as downloaded. A release tag
|
||||||
|
# can be moved; these cannot. Bumping the version means recording the new sums
|
||||||
|
# here. files/core-components.yaml carries patches/ on top, so its own sum differs.
|
||||||
|
CAPI_SHA256_COMPONENTS=0030264eb0a0d90ebacc9da8f6bbb717bee32e45ffadc4a74784fb5ad7b9bb0b
|
||||||
|
CAPI_SHA256_METADATA=c470906f551ac3e3e9aedc9a3e733b5a5994428693df43e95f65ea67c035f9fe
|
||||||
|
|
||||||
include ../../../hack/package.mk
|
include ../../../hack/package.mk
|
||||||
|
|
||||||
|
# Keep Chart.yaml appVersion equal to CAPI_VERSION: it selects the provider
|
||||||
|
# version and ConfigMap that the operator installs.
|
||||||
|
# patches/ is applied on top of the verified download. See the note in
|
||||||
|
# capi-providers-infraprovider-proxmox/Makefile on gzip -n.
|
||||||
|
.PHONY: components
|
||||||
|
components:
|
||||||
|
@command -v patch >/dev/null || { echo "patch(1) required"; exit 1; }
|
||||||
|
rm -rf .components-tmp
|
||||||
|
mkdir .components-tmp
|
||||||
|
curl -fL -o .components-tmp/core-components.yaml $(CAPI_URL)/core-components.yaml
|
||||||
|
curl -fL -o .components-tmp/metadata.yaml $(CAPI_URL)/metadata.yaml
|
||||||
|
printf '%s .components-tmp/core-components.yaml\n%s .components-tmp/metadata.yaml\n' $(CAPI_SHA256_COMPONENTS) $(CAPI_SHA256_METADATA) | sha256sum -c -
|
||||||
|
for p in patches/*.diff; do \
|
||||||
|
[ -e "$$p" ] || continue; \
|
||||||
|
(cd .components-tmp && patch core-components.yaml < ../$$p) || exit 1; \
|
||||||
|
done
|
||||||
|
mv .components-tmp/core-components.yaml files/core-components.yaml
|
||||||
|
mv .components-tmp/metadata.yaml files/metadata.yaml
|
||||||
|
gzip -9 -n -c files/core-components.yaml > files/components.gz
|
||||||
|
rm -rf .components-tmp
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../library/cozy-lib
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
v1.13.8
|
||||||
Binary file not shown.
+11364
-6277
File diff suppressed because it is too large.
Load diff
@@ -6,6 +6,18 @@
|
|||||||
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
|
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
|
||||||
kind: Metadata
|
kind: Metadata
|
||||||
releaseSeries:
|
releaseSeries:
|
||||||
|
- major: 1
|
||||||
|
minor: 14
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 13
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 12
|
||||||
|
contract: v1beta2
|
||||||
|
- major: 1
|
||||||
|
minor: 11
|
||||||
|
contract: v1beta2
|
||||||
- major: 1
|
- major: 1
|
||||||
minor: 10
|
minor: 10
|
||||||
contract: v1beta1
|
contract: v1beta1
|
||||||
|
|||||||
@@ -0,0 +1,181 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
: "${KUBE_CONTEXT:?}" "${NAMESPACE:?}" "${BRIDGE_VERSION:?}" "${TARGET_VERSION:?}"
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
printf 'CAPI upgrade: %s\n' "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
kube() {
|
||||||
|
local remaining=$((deadline - SECONDS)) status=0
|
||||||
|
((remaining > 0)) || fail "timed out before an API request"
|
||||||
|
timeout "$remaining" kubectl --context "$KUBE_CONTEXT" --namespace "$NAMESPACE" --request-timeout=10s "$@" || status=$?
|
||||||
|
((SECONDS < deadline)) || fail "timed out during an API request"
|
||||||
|
return "$status"
|
||||||
|
}
|
||||||
|
|
||||||
|
minor_version() {
|
||||||
|
local version="$1" kind="$2"
|
||||||
|
if [[ ! "$version" =~ ^v?1\.([0-9]+)\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
|
||||||
|
fail "invalid $kind version: $version"
|
||||||
|
fi
|
||||||
|
local minor="${BASH_REMATCH[1]}"
|
||||||
|
[[ "$minor" =~ ^(0|[1-9][0-9]?)$ ]] || fail "invalid $kind version: $version"
|
||||||
|
printf '%s\n' "$minor"
|
||||||
|
}
|
||||||
|
|
||||||
|
command -v timeout >/dev/null || fail "timeout command is required"
|
||||||
|
|
||||||
|
timeout_seconds="${CAPI_UPGRADE_TIMEOUT_SECONDS:-480}"
|
||||||
|
[[ "$timeout_seconds" =~ ^[1-9][0-9]{0,3}$ ]] || fail "invalid upgrade timeout"
|
||||||
|
deadline=$((SECONDS + timeout_seconds))
|
||||||
|
poll_seconds="${CAPI_UPGRADE_POLL_SECONDS:-2}"
|
||||||
|
[[ "$poll_seconds" =~ ^[0-9]+$ ]] || fail "invalid poll interval"
|
||||||
|
bridge_minor="$(minor_version "$BRIDGE_VERSION" intermediate)"
|
||||||
|
target_minor="$(minor_version "$TARGET_VERSION" target)"
|
||||||
|
((target_minor >= bridge_minor && target_minor - bridge_minor <= 3)) || fail "invalid intermediate release"
|
||||||
|
|
||||||
|
core="$(kube get coreproviders.operator.cluster.x-k8s.io cluster-api --ignore-not-found --output json)"
|
||||||
|
bootstrap="$(kube get bootstrapproviders.operator.cluster.x-k8s.io kubeadm --ignore-not-found --output json)"
|
||||||
|
installed_version() {
|
||||||
|
jq --raw-output '.status.installedVersion // empty' <<< "$1"
|
||||||
|
}
|
||||||
|
if [[ -z "$core" || -z "$(installed_version "$core")" ]]; then
|
||||||
|
[[ -z "$bootstrap" || -z "$(installed_version "$bootstrap")" ]] || fail "kubeadm is installed without an installed core provider"
|
||||||
|
printf 'No installed providers need an intermediate upgrade.\n'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
upgrade_version() {
|
||||||
|
# An unfinished install can complete at its old requested version while core upgrades.
|
||||||
|
jq --raw-output '(.status.installedVersion | select(. != null and . != "")) // .spec.version // empty' <<< "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_provider() {
|
||||||
|
local object="$1" suffix="$2" installed requested uid minor requested_minor newer
|
||||||
|
requested="$(jq --raw-output '.spec.version // empty' <<< "$object")"
|
||||||
|
requested_minor="$(minor_version "$requested" requested)"
|
||||||
|
installed="$(upgrade_version "$object")"
|
||||||
|
minor="$(minor_version "$installed" installed)"
|
||||||
|
newer="$(jq --null-input --arg installed "$installed" --arg target "$TARGET_VERSION" '
|
||||||
|
def base: ltrimstr("v") | split("-")[0] | split("+")[0] | split(".") | map(tonumber);
|
||||||
|
($installed | base) > ($target | base)')"
|
||||||
|
[[ "$newer" == false ]] || fail "$suffix provider downgrades are not supported"
|
||||||
|
((bridge_minor - minor <= 3)) || fail "$suffix is outside the intermediate upgrade window"
|
||||||
|
uid="$(jq --raw-output '.metadata.uid // empty' <<< "$object")"
|
||||||
|
[[ -n "$uid" ]] || fail "$suffix provider UID is missing"
|
||||||
|
if [[ "$requested" != "$installed" && "$requested" != "$BRIDGE_VERSION-$suffix" && "$requested" != "$TARGET_VERSION-$suffix" ]]; then
|
||||||
|
# A failed Helm action can restore the old spec after the bridge installed.
|
||||||
|
[[ "$installed" == "$BRIDGE_VERSION-$suffix" && "$requested_minor" -lt "$bridge_minor" ]] \
|
||||||
|
|| fail "$suffix: another upgrade is in progress"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_provider "$core" core
|
||||||
|
core_minor="$(minor_version "$(jq --raw-output '.status.installedVersion' <<< "$core")" installed)"
|
||||||
|
bootstrap_minor="$target_minor"
|
||||||
|
if [[ -n "$bootstrap" ]]; then
|
||||||
|
validate_provider "$bootstrap" bootstrap
|
||||||
|
bootstrap_minor="$(minor_version "$(upgrade_version "$bootstrap")" installed)"
|
||||||
|
fi
|
||||||
|
bridge_selector_needs_repair() {
|
||||||
|
jq --exit-status --arg version "$BRIDGE_VERSION-$2" '
|
||||||
|
.spec.version == $version and
|
||||||
|
.spec.fetchConfig.selector != {matchLabels: {"provider.cluster.x-k8s.io/version": $version}}' <<< "$1" >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((target_minor - core_minor <= 3 && target_minor - bootstrap_minor <= 3)) &&
|
||||||
|
! bridge_selector_needs_repair "$core" core &&
|
||||||
|
{ [[ -z "$bootstrap" ]] || ! bridge_selector_needs_repair "$bootstrap" bootstrap; }; then
|
||||||
|
printf 'Installed providers are within the supported upgrade window.\n'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
wait_provider() {
|
||||||
|
local resource="$1" name="$2" deployment="$3" expected="$4" uid="$5"
|
||||||
|
local object ready rollout
|
||||||
|
while ((SECONDS < deadline)); do
|
||||||
|
object="$(kube get "$resource" "$name" --output json)"
|
||||||
|
[[ "$(jq --raw-output '.metadata.uid' <<< "$object")" == "$uid" ]] || fail "$name was replaced during the upgrade"
|
||||||
|
[[ "$(jq --raw-output '.spec.version' <<< "$object")" == "$expected" ]] || fail "$name requested version changed during the upgrade"
|
||||||
|
ready="$(jq --raw-output --arg expected "$expected" '
|
||||||
|
.status.installedVersion == $expected and
|
||||||
|
.status.observedGeneration == .metadata.generation and
|
||||||
|
any(.status.conditions[]?; .type == "Ready" and .status == "True")' <<< "$object")"
|
||||||
|
if [[ "$ready" == true ]]; then
|
||||||
|
rollout="$(kube get deployments.apps "$deployment" --ignore-not-found --output json)"
|
||||||
|
if [[ -n "$rollout" ]]; then
|
||||||
|
ready="$(jq --raw-output '
|
||||||
|
(.spec.replicas // 1) as $replicas |
|
||||||
|
$replicas > 0 and
|
||||||
|
.status.observedGeneration == .metadata.generation and
|
||||||
|
.status.replicas == $replicas and
|
||||||
|
.status.updatedReplicas == $replicas and
|
||||||
|
.status.readyReplicas == $replicas and
|
||||||
|
.status.availableReplicas == $replicas' <<< "$rollout")"
|
||||||
|
if [[ "$ready" == true ]]; then
|
||||||
|
printf '%s is ready at %s.\n' "$name" "$expected"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sleep "$poll_seconds"
|
||||||
|
done
|
||||||
|
fail "$name timed out waiting for $expected"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage_provider() {
|
||||||
|
local resource="$1" name="$2" deployment="$3" suffix="$4" object="$5"
|
||||||
|
local installed requested uid minor requested_minor expected patch
|
||||||
|
installed="$(upgrade_version "$object")"
|
||||||
|
requested="$(jq --raw-output '.spec.version' <<< "$object")"
|
||||||
|
uid="$(jq --raw-output '.metadata.uid' <<< "$object")"
|
||||||
|
minor="$(minor_version "$installed" installed)"
|
||||||
|
requested_minor="$(minor_version "$requested" requested)"
|
||||||
|
expected="$requested"
|
||||||
|
if ((minor < bridge_minor)); then
|
||||||
|
if [[ "$requested" == "$installed" || "$requested" == "$BRIDGE_VERSION-$suffix" ]] || ((target_minor - minor > 3)); then
|
||||||
|
expected="$BRIDGE_VERSION-$suffix"
|
||||||
|
fi
|
||||||
|
elif [[ "$installed" == "$BRIDGE_VERSION-$suffix" ]] && ((requested_minor < bridge_minor)); then
|
||||||
|
expected="$BRIDGE_VERSION-$suffix"
|
||||||
|
fi
|
||||||
|
if [[ "$requested" != "$expected" ]] || bridge_selector_needs_repair "$object" "$suffix"; then
|
||||||
|
# The bridge bundles carry only the version label, so a selector keeping a
|
||||||
|
# legacy label would match nothing.
|
||||||
|
patch="$(jq --compact-output --arg uid "$uid" --arg old "$requested" --arg next "$expected" '
|
||||||
|
.spec as $spec |
|
||||||
|
($spec.fetchConfig // {} | .selector = {matchLabels: {"provider.cluster.x-k8s.io/version": $next}}) as $fetch |
|
||||||
|
[
|
||||||
|
{op: "test", path: "/metadata/uid", value: $uid},
|
||||||
|
{op: "test", path: "/spec/version", value: $old},
|
||||||
|
(if $spec | has("fetchConfig") then
|
||||||
|
{op: "test", path: "/spec/fetchConfig", value: $spec.fetchConfig}
|
||||||
|
else
|
||||||
|
{op: "test", path: "/spec", value: $spec}
|
||||||
|
end),
|
||||||
|
{op: "replace", path: "/spec/version", value: $next},
|
||||||
|
{op: (if $spec | has("fetchConfig") then "replace" else "add" end), path: "/spec/fetchConfig", value: $fetch}
|
||||||
|
]' <<< "$object")"
|
||||||
|
kube patch "$resource" "$name" --type=json --patch "$patch" >/dev/null
|
||||||
|
fi
|
||||||
|
wait_provider "$resource" "$name" "$deployment" "$expected" "$uid"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage_provider coreproviders.operator.cluster.x-k8s.io cluster-api capi-controller-manager core "$core"
|
||||||
|
bootstrap_uid="$(jq --raw-output '.metadata.uid // empty' <<< "$bootstrap")"
|
||||||
|
bootstrap="$(kube get bootstrapproviders.operator.cluster.x-k8s.io kubeadm --ignore-not-found --output json)"
|
||||||
|
if [[ -n "$bootstrap_uid" ]]; then
|
||||||
|
[[ "$(jq --raw-output '.metadata.uid // empty' <<< "$bootstrap")" == "$bootstrap_uid" ]] || fail "kubeadm was replaced during the upgrade"
|
||||||
|
fi
|
||||||
|
if [[ -n "$bootstrap" ]]; then
|
||||||
|
validate_provider "$bootstrap" bootstrap
|
||||||
|
bootstrap_minor="$(minor_version "$(upgrade_version "$bootstrap")" requested)"
|
||||||
|
# Unfinished supported requests may need repositories from the dependent bootstrap chart.
|
||||||
|
if [[ -n "$(installed_version "$bootstrap")" ]] || ((target_minor - bootstrap_minor > 3)); then
|
||||||
|
stage_provider bootstrapproviders.operator.cluster.x-k8s.io kubeadm capi-kubeadm-bootstrap-controller-manager bootstrap "$bootstrap"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
printf 'Intermediate provider upgrade completed.\n'
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
--- core-components.yaml
|
||||||
|
+++ core-components.yaml
|
||||||
|
@@ -20276,4 +20276,10 @@
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
+ startupProbe:
|
||||||
|
+ httpGet:
|
||||||
|
+ path: /healthz
|
||||||
|
+ port: healthz
|
||||||
|
+ failureThreshold: 30
|
||||||
|
+ periodSeconds: 10
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /healthz
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: v1.10.1-core
|
name: {{ .Chart.AppVersion }}-core
|
||||||
labels:
|
labels:
|
||||||
|
provider.cluster.x-k8s.io/version: {{ .Chart.AppVersion }}-core
|
||||||
core-components: cozy
|
core-components: cozy
|
||||||
annotations:
|
annotations:
|
||||||
provider.cluster.x-k8s.io/compressed: "true"
|
provider.cluster.x-k8s.io/compressed: "true"
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ metadata:
|
|||||||
name: cluster-api
|
name: cluster-api
|
||||||
spec:
|
spec:
|
||||||
# https://github.com/kubernetes-sigs/cluster-api
|
# https://github.com/kubernetes-sigs/cluster-api
|
||||||
version: v1.10.1-core
|
version: {{ .Chart.AppVersion }}-core
|
||||||
fetchConfig:
|
fetchConfig:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
|
provider.cluster.x-k8s.io/version: {{ .Chart.AppVersion }}-core
|
||||||
core-components: cozy
|
core-components: cozy
|
||||||
deployment:
|
deployment:
|
||||||
containers:
|
containers:
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
{{- $bridge := required "intermediate provider version is missing" (.Files.Get "files/bridge-version" | trim) -}}
|
||||||
|
{{- $name := printf "%s-upgrade" .Release.Name -}}
|
||||||
|
{{- $timeout := 480 -}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: pre-install,pre-upgrade
|
||||||
|
helm.sh/hook-weight: "-20"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
|
||||||
|
data:
|
||||||
|
upgrade-providers.sh: |
|
||||||
|
{{- required "provider upgrade script is missing" (.Files.Get "files/upgrade-providers.sh") | nindent 4 }}
|
||||||
|
kubeconfig: |
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Config
|
||||||
|
current-context: capi-upgrade
|
||||||
|
clusters:
|
||||||
|
- name: in-cluster
|
||||||
|
cluster:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
certificate-authority: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||||
|
contexts:
|
||||||
|
- name: capi-upgrade
|
||||||
|
context:
|
||||||
|
cluster: in-cluster
|
||||||
|
user: upgrade
|
||||||
|
users:
|
||||||
|
- name: upgrade
|
||||||
|
user:
|
||||||
|
tokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: pre-install,pre-upgrade
|
||||||
|
helm.sh/hook-weight: "-10"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: pre-install,pre-upgrade
|
||||||
|
helm.sh/hook-weight: "-10"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
|
||||||
|
rules:
|
||||||
|
- apiGroups: [operator.cluster.x-k8s.io]
|
||||||
|
resources: [coreproviders]
|
||||||
|
resourceNames: [cluster-api]
|
||||||
|
verbs: [get, patch]
|
||||||
|
- apiGroups: [operator.cluster.x-k8s.io]
|
||||||
|
resources: [bootstrapproviders]
|
||||||
|
resourceNames: [kubeadm]
|
||||||
|
verbs: [get, patch]
|
||||||
|
- apiGroups: [apps]
|
||||||
|
resources: [deployments]
|
||||||
|
resourceNames: [capi-controller-manager, capi-kubeadm-bootstrap-controller-manager]
|
||||||
|
verbs: [get]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: pre-install,pre-upgrade
|
||||||
|
helm.sh/hook-weight: "-10"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: {{ $name }}
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ $name }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: pre-install,pre-upgrade
|
||||||
|
helm.sh/hook-weight: "0"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation
|
||||||
|
spec:
|
||||||
|
backoffLimit: 0
|
||||||
|
activeDeadlineSeconds: {{ add $timeout 60 }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
policy.cozystack.io/allow-to-apiserver: "true"
|
||||||
|
spec:
|
||||||
|
serviceAccountName: {{ $name }}
|
||||||
|
restartPolicy: Never
|
||||||
|
securityContext:
|
||||||
|
runAsNonRoot: true
|
||||||
|
runAsUser: 65532
|
||||||
|
runAsGroup: 65532
|
||||||
|
fsGroup: 65532
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
|
containers:
|
||||||
|
- name: upgrade
|
||||||
|
image: {{ include "cozy-lib.image" (list .Values.upgrade.image $) | quote }}
|
||||||
|
command: [bash, /scripts/upgrade-providers.sh]
|
||||||
|
env:
|
||||||
|
- name: HOME
|
||||||
|
value: /tmp
|
||||||
|
- name: KUBECONFIG
|
||||||
|
value: /scripts/kubeconfig
|
||||||
|
- name: KUBE_CONTEXT
|
||||||
|
value: capi-upgrade
|
||||||
|
- name: NAMESPACE
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: metadata.namespace
|
||||||
|
- name: BRIDGE_VERSION
|
||||||
|
value: {{ $bridge | quote }}
|
||||||
|
- name: TARGET_VERSION
|
||||||
|
value: {{ .Chart.AppVersion | quote }}
|
||||||
|
- name: CAPI_UPGRADE_TIMEOUT_SECONDS
|
||||||
|
value: {{ $timeout | quote }}
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
readOnlyRootFilesystem: true
|
||||||
|
capabilities:
|
||||||
|
drop: [ALL]
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 64Mi
|
||||||
|
limits:
|
||||||
|
cpu: 500m
|
||||||
|
memory: 256Mi
|
||||||
|
volumeMounts:
|
||||||
|
- name: scripts
|
||||||
|
mountPath: /scripts
|
||||||
|
readOnly: true
|
||||||
|
- name: tmp
|
||||||
|
mountPath: /tmp
|
||||||
|
volumes:
|
||||||
|
- name: scripts
|
||||||
|
configMap:
|
||||||
|
name: {{ $name }}
|
||||||
|
- name: tmp
|
||||||
|
emptyDir: {}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
upgrade:
|
||||||
|
image: docker.io/alpine/k8s:1.33.4@sha256:b0523f0a244ddc4c8e055aa335c040d3d78b3ead5528f4544395f7f9f69c7b68
|
||||||
@@ -5,9 +5,10 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
# https://github.com/ionos-cloud/cluster-api-provider-proxmox
|
# https://github.com/ionos-cloud/cluster-api-provider-proxmox
|
||||||
#
|
#
|
||||||
# Pinned to the v0.7 series: from v0.8 capmox declares the v1beta2 Cluster API
|
# Pinned to the v0.7 series. v0.8 moves capmox to the v1beta2 contract and
|
||||||
# contract, while the core provider shipped here is v1.10.1, which serves
|
# stores v1alpha2. v1alpha1 is still served through conversion, but that has
|
||||||
# v1beta1. Bump this together with capi-providers-core, not on its own.
|
# not been tested with the kubernetes-nodes templates, and in-cluster IPAM
|
||||||
|
# should move to v1.1 at the same time. Bump the two together.
|
||||||
version: v0.7.7-infraprovider-proxmox
|
version: v0.7.7-infraprovider-proxmox
|
||||||
configSecret:
|
configSecret:
|
||||||
name: {{ .Values.credentialsSecretName | quote }}
|
name: {{ .Values.credentialsSecretName | quote }}
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ spec:
|
|||||||
# Who needs this, and why it is not in a KubeVirt install: see the dependsOn
|
# Who needs this, and why it is not in a KubeVirt install: see the dependsOn
|
||||||
# edge in packages/core/platform/sources/capi-provider-infra-proxmox.yaml.
|
# edge in packages/core/platform/sources/capi-provider-infra-proxmox.yaml.
|
||||||
#
|
#
|
||||||
# v1.0.x, not v1.1.0: both serve InClusterIPPool v1alpha2, but the v1.0 series
|
# v1.0.x, not v1.1: both serve InClusterIPPool v1alpha2, but v1.1 moves to the
|
||||||
# declares the v1beta1 contract that matches capi-providers-core v1.10.1.
|
# v1beta2 contract and its IPAddressClaim API, while capmox v0.7, the only
|
||||||
|
# consumer here, is a v1beta1-contract provider. Move the two together.
|
||||||
version: v1.0.3-ipam-in-cluster
|
version: v1.0.3-ipam-in-cluster
|
||||||
fetchConfig:
|
fetchConfig:
|
||||||
selector:
|
selector:
|
||||||
|
|||||||
Reference in new issue
Block a user