Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

⚠️ Certificate extraction #222

Merged
merged 2 commits into from
Sep 19, 2019

Conversation

chuckha
Copy link
Contributor

@chuckha chuckha commented Sep 11, 2019

What this PR does / why we need it:
This PR extracts certificate management from the Reconciler keeping the scope of the reconciler more focused.

It fixes #217.
Related to #59

This does not support external etcd yet because of the way kubeadm works. There will be a following PR to add support for external etcd.

This is a BREAKING API change.

I would like to see this project move to a non-library layout as this code was not intended to used as a library and we are not versioning it as such.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 11, 2019
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 11, 2019
@vincepri
Copy link
Contributor

@chuckha
Copy link
Contributor Author

chuckha commented Sep 11, 2019

@vincepri I could use those and delete (a lot) more code!

@chuckha chuckha force-pushed the cert-refactor branch 3 times, most recently from 5568e0b to a467d8c Compare September 11, 2019 16:28
@chuckha
Copy link
Contributor Author

chuckha commented Sep 11, 2019

/hold

need to run some local tests, will update with results

@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 Sep 11, 2019
@ncdc
Copy link
Contributor

ncdc commented Sep 11, 2019

I wouldn't call the package internal (I'm trying to get us to move away from generic names like internal and util). You could do internal/certs?

@chuckha
Copy link
Contributor Author

chuckha commented Sep 11, 2019

@ncdc the logic behind the name was that it wasn't complex enough for its own package and certs.Certificates stutters a bit.

What about hmm, cluster?

@ncdc
Copy link
Contributor

ncdc commented Sep 11, 2019

Not that this is a valid justification, but there is at least context.Context as precedent.

I'm fine with internal/cluster for the time being, though!

@chuckha
Copy link
Contributor Author

chuckha commented Sep 12, 2019

/hold cancel

Looks good from my end (both docker and aws provider 👍)

/cc @ncdc

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 12, 2019
@chuckha
Copy link
Contributor Author

chuckha commented Sep 12, 2019

/assign @fabriziopandini

@ncdc
Copy link
Contributor

ncdc commented Sep 12, 2019

I will try to review later today

@chuckha chuckha force-pushed the cert-refactor branch 5 times, most recently from 3daa5d8 to 0854478 Compare September 13, 2019 15:51
Copy link
Contributor

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

@chuckha
Few comments, nothing really blocking


// AsFiles converts a slice of certificates into bootstrap files.
func (c Certificates) AsFiles() []bootstrapv1.File {
clusterCA := c.GetByName(ClusterCAName)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if this func is called before the certificates are read/generated?
Should we add a check to prevent this condition?

}

// AsSecret converts a single certificate into a Kubernetes secret.
func (c *Certificate) AsSecret(cluster *clusterv1.Cluster, config *bootstrapv1.KubeadmConfig) *corev1.Secret {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if this func is called before the certificates are read/generated?
Should we add a check to prevent this condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We certainly could. Would it be ok to do this in a follow up issue so we can discuss behavior expectations?

It might be worth mentioning this package is internal so no one outside of CABPK will be able to use it, but I'm sure it would still be more friendly to return an error or produce an empty secret.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure things!

@fabriziopandini
Copy link
Contributor

/approve
Pending for @ncdc answer to comment before lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chuckha, fabriziopandini

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:
  • OWNERS [chuckha,fabriziopandini]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ncdc
Copy link
Contributor

ncdc commented Sep 18, 2019

@fabriziopandini over to you for lgtm (the f2f is keeping me busy) - thanks!

@fabriziopandini
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 19, 2019
@k8s-ci-robot k8s-ci-robot merged commit 53d5475 into kubernetes-retired:master Sep 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CA Secret causes cluster to stop provisioning
5 participants