operator-framework / operator-controller

A new and improved management framework for extending Kubernetes with Operators
https://operator-framework.github.io/operator-controller/
Apache License 2.0
61 stars 53 forks source link

:seedling: Add kubefwd and local-dev target #1034

Closed perdasilva closed 3 months ago

perdasilva commented 3 months ago

Description

Adds:

It's helpful to be able to run/debug operator-controller directly from the IDE. Tilt is pretty nifty, but too many moving parts for me. I just want to click debug on the IDE and be done.

./hack/tools/bootstrap-local-dev
Scaling down operator-controller-controller-manager deployment
deployment.apps/operator-controller-controller-manager scaled
Copying operator-controller system namespace service certificates from kind cluster
set --ca-certs-dir=/home/perdasilva/repos/perdasilva/operator-controller/hack/certs
Starting kubefwd - sudo is needed for this
[sudo] password for perdasilva: 
INFO[10:33:28]  _          _           __             _     
INFO[10:33:28] | | ___   _| |__   ___ / _|_      ____| |    
INFO[10:33:28] | |/ / | | | '_ \ / _ \ |_\ \ /\ / / _  |    
INFO[10:33:28] |   <| |_| | |_) |  __/  _|\ V  V / (_| |    
INFO[10:33:28] |_|\_\\__,_|_.__/ \___|_|   \_/\_/ \__,_|    
INFO[10:33:28]                                              
INFO[10:33:28] Version 0.0.0                                
INFO[10:33:28] https://github.com/txn2/kubefwd              
INFO[10:33:28]                                              
INFO[10:33:28] Press [Ctrl-C] to stop forwarding.           
INFO[10:33:28] 'cat /etc/hosts' to see all host entries.    
INFO[10:33:28] Loaded hosts file /etc/hosts                 
INFO[10:33:28] HostFile management: Original hosts backup already exists at /root/hosts.original 
INFO[10:33:28] Successfully connected context: kind-operator-controller 
WARN[10:33:28] WARNING: No Running Pods returned for service operator-controller-controller-manager-metrics-service.olmv1-system.kind-operator-controller 
INFO[10:33:28] Port-Forward:       127.1.27.1 catalogd-controller-manager-metrics-service:8443 to pod catalogd-controller-manager-5cbc444644-jdrgf:8443 
INFO[10:33:28] Port-Forward:       127.1.27.2 catalogd-catalogserver:443 to pod catalogd-controller-manager-5cbc444644-jdrgf:8083 

This way you can start operator-controller with --ca-certs-dir=hack/certs and you should be able to talk to catalogd

Reviewer Checklist

netlify[bot] commented 3 months ago

Deploy Preview for olmv1 ready!

Name Link
Latest commit c5638f8a51e37630f5f5fbf4c5e3721712f2a126
Latest deploy log https://app.netlify.com/sites/olmv1/deploys/669041b8b65ab30008ff7fc3
Deploy Preview https://deploy-preview-1034--olmv1.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 77.00%. Comparing base (fe591d4) to head (c5638f8). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1034 +/- ## ========================================== - Coverage 77.60% 77.00% -0.60% ========================================== Files 18 19 +1 Lines 1268 1357 +89 ========================================== + Hits 984 1045 +61 - Misses 202 222 +20 - Partials 82 90 +8 ``` | [Flag](https://app.codecov.io/gh/operator-framework/operator-controller/pull/1034/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=operator-framework) | Coverage Ξ” | | |---|---|---| | [e2e](https://app.codecov.io/gh/operator-framework/operator-controller/pull/1034/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=operator-framework) | `56.44% <ΓΈ> (ΓΈ)` | | | [unit](https://app.codecov.io/gh/operator-framework/operator-controller/pull/1034/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=operator-framework) | `53.86% <ΓΈ> (+1.02%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=operator-framework#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

bentito commented 3 months ago

Awesome sauce, serves as a nice demo of using bingo for conditional deps too. /lgtm

joelanford commented 3 months ago

Oh this is nice. Similar to make run in the standard operator-sdk scaffolding. If I understand correctly, this ends up using the local dev user's credentials and not the operator-controller service account? How much trouble would it be to also fetch the op-con SA token and use that?

joelanford commented 3 months ago

Is the primary use case here to be able to hook up the debugger? Outside of that, it seems like our existing Tilt setup covers most of the local dev ground. My only πŸ‘Ž is that this will be a second local-dev option.

I know our Tilt configuration has a delve container, so maybe it is possible to hook that up with the IDE?

joelanford commented 3 months ago

so maybe it is possible to hook that up with the IDE?

Yeah, looks like we run all the OLM pods with a delve entrypoint and forward the delve port out to the local environment: https://github.com/operator-framework/tilt-support/blob/255e8f7a550634d40c4efc0c9844c278c67135a4/Tiltfile#L148

openshift-ci[bot] commented 3 months ago

New changes are detected. LGTM label has been removed.