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

Webhook refactor #454

Merged
merged 3 commits into from
Mar 24, 2021
Merged

Webhook refactor #454

merged 3 commits into from
Mar 24, 2021

Conversation

thisisnotashwin
Copy link
Contributor

@thisisnotashwin thisisnotashwin commented Mar 12, 2021

Refactor the connect-inject webhook to use the admission.Webhook library for it's behavior. The behavior of the webhook should remain unchanged. The difference now is that the webhook does not manage its own certificates. Rather it relies on the webhook cert manager to provision certificates for it as a mounted secret.

This allows us to remove our dependency from DiskCerts and also remove the code involved with cert generation on the connect webhook. This is hopefully allow for the a degree of HA with the deployment as the webhook certificates will be consistent across the pods and webhook configuration.

I have also updated some of the methods within the connect package that previously has method signatures with (*Pod) -> (Pod) as they were not performing modifications on the Pod object.

How to test this PR: Code Review

There will be a companion Helm PR where these changes shall be acceptance tested and will try and ensure behavior is still the same.

@thisisnotashwin thisisnotashwin changed the base branch from feature-tproxy to endpoints-controller March 12, 2021 23:05
Copy link
Contributor

@ndhanushkodi ndhanushkodi left a comment

Choose a reason for hiding this comment

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

Had a few comments during an initial lookover, I like how it's coming together!

connect-inject/handler.go Show resolved Hide resolved
connect-inject/handler.go Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

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

The approach looks good to me!

I had one minor question, but overall I think this is the right direction. Thanks for doing the refactor!

connect-inject/handler.go Outdated Show resolved Hide resolved
@thisisnotashwin
Copy link
Contributor Author

The failing tests seem related to the refactor with consul-init. It was failing on the branch and i didnt spend too much time digging into it.

@thisisnotashwin thisisnotashwin marked this pull request as ready for review March 16, 2021 16:41
@thisisnotashwin thisisnotashwin changed the base branch from endpoints-controller to basic-endpoints-controller-and-tests March 16, 2021 23:05
@thisisnotashwin thisisnotashwin force-pushed the webhook-refactor branch 5 times, most recently from 11a22f7 to 5afa987 Compare March 17, 2021 13:53
Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

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

Looks great!!! I ❤️ how you cleaned up the handler and that we don't need cert watcher anymore and to run our own webhook server!

I left some minor comments. The only blocking question on my side is whether we should keep the -listen flag backward compatible.

connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/handler.go Show resolved Hide resolved
helper/cert/source_disk.go Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command_test.go Show resolved Hide resolved
@thisisnotashwin thisisnotashwin force-pushed the webhook-refactor branch 2 times, most recently from 6f5f8e7 to 2d1c75b Compare March 18, 2021 14:18
Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

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

Looks great!

subcommand/inject-connect/command_test.go Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

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

This looks great.
I left a couple "nit" suggestions, and two questions but otherwise 🆗 !
(the compilation error of course being a blocker but I'm sure it'll be sorted)

Copy link
Contributor

@ndhanushkodi ndhanushkodi left a comment

Choose a reason for hiding this comment

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

I love the cleanup and simplification of the code you've done!! Amazing work!! Had a few suggestions around comments/logging and a question/thought about the tests in CI with the manager running.

connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/handler.go Show resolved Hide resolved
connect-inject/handler.go Show resolved Hide resolved
connect-inject/handler.go Show resolved Hide resolved
connect-inject/handler.go Show resolved Hide resolved
connect-inject/handler.go Show resolved Hide resolved
subcommand/inject-connect/command_test.go Show resolved Hide resolved
@ndhanushkodi ndhanushkodi force-pushed the basic-endpoints-controller-and-tests branch from 752eca4 to 715854a Compare March 22, 2021 22:27
@thisisnotashwin thisisnotashwin force-pushed the webhook-refactor branch 2 times, most recently from 9b36f01 to c2c32fb Compare March 23, 2021 14:21
Copy link
Contributor

@ndhanushkodi ndhanushkodi left a comment

Choose a reason for hiding this comment

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

Looks great!!

subcommand/inject-connect/command_test.go Show resolved Hide resolved
Base automatically changed from basic-endpoints-controller-and-tests to feature-tproxy March 24, 2021 22:01
ndhanushkodi and others added 3 commits March 24, 2021 19:06
* supports using serviceName annotation (different k8s service name)
* supports using servicePort annotation
* supports creating endpoints (with serviceName annotation)
* supports updating endpoints (adding and removing addresses)
* supports deleting endpoints (with different k8s service name)

todo:
* tags, meta, and upstreams from annotations + tests
* cleaning up and refactoring code to run the endpoints controller with
manager
* deleting old service registration
* testing with new connect-init command
* testing end to end

Co-authored-by: Iryna Shustava <iryna@hashicorp.com>
Co-authored-by: Kyle Schochenmaier <kyle.schochenmaier@hashicorp.com>
- Replace pointer references with values refernces in methods used
  by connect-inject for Pods.
- This watcher watches for Consul Agent pods to be in a running phase
  and the condition ready to be true and then reconcile all endpoints
that have a ready/not-ready address that share a node name with that of
the consul agent pod.
@thisisnotashwin thisisnotashwin merged commit a6c110c into feature-tproxy Mar 24, 2021
@thisisnotashwin thisisnotashwin deleted the webhook-refactor branch March 24, 2021 23:34
thisisnotashwin added a commit that referenced this pull request Mar 26, 2021
* Refactor handler webhook to be of type admission.Webhook
- Replace pointer references with values refernces in methods used
  by connect-inject for Pods.

* Add watcher for agent pods to endpoints controller
- This watcher watches for Consul Agent pods to be in a running phase
  and the condition ready to be true and then reconcile all endpoints
that have a ready/not-ready address that share a node name with that of
the consul agent pod.
thisisnotashwin added a commit that referenced this pull request Mar 26, 2021
* Refactor handler webhook to be of type admission.Webhook
- Replace pointer references with values refernces in methods used
  by connect-inject for Pods.

* Add watcher for agent pods to endpoints controller
- This watcher watches for Consul Agent pods to be in a running phase
  and the condition ready to be true and then reconcile all endpoints
that have a ready/not-ready address that share a node name with that of
the consul agent pod.
ishustava pushed a commit that referenced this pull request Apr 14, 2021
* Refactor handler webhook to be of type admission.Webhook
- Replace pointer references with values refernces in methods used
  by connect-inject for Pods.

* Add watcher for agent pods to endpoints controller
- This watcher watches for Consul Agent pods to be in a running phase
  and the condition ready to be true and then reconcile all endpoints
that have a ready/not-ready address that share a node name with that of
the consul agent pod.
ndhanushkodi pushed a commit to ndhanushkodi/consul-k8s that referenced this pull request Jul 9, 2021
…nit-role

Restrict permissions for the server-acl-init job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants