-
Notifications
You must be signed in to change notification settings - Fork 36
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
.*: TLS and Etcd v3 support #195
.*: TLS and Etcd v3 support #195
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
32da207
to
6b8633d
Compare
6b8633d
to
99687be
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.
Hey, thanks for the pull request. Sorry that I haven't been able to review this in a while.
The PR generally looks good with some comments.
Some comments for myself:
- etcd v3.4 disables the v2 API by default. We were using it for the version and membership API. This PR adds support for the v3 API instead. I don't remember why we opted to use the v2 API (when the operator only supports v3 and above), but note to self we could probably simplify this in the future and remove the v2 codepath.
- There were references to v2 structs, so a shim was made to provide compatibility for other bits of the codebase.
- There's a drive-by pprof option for the controller.
@@ -3,7 +3,8 @@ package controllers | |||
const ( | |||
etcdClientPort = 2379 | |||
etcdPeerPort = 2380 | |||
etcdDataMountPath = "/var/lib/etcd" | |||
EtcdDataMountPath = "/var/lib/etcd" |
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.
Does this need to be an exported variable?
|
||
etcdclient "go.etcd.io/etcd/client" | ||
"go.etcd.io/etcd/version" | ||
"github.com/blang/semver" |
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.
small nit, there's an existing dependency on github.com/coreos/go-semver
which should be used instead of another semver lib.
@@ -0,0 +1,202 @@ | |||
|
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.
We don't currently vendor dependencies in this repo, is there a need for them?
@cheahjs thx for having a look on this PR. |
@FlorinPeter hey, any updates? |
@cheahjs worked on some stuff, I hope to make progress in the next week, sorry for the delay. |
@FlorinPeter @cheahjs Any updates on this? Anything I could maybe help you with? |
func clientCertForCluster(cluster *etcdv1alpha1.EtcdCluster, caCert, caKey []byte) (*v1.Secret, error) { | ||
name := clientSecretName(cluster.Name, cluster.Namespace) | ||
|
||
clientCert, clientKey, err := tls.Issue([]string{name.Name}, caCert, caKey) |
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.
AFAIU this creates a client cert with the DNS name clusterName-client
.
Shouldn't there be a svc with the same name going along with it? How else would you connect to the cluster as a client and have a correct name verification?
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.
@FlorinPeter @cheahjs Any updates on this? Anything I could maybe help you with?
Sorry for delaying this PR, there are to many topics on my desk, my plan was to find a couple of hours next week to go over the review.
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.
You might be thinking of the peer's client certificate which requires that the Subject Alternative Name (SAN) includes DNS hostnames and/or IPs that match that of the peer. That certificate is generated in the EtcdPeer reconciler over here: https://github.com/improbable-eng/etcd-cluster-operator/pull/195/files#diff-2e9c68c9fc75a29d6beb2fe742c18d4b97a48e76796ccea4da15e663c3cfe6a4R659-R681
This bit of code is generating the client certificate for etcd clients, and the Common Name (CN) is used for logging in as the username in the CN (in this case, hardcoded to be Etcd Cluster Operator
as per the Subject
field).
Reference: https://etcd.io/docs/v3.4/op-guide/security/
@FlorinPeter Would you mind if I carry this PR further? |
@gottwald sure please go ahead as I have no time to work on that at the moment. |
First of all thx for this awesome etcd operator ❤️ and sorry for this huge update.
I started first to add tls support and ended later on by adding support vor etcd v3 api that allows to run the latest etcd v3.4.x versions.
My focus was on keeping the changes as minimum as possible and to maintain compatibility with etcd v2.
Changes
Verification
Deploy a cluster like: