cluster-api
cluster-api copied to clipboard
Substitute environment variables in clusterctl.yaml
User Story
As a operator I would like to use variables inside my clusterctl.yaml that will be substrituted with environment variables so we can use relative paths inside clusterctl.yaml e.g. to configure relative, local URIs.
Detailed Description
In an air-gapped environment you'll often find yourself in a situation where you have to provide all images and manifests localy when initializing a CAPI cluster. To have the setup documented and reproduceable it makes sense to package all the dependencies on your local CRD manifest files as well as the used clusterctl.yaml in some source code management system like Git.
Because the content of clusterctl.yaml is currently static it's not possible however to make such a setup independet of the system we're executing clusterctl from since e.g. we can't use relative paths or other system specific configurations. You end up having to edit the clusterctl.yaml depending on which system you're executing clusterctl on.
I'd like to request a new feature to change the YAML processor used to read the clusterctl.yaml so it has an option to substitute variables, e.g.
in this example:
providers:
- name: "cluster-api"
type: "CoreProvider"
url: "$HOME/.cluster-api/overrides/cluster-api/v1.0.0/core-components.yaml"
the url would be expanded to /home/myuser/.cluster-api/overrides/cluster-api/v1.0.0/core-components.yaml. This is just a single example on how this could be used to make the use of clusterctl.yaml more flexible.
I'm not sure which YAML processor is used currently for this but processors exist that provide such functions already as well as the required escape functions in case someone actually would like to use the string $HOME and not have that substituted in the example above.
/kind feature
/area clusterctl /milestone v1.0
TBD if we should rely on envsubst syntax or on pain bash variable interpolation
Using envsubst might be simpler as we already have the dependency and it's consistent with how we render the cluster templates (and thus the allowed syntax/features in those files).
I'm good with envsubst and think it's syntax probably more reliable then bash. The bash syntax like example I gave above was just for illustration.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale - Mark this issue or PR as rotten with
/lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale /help
@fabriziopandini: This request has been marked as needing help from a contributor.
Guidelines
Please ensure that the issue body includes answers to the following questions:
- Why are we solving this issue?
- To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
- Does this issue have zero to low barrier of entry?
- How can the assignee reach out to you for help?
For more details on the requirements of such an issue, please see here and ensure that they are met.
If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.
In response to this:
/remove-lifecycle stale /help
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
/assign @sbueringer @fabriziopandini I'd like to give this a shot. Where would we want to handle the variable substitution? Would we want to make changes to the Go code where the config file is read in, i.e. in this file? It looks like we handle stuff for envsubst in the Makefile as well so I'm not sure what the best way too approach the problem is.
@ykakarap to provide guidance
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale - Mark this issue or PR as rotten with
/lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/lifecycle frozen
/triage accepted
@Jont828 Sorry missed this in February. I've implemented a solution for it in #7343 (we would like to use the functionality at a KubeCon tutorial in two weeks)
/assign
/unassign @Jont828