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

Verify that the api-server serves the correct CRDs that this client expects #1664

Merged
merged 8 commits into from
Sep 14, 2020

Conversation

ANeumann82
Copy link
Member

Signed-off-by: Andreas Neumann aneumann@mesosphere.com

What this PR does / why we need it:

When planning the structured parameters, I thought about client/api-server compatibility.

The CLI currently checks if the CRDs are correctly installed, which is not really what we want - we want to make sure that the API server understands the CRD version that we speak. This PR ensures this behaviour.

This PR:

  • Removed the usage of the deprecated version field of the CRDs and uses the new versions field.
  • crdInitializer.verifyInstallation now verifies that the installed CRD is the same as this CLI would install
  • There is a new crdInitializer.verifyServedVersion that ensures that the k8s api-server understands the CRD version that we use to read/write our O, OV and I resources. This func is used when we initialise our kudo client.

If the API server does not server the CRD version that we support, the user has to update the CLI version.

Fixes #

…xpects

Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>

# Conflicts:
#	pkg/kudoctl/kudoinit/crd/crds.go
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
# Conflicts:
#	pkg/kudoctl/util/kudo/kudo_test.go
Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

I left a few nits so PTAL but otherwise LGTM 🚢

pkg/kudoctl/kudoinit/crd/crds.go Show resolved Hide resolved
@@ -102,6 +91,20 @@ func NewClientFromK8s(kudo versioned.Interface, kube kubernetes.Interface) *Clie
return &result
}

func (c *Client) VerifyServedCRDs(kubeClient *kube.Client) error {
result := verifier.NewResult()
err := crd.NewInitializer().VerifyServedVersion(kubeClient, v1beta1.SchemeGroupVersion.Version, &result)
Copy link
Contributor

Choose a reason for hiding this comment

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

The v1beta1.SchemeGroupVersion.Version parameter sort of hard-codes support for the v1beta1 version. Once we introduce a new version, we should not forget to update this method with the check with the new version?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's true. Sadly there's no way to get the GV from the generated client - that would make it a bit easier.

pkg/kudoctl/util/kudo/kudo_test.go Outdated Show resolved Hide resolved
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
@ANeumann82 ANeumann82 merged commit 3c51361 into main Sep 14, 2020
@ANeumann82 ANeumann82 deleted the an/verify-served-crd-version branch September 14, 2020 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants