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

Add kubernetes-based backend #250

Merged
merged 1 commit into from
May 5, 2022
Merged

Conversation

micahhausler
Copy link
Contributor

@micahhausler micahhausler commented Apr 6, 2022

Signed-off-by: Micah Hausler mhausler@amazon.com

Description

The new backend uses the Kubernetes CRD types in Tinkerbell core. Boots could use a bit of a refactor/organization in how the backends work, but for now I've tried to fit in to the existing structure.

Why is this needed

This is the boots side of work for tinkerbell/proposals#46

Fixes: #

How Has This Been Tested?

Tested with real bare metal workers using an image built from this branch. I will add E2E tests in a follow up PR, or can add to this branch

How are existing users impacted? What migration steps/scripts do we need?

No impact to existing users

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

@codecov
Copy link

codecov bot commented Apr 11, 2022

Codecov Report

Merging #250 (785b2fa) into main (1138ed3) will decrease coverage by 1%.
The diff coverage is 14%.

❗ Current head 785b2fa differs from pull request most recent head 4d162dd. Consider uploading reports for the commit 4d162dd to get more accurate results

@@         Coverage Diff          @@
##           main   #250    +/-   ##
====================================
- Coverage    39%    37%    -2%     
====================================
  Files        37     41     +4     
  Lines      2424   3007   +583     
====================================
+ Hits        948   1133   +185     
- Misses     1413   1784   +371     
- Partials     63     90    +27     
Impacted Files Coverage Δ
cmd/boots/dhcp.go 11% <0%> (+<1%) ⬆️
cmd/boots/http.go 21% <0%> (+<1%) ⬆️
packet/client.go 28% <0%> (ø)
packet/endpoints.go 27% <0%> (ø)
packet/k8s_client.go 0% <0%> (ø)
packet/k8s_models.go 19% <19%> (ø)
cmd/boots/main.go 20% <66%> (+4%) ⬆️
conf/mirror.go 62% <0%> (-23%) ⬇️
installers/vmware/main.go 62% <0%> (-12%) ⬇️
job/ipxe.go 0% <0%> (ø)
... and 40 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1138ed3...4d162dd. Read the comment docs.

.github/workflows/ci.yaml Outdated Show resolved Hide resolved
packet/k8s_client.go Outdated Show resolved Hide resolved
packet/k8s_client.go Outdated Show resolved Hide resolved
packet/k8s_client.go Outdated Show resolved Hide resolved
packet/client.go Outdated Show resolved Hide resolved
packet/endpoints.go Outdated Show resolved Hide resolved
packet/k8s_client.go Outdated Show resolved Hide resolved
Copy link
Member

@jacobweinstock jacobweinstock left a comment

Choose a reason for hiding this comment

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

Looking good. Had a few questions and suggestions.

@micahhausler micahhausler force-pushed the krm/client branch 3 times, most recently from 867dc93 to 4282254 Compare May 3, 2022 19:35
@mmlb mmlb mentioned this pull request May 3, 2022
3 tasks
@mmlb
Copy link
Contributor

mmlb commented May 3, 2022

@micahhausler can we wait until tinkerbell/tink#258 is merged to get this in? I'd be a ok with doing the actual rebase and handling the changes necessary. Having to rebase tinkerbell/tink#258 is quite the pain.

@micahhausler
Copy link
Contributor Author

@micahhausler can we wait until tinkerbell/tink#258 is merged to get this in? I'd be a ok with doing the actual rebase and handling the changes necessary. Having to rebase tinkerbell/tink#258 is quite the pain.

Sure, thats fine with me. I'd like to get this in soon though, maybe by Friday this week?

@mmlb
Copy link
Contributor

mmlb commented May 4, 2022

I'm here to make good on my promise @micahhausler want me to rebase and fixup?

@micahhausler
Copy link
Contributor Author

@mmlb I'm good to do it, thanks though!

jacobweinstock
jacobweinstock previously approved these changes May 4, 2022
Copy link
Member

@jacobweinstock jacobweinstock left a comment

Choose a reason for hiding this comment

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

thanks @micahhausler , just two small requests

cmd/boots/main.go Outdated Show resolved Hide resolved
@jacobweinstock
Copy link
Member

jacobweinstock commented May 4, 2022

oh, also would you be able to provide some really basic instructions for use? maybe just how (or that its needed) to generate the crds from the tink repo and apply them to a cluster? or a link maybe to a guide for deploying Tink server/controller?

client/kubernetes/hardware_finder.go Outdated Show resolved Hide resolved
client/kubernetes/hardware_finder.go Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
client/kubernetes/k8s_models_test.go Outdated Show resolved Hide resolved
client/tinkerbell/hardware_finder.go Outdated Show resolved Hide resolved
cmd/boots/dhcp.go Show resolved Hide resolved
@@ -220,15 +225,17 @@ func main() {
}
}

// getWorkflowFinder returns a no-op workflow finder if tinkerbell is not the backend
func getWorkflowFinder() (client.WorkflowFinder, error) {
// getWorkflowFinder returns a no-op workflow finder if tinkerbell or kubernetes is not the backend
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm I think standalone should be allowed too right @jacobweinstock ?

Copy link
Member

Choose a reason for hiding this comment

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

ah yes. seems like standalone should be in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How does that apply? Standalone doesn't have a Tinkerbell backend right?

Copy link
Contributor

Choose a reason for hiding this comment

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

standalone only applies to the hardware fetcher, workflows can still happen with standalone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With which Tinkerbell data model? Tink on K8s or Tink on postgres?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For backwards compatibility, I'll use Tink on Postgres. We'll have to figure how to transition this later

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if standalone should also imply workflows from json too 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

@jacobweinstock I take it you use standalone w/ workflows, thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

i use standalone mainly for testing, this seems fine regardless.

@micahhausler
Copy link
Contributor Author

oh, also would you be able to provide some really basic instructions for use? maybe just how (or that its needed) to generate the crds from the tink repo and apply them to a cluster? or a link maybe to a guide for deploying Tink server/controller?

I'm going to hold of on E2E instructions for now, and do comprehensive documentation for all the components once the Hegel changes get in

jacobweinstock
jacobweinstock previously approved these changes May 5, 2022
@jacobweinstock
Copy link
Member

Looks like a rebase of main is needed.

jacobweinstock
jacobweinstock previously approved these changes May 5, 2022
var wf client.WorkflowFinder = &client.NoOpWorkflowFinder{}
var err error

switch os.Getenv("DATA_MODEL_VERSION") {
Copy link
Member

Choose a reason for hiding this comment

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

Have we a 'todo' somewhere, or on someones list, to figure out wiring of configuration in Boots generally?

@jacobweinstock @micahhausler

Copy link
Contributor Author

@micahhausler micahhausler May 5, 2022

Choose a reason for hiding this comment

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

@@ -351,6 +370,8 @@ func newCLI(cfg *config, fs *flag.FlagSet) *ffcli.Command {
fs.StringVar(&cfg.dhcpAddr, "dhcp-addr", conf.BOOTPBind, "IP and port to listen on for DHCP.")
fs.StringVar(&cfg.syslogAddr, "syslog-addr", conf.SyslogBind, "IP and port to listen on for syslog messages.")
fs.StringVar(&cfg.extraKernelArgs, "extra-kernel-args", "", "Extra set of kernel args (k=v k=v) that are appended to the kernel cmdline when booting via iPXE.")
fs.StringVar(&cfg.kubeconfig, "kubeconfig", "", "The Kubernetes config file location. Only applies if DATA_MODEL_VERSION=kubernetes.")
fs.StringVar(&cfg.kubeAPI, "kubernetes", "", "The Kubernetes API URL, used for in-cluster client construction. Only applies if DATA_MODEL_VERSION=kubernetes.")
Copy link
Member

Choose a reason for hiding this comment

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

I think this is different to Tink and Hegel. I think Tink and Hegel use --kubernetes-api?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'll update tink to use --kubernetes to match the upstream argument names

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha. I'll do the same on Hegel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated tinkerbell/tink#619 with reasons

@chrisdoherty4
Copy link
Member

lgtm

chrisdoherty4
chrisdoherty4 previously approved these changes May 5, 2022
Comment on lines 25 to 28
func init() {
_ = clientgoscheme.AddToScheme(runtimescheme)
_ = v1alpha1.AddToScheme(runtimescheme)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we're trying to minimize init()s can this be done some other way? sync.Once.Do() in NewCluster maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: Micah Hausler <mhausler@amazon.com>
Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

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

🎉

@mmlb mmlb added the ready-to-merge Signal to Mergify to merge the PR. label May 5, 2022
@mergify mergify bot merged commit 3f3b97c into tinkerbell:main May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Signal to Mergify to merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants