KubeVirt Implementation: Who Needs It and Why?
KubeVirt lets Kubernetes manage VMs with containers, streamlining infrastructure. It supports legacy apps, cuts costs, enhances flexibility, and is easy to deploy.
Join the DZone community and get the full member experience.
Join For FreeThe adoption of cloud-native architectures and containerization is transforming the way we develop, deploy, and manage applications. Containers offer speed, agility, and scalability, fueling a significant shift in IT strategies. However, the reality for many organizations is that virtual machines (VMs) continue to play a critical role, especially when it comes to legacy or stateful applications. Even leading financial institutions like Goldman Sachs recognize the value of VMs alongside containerized workloads and are exploring ways to manage them efficiently.
This creates a potential divide: the benefits of containerization on one side and the enduring need for VMs on the other. KubeVirt bridges this gap by extending the power of Kubernetes to virtual machine management, giving you the ability to unify your infrastructure while enabling a smoother transition to cloud-native technologies.
In this article, we explore why KubeVirt is a compelling solution for organizations seeking to streamline IT operations and gain flexibility in a hybrid infrastructure environment.
What Exactly is KubeVirt?
KubeVirt is an open-source project that transforms Kubernetes into a powerful platform capable of managing both containers and virtual machines. Put simply, KubeVirt turns Kubernetes into a single control plane for your entire infrastructure.
Here’s how it works:
- KubeVirt as an extension: KubeVirt adds custom resource definitions (CRDs) to Kubernetes, introducing a new object type representing virtual machines.
- Virtual machines as “pods”: Using KubeVirt, each VM runs within a specialized pod, which tightly integrates VMs into the Kubernetes ecosystem.
- Simplified VM management with Kubernetes: You can now leverage the same Kubernetes tools (
kubectl
and the Kubernetes API) and best practices to create, start, stop, migrate, and monitor VMs alongside your containerized workloads.
Think of KubeVirt as enabling Kubernetes to speak the language of virtualization, opening a world of possibilities for your infrastructure management.
The Business Impact of KubeVirt
KubeVirt delivers tangible benefits that go beyond technical elegance. By adopting KubeVirt, your organization stands to gain the following:
- Seamless workload management: Break down the walls between your VM-based applications and your containerized workloads. Manage everything from a single platform using the same tools and processes, significantly simplifying operations and reducing complexity.
- Enhanced resource efficiency: KubeVirt empowers you to run both traditional VMs and containers on the same underlying cluster hardware. Optimize resource utilization, improve infrastructure density, and potentially realize significant cost savings.
- Accelerated modernization: Legacy applications tied to VMs don’t have to be a roadblock to innovation. KubeVirt provides a gradual pathway to modernizing applications at your own pace. You can containerize and migrate components over time, all within the same Kubernetes environment, minimizing disruption.
- Future-proof infrastructure: By investing in KubeVirt, you align with cloud-native principles and position Kubernetes as the backbone of your technology stack. This fosters flexibility and agility, enabling you to adapt readily to evolving business requirements.
Why Should Your Organization Care?
KubeVirt delivers compelling value, especially in these areas:
- IT Teams and DevOps: KubeVirt simplifies operations by providing a unified control plane for all your workloads. It lets you streamline workflows, reduce tooling overhead, and improve overall team efficiency.
- Executives: Gain operational flexibility and achieve cost reductions and a streamlined path toward infrastructure modernization. KubeVirt aligns technology investments with long-term business success.
- Mixed workloads: If you’re managing both legacy VM-based applications and modern containerized deployments, KubeVirt is essential. It lets you avoid vendor lock-in, minimize complexity, and maintain full control over your infrastructure choices.
Here are some specific pain points that KubeVirt addresses:
- Frustrated with managing separate environments for VMs and containers? KubeVirt brings them together, making management far easier.
- Seeking flexibility without compromising on existing investments? KubeVirt lets you leverage your VM infrastructure while modernizing.
- Want to improve cost efficiency and resource usage? KubeVirt helps consolidate workloads for better utilization.
- Struggling with complex migrations of legacy apps? Modernize incrementally and control your pace with KubeVirt.
Getting Started: Deployment and Implementation
Deploying KubeVirt requires a well-prepared Kubernetes environment. This section provides a detailed guide to help you set up and implement KubeVirt in your infrastructure.
Prerequisites
Before you begin, ensure the following requirements are met:
1. Kubernetes Cluster
You need a Kubernetes cluster (or a derivative such as OpenShift) based on one of the latest three Kubernetes releases available at the time of the KubeVirt release.
2. Kubernetes API Server Configuration
The Kubernetes API server must be configured with --allow-privileged=true
to run KubeVirt's privileged DaemonSet.
3. Kubectl Utility
Ensure you have the kubectl
client utility installed and configured to interact with your cluster.
4. Container Runtime Support
KubeVirt is supported on the following container runtimes:
Containerd
crio
(withrunv
)
Other container runtimes should work as well, but the mentioned ones are the primary targets.
5. Hardware Virtualization
Hardware with virtualization support is recommended. You can use virt-host-validate
to ensure your hosts are capable of running virtualization workloads:
$ virt-host-validate qemu
Network and Security Considerations
-
Network Configuration: Plan how your VMs will connect and interact with external networks and the rest of your Kubernetes environment.
-
AppArmor Integration: On systems with AppArmor enabled, you might need to modify the AppArmor profiles to allow the execution of KubeVirt-privileged containers. For example:
# vim /etc/apparmor.d/usr.sbin.libvirtd
/usr/libexec/qemu-kvm PUx,
# apparmor_parser -r /etc/apparmor.d/usr.sbin.libvirtd
KubeVirt Installation
To install KubeVirt, follow these steps:
1. Install the KubeVirt Operator
The KubeVirt operator simplifies the installation and management of KubeVirt components. Run the following commands to deploy the latest KubeVirt release:
# Point at latest release
$ export RELEASE=$(curl https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt)
# Deploy the KubeVirt operator
$ kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${RELEASE}/kubevirt-operator.yaml
# Create the KubeVirt CR (instance deployment request) which triggers the actual installation
$ kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${RELEASE}/kubevirt-cr.yaml
# Wait until all KubeVirt components are up
$ kubectl -n kubevirt wait kv kubevirt --for condition=Available
2. Configuration for Non-Hardware Virtualization
If hardware virtualization is not available, enable software emulation by setting useEmulation to true in the KubeVirt CR:
$ kubectl edit -n kubevirt kubevirt kubevirt
# Add the following to the kubevirt.yaml file
spec:
configuration:
developerConfiguration:
useEmulation: true
Implementation Best Practices
To get the most out of KubeVirt, follow these best practices:
1. Conduct a Workload Assessment
Prioritize VMs that are suitable for containerization. Start with less mission-critical applications to gain practical experience.
2. Assess Networking and Storage
Plan how to bridge VM networking with your existing Kubernetes networking and integrate storage solutions for persistent data using Container Storage Interface (CSI) plugins.
3. Emphasize Monitoring and Management
Use Kubernetes monitoring tools or explore KubeVirt-specific solutions to gain visibility into VM performance alongside your containers.
4. Live Migration
Enable and configure live migration to move running VMs to other compute nodes without downtime. This involves setting feature gates and configuring migration-specific parameters in the KubeVirt CR:
apiVersion: kubevirt.io/v1
kind: KubeVirt
metadata:
name: kubevirt
namespace: kubevirt
spec:
configuration:
developerConfiguration:
featureGates:
- LiveMigration
migrations:
parallelMigrationsPerCluster: 5
parallelOutboundMigrationsPerNode: 2
bandwidthPerMigration: 64Mi
completionTimeoutPerGiB: 800
progressTimeout: 150
Example Installation on OpenShift (OKD)
If you're using OKD, additional steps include configuring Security Context Constraints (SCC):
$ oc adm policy add-scc-to-user privileged -n kubevirt -z kubevirt-operator
Example Installation on k3OS
For k3OS, ensure you load the required modules on all nodes before deploying KubeVirt:
k3os:
modules:
- kvm
- vhost_net
Restart the nodes with this configuration and then deploy KubeVirt as described above.
Installation of Daily Developer Builds
For the latest developer builds, run:
$ LATEST=$(curl -L https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/kubevirt/latest)
$ kubectl apply -f https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/kubevirt/${LATEST}/kubevirt-operator.yaml
$ kubectl apply -f https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/kubevirt/${LATEST}/kubevirt-cr.yaml
Deployment From Source
By following these steps and best practices, you can ensure a smooth and successful KubeVirt implementation, providing a unified infrastructure management solution that leverages both virtual machines and containers.
Implementation Best Practices
Follow these best practices to get the most out of KubeVirt:
- Conduct a workload assessment: Not every application is immediately suitable for KubeVirt. Prioritize VMs with good potential for containerization. Less mission-critical applications can be a great way to gain practical experience while minimizing risk.
- Assess networking and storage: Carefully consider how to bridge VM networking with your existing Kubernetes networking. Plan storage integration for persistent data using solutions like Container Storage Interface (CSI) plugins.
- Emphasize monitoring and management: Adapt your existing Kubernetes monitoring tools or explore KubeVirt-specific solutions to gain visibility into VM performance alongside your containers.
Conclusion
KubeVirt offers a compelling path for organizations seeking to reap the benefits of cloud-native technologies while maximizing the value of existing virtual machine investments. It boosts operational efficiency, fosters flexibility, and accelerates your modernization journey.
Opinions expressed by DZone contributors are their own.
Comments