Skip to content

Conversation

@trawler
Copy link
Contributor

@trawler trawler commented Jul 6, 2018

fixes INST-1111 & INST-1113

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 6, 2018
@trawler trawler requested review from enxebre, spangenberg and squat July 6, 2018 16:05
@trawler trawler changed the title installer/pkg/config-generator/tls: add kube tls certs installer/pkg/config-generator/tls: add kube tls certs Jul 6, 2018
@trawler trawler changed the title installer/pkg/config-generator/tls: add kube tls certs installer/pkg/config-generator/tls: add kube + tnc tls certs Jul 6, 2018
@paulfantom
Copy link
Contributor

/retest

Copy link
Contributor

@squat squat 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 overall. I have some nits


if _, _, err := generateCert(clusterDir, kubeCAKey, kubeCACert, ingressKeyPath, ingressCertPath, cfg); err != nil {
return fmt.Errorf("failed to generate ingress CAs: %v", err)
if _, _, err = generateCert(clusterDir, kubeCAKey, kubeCACert, ingressKeyPath, ingressCertPath, cfg); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove the : from here? we can happily keep it like we do in the rest of the instances above

ExtKeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},
Subject: pkix.Name{CommonName: "system:admin", Organization: []string{"system:masters"}},
Validity: validityThreeYears,
IsCA: false}
Copy link
Contributor

Choose a reason for hiding this comment

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

it's convention to terminate the curly brace on a new line

Validity: validityThreeYears,
IsCA: false}

if _, _, err = generateCert(clusterDir, kubeCAKey, kubeCACert, adminKeyPath, adminCertPath, cfg); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing about the : here

DNSNames: []string{fmt.Sprintf("%s-%s.%s", c.Name, "api", c.BaseDomain), "kubernetes", "kubernetes.default", "kubernetes.default.svc", "kubernetes.default.svc.cluster.local"},
Validity: validityThreeYears,
IPAddresses: []net.IP{net.ParseIP(apiServerAddress)},
IsCA: false}
Copy link
Contributor

Choose a reason for hiding this comment

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

same note about the closing curly brace here

"localhost", "127.0.0.1"},
Validity: validityThreeYears,
IPAddresses: []net.IP{net.ParseIP(apiServerAddress)},
IsCA: false}
Copy link
Contributor

Choose a reason for hiding this comment

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

same again here

IsCA: false}

if _, _, err := generateCert(clusterDir, kubeCAKey, kubeCACert, osAPIServerKeyPath, osAPIServerCertPath, cfg); err != nil {
return fmt.Errorf("failed to generate kube openshift server certificate: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

what is kube openshift server? make it should be openshift API server?

Validity: validityThreeYears,
IsCA: false}

if _, _, err = generateCert(clusterDir, caKey, caCert, tncKeyPath, tncCertPath, cfg); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

same note about : here.

DNSNames: []string{tncDomain},
Subject: pkix.Name{CommonName: tncDomain},
Validity: validityThreeYears,
IsCA: false}
Copy link
Contributor

Choose a reason for hiding this comment

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

same note about the closing curly brace

IsCA: false}

if _, _, err = generateCert(clusterDir, caKey, caCert, tncKeyPath, tncCertPath, cfg); err != nil {
return fmt.Errorf("failed to generate tnc certs: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/certs/certificate/

Copy link
Member

Choose a reason for hiding this comment

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

Instead of using %s to format the hard-coded api string, why not include that in the template?

fmt.Sprintf("%s-api.%s", c.Name, c.BaseDomain)

For precedent on this approach, see here, here, and likely other places. If the pattern sounds appealing, there are some other fmt.Sprintf calls in your PR that could also be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair point 👍

@enxebre
Copy link
Member

enxebre commented Jul 9, 2018

lgtm, can we add a unit for generateCert?

@trawler
Copy link
Contributor Author

trawler commented Jul 9, 2018

@enxebre we already have unit testing for private key, create certificate and certificate request in installer/pkg/tls (all included in generateCert). What would be the benefit of adding an additional unit test?

@enxebre
Copy link
Member

enxebre commented Jul 9, 2018

I still see value in testing generateCert which integrate those functions behaves as expected. Then you can change the internal implementation details and the consumed functions being confident that you are no breaking the layer on top and the expected output is satisfied

Copy link
Member

Choose a reason for hiding this comment

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

hint: We should align formats with the DNSNames field below so either always inline or always multiline, also those could be moved into constants

@trawler trawler merged commit ae41b0a into openshift:master Jul 9, 2018
wking added a commit to wking/openshift-installer that referenced this pull request Jul 10, 2018
Both of these lines were touched by ae41b0a (Merge pull request openshift#22
from trawler/kube_tls_certs, 2018-07-09), but there's no need to use
Sprintf to inject string literals into the format template.  26930f2
(post-review fixes, 2018-07-07, openshift#22) fixed one such instance, but left
these.  The * instance dates back to bf61dc9
(installer/pkg/config-generator/tls: generate ingress certs,
2018-07-06, openshift#16).
stbenjam pushed a commit to stbenjam/installer that referenced this pull request Apr 30, 2019
stbenjam pushed a commit to stbenjam/installer that referenced this pull request Feb 10, 2021
zaneb pushed a commit to zaneb/openshift-installer that referenced this pull request Apr 29, 2022
…-nmstateconfig

AGENT-39: Read node0 IP from nmstateconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

6 participants