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 KubeVirt addon #8275

Merged
merged 1 commit into from
Jun 3, 2020
Merged

Conversation

ashleyschuett
Copy link
Contributor

Description

This PR fixes #2178

It adds the KubeVirt operator as an addon that can be enabled, as well as allowing users to separately create an instance of the KubeVirt custom resource to deploy the full environment.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 26, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @ashleyschuett!

It looks like this is your first PR to kubernetes/minikube 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/minikube has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 26, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @ashleyschuett. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 26, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ashleyschuett
To complete the pull request process, please assign sharifelgamal
You can assign the PR to them by writing /assign @sharifelgamal in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@codecov-commenter
Copy link

codecov-commenter commented May 26, 2020

Codecov Report

Merging #8275 into master will decrease coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8275      +/-   ##
==========================================
- Coverage   34.46%   34.37%   -0.09%     
==========================================
  Files         147      147              
  Lines        9428     9469      +41     
==========================================
+ Hits         3249     3255       +6     
- Misses       5780     5814      +34     
- Partials      399      400       +1     
Impacted Files Coverage Δ
cmd/minikube/cmd/docker-env.go 41.59% <0.00%> (-7.89%) ⬇️
cmd/minikube/cmd/start.go 13.51% <0.00%> (-0.22%) ⬇️
pkg/minikube/cluster/ip.go 0.00% <0.00%> (ø)
pkg/minikube/machine/fix.go 38.31% <0.00%> (ø)
pkg/minikube/machine/start.go 62.67% <0.00%> (ø)
pkg/minikube/driver/driver_linux.go 0.00% <0.00%> (ø)
cmd/minikube/cmd/start_flags.go 50.80% <0.00%> (+0.96%) ⬆️
pkg/minikube/machine/ssh.go 44.44% <0.00%> (+1.58%) ⬆️
cmd/minikube/cmd/ssh.go 15.00% <0.00%> (+2.50%) ⬆️
pkg/minikube/cruntime/cruntime.go 60.60% <0.00%> (+2.54%) ⬆️

@ashleyschuett
Copy link
Contributor Author

/assign @sharifelgamal

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

thank you for adding this addon, this looks good just minior nits !

@@ -0,0 +1,45 @@
## kubevirt Addon
Copy link
Member

@medyagh medyagh May 26, 2020

Choose a reason for hiding this comment

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

@ashleyschuett
thank you for adding this readme, could u please this read me to our site section ?
maybe under tutorials ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, I added the readme under the tutorials section. Would you like the readme in the deploy folder to be removed, or is it okay for it to live in both places?

Copy link
Member

Choose a reason for hiding this comment

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

thank you we can have a readme in the addon folder but with a link to the website, so anyone goes to that can find out where is the tutorial for this addon.

Copy link
Contributor

@fabiand fabiand left a comment

Choose a reason for hiding this comment

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

@ashleyschuett it is awesome to finally see this PR. Many thanks.

A few notes inside.

To disable this addon, simply run:
```shell script
minikube addons disable kubevirt
minikube addons disable kubevirt-provisioner
Copy link
Contributor

Choose a reason for hiding this comment

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

@ashleyschuett what about sqashing these two commands into one (just kubevirt).
If somebody wants to separate operator deployment from kubevirt deployment then the user can just do it manually using the yamls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After looking into this a bit and trying to get this to work I am unable to.

The issue is if we enable kubevirt with a single command, it then also needs to be able to be disabled. When disabling all the manifests get removed at the same time. In this case, the operator deletes much quicker than the KubeVirt CR. When this happens the CR will still have a finalizer and will get stuck in a terminating state along with the namespace since the operator is gone and unable to remove it.

I attempted to hook into the "preStop" lifecycle of the container but while the pod will then wait to delete it will still be in the "terminating" state meaning that the validating webhook will not respond and the kubevirt cr will not delete.

Because of this, I think the options are to keep the deployments/commands as is. Or if we change them to be kubevirt and kubevirt-with-emulation then in the read me we have the user create the kubevirt CR, and let them know to remove it before disabling the addon. Does either of the options sound okay? Or is there another way to get around the previously mentioned issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch. And sad.

Now, I dislike to say it, but what about writing a pod which does all this:

  1. Deployment on creation and start
  2. Undeploy on deletion of the pod

The reason that I think that this could work is, because we can set a terminationGrace period on the pod - which gives the pod some time to complete - and inside the pod we can just serialize the deleition of the CR and the followed deletion of the operator.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think what you mean by this is that the enable/disable would only be deploying a pod, which would then have / run a script that would match the minikube quick start documentation we have? Then on disable delete the resources in the proper order?

The only problem I see what that is that namespace would still need to be created first in the manifests, and it would then also be deleted first which would mean that the operator deployment could be deleted before the pod runs the deletion.

I have changed the minikube code to delete resources in the opposite that they are created in, but i think that would need buy in from more people in this project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have update the addon to use your suggestions, let me know what you think!

```
If the command does not generate any output, create the following ConfigMap so that KubeVirt uses emulation mode, otherwise skip to the next section:
```shell script
kubectl create configmap kubevirt-config -n kubevirt --from-literal debug.useEmulation=true
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed:

We can consider doing this with two options:

kubevirt -- regular
kubevirt -with-emmulation -- if emualation is needed to workaround missing kvm

@@ -0,0 +1,60 @@
---
title: "KubeVirt support"
Copy link
Member

Choose a reason for hiding this comment

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

I would change this to a
How To... format, for example how to use KubeVirt with minikube

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this has been updated! and the PR is ready for a rereview!

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 29, 2020
Copy link
Contributor

@fabiand fabiand left a comment

Choose a reason for hiding this comment

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

@ashleyschuett this looks good. If this works, then this is pretty cool!

install.sh: |
#!/bin/bash

export KUBEVIRT_VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- - | sort -V | tail -1 | awk -F':' '{print $2}' | sed 's/,//' | xargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ha. Nifty, nice to see that this is not the naive approach of retrieving the highest version :)

@sharifelgamal
Copy link
Collaborator

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 3, 2020
@minikube-pr-bot
Copy link

kvm2 Driver
docker Driver

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

looks good to me, thank you for adding this addon @ashleyschuett

@medyagh medyagh merged commit 4eb09e7 into kubernetes:master Jun 3, 2020
@ashleyschuett ashleyschuett deleted the add-kubevirt-addon branch June 4, 2020 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a KubeVirt add-on
8 participants