-
Notifications
You must be signed in to change notification settings - Fork 95
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
🌱 Support for ClusterClass template #1405
🌱 Support for ClusterClass template #1405
Conversation
Hi @p-strusiewiczsurmacki-mobica. Thanks for your PR. I'm waiting for a metal3-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
Converting this to draft as I am yet trying to create testing environment for this change. |
6849485
to
d8f1d12
Compare
@Rozzii: GitHub didn't allow me to request PR reviews from the following users: FYI. Note that only metal3-io members and repo collaborators can review this PR, and authors cannot review their own PRs. |
/cc @kashifest |
8bd749e
to
8834b66
Compare
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I think the code is looking good already but I'm a bit confused about the kustomizations under examples...
Why is it split up in cluster, controlplane and machinedeployment? I would expect to have one kustomization with everything needed for the ClusterClass (Metal3MachineTemplates, Metal3ClusterTemplate, KubeadmControlPlaneTemplate, KubeadmConfigTemplates, and also Metal3DataTemplates and IPPools). Then the ClusterClass kustomization would be "self-contained" and we can have a separate cluster-template to create clusters based on this class. What do you think?
--- | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: Cluster | ||
metadata: | ||
name: ${CLUSTER_NAME} | ||
namespace: ${NAMESPACE} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cluster-template should be separate from the ClusterClass IMO, and we should not rely on the CLUSTER_NAME
in the ClusterClass at all. That way it will be possible to reuse the ClusterClass for multiple clusters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed that. I previously left the old names as it was easier for me to make clusterclass example similar to the non-clusterclass one as possible.
Can you check if this is what you've meant?
examples/generate.sh
Outdated
@@ -94,14 +97,26 @@ ENVSUBST="${SOURCE_DIR}/envsubst-go" | |||
curl --fail -Ss -L -o "${ENVSUBST}" https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-"$(uname -s)"-"$(uname -m)" | |||
chmod +x "$ENVSUBST" | |||
|
|||
SRC_DIR="${SOURCE_DIR}" | |||
REORDER_TYPE="--reorder=legacy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly --reorder=none
is required for clusterclass example. By default kustomization will use reorder=legacy
and will reorder definitions in the outcome file alphabetically. Now, if the definitions are ordered and ClusterClass will be in the outcome file above the Metal3 definitions (e.g. Metal3DataTemplate
), during deletion with make delete-examples-clusterclass
the operation will fail as k8s will first delete ClusterClass and associated Metal3 objects and will try to delete Metal3 objects once again. At least that's what's happening to me, hence reored=none
was added for ClusterClass example and reorder=legacy
was added for non-ClusterClass example generation.
However, I've deleted this reorder=legacy
and now only reorder=none
will be used and only for ClusterClass.
g.Expect(c.Spec).To(Equal(Metal3ClusterTemplateSpec{})) | ||
} | ||
|
||
func TestMetal3ClusterTemplateValidation(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add one test for when the template is invalid also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
48e7b67
to
a355040
Compare
Added changes required by @lentzi90 Additionally added some changes in the Tiltfile and other scripts.
Additionally, I was able to change the example available in metal3-dev-env and to deploy and provision cluster using ClusterClass, so I'm moving this from If anyone wants to try to test it with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not worry about the tilt setup here honestly. If you want to work on it, fine, but isn't it easier to just use CAPI's directly?
The template and ClusterClass that you have here will work great with that already. The only thing you have to do is to add the folder to template_dirs
in the tilt settings.
host: ${CLUSTER_APIENDPOINT_HOST} | ||
port: ${CLUSTER_APIENDPOINT_PORT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make these variables in the ClusterClass or it will be impossible to create more than one cluster from it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Added variables and patches to ClusterClass
and referenced those from Cluster
itself. Seems to work fine regarding to my tests.
Just one question - currently Metal3ClusterTemplate
is validated by the webhook for controlPlaneEndpoint
definition, meaning something
has always be defined there. Should this validation be omitted and we should allow empty definition (without specifying controlPlaneEndpoint`)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understood the question. I think the controlPlaneEndpoint is always required. How would the cluster work without it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently Metal3ClusterTemplate
is required to have controlPlaneEndpoint
defined, e.g:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: Metal3ClusterTemplate
metadata:
name: example-cluster-template
spec:
template:
spec:
controlPlaneEndpoint:
host: 127.0.0.1
port: 6443
noCloudProvider: true
But I think that makes it not reusable, right? Do we want to accept something like this (with no controlPlaneEndpoint
):
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: Metal3ClusterTemplate
metadata:
name: example-cluster-template
spec:
template:
spec:
noCloudProvider: true
And then controlPlaneEndpoint should be defined in Cluster
resource, I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok now I understand!
I think the way to handle this is to use variables in the ClusterClass. So set it like you already did in the Metal3ClusterTemplate, but then add a variable and patch to override it. Then it would be possible to create clusters like
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: my-cluster
spec:
...
topology:
class: example-clusterclass
version: v1.29.0
variables:
- name: controlPlaneEndpointHost
value: 192.168.0.100
checksum: ${IMAGE_CHECKSUM} | ||
checksumType: ${IMAGE_CHECKSUM_TYPE} | ||
format: ${IMAGE_FORMAT} | ||
url: ${IMAGE_URL} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These would also be nice to set through ClusterClass variables, but more as a nice to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
hack/gen_tilt_settings.sh
Outdated
@@ -44,10 +44,27 @@ get_latest_release() { | |||
CAPIRELEASEPATH="${CAPIRELEASEPATH:-https://api.github.com/repos/${CAPI_BASE_URL:-kubernetes-sigs/cluster-api}/releases}" | |||
export CAPIRELEASE="${CAPIRELEASE:-$(get_latest_release "${CAPIRELEASEPATH}" "v1.3.")}" | |||
|
|||
# ClusterClass enable flag | |||
CLUSTERCLASS_ENABLE="${CLUSTERCLASS:-}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use the same variable as CAPI does, so this should be CLUSTER_TOPOLOGY
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way of generating manifests with kustomize
and envsubst
doesn't seem to really give us anything useful from what I can see. I'm fine having it here is if it useful to you but I wonder if we should not just put the ClusterClass and cluster-template in templates
instead? No kustomize needed (we are anyway not doing anything useful with it) and they would be easily discovered and useful. It also matches exactly what CAPI has for CAPD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've deleted customization files and moved clusterclass.yaml
and cluster.yaml
to examples/templates/
.
60b4bb7
to
a8d4f82
Compare
examples/templates/clusterclass.yaml
Outdated
clusterConfiguration: | ||
apiServer: | ||
extraArgs: | ||
cloud-provider: baremetal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this cloud provider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be CCM, and looks like a leftover before the rename (baremetal=>metal3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I've copied it from the existing example: https://github.com/metal3-io/cluster-api-provider-metal3/blob/main/examples/controlplane/controlplane.yaml#L28
Should this be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about what this does honestly. I think we can remove it. We don't use it in the tests at least: https://github.com/metal3-io/cluster-api-provider-metal3/blob/main/test/e2e/data/infrastructure-metal3/bases/cluster/cluster-with-kcp.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, removed all references to cloud-provider: baremetal
.
examples/templates/clusterclass.yaml
Outdated
metadata: | ||
name: example-md-metadata | ||
spec: | ||
clusterName: example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad we have the clusterName on the Metal3DataTemplate and IPPool 😞
I guess this makes it quite hard to use them from the ClusterClass? Would it make more sense to have them separate or in the cluster.yaml?
This would need squashing of the commits I suppose, @furkatgofurov7 PTAL |
@kashifest I approved it already, had a small comment but this is not a blocker for this PR. And yes, the last 2 commits could be squashed into 1, preferably. |
93f5b4f
to
4552910
Compare
@p-strusiewiczsurmacki-mobica: The following test failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
4552910
to
48687d0
Compare
I've left 2 commits now. Is it OK, or should squash it into 1? Also, I've just rebased the branch as there were some conflicts. Trying to run e2e tests to check if everything is correct just now. |
Well, both this branch and EDIT: Apart from that, the clusterclass and cluster resource are created correctly, so I think the PR itself should be OK. |
48687d0
to
854ef91
Compare
I am fine with as is (2 commits). |
/test-centos-e2e-integration-main |
1 similar comment
/test-centos-e2e-integration-main |
@kashifest tests are not triggered, is this a known issue or triggers have changed? |
Yeah its a known issue, CI admins are working on it, tests are getting triggered but status is not getting updated on github. |
May I know when could this PR be merged and when is the next release that contains this change? @p-strusiewiczsurmacki-mobica |
I think this is ready to go in , pending a rebase |
spec: | ||
joinConfiguration: | ||
nodeRegistration: | ||
name: '{{ ds.meta_data.hostname }}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work for me(virtualized env). Shouldn't it be '{{ ds.meta_data.local_hostname }}'
or '{{ ds.meta_data.name }}'
?. The question is also, what is the difference between local_hostname
and name
because I see both here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can fix it in a followup or leave it out completely from the template in a followup PR. @p-strusiewiczsurmacki-mobica would you be interested in a followup PR? For now, we take this PR in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kashifest I'll try to take a look at this as soon as I can. However if anyone wants to work on this before I'll be able to, then go ahead. :)
Co-authored-by: Lennart Jern <[email protected]> Co-authored-by: Furkat Gofurov <[email protected]> Signed-off-by: Patryk Strusiewicz-Surmacki <[email protected]>
Signed-off-by: Patryk Strusiewicz-Surmacki <[email protected]>
854ef91
to
7e3d56c
Compare
Hi, I've just rebased it :) |
/lgtm |
/test metal3-centos-e2e-integration-test-main |
What this PR does / why we need it:
This PR adds support for ClusterClass API as discussed in #1267
Which issue(s) this PR fixes:
Fixes #1267