Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"auto_release": "y",
"copyright_holder": "VSHN AG <info@vshn.ch>",
"copyright_year": "2026",
"github_owner": "vshn",
"github_owner": "projectsyn",
"github_name": "component-capi-provider-talos",
"github_url": "https://github.com/vshn/component-capi-provider-talos",
"github_url": "https://github.com/projectsyn/component-capi-provider-talos",
"_template": "https://github.com/projectsyn/commodore-component-template.git",
"_commit": "aec8da7344f670fff4f96fb20cbdcfbdeb2113d4"
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
/_public

# Additional entries
envsubst-v*
1 change: 1 addition & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ ignore: |
manifests/
vendor/
compiled/
tests/golden/**
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
This code repository is part of Project Syn and the contribution guide at
https://syn.tools/syn/about/contribution_guide.html does apply.

Submit Pull Requests at https://github.com/vshn/component-capi-provider-talos/pulls.
Submit Pull Requests at https://github.com/projectsyn/component-capi-provider-talos/pulls.
44 changes: 43 additions & 1 deletion class/capi-provider-talos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,46 @@ parameters:
- input_paths:
- ${_base_directory}/component/main.jsonnet
input_type: jsonnet
output_path: capi-provider-talos/
output_path: .
- input_paths:
- ${_base_directory}/component/bootstrap-provider.jsonnet
input_type: jsonnet
output_path: ${_base_directory}/manifests/capi-bootstrap-provider-talos/
- input_type: external
output_path: .
input_paths:
- ${_kustomize_wrapper}
env_vars:
INPUT_DIR: ${_base_directory}/manifests/capi-bootstrap-provider-talos/
args:
- ${_base_directory}/manifests/capi-bootstrap-provider-talos-rendered/
- input_type: external
output_path: .
input_paths:
- ${_base_directory}/envsubst-dir
# map env vars from parameters as needed
env_vars: ${capi_provider_talos:bootstrap:variables}
args:
- ${_base_directory}/manifests/capi-bootstrap-provider-talos-rendered
- \${compiled_target_dir}/capi-provider-talos/bootstrap/10_kustomize
- input_paths:
- ${_base_directory}/component/controlplane-provider.jsonnet
input_type: jsonnet
output_path: ${_base_directory}/manifests/capi-controlplane-provider-talos/
- input_type: external
output_path: .
input_paths:
- ${_kustomize_wrapper}
env_vars:
INPUT_DIR: ${_base_directory}/manifests/capi-controlplane-provider-talos/
args:
- ${_base_directory}/manifests/capi-controlplane-provider-talos-rendered/
- input_type: external
output_path: .
input_paths:
- ${_base_directory}/envsubst-dir
# map env vars from parameters as needed
env_vars: ${capi_provider_talos:controlplane:variables}
args:
- ${_base_directory}/manifests/capi-controlplane-provider-talos-rendered
- \${compiled_target_dir}/capi-provider-talos/controlplane/10_kustomize
18 changes: 17 additions & 1 deletion class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,20 @@ parameters:
capi_provider_talos:
=_metadata:
multi_tenant: true
namespace: syn-capi-provider-talos
namespace: syn-cluster-api

images:
capi-bootstrap-provider-talos:
registry: ghcr.io
image: siderolabs/cluster-api-bootstrap-talos-controller
tag: v0.6.12
capi-controlplane-provider-talos:
registry: ghcr.io
image: siderolabs/cluster-api-control-plane-talos-controller
tag: v0.5.13

bootstrap:
variables: {}

controlplane:
variables: {}
8 changes: 7 additions & 1 deletion component/app.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ local inv = kap.inventory();
local params = inv.parameters.capi_provider_talos;
local argocd = import 'lib/argocd.libjsonnet';

local app = argocd.App('capi-provider-talos', params.namespace);
local app = argocd.App('capi-provider-talos', params.namespace) {
spec+: {
syncOptions+: [
'ServerSideApply=true',
],
},
};

local appPath =
local project = std.get(std.get(app, 'spec', {}), 'project', 'syn');
Expand Down
42 changes: 42 additions & 0 deletions component/bootstrap-provider.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
local com = import 'lib/commodore.libjsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local inv = kap.inventory();
// The hiera parameters for the component
local params = inv.parameters.capi_provider_talos;

local manifest_path = 'config/default';

com.Kustomization(
'https://github.com/siderolabs/cluster-api-bootstrap-provider-talos/' + manifest_path,
params.images['capi-bootstrap-provider-talos'].tag,
{
'ghcr.io/siderolabs/cluster-api-bootstrap-talos-controller': {
local image = params.images['capi-bootstrap-provider-talos'],
newTag: image.tag,
newName: '%(registry)s/%(image)s' % image,
},
},
{
namespace: params.namespace,
labels+: [
{
pairs: {
'app.kubernetes.io/managed-by': 'commodore',
},
},
],
patchesStrategicMerge: [ 'rm-namespace.yaml' ],
},
) {
'rm-namespace': [
{
'$patch': 'delete',
apiVersion: 'v1',
kind: 'Namespace',
metadata: {
name: 'cabpt-system',
},
},
],
}
42 changes: 42 additions & 0 deletions component/controlplane-provider.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
local com = import 'lib/commodore.libjsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local inv = kap.inventory();
// The hiera parameters for the component
local params = inv.parameters.capi_provider_talos;

local manifest_path = 'config/default';

com.Kustomization(
'https://github.com/siderolabs/cluster-api-control-plane-provider-talos/' + manifest_path,
params.images['capi-controlplane-provider-talos'].tag,
{
'ghcr.io/siderolabs/cluster-api-control-plane-talos-controller': {
local image = params.images['capi-controlplane-provider-talos'],
newTag: image.tag,
newName: '%(registry)s/%(image)s' % image,
},
},
{
namespace: params.namespace,
labels+: [
{
pairs: {
'app.kubernetes.io/managed-by': 'commodore',
},
},
],
patchesStrategicMerge: [ 'rm-namespace.yaml' ],
},
) {
'rm-namespace': [
{
'$patch': 'delete',
apiVersion: 'v1',
kind: 'Namespace',
metadata: {
name: 'cacppt-system',
},
},
],
}
2 changes: 2 additions & 0 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ local inv = kap.inventory();
// The hiera parameters for the component
local params = inv.parameters.capi_provider_talos;

assert std.member(inv.applications, 'capi-core') : 'Component capi-provider-talos requires component capi-core';

// Define outputs below
{
}
55 changes: 54 additions & 1 deletion docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,67 @@ The parent key for all of the following parameters is `capi_provider_talos`.

[horizontal]
type:: string
default:: `syn-capi-provider-talos`
default:: `syn-cluster-api`

The namespace in which to deploy this component.
The component assumes that this namespace already exists via dependency `component-capi-core`.

== `images`

[horizontal]
type:: dict
default:: See `class/defaults.yml`

The default Docker image location and tag to use for the CAPI provider talos components (keys `capi-boostrap-provider-talos` and `capi-controlplane-provider-talos`).

Entries in this dict should be dictionaries with keys `registry`, `image`, and `tag`. This structure provides the basis for dependency maintenance with Renovate.

The values of `capi-bootstrap-provider-talos.tag` and `capi-controlplane-provider-talos.tag` in this dict is used by the component to select the versions of the upstream CAPI provider talos components.

== `bootstrap.variables`

[horizontal]
type:: dict
default:: See `class/defaults.yml`

An object with environment variables that the generated manifests of the bootstrap provider will be templated with, similar to `clusterctl`.
Variables should be specified in the format:

[source,yaml]
----
variables:
FOO: bar
----

== `controlplane.variables`

[horizontal]
type:: dict
default:: See `class/defaults.yml`

An object with environment variables that the generated manifests of the control plane provider will be templated with, similar to `clusterctl`.
variables should be specified in the format:

[source,yaml]
----
variables:
FOO: bar
----

== Example

[source,yaml]
----
namespace: example-namespace
images:
capi-bootstrap-provider-talos:
tag: tag: v0.6.12
capi-controlplane-provider-talos:
tag: tag: v0.5.13
bootstrap:
variables:
MY_VARIABLE: value
controlplane:
variables:
MY_VARIABLE: value
----
77 changes: 77 additions & 0 deletions envsubst-dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -euo pipefail

basedir=$(dirname "$0")
version="${ENVSUBST_VERSION:-v1.4.3}"

src="$1"
dst="$2"

ensure_envsubst () {
set -eu

local dir="$1"
# Version with leading `v`.
local version="$2"

local arch
arch=$(uname -m)
case $arch in
aarch64|arm64) arch="arm64";;
x86_64|amd64) arch="x86_64";;
*)
>&2 echo "Unsupported arch: $arch"
exit 5
::
esac

local os
os=$(uname -s)
if [[ "$os" != "Linux" && "$os" != "Darwin" ]]; then
>&2 echo "Unsupported os: $os"
exit 5
fi

if [ ! -x "${dir}/envsubst-${version}-${os}-${arch}" ]; then
download_envsubst "${dir}" "${version}" "${os}" "${arch}"
else
>&2 echo "envsubst-${version}-${os}-${arch} already installed"
fi

echo "${dir}/envsubst-${version}-${os}-${arch}"
}

download_envsubst () {
set -eu

local dir="$1"
local version="$2"
local os="$3"
local arch="$4"

local url="https://github.com/a8m/envsubst/releases/download/${version}/envsubst-${os}-${arch}"

>&2 echo "Downloading envsubst-${version}-${os}-${arch} from ${url}"

curl -fsSLo "${dir}/envsubst-${version}-${os}-${arch}" "${url}"
chmod +x "${dir}/envsubst-${version}-${os}-${arch}"

>&2 echo "envsubst-${version}-${os}-${arch} successfully installed"
}

envsubst="$(ensure_envsubst "${basedir}" "${version}")"

mkdir -p "$dst"

find "$src" -type f -name '*.yaml' -print0 |
while IFS= read -r -d '' file; do
relative="${file#$src/}"
output="$dst/$relative"

mkdir -p "$(dirname "$output")"

"$envsubst" \
-no-unset \
-i "$file" \
-o "$output"
done
3 changes: 3 additions & 0 deletions tests/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Overwrite parameters here

applications:
- capi-core

# parameters: {...}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spec:
syncOptions:
- ServerSideApply=true
Loading
Loading