-
Notifications
You must be signed in to change notification settings - Fork 0
Initial implementation using kustomize and envsubst #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e2b5523
Initial implementation using kustomize and envsubst
thobens b136f9b
Ignore linting for golden tests as output is from envsubst
thobens 3a8888b
Apply changes from code review
thobens 546f66d
Download envsubst dependency local to component
thobens 27f5016
Apply changes from code review
thobens 655fac6
Prepare to move repository to projectsyn
thobens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,4 @@ ignore: | | |
| manifests/ | ||
| vendor/ | ||
| compiled/ | ||
| tests/golden/** | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,46 @@ | ||
| // 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_cloudscale; | ||
|
|
||
| // Define outputs below | ||
| { | ||
| assert std.member(inv.applications, 'capi-core') : 'Application capi-core is not available'; | ||
|
thobens marked this conversation as resolved.
Outdated
|
||
| assert std.length(params.variables.cloudscale_api_token) > 0 : 'capi-provider-cloudscale:variables:cloudscale_api_token must be set'; | ||
|
|
||
| local manifest_path = 'config/default'; | ||
|
|
||
| com.Kustomization( | ||
| 'https://github.com/cloudscale-ch/cluster-api-provider-cloudscale/' + manifest_path, | ||
| params.images['capi-provider-cloudscale'].tag, | ||
| { | ||
| 'quay.io/cloudscalech/capcs-staging': { | ||
| local image = params.images['capi-provider-cloudscale'], | ||
| 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: 'capcs-system', | ||
| }, | ||
| }, | ||
| ], | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| # Overwrite parameters here | ||
|
|
||
| # parameters: {...} | ||
| applications: | ||
| - capi-core | ||
|
|
||
| parameters: | ||
| capi_provider_cloudscale: | ||
| variables: | ||
| cloudscale_api_token: "MY_CLOUDSCALE_API_TOKEN" | ||
|
thobens marked this conversation as resolved.
Outdated
|
||
90 changes: 90 additions & 0 deletions
90
...stration.k8s.io_v1_mutatingwebhookconfiguration_capcs-mutating-webhook-configuration.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: MutatingWebhookConfiguration | ||
| metadata: | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: capcs-system/capcs-serving-cert | ||
| labels: | ||
| app.kubernetes.io/managed-by: commodore | ||
| cluster.x-k8s.io/provider: infrastructure-cloudscale-ch-cloudscale | ||
| name: capcs-mutating-webhook-configuration | ||
| webhooks: | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: capcs-webhook-service | ||
| namespace: syn-cluster-api | ||
| path: /mutate-infrastructure-cluster-x-k8s-io-v1beta2-cloudscalecluster | ||
| failurePolicy: Fail | ||
| name: mcloudscalecluster-v1beta2.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - infrastructure.cluster.x-k8s.io | ||
| apiVersions: | ||
| - v1beta2 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - cloudscaleclusters | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: capcs-webhook-service | ||
| namespace: syn-cluster-api | ||
| path: /mutate-infrastructure-cluster-x-k8s-io-v1beta2-cloudscaleclustertemplate | ||
| failurePolicy: Fail | ||
| name: mcloudscaleclustertemplate-v1beta2.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - infrastructure.cluster.x-k8s.io | ||
| apiVersions: | ||
| - v1beta2 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - cloudscaleclustertemplates | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: capcs-webhook-service | ||
| namespace: syn-cluster-api | ||
| path: /mutate-infrastructure-cluster-x-k8s-io-v1beta2-cloudscalemachine | ||
| failurePolicy: Fail | ||
| name: mcloudscalemachine-v1beta2.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - infrastructure.cluster.x-k8s.io | ||
| apiVersions: | ||
| - v1beta2 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - cloudscalemachines | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: capcs-webhook-service | ||
| namespace: syn-cluster-api | ||
| path: /mutate-infrastructure-cluster-x-k8s-io-v1beta2-cloudscalemachinetemplate | ||
| failurePolicy: Fail | ||
| name: mcloudscalemachinetemplate-v1beta2.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - infrastructure.cluster.x-k8s.io | ||
| apiVersions: | ||
| - v1beta2 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - cloudscalemachinetemplates | ||
| sideEffects: None |
90 changes: 90 additions & 0 deletions
90
...tion.k8s.io_v1_validatingwebhookconfiguration_capcs-validating-webhook-configuration.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: ValidatingWebhookConfiguration | ||
| metadata: | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: capcs-system/capcs-serving-cert | ||
| labels: | ||
| app.kubernetes.io/managed-by: commodore | ||
| cluster.x-k8s.io/provider: infrastructure-cloudscale-ch-cloudscale | ||
| name: capcs-validating-webhook-configuration | ||
| webhooks: | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: capcs-webhook-service | ||
| namespace: syn-cluster-api | ||
| path: /validate-infrastructure-cluster-x-k8s-io-v1beta2-cloudscalecluster | ||
| failurePolicy: Fail | ||
| name: vcloudscalecluster-v1beta2.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - infrastructure.cluster.x-k8s.io | ||
| apiVersions: | ||
| - v1beta2 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - cloudscaleclusters | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: capcs-webhook-service | ||
| namespace: syn-cluster-api | ||
| path: /validate-infrastructure-cluster-x-k8s-io-v1beta2-cloudscaleclustertemplate | ||
| failurePolicy: Fail | ||
| name: vcloudscaleclustertemplate-v1beta2.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - infrastructure.cluster.x-k8s.io | ||
| apiVersions: | ||
| - v1beta2 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - cloudscaleclustertemplates | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: capcs-webhook-service | ||
| namespace: syn-cluster-api | ||
| path: /validate-infrastructure-cluster-x-k8s-io-v1beta2-cloudscalemachine | ||
| failurePolicy: Fail | ||
| name: vcloudscalemachine-v1beta2.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - infrastructure.cluster.x-k8s.io | ||
| apiVersions: | ||
| - v1beta2 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - cloudscalemachines | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: capcs-webhook-service | ||
| namespace: syn-cluster-api | ||
| path: /validate-infrastructure-cluster-x-k8s-io-v1beta2-cloudscalemachinetemplate | ||
| failurePolicy: Fail | ||
| name: vcloudscalemachinetemplate-v1beta2.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - infrastructure.cluster.x-k8s.io | ||
| apiVersions: | ||
| - v1beta2 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - cloudscalemachinetemplates | ||
| sideEffects: None |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.