-
Notifications
You must be signed in to change notification settings - Fork 109
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
blog: Managing KubeVirt VMs with Ansible #916
Conversation
/hold Change YouTube link in post first |
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.
Nice job! :) Just a small comment.
|
||
While working with existing VMs is already quite useful, it would be even better to control the entire lifecycle of KubeVirt `VirtualMachines` from Ansible. This is made possible by the `kubevirt_vm` module provided by the `kubevirt.core` collection. | ||
|
||
The `kubevirt_vm` module is a thin wrapper around the [kubernetes.core.k8s](https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_module.html) module and it allows you to control the essential fields of a KubeVirt `VirtualMachine`'s specification. In true Ansible fashion, this module tries to be as idempotent as possible and only makes changes to objects within Kubernetes if necessary. With its `wait` feature, it is possible to delay further tasks until a VM was successfully created or updated and is in the ready state or the VM was successfully deleted. |
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.
The `kubevirt_vm` module is a thin wrapper around the [kubernetes.core.k8s](https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_module.html) module and it allows you to control the essential fields of a KubeVirt `VirtualMachine`'s specification. In true Ansible fashion, this module tries to be as idempotent as possible and only makes changes to objects within Kubernetes if necessary. With its `wait` feature, it is possible to delay further tasks until a VM was successfully created or updated and is in the ready state or the VM was successfully deleted. | |
The `kubevirt_vm` module is a thin wrapper around the [kubernetes.core.k8s](https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_module.html) module and it allows you to control the essential fields of a KubeVirt `VirtualMachine`'s specification. In true Ansible fashion, this module tries to be as idempotent as possible and only makes changes to objects within Kubernetes if necessary. With its `wait` feature, it is possible to delay further tasks until a VM was successfully created or updated and the VM is in the ready state or was successfully deleted. |
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.
Great stuff. I've made a couple of suggestions, and added the youtube link for the demo.
|
||
This article will review some of the features and their use associated with this initial release. | ||
|
||
Note: There is also a video version of this blog, which can be found on [YouTube](insertlink). |
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.
Note: There is also a video version of this blog, which can be found on [YouTube](insertlink). | |
Note: There is also a video version of this blog, which can be found on [YouTube](https://youtu.be/GVROaPgJD_8). |
|
||
Before diving into the featureset of the collection itself, let's review why the collection was created in the first place. | ||
|
||
While incorporating KubeVirt and Kubernetes has the potential to disrupt the workflows of teams that typically manage VM infrastructure, including the end users themselves, many of the same paradigms remain: |
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.
nit: s/incorporating/adopting/ ?
At least, the use of 'incorporating' here I think requires an additional subject that KubeVirt and K8s are being incorporated in to.
- In many cases, communicating with KubeVirt VMs makes use of the same protocols and schemes as non-Kubernetes based environments. | ||
- The management of VMs still represents a challenge. | ||
|
||
For these reasons and more, it is only natural that a tool, like Ansible, is introduced within the KubeVirt community. Not only can it help manage the KubeVirt Kubernetes resources, like `VirtualMachines`, but also to enable the extensive Ansible ecosystem for managing guest configurations. |
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.
For these reasons and more, it is only natural that a tool, like Ansible, is introduced within the KubeVirt community. Not only can it help manage the KubeVirt Kubernetes resources, like `VirtualMachines`, but also to enable the extensive Ansible ecosystem for managing guest configurations. | |
For these reasons and more, it is only natural that a tool, like Ansible, is introduced within the KubeVirt community. Not only can it help manage KubeVirt and Kubernetes resources, like `VirtualMachines`, but also to enable the extensive Ansible ecosystem for managing guest configurations. |
|
||
## What next? | ||
|
||
While the content included within this writeup only provided a brief introduction and usage of the newly released `kubevirt.core` collection. Nevertheless, it is the hope that it helped to showcase the integration now available between KubeVirt and Ansible, including how easy it is to manage KubeVirt assets. A next potential iteration could be to expose a VM via a Kubernetes `Service` using one of the methods described in [this article](https://kubevirt.io/user-guide/virtual_machines/service_objects/#service-objects) instead of a secondary interface as was covered in this walkthrough. Not only does it leverage existing models outside the KubeVirt ecosystem, but helps enable a uniform method for exposing content. |
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.
While the content included within this writeup only provided a brief introduction and usage of the newly released `kubevirt.core` collection. Nevertheless, it is the hope that it helped to showcase the integration now available between KubeVirt and Ansible, including how easy it is to manage KubeVirt assets. A next potential iteration could be to expose a VM via a Kubernetes `Service` using one of the methods described in [this article](https://kubevirt.io/user-guide/virtual_machines/service_objects/#service-objects) instead of a secondary interface as was covered in this walkthrough. Not only does it leverage existing models outside the KubeVirt ecosystem, but helps enable a uniform method for exposing content. | |
This has been a brief introduction to the concepts and usage of the newly released `kubevirt.core` collection. Nevertheless, we hope that it helped to showcase the integration now available between KubeVirt and Ansible, including how easy it is to manage KubeVirt assets. A next iteration could be to expose a VM via a Kubernetes `Service` using one of the methods described in [this article](https://kubevirt.io/user-guide/virtual_machines/service_objects/#service-objects) instead of a secondary interface as was covered in this walkthrough. Not only does it leverage existing models outside the KubeVirt ecosystem, but it helps to enable a uniform method for exposing content. |
@jcanocan @aburdenthehand Updated the PR with your suggestions. |
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.
Sorry, two more of the tiniest nits
|
||
This article will review some of the features and their use associated with this initial release. | ||
|
||
Note: There is also a video version of this blog, which can be found on [YouTube](https://youtu.be/GVROaPgJD_8). |
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.
Note: There is also a video version of this blog, which can be found on [YouTube](https://youtu.be/GVROaPgJD_8). | |
Note: There is also a video version of this blog, which can be found on the [KubeVirt YouTube channel](https://youtu.be/GVROaPgJD_8). |
While adopting KubeVirt and Kubernetes has the potential to disrupt the workflows of teams that typically manage VM infrastructure, including the end users themselves, many of the same paradigms remain: | ||
|
||
- Kubernetes and the resources associated with KubeVirt can be represented in a declarative fashion. | ||
- In many cases, communicating with KubeVirt VMs makes use of the same protocols and schemes as non-Kubernetes based environments. |
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.
- In many cases, communicating with KubeVirt VMs makes use of the same protocols and schemes as non-Kubernetes based environments. | |
- In many cases, communicating with KubeVirt VMs makes use of the same protocols and schemes as non-Kubernetes-based environments. |
@aburdenthehand Adressed! |
/lgtm |
/hold cancel |
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.
This is looking amazing! Just a few comments.
ansible-playbook play-create.yml | ||
``` | ||
|
||
Once the playbook completes successfully, the defined VM will be running in the `kubevirt-ansible` namespace, which can be confirmed by querying for `VirtualMachines` in this namespace. |
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.
Once the playbook completes successfully, the defined VM will be running in the `kubevirt-ansible` namespace, which can be confirmed by querying for `VirtualMachines` in this namespace. | |
Once the playbook completes successfully, the defined VM will be running in the `kubevirt-ansible` namespace, which can be confirmed by querying for `VirtualMachines` in this namespace: |
label_selector: app=test | ||
``` | ||
|
||
Use the `ansible-inventory` command to confirm the VM becomes added to the Ansible inventory. |
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.
Use the `ansible-inventory` command to confirm the VM becomes added to the Ansible inventory. | |
Use the `ansible-inventory` command to confirm the VM becomes added to the Ansible inventory: |
ansible-inventory -i inventory.kubevirt.yml --list | ||
``` | ||
|
||
Next, make use of the host by querying for all of the facts exposed by the VM using the setup module. |
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.
Next, make use of the host by querying for all of the facts exposed by the VM using the setup module. | |
Next, make use of the host by querying for all of the facts exposed by the VM using the setup module: |
|
||
## Introduction | ||
|
||
Infrastructure teams managing virtual machines (VMs) and the end users of these systems make use of a variety of tools as part of their day-to-day world. One such tool that is shared amongst these two groups is Ansible, an agentless automation tool for the enterprise. To simplify both the adoption and usage of KubeVirt as well as to integrate seamlessly into existing workflows, the KubeVirt community is excited to introduce the release of the first version of the KubeVirt collection for Ansible, `kubevirt.core`, which includes a number of tools that you do not want to miss. |
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.
the KubeVirt community is excited to introduce the release of the first version of the KubeVirt collection for Ansible, ...
Link to Ansible website?
This post explains how to manage KubeVirt VMs with the kubevirt.core Ansible collection. Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
@jcanocan Addressed |
Nice job! :) |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: phoracek The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
This post explains how to manage KubeVirt VMs with the kubevirt.core Ansible collection.
Note: YouTube video still needs to be uploaded and link changed in post.