Skip to content
Merged
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/**
20 changes: 20 additions & 0 deletions class/capi-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,23 @@ parameters:
- ${_base_directory}/component/main.jsonnet
input_type: jsonnet
output_path: capi-core/
- input_paths:
- ${_base_directory}/component/cluster-api.jsonnet
input_type: jsonnet
output_path: ${_base_directory}/manifests/cluster-api/
- input_type: external
output_path: .
input_paths:
- ${_kustomize_wrapper}
env_vars:
INPUT_DIR: ${_base_directory}/manifests/cluster-api/
args:
- ${_base_directory}/manifests/cluster-api-rendered/
- input_type: external
output_path: .
input_paths:
- ${_base_directory}/scripts/envsubst-dir
env_vars: {} # map env vars from parameters as needed
args:
- ${_base_directory}/manifests/cluster-api-rendered
- \${compiled_target_dir}/capi-core/cluster-api/10_kustomize
14 changes: 13 additions & 1 deletion class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@ parameters:
capi_core:
=_metadata:
multi_tenant: true
namespace: syn-capi-core
namespace: syn-cluster-api

images:
cluster-api:
registry: registry.k8s.io
image: cluster-api/cluster-api-controller
tag: v1.13.4

# An object with variables that the generated manifests will be templated with.
# They should be specified in the format:
# variables:
# foo: bar
variables: {}
42 changes: 42 additions & 0 deletions component/cluster-api.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// main template for capi-core
local com = import 'lib/commodore.libjsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local inv = kap.inventory();
// The hiera parameters for the component
local params = inv.parameters.capi_core;

local manifest_path = 'config/default';
Comment thread
thobens marked this conversation as resolved.
Outdated

com.Kustomization(
'https://github.com/kubernetes-sigs/cluster-api/' + manifest_path,
params.images['cluster-api'].tag,
{
'registry.k8s.io/cluster-api/cluster-api-controller': {
local image = params.images['cluster-api'],
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: 'capi-system',
},
},
],
}
3 changes: 2 additions & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// main template for capi-core
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_core;

// Define outputs below
{
'00_namespace': kube.Namespace(params.namespace),
}
20 changes: 20 additions & 0 deletions scripts/envsubst-dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

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

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 \
Comment thread
thobens marked this conversation as resolved.
Outdated
-no-unset \
-i "$file" \
-o "$output"
done
8 changes: 7 additions & 1 deletion tests/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Overwrite parameters here
applications:
- capi-core

# parameters: {...}
parameters:
components:
capi-core:
url: https://github.com/projectsyn/component-capi-core.git
version: alde-262/implement-capi-core-component
7 changes: 7 additions & 0 deletions tests/golden/defaults/capi-core/capi-core/00_namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
annotations: {}
labels:
name: syn-cluster-api
name: syn-cluster-api
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: capi-system/capi-serving-cert
labels:
app.kubernetes.io/managed-by: commodore
cluster.x-k8s.io/provider: cluster-api
name: capi-mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: capi-webhook-service
namespace: syn-cluster-api
path: /mutate-cluster-x-k8s-io-v1beta2-cluster
failurePolicy: Fail
matchPolicy: Equivalent
name: default.cluster.cluster.x-k8s.io
rules:
- apiGroups:
- cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- clusters
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: capi-webhook-service
namespace: syn-cluster-api
path: /mutate-addons-cluster-x-k8s-io-v1beta2-clusterresourceset
failurePolicy: Fail
matchPolicy: Equivalent
name: default.clusterresourceset.addons.cluster.x-k8s.io
rules:
- apiGroups:
- addons.cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- clusterresourcesets
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: capi-webhook-service
namespace: syn-cluster-api
path: /mutate-runtime-cluster-x-k8s-io-v1beta2-extensionconfig
failurePolicy: Fail
matchPolicy: Equivalent
name: default.extensionconfig.runtime.addons.cluster.x-k8s.io
rules:
- apiGroups:
- runtime.cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- extensionconfigs
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: capi-webhook-service
namespace: syn-cluster-api
path: /mutate-cluster-x-k8s-io-v1beta2-machine
failurePolicy: Fail
matchPolicy: Equivalent
name: default.machine.cluster.x-k8s.io
rules:
- apiGroups:
- cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- machines
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: capi-webhook-service
namespace: syn-cluster-api
path: /mutate-cluster-x-k8s-io-v1beta2-machinedeployment
failurePolicy: Fail
matchPolicy: Equivalent
name: default.machinedeployment.cluster.x-k8s.io
rules:
- apiGroups:
- cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- machinedeployments
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: capi-webhook-service
namespace: syn-cluster-api
path: /mutate-cluster-x-k8s-io-v1beta2-machinehealthcheck
failurePolicy: Fail
matchPolicy: Equivalent
name: default.machinehealthcheck.cluster.x-k8s.io
rules:
- apiGroups:
- cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- machinehealthchecks
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: capi-webhook-service
namespace: syn-cluster-api
path: /mutate-cluster-x-k8s-io-v1beta2-machinepool
failurePolicy: Fail
matchPolicy: Equivalent
name: default.machinepool.cluster.x-k8s.io
rules:
- apiGroups:
- cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- machinepools
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: capi-webhook-service
namespace: syn-cluster-api
path: /mutate-cluster-x-k8s-io-v1beta2-machineset
failurePolicy: Fail
matchPolicy: Equivalent
name: default.machineset.cluster.x-k8s.io
rules:
- apiGroups:
- cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- machinesets
sideEffects: None
Loading
Loading