Skip to content
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

🌱 ClusterClass: add ref and controlPlane name builtin variables #6208

Merged

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Feb 25, 2022

Signed-off-by: Stefan Büringer [email protected]

What this PR does / why we need it:
While writing ClusterClasses for CAPZ, we discovered that additional builtin variables are needed.

CAPZ has a controller which generates secrets which are eventually used for Machines. These secrets then have to be configured in KCP.spec..kubeadmConfigSpec and in KubeadmConfigTemplates.

The secrets are generated with the names of the corresponding current AzureMachineTemplates. So essentially CAPZ has to be able to take the name of the currently referenced AzureMachineTemplate of KCP/MD and then patch KCP / the KubeadmConfigTemplate accordingly.

To make this possible we introduce builtin variables for all references in KCP / MD.

We additionally add builtin.controlPlane.name because it seems to be a good variable to have.

For additional context, please see this Slack thread: https://kubernetes.slack.com/archives/CEX9HENG7/p1645731252682719

The plan is to cherry-pick this PR to release-1.1 too. This way it will be possible to experiment
with CAPZ ClusterClasses after the next CAPZ and CAPI core release.
This does not block the CAPZ release (because the next CAPZ release won't include cluster-templates using ClusterClasses)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 25, 2022
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 25, 2022
@sbueringer
Copy link
Member Author

/cc @CecileRobertMichon @enxebre @fabriziopandini @vincepri @shysank

/cherry-pick release-1.1

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.1 in a new PR and assign it to you.

In response to this:

/cc @CecileRobertMichon @enxebre @fabriziopandini @vincepri @shysank

/cherry-pick release-1.1

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.

@sbueringer
Copy link
Member Author

sbueringer commented Feb 25, 2022

Tested it locally with my limited CAPZ knowhow. Looks like it works, e.g. KCP:

      files:
      - contentFrom:
          secret:
            key: control-plane-azure.json
            name: my-azure-cluster-control-plane-hqc7h-azure-json
...
    machineTemplate:
      infrastructureRef:
        apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
        kind: AzureMachineTemplate
        name: my-azure-cluster-control-plane-hqc7h
        namespace: default

@sbueringer sbueringer force-pushed the pr-add-ref-builtilns-vars branch from 8dd9951 to 4001401 Compare February 25, 2022 09:36
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-full-main
/test pull-cluster-api-e2e-workload-upgrade-1-23-latest-main

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one nit

@sbueringer sbueringer force-pushed the pr-add-ref-builtilns-vars branch from 4001401 to 4b91d22 Compare February 25, 2022 15:06
@shysank
Copy link
Contributor

shysank commented Feb 25, 2022

Tested it locally, it works. Thanks @sbueringer !
image

@fabriziopandini
Copy link
Member

/lgtm
@killianmuldoon if you can give another pass

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 25, 2022
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 28, 2022
@k8s-ci-robot k8s-ci-robot merged commit f4ededd into kubernetes-sigs:main Feb 28, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.2 milestone Feb 28, 2022
@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #6215

In response to this:

/cc @CecileRobertMichon @enxebre @fabriziopandini @vincepri @shysank

/cherry-pick release-1.1

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants