IBM & Red Hat on AWS
Using ArgoCD and pipelines to provision and manage new virtual machines
Customers looking to run virtual machines (VM’s), and container workloads on a single platform are flocking to OpenShift Virtualization on Red Hat OpenShift Service on AWS (ROSA). OpenShift Virtualization provides a modernization path that preserves your existing VM estate while simultaneously offering cloud-native management, enhancements, and scalability. This minimizes operational overhead by providing a consistent platform that runs on AWS with a single management interface and set of development and operations tools that bring the benefits of OpenShift and Kubernetes to applications running in VMs.
Customers can preserve their existing virtualization investments by migrating their virtual machines to OpenShift Virtualization, while gradually leveraging its cloud-native hybrid cloud application development and delivery capabilities. This also provides the added benefit of training AI models and incorporating AI features as they modernize their applications.
In this blog, we will explain how to use DevOps processes with OpenShift Virtualization to manage your workloads on AWS. The solution will utilize OpenShift GitOps (based on ArgoCD) to deploy and manage virtual machines in ROSA.
Overview of solution
This tutorial will demonstrate the installation and configuration of the OpenShift GitOps Operator (based on ArgoCD) in a ROSA cluster with OpenShift Virtualization. Once configured, we will use OpenShift GitOps to deploy two VM’s, verify operation in the console, and make changes to the VM configurations. Finally, we’ll manage VM definitions and deployment from the ArgoCD interface.
Reference Architecture
OpenShift Virtualization is an included feature of ROSA that offers customers a modern infrastructure platform to which they can migrate their traditional virtual machines (VMs). It simplifies both the migration process and subsequent management of their existing virtual machines (VMs) on a single scalable modern enterprise-grade application platform.
![OpenShift Virtualization Reference Architecture](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-9.37.00 AM.png)
OpenShift Virtualization Reference Architecture
Prerequisites
For this walkthrough, you should have the following prerequisites:
- An AWS account
- A ROSA Cluster with OpenShift Virtualization (see OpenShift Virtualization on ROSA) and cluster-admin privileges.
- The git binary installed on your machine (can be downloaded from the git website).
Prepare the environment
- Retrieve the source code to deploy VM’s with OpenShift GitOps
$ git clone https://github.com/aws-samples/osa-virtualization-pipelines-sample
$ cd osa-virtualization-pipelines-sample
- Log in to Red Hat and retrieve your cluster token
![OpenShift token login](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-9.38.44 AM.png)
OpenShift token login
- Use the cluster token to log in to the oc CLI
![OpenShift login output](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-9.40.39 AM.png)
OpenShift login output
Install the OpenShift GitOps Operator
- Run the following command using the oc CLI to install the operator
cat << EOF | oc apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: openshift-gitops-operator
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: openshift-gitops-operator
namespace: openshift-gitops-operator
spec:
upgradeStrategy: Default
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: openshift-gitops-operator
namespace: openshift-gitops-operator
spec:
source: redhat-operators
installPlanApproval: Automatic
sourceNamespace: openshift-marketplace
name: openshift-gitops-operator
channel: latest
EOF
Expected output (sample):
namespace/openshift-gitops-operator unchanged
operatorgroup.operators.coreos.com/openshift-gitops-operator created
subscription.operators.coreos.com/openshift-gitops-operator configured
Configure OpenShift GitOps
- Provide OpenShift GitOps the appropriate permissions
Run the following command to give the OpenShift GitOps service account cluster admin privileges so it can deploy VMs to any namespace.
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:openshift-gitops:openshift-gitops-argocd-application-controller
- Create an OpenShift GitOps Application Set
For this tutorial we will deploy Dev and Production VMs. Typically, these VMs would exist in different clusters, but we will separate them by namespaces here.
oc apply -n openshift-gitops -f applicationsets/vm/applicationset-vm.yaml
- Verify the applications (VMs) were created in OpenShift GitOps
Retrieve the OpenShift GitOps URL by executing the following command
oc get route openshift-gitops-server -n openshift-gitops -o jsonpath='{.spec.host}{"\n"}'
- In a browser, navigate to the OpenShift GitOps URL retrieved in step 3, using your OpenShift credentials to log in.
![Argo Login](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-9.59.14 AM.png)
Argo Login
Note: On first log in you will be required to approve the service account permissions
![First login Argo permissions](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.00.24 AM.png)
First login Argo permissions
- Verify that both the dev-vm and prod-vm applications have been deployed
![OpenShift GitOps Console](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.01.33 AM.png)
OpenShift GitOps Console
- Select one of the applications to observe the resources created and current sync status
![OpenShift GitOps Application View](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.02.32 AM.png)
OpenShift GitOps Application View
Manage Virtual Machines in OpenShift
- Return to the OpenShift Cluster web console and select Virtualization -> Virtual Machines from the left navigation menu
Note: Be sure that “All Projects” is selected
![OpenShift virtualization machine view](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.03.35 AM.png)
OpenShift virtualization machine view
Notice that the virtual machines are deployed in unique namespaces, dev-vm and prod-vm
- Manually change a virtual machine to validate that OpenShift GitOps will maintain the state of resources
The VirtualMachine definition file specifies that the vm should be in a running state
![OpenShift virtual machine definition](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.05.30 AM.png)
OpenShift virtual machine definition
Additionally, the ArgoCD ApplicationSet was deployed with self healing enabled
So let’s test out if manually stopping a VM will result in ArgoCD automatically restarting it
- In the OpenShift console, select one of the VMs and select stop
![OpenShift VirtualMachines console commands](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.07.38 AM.png)
OpenShift VirtualMachines console commands
In the ArgoCD console you will almost immediately see the App Health switch to “Progressing” as the dev-vm is restarted automatically
![OpenShift GitOps view of VM stopping](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.08.47 AM.png)
OpenShift GitOps view of VM stopping
After just a few seconds, when the VM has returned to service, the ArgoCD console shows the application as health again
![OpenShift GitOps view of healthy VM](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.09.35 AM.png)
OpenShift GitOps view of healthy VM
Viewing the event from the OpenShift console you will be able to see the VM go from “starting” to “Running” in seconds
![OpenShift Console view of VM restart](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.10.40 AM.png)
OpenShift Console view of VM restart
This demonstrates the benefits of OpenShift GitOps using VirtualMachine definition files and ArgoCD ApplicationSets to maintain VM operation and eliminate application drift.
Manage Virtual Machines through Git
Now, let’s take a reverse approach and demonstrate how changes in Git will be picked up by OpenShift GitOps and allow for VM management
OpenShift Virtualization improves time to production with self-service options for faster VM deployment. Application teams can integrate VMs with OpenShift GitOps to automate the entire VM lifecycle from deployment to decommission, eliminating manual tasks and improving overall efficiency.
- First, we must delete the ArgoCD application set and VMs that were previously created in this tutorial by running the following command
oc delete ApplicationSet vms -n openshift-gitops
![OpenShift GitOps view of the VM deletion](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.13.31 AM.png)
OpenShift GitOps view of the VM deletion
- Fork the https://github.com/rosa-virt-gitops repo to your personal account
- Clone the repo in your github account locally and switch to that directory
export GIT_USERNAME=<YOUR GITHUB USERNAME>
git clone https://github.com/$GIT_USERNAME/osa-virtualization-pipelines-sample
cd osa-virtualization-pipelines-sample
- Edit the applicationset-vm.yaml file in the local rosa-virtualization-pipelines-sample/applicationsets/vm/ directory, changing the repoURL to your repo (https://github.com/<GIT_USERNAME>/osa-virtualization-pipelines-sample.git)
- Save, commit, and push the file to git
git commit -am "update applicationset-vm repo usrl"
git push
- Using the OpenShift CLI (oc) apply the update ApplicationSet to recreate the two ArgoCD applications and two VMs
oc apply -n openshift-gitops -f applicationsets/vm/applicationset-vm.yaml
Once complete, the applications and VM’s should be visible in the OpenShift GitOps and ROSA console
![View of the dev-vm application in the GitOps console](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.24.15 AM.png)
View of the dev-vm application in the GitOps console
![View of the two VM’s deployed](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.25.01 AM.png)
View of the two VM’s deployed
- Modify the VirtualMachine definition to set the VM running state as “false” and increase the memory to 3Gi
Modify the dev kustomization.yaml file located in the /applicationsets/vm/kustomize/dev/ directory of your personal repo.
Set “/spec/running” value to “true” and “memory/guest” to “3Gi”
![Before and After view of the kustomization.yaml file](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.26.21 AM.png)
Before and After view of the kustomization.yaml file
- Save, commit, and push the file to git
git commit -am "stopping the VM and increasing memory"
git push
- Manually sync the changes in the ArgoCD console for the dev-vm application
Select SYNC from the top navigation bar and then SYNCHRONIZE from the right side menu to initiate the process
![Manual synchronization process through the ArgoCD console](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.27.21 AM.png)
Manual synchronization process through the ArgoCD console
The application will show as OutOfSync for a short period of time while the change is propagated and VM restarted
![View of an OutOfSync application](https://d2908q01vomqb2.cloudfront.net/c097638f92de80ba8d6c696b26e6e601a5f61eb7/2024/11/12/Screenshot-2024-11-12-at-10.28.06 AM.png)
View of an OutOfSync application
Once the sync is complete, the VM will show as “Stopped” and configured with 3GiB of Memory, as designated by the changes we made to the customization.yaml file and checked in to Git.
Cleaning up
Remove the VM’s deployed via the OpenShift Cluster console or oc CLI to avoid charges
Conclusion
Red Hat OpenShift Virtualization on ROSA offers a unified, scalable platform for migrating traditional virtual machines to AWS. It ensures consistent hybrid management and supports modernization efforts, enabling organizations to efficiently manage and deploy VM and container workloads with a comprehensive set of development and operations tools. It integrates seamlessly with existing tools like OpenShift GitOps, allowing for efficient management of workloads. Additionally, ROSA’s native integrations with AWS services allows customers to take advantage of the wide range of AWS compute, database, analytics, machine learning (ML), networking, mobile, and other services to build secure and scalable applications faster.