Table of Contents generated with DocToc
For both simplicity and consistency, all tutorials and working demos are designed using a single unique sample application, Robot Shop, which is small enough to run on a developer’s laptop but still have enough complexity to be interesting and not just a “Hello World” example.
Another reason to choose Robot Shop as sample application is that it includes all required components installed and configured for native observability which provides automatic instrumentation for complete end to end tracing and visibility into time series metrics supported by Instana. This closes the gap of application deployment in production environment using GitOps by verifying the system status via application metrics.
This scenario is aimed to demonstrate how you can define the desired states for an application in a Git repository, then use GitOps tools to deploy the application to a target environment and keep the actual states and desired states in sync.
As an example, in this document, we will use Robot Shop as a sample application and use Argo CD to deploy it to a cluster.
- OpenShift
- OpenShift GitOps (Argo CD)
- Helm
A Quick Video Tutorial is available online to walkthrough the deployment process.
First a ArgoCD Gitops server need to be set up, if you haven't done so, you can refer to GitOps control panel set up instruction to set it up.
Before you can deploy the application using GitOps, you need to prepare the environment first which is one off work. For example, to configure Argo CD with custom settings, to prepare storage for your application persistence, and so on. All these work can also be completed using GitOps.
In our case, we defined some customized health checks for Kubernetes custom resources that are not supported in Argo CD by default. We also use rook-ceph as the storage provider to provision persistent volume automatically for our application. All these configuration are stored inside the environment configuration repository.
To simplify the scenario, we will apply these configuration to the cluster that runs the Argo CD instance, so that the application will also be co-located with Argo CD in the same cluster.
Following steps need to be performed to prepare environment:
- Set environment variables.
- Replace the
<my-target-cluster-domain>
in below command with your own domian name. - Use
TARGET_CLUSTER=https://kubernetes.default.svc
instead if you plan to deploy to the local cluster. - When the target cluster is a remote cluster, a argocd instance also need to be installed in the target cluster before hand.
- Replace the
GIT_REPO='https://github.com/cloud-pak-gitops/sample-app-gitops.git'
TARGET_CLUSTER='https://<my-target-cluster-domain>.com:6443'
- Configure Argo CD
argocd app create sample-argo --repo $GIT_REPO \
--dest-server $TARGET_CLUSTER \
--sync-policy automated \
--revision HEAD \
--path config/services/argocd
- Setup Storage
Skip this step if you already have persistent storage configured in the target cluster.
argocd app create sample-storage --repo $GIT_REPO \
--dest-server $TARGET_CLUSTER \
--sync-policy automated \
--revision HEAD \
--path config/services/rook-ceph
rook-cepth storage deployment will take a while, usually over 15 minutes.
Use below command to check the rook-ceph deployment status in the target cluster, once deployment completed, all pods should be showing status Running
.
oc get pod -n rook-ceph
argocd app create sample-robot-shop --repo $GIT_REPO \
--dest-server $ARGO_CLUSTER \
--sync-policy automated \
--revision HEAD \
--path config/apps/robot-shop
Use below command to check the robot-shop deployment status in the target cluster, once deployment completed, all pods should be showing status Running
.
oc get pod -n robot-shop
In this example, we will use https://my-target-cluster-domain.com:6443
as the example target cluster for the deployment, replace it with your own target cluster when performing deployment.
In Argo CD application management, click NEW APP
button.
- Genrnal section
- Source section
- Destination section
In Argo CD application management, click NEW APP
button.
- Genrnal section
- Source section
- Destination section
rook-cepth storage deployment will take a while, usually over 15 minutes.
Use below command to check the rook-ceph deployment status in the target cluster, once deployment completed, all pods should be showing status Running
.
oc get pod -n rook-ceph
In Argo CD application management, click NEW APP
button.
- Genrnal section
- Source section
- Destination section
Use below command to check the robot-shop deployment status in the target cluster, once deployment completed, all pods should be showing status Running
.
oc get pod -n robot-shop
To access the application, you can go back to the OpenShift Console, and open the menu on the top right side of the page. There will be a new menu item added for the application that we created just now.
Click that menu item will bring you to the application home page.
Congratulations! You have successfully deployed the sample application Robot Shop using GitOps.
To uninstall the application, choose the Application named sample-robot-shop
from Argo CD Applications
page, then click DELETE
button. This will bring down the application. Wait for a while till the Application along with its child Applications are all completely deleted, then go to check the menu on the top right side of OpenShift Console, you will see the menu item for the application has been removed.