-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
storage/kubernetes: add CRD support #1062
Conversation
storage/kubernetes/storage.go
Outdated
// they'll immediately be available, but ensures that the client will actually try | ||
// once. | ||
logger.Errorf("failed creating custom resource definitions: %v", err) | ||
go func() { |
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 go statement needs to be inside the if block above.
storage/kubernetes/storage.go
Outdated
if err != nil { | ||
return nil, fmt.Errorf("create client: %v", err) | ||
} | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
|
||
if c.UseCRD { | ||
if !cli.createCustomResourceDefinitions() { |
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.
Instead of reproducing this logic, I'd recommend just replacing the createThirdPartyResources
call bellow with something that conditionally creates either CRDs or TPRs. E.g.
// Create either TPRs or CRDs.
cli.registerCustomResoruces(c.UseCRD)
And not having this block be reproduced.
storage/kubernetes/types.go
Outdated
Group: apiGroup, | ||
Version: "v1", | ||
Names: k8sapi.CustomResourceDefinitionNames{ | ||
Plural: "signingkeies", |
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.
Can you add a comment why we chose not to change this? E.g.
// An artifact from the old TPR pluralization. Since users don't directly interact with this value, it'd be more of
// a pain to correct this than to leave as is.
storage/kubernetes/storage.go
Outdated
@@ -38,6 +38,8 @@ const ( | |||
type Config struct { | |||
InCluster bool `json:"inCluster"` | |||
KubeConfigFile string `json:"kubeConfigFile"` | |||
APIVersion string `json:"apiVersion"` // API Group and version |
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'd rather not expose this. It's always implied by "useCRD"
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.
but how else would users configure the APIVersion?
storage/kubernetes/storage.go
Outdated
@@ -38,6 +38,8 @@ const ( | |||
type Config struct { | |||
InCluster bool `json:"inCluster"` | |||
KubeConfigFile string `json:"kubeConfigFile"` | |||
APIVersion string `json:"apiVersion"` // API Group and version | |||
UseCRD bool `json:"useCRD"` // Flag option to use CRDs instead of TPRs |
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.
At some point we need to leave a comment that this will default to true
.
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.
few nits, but overall looks good. thanks!
Also some lint checks are failing
|
336929f
to
3ff69a6
Compare
@ericchiang addressed all feedback |
Testing:
TODO: still need to add docs regarding migration |
Sample CRD that gets created:
|
code lgtm. Can you add a doc and switch the conformance tests to use CRDs? |
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.
Very clean, just one kind of annoying overall comment.
storage/kubernetes/storage.go
Outdated
type Config struct { | ||
InCluster bool `json:"inCluster"` | ||
KubeConfigFile string `json:"kubeConfigFile"` | ||
UseCRD bool `json:"useCRD"` // Flag option to use CRDs instead of TPRs |
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 know this sounds kind of silly, but I would make the flag UseTPR
instead of UseCRD
. You can bump to a new major version for this, so clients have to explicitly set UseTPR
if they want to. Then removing the flag later will be much cleaner and require no changes from conforming clients.
(Note that this applies to all the boolean vars you plumb through everywhere).
b0f721b
to
6dccfa9
Compare
Addressed all feedback. Added basic CRD documentation for now. Will handle CRD migration docs and script in a separate PR |
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.
LGTM
Documentation/storage.md
Outdated
type: kubernetes | ||
config: | ||
kubeConfigFile: kubeconfig | ||
useCRD: true |
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.
nit: this is "useTPR"
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 catching that
6dccfa9
to
1311caf
Compare
storage/kubernetes: add CRD support
This PR makes the following changes:
useCRD
).