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

OpenShift Virtualization Reference Architecture

Prerequisites

For this walkthrough, you should have the following prerequisites:

Prepare the environment

  1. 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

  1. Log in to Red Hat and retrieve your cluster token
OpenShift token login

OpenShift token login

  1. Use the cluster token to log in to the oc CLI
OpenShift login output

OpenShift login output

Install the OpenShift GitOps Operator

  1. 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

  1. 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

  1. 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

  1. 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"}'

  1. In a browser, navigate to the OpenShift GitOps URL retrieved in step 3, using your OpenShift credentials to log in.
Argo Login

Argo Login

Note: On first log in you will be required to approve the service account permissions

First login Argo permissions

First login Argo permissions

  1. Verify that both the dev-vm and prod-vm applications have been deployed
OpenShift GitOps Console

OpenShift GitOps Console

  1. Select one of the applications to observe the resources created and current sync status
OpenShift GitOps Application View

OpenShift GitOps Application View

Manage Virtual Machines in OpenShift

  1. 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

OpenShift virtualization machine view

Notice that the virtual machines are deployed in unique namespaces, dev-vm and prod-vm

  1. 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

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

  1. In the OpenShift console, select one of the VMs and select stop
OpenShift VirtualMachines console commands

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

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

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

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.

  1. 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

OpenShift GitOps view of the VM deletion

  1. Fork the https://github.com/rosa-virt-gitops repo to your personal account

  1. 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

  1. 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)

  1. Save, commit, and push the file to git

git commit -am "update applicationset-vm repo usrl"

git push

  1. 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

View of the dev-vm application in the GitOps console

View of the two VM’s deployed

View of the two VM’s deployed

  1. 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

Before and After view of the kustomization.yaml file

  1. Save, commit, and push the file to git

git commit -am "stopping the VM and increasing memory"

git push

  1. 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

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

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.

Steve Mirman

Steve Mirman

Steve Mirman is an ex-Red Hatter, ex-IBMer, and current Partner Solutions Architect at AWS. He has over 20 years of experience helping customers architect, develop, deploy, and migrate enterprise applications.

Kevin Collins

Kevin Collins

Kevin Collins is a Senior Managed OpenShift Black Belt, Red Hat. A dynamic sales leader and technical expert specializing in cloud native platforms with over 25 years of experience across IBM and Red HatIn his current role at Red Hat, he leads technical pre-sales for Managed OpenShift, collaborating with global customer account teams to accelerate cloud adoption across all major cloud platforms.