Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

mengqiy
Copy link
Member

@mengqiy mengqiy commented Sep 22, 2018

Some test changes make the PR looks big, but it's actually not that big :)

@mengqiy mengqiy requested a review from droot September 22, 2018 19:34
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 22, 2018
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 22, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mengqiy
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: droot

If they are not already assigned, you can assign the PR to them by writing /assign @droot in a comment when ready.

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

Copy link
Contributor

@droot droot left a 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,
Copy link
Contributor

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 ?

@@ -129,6 +135,14 @@ func (s *Server) installWebhookConfig() error {
return s.err
}

if !s.GenerateManifests && s.DisableInstaller {
log.Info("webhook installer is disabled")
Copy link
Contributor

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"

},
},
}
}
Copy link
Contributor

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 ?

Copy link
Member Author

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
Copy link
Contributor

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()
Copy link
Contributor

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 ? )

Copy link
Member Author

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)
Copy link
Contributor

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)
Copy link
Contributor

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 ?

Copy link
Member Author

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.

@DirectXMan12
Copy link
Contributor

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?

@mengqiy
Copy link
Member Author

mengqiy commented Oct 18, 2018

It makes more sense to have the generator in controller-tools.
I will close this PR as a record.

@mengqiy mengqiy closed this Oct 18, 2018
@mengqiy mengqiy deleted the gen_manifests branch December 6, 2018 19:38
DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
Documentation for creating events
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants