Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ $(test_instances):

.PHONY: clean
clean: ## Clean the project
rm -rf .cache compiled dependencies vendor helmcharts jsonnetfile*.json || true
rm -rf .cache compiled dependencies vendor helmcharts manifests jsonnetfile*.json || true
Comment thread
thobens marked this conversation as resolved.
Outdated
45 changes: 44 additions & 1 deletion class/capi-provider-talos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,47 @@ 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}/scripts/envsubst-dir
# map env vars from parameters as needed
env_vars: {}
Comment thread
thobens marked this conversation as resolved.
Outdated
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}/scripts/envsubst-dir
# map env vars from parameters as needed
env_vars:
Comment thread
thobens marked this conversation as resolved.
Outdated
ENVSUBST_VERSION: v1.4.3
Comment thread
thobens marked this conversation as resolved.
Outdated
args:
- ${_base_directory}/manifests/capi-controlplane-provider-talos-rendered
- \${compiled_target_dir}/capi-provider-talos/controlplane/10_kustomize
29 changes: 28 additions & 1 deletion class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,31 @@ parameters:
capi_provider_talos:
=_metadata:
multi_tenant: true
namespace: syn-capi-provider-talos
# The component assumes that this namespace already exists via dependency `component-capi-core`
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:

# An object with variables that the generated manifests will be templated with.
# They should be specified in the format:
# variables:
# my_variable: bar
variables: {}

controlplane:

# An object with variables that the generated manifests will be templated with.
# They should be specified in the format:
# variables:
# my_variable: bar
Comment thread
thobens marked this conversation as resolved.
Outdated
variables: {}
43 changes: 43 additions & 0 deletions component/bootstrap-provider.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// main template for capi-provider-cloudscale
Comment thread
thobens marked this conversation as resolved.
Outdated
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',
},
},
],
}
43 changes: 43 additions & 0 deletions component/controlplane-provider.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// main template for capi-provider-cloudscale
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') : 'Application capi-core is not available';
Comment thread
thobens marked this conversation as resolved.
Outdated

// Define outputs below
{
}
77 changes: 77 additions & 0 deletions scripts/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")/../dependencies
Comment thread
thobens marked this conversation as resolved.
Outdated
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,49 @@
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: syn-cluster-api/cabpt-serving-cert
labels:
app.kubernetes.io/managed-by: commodore
cluster.x-k8s.io/provider: bootstrap-talos
name: cabpt-validating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: cabpt-webhook-service
namespace: syn-cluster-api
path: /validate-bootstrap-cluster-x-k8s-io-v1alpha3-talosconfig
failurePolicy: Fail
name: vtalosconfig.cluster.x-k8s.io
rules:
- apiGroups:
- bootstrap.cluster.x-k8s.io
apiVersions:
- v1alpha3
operations:
- CREATE
- UPDATE
resources:
- talosconfigs
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: cabpt-webhook-service
namespace: syn-cluster-api
path: /validate-bootstrap-cluster-x-k8s-io-v1alpha3-talosconfigtemplate
failurePolicy: Fail
name: vtalosconfigtemplate.cluster.x-k8s.io
rules:
- apiGroups:
- bootstrap.cluster.x-k8s.io
apiVersions:
- v1alpha3
operations:
- UPDATE
resources:
- talosconfigtemplates
sideEffects: None
Loading
Loading