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

Add dynamic certificate serving feature to controller #2923

Merged
merged 1 commit into from
Aug 17, 2018

Conversation

hnrytrn
Copy link
Contributor

@hnrytrn hnrytrn commented Aug 9, 2018

What this PR does / why we need it:

This PR is a part of adding dynamic certificate serving functionality. It adds a new flag enable-dynamic-certificates. When enabled, the controller will POST certificates to a Lua endpoint (#2889), avoid reloading NGINX when certificates are updated, and avoid writing certificates on disk. There will be another PR following this to serve the certificates that are POSTed.

Special notes for your reviewer:

This feature currently does not support OCSP because the future PR that will serve the certificates will use Open Resty's ngx.ssl module (https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md), which does not support OCSP.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 9, 2018
@aledbf aledbf added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 9, 2018
@codecov-io
Copy link

codecov-io commented Aug 9, 2018

Codecov Report

Merging #2923 into master will decrease coverage by 0.01%.
The diff coverage is 52.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2923      +/-   ##
==========================================
- Coverage   47.58%   47.56%   -0.02%     
==========================================
  Files          77       77              
  Lines        5533     5632      +99     
==========================================
+ Hits         2633     2679      +46     
- Misses       2560     2600      +40     
- Partials      340      353      +13
Impacted Files Coverage Δ
internal/ingress/sslcert.go 50% <ø> (ø) ⬆️
internal/ingress/controller/config/config.go 98.29% <ø> (-0.02%) ⬇️
internal/ingress/types_equals.go 13.08% <0%> (-0.09%) ⬇️
internal/ingress/controller/controller.go 2.19% <0%> (-0.01%) ⬇️
internal/ingress/controller/store/store.go 62.79% <100%> (+0.1%) ⬆️
internal/ingress/controller/store/backend_ssl.go 43% <25%> (-1.22%) ⬇️
internal/net/ssl/ssl.go 37.95% <34.04%> (-0.82%) ⬇️
cmd/nginx/flags.go 82.24% <57.14%> (-1.09%) ⬇️
internal/ingress/controller/nginx.go 16.04% <72.5%> (+4.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b4942cc...7faf089. Read the comment docs.

@aledbf aledbf removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 12, 2018
@aledbf
Copy link
Member

aledbf commented Aug 13, 2018

@hnrytrn my only question is related to OCSP. From the ssl.md link I see this https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ocsp.md
What's required to use that feature?

Edit: this can be done in a different PR

@ElvinEfendi
Copy link
Member

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 13, 2018
@aledbf
Copy link
Member

aledbf commented Aug 13, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 13, 2018
@hnrytrn
Copy link
Contributor Author

hnrytrn commented Aug 13, 2018

@aledbf Hi, yes I was planning on adding OCSP functionality using Open Resty's OCSP module in the next iteration of this feature.

if !n.IsDynamicConfigurationEnough(newConfig) {
t.Errorf("Expected to be dynamically configurable when backend and SSLCert changes")
}

Copy link
Member

Choose a reason for hiding this comment

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

can you also add a test when dynamic certificate configuration is enabled and a server in new configuration has a change other than certificate.

}

if strings.Index(body, "service") != -1 {
t.Errorf("unexpected service reference in JSON content: %v", body)
Copy link
Member

Choose a reason for hiding this comment

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

Why do you have these two assertions?

c := certutil.EncodeCertPEM(cert.Cert)
k := certutil.EncodePrivateKeyPEM(cert.Key)

ngxCert, err := CreateSSLCert(name, c, k, []byte{})
Copy link
Member

Choose a reason for hiding this comment

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

I don't see how are you asserting that c and k are properly formatted and bundled into ngxCert, am I missing something?

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 16, 2018
@ElvinEfendi
Copy link
Member

/hold cancel
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Aug 16, 2018
@hnrytrn hnrytrn force-pushed the dynamic-certs-controller branch from c358afd to 566ffd3 Compare August 16, 2018 23:11
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 16, 2018
@hnrytrn hnrytrn force-pushed the dynamic-certs-controller branch from 566ffd3 to d081687 Compare August 16, 2018 23:45
@hnrytrn hnrytrn force-pushed the dynamic-certs-controller branch from d081687 to 7faf089 Compare August 17, 2018 00:19
@ElvinEfendi
Copy link
Member

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, ElvinEfendi, hnrytrn

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 ab1072e into kubernetes:master Aug 17, 2018
@hnrytrn hnrytrn deleted the dynamic-certs-controller branch August 17, 2018 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants