Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

⚠️ Update VC controller-runtime #70

Conversation

christopherhein
Copy link
Contributor

This is a relatively large change unfortunately, cause controller runtime's APIs changed a fair amount, adding context support throughout. Also as of v1.20.x kubelet doesn't support redirects anymore only streaming configs which I have filed #69 to which needs to be followed up on.

Related

closes #27

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 22, 2021
@k8s-ci-robot k8s-ci-robot requested review from adohe and Fei-Guo May 22, 2021 01:36
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 22, 2021
@christopherhein
Copy link
Contributor Author

/assign @Fei-Guo

@christopherhein
Copy link
Contributor Author

/cc @weiling61

@k8s-ci-robot k8s-ci-robot requested a review from weiling61 May 22, 2021 01:36
@christopherhein
Copy link
Contributor Author

/kind cleanup
/milestone v0.1.x

@k8s-ci-robot k8s-ci-robot added this to the v0.1.x milestone May 22, 2021
@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label May 22, 2021
@christopherhein christopherhein force-pushed the update-vc-controller-runtime branch from 465cac2 to 8fc0b77 Compare May 22, 2021 03:11
Copy link

@Fei-Guo Fei-Guo left a comment

Choose a reason for hiding this comment

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

Awesome work. This change bumps up Kubernetes dependency to 1.20 as well.

@christopherhein christopherhein force-pushed the update-vc-controller-runtime branch 4 times, most recently from 290ef50 to f4b635e Compare May 23, 2021 23:16
@christopherhein
Copy link
Contributor Author

Awesome work. This change bumps up Kubernetes dependency to 1.20 as well.

We still don't support the one annoying thing about the ClusterVersion CR where if you regenerate it using the proper version of controller-gen for the version of controller runtime we use then you end up with a huge ClusterVersion CRD and run into issues, so for now in the make file I've disabled generating the CRD manifests so that we continue to use the current working ones.

Copy link
Contributor

@weiling61 weiling61 left a comment

Choose a reason for hiding this comment

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

LGTM. (Most changes are due to runtime package switch, no major logic modification)

@christopherhein
Copy link
Contributor Author

LGTM. (Most changes are due to runtime package switch, no major logic modification)

@weiling61 yup, thanks for giving this a read-through. Something to take into consideration is how the new MCController is implemented note I've broken the implementation for List and Get and removed ListByObjectType and GetByObjectType. Instead using Get and List which take in a pointer to client.Object or client.ObjectList respectively which allows us to populate that object instead of having to return the object back and do type assertions. I've also made one other change to remove us having to have a custom scheme now all "core" types are supported out of the box without us having https://github.com/kubernetes-sigs/cluster-api-provider-nested/pull/70/files#diff-f9cddd7f54205f0c3f3483eb332fb22f9fa9c1184b76ec5223af230b5ab7c14b

@Fei-Guo
Copy link

Fei-Guo commented May 24, 2021

“I've also made one other change to remove us having to have a custom scheme now all "core" types are supported out of the box without us having”

Will this make syncing CR resources (not CRD) harder or break existing CR synchronization?

@christopherhein
Copy link
Contributor Author

Will this make syncing CR resources (not CRD) harder or break existing CR synchronization?

@Fei-Guo this should make it easier to manage these for folks cause we can leverage a lot of the tools that have been built already like controller-runtimes SchemeBuilder which is preconfigured for all kubebuilder/controller runtime projects. This would allow you to take a package like https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/project-v2/api/v1 and all you'd need to do is:

import (
  "sigs.k8s.io/kubebuilder/testdata/project-v2/api/v1"
  "sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/util/scheme"
)

func init() {
  // custom scheme we want to add 
  v1.AddToScheme(scheme.Scheme)
}

This will use the SchemeBuilder from https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v2/api/v1/groupversion_info.go#L27-L36 and takes in a defined *runtime.Scheme to add those new types and GVK for you.

@christopherhein christopherhein force-pushed the update-vc-controller-runtime branch from f4b635e to b56f310 Compare May 24, 2021 22:43
@christopherhein
Copy link
Contributor Author

As I was reviewing that I did make one mistake which I've just cleaned up the var Scheme = runtime.NewScheme() was supposed to use https://github.com/kubernetes/client-go/blob/v0.21.1/kubernetes/scheme/register.go#L72 instead which is the client-go scheme that has everything defined already. So I've just updated that. Just waiting on tests to build.

@zhuangqh
Copy link
Contributor

thanks for your job! controller runtime style client makes everything simple 😄

Copy link
Contributor

@zhuangqh zhuangqh left a comment

Choose a reason for hiding this comment

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

LGTM

@christopherhein
Copy link
Contributor Author

Awesome, thanks @zhuangqh. Looks like we just need someone to /lgtm and we'll get this merged.

@Fei-Guo
Copy link

Fei-Guo commented May 25, 2021

/approve
/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christopherhein, Fei-Guo, weiling61, zhuangqh

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 merged commit dcdeedb into kubernetes-retired:main May 25, 2021
@christopherhein christopherhein deleted the update-vc-controller-runtime branch May 25, 2021 03:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants