cluster-api icon indicating copy to clipboard operation
cluster-api copied to clipboard

Substitute environment variables in clusterctl.yaml

Open omniproc opened this issue 4 years ago • 11 comments

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

omniproc avatar Oct 20 '21 10:10 omniproc

/area clusterctl /milestone v1.0

TBD if we should rely on envsubst syntax or on pain bash variable interpolation

fabriziopandini avatar Oct 20 '21 10:10 fabriziopandini

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).

sbueringer avatar Oct 20 '21 11:10 sbueringer

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.

omniproc avatar Oct 20 '21 13:10 omniproc

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Jan 20 '22 18:01 k8s-triage-robot

/remove-lifecycle stale /help

fabriziopandini avatar Jan 20 '22 18:01 fabriziopandini

@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.

k8s-ci-robot avatar Jan 20 '22 18:01 k8s-ci-robot

/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.

Jont828 avatar Feb 25 '22 23:02 Jont828

@ykakarap to provide guidance

fabriziopandini avatar Feb 28 '22 10:02 fabriziopandini

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar May 29 '22 11:05 k8s-triage-robot

/lifecycle frozen

fabriziopandini avatar May 31 '22 09:05 fabriziopandini

/triage accepted

fabriziopandini avatar Aug 05 '22 17:08 fabriziopandini

@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

sbueringer avatar Oct 05 '22 12:10 sbueringer

/unassign @Jont828

fabriziopandini avatar Oct 06 '22 10:10 fabriziopandini