-
Notifications
You must be signed in to change notification settings - Fork 1.2k
support gen-manifests and disable-installer #158
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
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mengqiy If they are not already assigned, you can assign the PR to them by writing 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 |
36660e1
to
5cd64e2
Compare
5cd64e2
to
402440c
Compare
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.
Looks good, have a few comments.
example/main.go
Outdated
@@ -39,18 +39,26 @@ import ( | |||
var log = logf.Log.WithName("example-controller") | |||
|
|||
func main() { | |||
var genManifests, disableInstaller bool | |||
flag.BoolVar(&genManifests, "generate-manifests", false, |
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.
Do we want to be more specific here ? generate-webhook-manifests
?
pkg/webhook/bootstrap.go
Outdated
@@ -129,6 +135,14 @@ func (s *Server) installWebhookConfig() error { | |||
return s.err | |||
} | |||
|
|||
if !s.GenerateManifests && s.DisableInstaller { | |||
log.Info("webhook installer is disabled") |
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.
log seems to be incorrect. may be add "and generating webhook manifests is also disabled"
}, | ||
}, | ||
} | ||
} |
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 was thinking about just printing out the webhook config only. Outputting other manifests means, now we have two different ways to generate the manifests for controller ?
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.
IMO using generated Deployment (can also be a StatefulSet with a headless Service) is less error-prone.
There are quite some places need to be set correctly in order to make the webhook server binary work correctly.
We can discuss in person tomorrow :)
type SelfSignedCertGenerator struct{} | ||
type SelfSignedCertGenerator struct { | ||
CAKey []byte | ||
CACert []byte |
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 are they public ? (if they are public then probably we don't need the SetCA
method ?
var valid bool | ||
var err error | ||
|
||
valid, signingKey, signingCert = cp.validCACert() |
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 these become invalid due to cert expiry ? Do we need to differentiate between expiry from other scenario ? (in case of expiry, we probably don't need to re-generate the CA ? )
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 generated CA is valid for 10 years.
I added some check to ensure it won't expire in 1 year.
@@ -39,7 +41,7 @@ const ( | |||
// CertWriter provides method to handle webhooks. | |||
type CertWriter interface { | |||
// EnsureCert provisions the cert for the webhookClientConfig. | |||
EnsureCert(dnsName string, dryrun bool) (*generator.Artifacts, bool, error) | |||
EnsureCert(dnsName string) (*generator.Artifacts, bool, error) |
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.
Making these pkgs internal is helping us today :)
certs := secretToCerts(secret) | ||
if certs != nil { | ||
// Store the CA for next usage. | ||
s.CertGenerator.SetCA(certs.CAKey, certs.CACert) |
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 am assuming secret will be updated only if installer is enabled ?
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 always true.
Disabling the installer only skip installation during bootstrapping.
The webhook server will refresh its cert if the the cert is expiring.
IMO installer only cover bootstrapping time, after that the server may try to rotate its cert if necessary. If it doesn't have permission it will fail.
We probably want to reconsider if it should fail or just log a warning.
What's the main reason that we've added install-webhook-config to controller-runtime, but we removed the equivalent install-crds? Is there any reason not to have the manifest generation in controller-tools like for CRDs? |
It makes more sense to have the generator in controller-tools. |
Documentation for creating events
Some test changes make the PR looks big, but it's actually not that big :)