Chapter 9. Automating application management with the GitOps controller
You can consistently configure and deploy Kubernetes-based infrastructure and applications across node and development lifecycles by using the declarative Red Hat OpenShift GitOps engine.
9.1. What you can do with the GitOps agent Copy linkLink copied to clipboard!
You can manage application lifecycles and use automated processes to manage application changes with Red Hat OpenShift GitOps.
GitOps with Argo CD for MicroShift is a lightweight, optional add-on controller derived from the GitOps Operator.
The GitOps agent for MicroShift uses the command-line interface (CLI) of Argo CD to interact with the GitOps controller. The controller acts as the declarative GitOps engine. By using the GitOps with Argo CD agent for MicroShift, you can use the following principles:
Implement application lifecycle management:
- Create and manage your node and application configuration files using the core principles of developing and maintaining software in a Git repository.
- You can update the single repository and GitOps automates the deployment of new applications or updates to existing ones.
- For example, if you have 1,000 edge devices, each using MicroShift and a local GitOps agent, you can easily add or update an application on all 1,000 devices with just one change in your central Git repository.
- The Git repository contains a declarative description of the infrastructure you need in your specified environment and contains an automated process to make your environment match the described state.
- You can also use the Git repository as an audit trail of changes so that you can create processes based on Git flows such as review and approval for merging pull requests that implement configuration changes.
9.2. Limitations of using the GitOps agent with MicroShift Copy linkLink copied to clipboard!
Using Red Hat OpenShift GitOps with Argo CD for MicroShift is different from using the entire GitOps Operator in the following ways:
-
The
gitops-operatorcomponent is not used with MicroShift. - To maintain the small resource use of MicroShift use the Argo CD CLI. The Argo CD web console is not available.
- Because MicroShift is single-node, there is no multi-node support. Each instance of MicroShift is paired with a local GitOps agent.
-
The
oc adm must-gathercommand is not available in MicroShift.
9.3. Installing the GitOps Argo CD manifests from an RPM package Copy linkLink copied to clipboard!
You can use a lightweight version of Red Hat OpenShift GitOps with MicroShift to help manage your applications by installing the microshift-gitops RPM package.
The microshift-gitops RPM package includes the necessary manifests to run core Argo CD.
The Argo CD web console is not available on MicroShift. This process installs basic GitOps functions.
Prerequisites
- You installed MicroShift version 4.16 or later.
- You configured 250MB RAM of additional storage.
Procedure
Enable the GitOps repository with the subscription manager by running the following command:
sudo subscription-manager repos --enable=gitops-1.16-for-rhel-9-$(uname -m)-rpms
$ sudo subscription-manager repos --enable=gitops-1.16-for-rhel-9-$(uname -m)-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the MicroShift GitOps package by running the following command:
sudo dnf install -y microshift-gitops
$ sudo dnf install -y microshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow To deploy Argo CD pods, restart MicroShift by running the following command:
sudo systemctl restart microshift
$ sudo systemctl restart microshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
You can verify that your pods are running properly by entering the following command:
oc get pods -n openshift-gitops
$ oc get pods -n openshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE argocd-application-controller-0 1/1 Running 0 4m11s argocd-redis-56844446bc-dzmhf 1/1 Running 0 4m12s argocd-repo-server-57b4f896cf-7qk8l 1/1 Running 0 4m12s
NAME READY STATUS RESTARTS AGE argocd-application-controller-0 1/1 Running 0 4m11s argocd-redis-56844446bc-dzmhf 1/1 Running 0 4m12s argocd-repo-server-57b4f896cf-7qk8l 1/1 Running 0 4m12sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.4. Creating GitOps applications on MicroShift Copy linkLink copied to clipboard!
You can create a custom configuration by using a YAML file to deploy and manage applications in your MicroShift service after you install the Red Hat OpenShift GitOps Argo CD manifests from an RPM package.
Prerequisites
-
You installed the
microshift-gitopspackages. -
The Argo CD pods are running in the
openshift-gitopsnamespace.
Procedure
Create a YAML file and add your customized configurations for the application:
Example YAML for a
spring-petclinicapplicationCopy to Clipboard Copied! Toggle word wrap Toggle overflow To deploy the applications defined in the YAML file, run the following command:
oc apply -f <my_app.yaml>
$ oc apply -f <my_app.yaml>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<my_app.yaml>with the name of your application YAML.
Verification
To verify your application is deployed and synced, run the following command:
oc get applications -A
$ oc get applications -ACopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait a few minutes for the application to show a
Healthystatus.Example output
NAMESPACE NAME SYNC STATUS HEALTH STATUS openshift-gitops spring-petclinic Synced Healthy
NAMESPACE NAME SYNC STATUS HEALTH STATUS openshift-gitops spring-petclinic Synced HealthyCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.5. Debugging GitOps with oc adm inspect Copy linkLink copied to clipboard!
If you have problems with your Argo CD for MicroShift Red Hat OpenShift GitOps controller, you can use the OpenShift CLI (oc) tool to inspect it for errors.
Prerequisites
-
The
occommand-line tool is installed.
Procedure
Run the
oc adm inspectcommand when in the GitOps namespace:oc adm inspect ns/openshift-gitops
$ oc adm inspect ns/openshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Gathering data for ns/openshift-gitops... W0501 20:34:35.978508 57625 util.go:118] the server doesn't have a resource type egressfirewalls, skipping the inspection W0501 20:34:35.980881 57625 util.go:118] the server doesn't have a resource type egressqoses, skipping the inspection W0501 20:34:36.040664 57625 util.go:118] the server doesn't have a resource type servicemonitors, skipping the inspection Wrote inspect data to inspect.local.2673575938140296280.
Gathering data for ns/openshift-gitops... W0501 20:34:35.978508 57625 util.go:118] the server doesn't have a resource type egressfirewalls, skipping the inspection W0501 20:34:35.980881 57625 util.go:118] the server doesn't have a resource type egressqoses, skipping the inspection W0501 20:34:36.040664 57625 util.go:118] the server doesn't have a resource type servicemonitors, skipping the inspection Wrote inspect data to inspect.local.2673575938140296280.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
-
If
oc adm inspectdid not show the information you need, you can run an sos report.