-
Notifications
You must be signed in to change notification settings - Fork 39
Add reconciler for client, peer, server certificate #173
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ArkaSaha30 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 |
bea3c32
to
c980e01
Compare
/test pull-etcd-operator-test-e2e |
dd9729a
to
fe533db
Compare
/test pull-etcd-operator-test-e2e |
3f702a6
to
eba6759
Compare
|
e37260a
to
5e902b6
Compare
1b79a53
to
6192aa2
Compare
} | ||
|
||
func createCertificate(ec *ecv1alpha1.EtcdCluster, ctx context.Context, c client.Client, certName string) error { | ||
cert, certErr := certificate.NewProvider(certificate.ProviderType(ec.Spec.TLS.Provider), c) |
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.
ensure provider matches the providerConfig.
829112a
to
84bb9d8
Compare
3027592
to
1d32631
Compare
Hi @ArkaSaha30, we discussed this in our community meeting. We would want to have the e2e tests in this pull request too, before we consider it mergeable. Thanks. |
Yes, I'm working on the e2e tests. Will update the PR by EOW. |
This commit will add reconciler logic for creating - client certificate to communicate with the etcdCluster - server, peer certificate for each of the etcd member communication Also, mount certificate secrets to member pods Signed-off-by: ArkaSaha30 <[email protected]>
Signed-off-by: ArkaSaha30 <[email protected]>
565b1a7
to
47b635b
Compare
Client, server, peer certificates and their respective secrets:
Server and peer secret are mounted to each of the members:
|
@@ -84,6 +91,17 @@ func (r *EtcdClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) | |||
etcdCluster.Spec.ImageRegistry = r.ImageRegistry | |||
} | |||
|
|||
// Create Client Certificate for etcd-operator to communicate with the etcdCluster | |||
if etcdCluster.Spec.TLS != nil { | |||
clientCertErr := createClientCertificate(etcdCluster, ctx, r.Client) |
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.
minor comment: usually context is the first parameter for a function or method
serverCertName := fmt.Sprintf("%s-%s-tls", ec.Name, "server") | ||
peerCertName := fmt.Sprintf("%s-%s-tls", ec.Name, "peer") |
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.
Please create two functions to generate/get the serverCertName and peerCertName, so that we have a centralized place to maintain the names.
ExtraConfig: map[string]any{ | ||
"issuerName": cmConfig.IssuerName, | ||
"issuerKind": cmConfig.IssuerKind, | ||
}, |
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.
Two solutions:
- refer to the
IssuerNameKey
andIssuerNameKey
- get the details of populating the
ExtraConfig
encapsulated in the certificate package.
For simplicity, let's follow solution 1 for now, and revisit 2 in future if needed.
} | ||
|
||
func createClientCertificate(ec *ecv1alpha1.EtcdCluster, ctx context.Context, c client.Client) error { | ||
certName := fmt.Sprintf("%s-%s-tls", ec.Name, "client") |
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.
create a function to get the secret for client
return ctx | ||
}, | ||
) | ||
|
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.
Please also verify that we can access the etcdcluster via client certificate.
- write a key/value pair and read it back
@@ -54,6 +56,11 @@ type EtcdClusterReconciler struct { | |||
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete | |||
// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;create;update;patch;delete | |||
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch;get;list;update | |||
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;patch;update;delete | |||
// +kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch |
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.
Quick question: I see that we're querying the STS, and checking the podSpec from there, but I'm not sure why we would need to query the pod directly. Am I missing something? Or, is there a particular reason why you added this permission?
This PR will implement the reconciler for client, peer and server certificate creation for the etcdCluster object and its respective members.
Fixes: #10