ArgoCD Example
Introduction
This guide explains how to use the provided example to deploy a complete OceanBase environment using ArgoCD. The example follows the "App of Apps" pattern, where a single parent ArgoCD application (oceanbase-stack
) manages the deployment of all the other child applications, ensuring they are created in the correct order using a combination of Sync Phases and Waves.
Prerequisites
Before you begin, ensure you have the following:
- A running Kubernetes cluster.
- ArgoCD installed on your cluster. You can find the installation instructions in the official ArgoCD documentation.
kubectl
installed and configured to connect to your cluster.
Installation
The installation process involves applying a single manifest to your ArgoCD cluster, which will then deploy all the necessary components.
Step 1: Configure Custom Health Checks
For ArgoCD to accurately report the status of all resources, you must add custom health check scripts to the argocd-cm
ConfigMap.
-
Create a file named
argocd-health-patch.yaml
with the following content:data:
resource.customizations.health.argoproj.io_Application: |
hs = {}
hs.status = "Progressing"
hs.message = ""
if obj.status ~= nil then
if obj.status.health ~= nil then
hs.status = obj.status.health.status
if obj.status.health.message ~= nil then
hs.message = obj.status.health.message
end
end
end
return hs
resource.customizations.health.oceanbase.oceanbase.com_OBCluster: |
hs = {}
if obj.status == nil or obj.status.status == nil then
hs.status = "Progressing"
hs.message = "Waiting for status"
return hs
end
local current_status = obj.status.status
if current_status == "running" then
hs.status = "Healthy"
hs.message = "Cluster is running"
elseif current_status == "failed" then
hs.status = "Degraded"
hs.message = "Cluster has failed"
else
hs.status = "Progressing"
hs.message = "Cluster is " .. current_status
end
return hs
resource.customizations.health.oceanbase.oceanbase.com_OBTenant: |
hs = {}
if obj.status == nil or obj.status.status == nil then
hs.status = "Progressing"
hs.message = "Waiting for status"
return hs
end
local current_status = obj.status.status
if current_status == "running" then
hs.status = "Healthy"
hs.message = "Tenant is running"
elseif current_status == "failed" then
hs.status = "Degraded"
hs.message = "Tenant has failed"
else
hs.status = "Progressing"
hs.message = "Tenant is " .. current_status
end
return hs -
Apply the patch to your
argocd-cm
ConfigMap:kubectl patch configmap argocd-cm -n argocd --patch-file argocd-health-patch.yaml
Step 2: Prepare the Repository
The example files are configured to be deployed from the upstream OceanBase operator repository. If you are deploying from your own fork of the repository, you must first update the repoURL
in the application manifests.
The following files need to be updated to point to your Git repository:
example/argocd/oceanbase-stack.yaml
example/argocd/apps/secrets.yaml
example/argocd/apps/obcluster.yaml
example/argocd/apps/obtenant.yaml
example/argocd/apps/ob-configserver.yaml
example/argocd/apps/obproxy.yaml
In each file, change the repoURL
to your forked repository's URL.
Step 3: Deploy the Application Stack
The oceanbase-stack
application is the parent application that manages all other components. Deploy it to your ArgoCD instance using the following command:
kubectl apply -f example/argocd/oceanbase-stack.yaml -n argocd
Step 4: Monitor the Deployment
Once the oceanbase-stack
application is created, you can monitor the deployment process in the ArgoCD UI. The deployment follows a specific order to ensure dependencies are met:
-
Pre-Sync Phase: The following applications are deployed first to set up the foundational components. ArgoCD will wait for these to complete and become Healthy before moving on.
ob-operator
: Installs the OceanBase operator and its CRDs.secrets
: Creates the necessary password secrets.ob-configserver
: Deploys the configuration server.
-
Wave 1: After the Pre-Sync phase is successful, this wave deploys the main cluster components.
obcluster
: Deploys the OceanBase cluster.obproxy
: Deploys the proxy.
-
Wave 2: After Wave 1 is healthy, the final wave deploys the tenant.
obtenant
: Deploys the tenant.
Verification
After the sync process is complete, all applications in the ArgoCD UI should have a Synced
and Healthy
status.
You can also verify the deployment using kubectl
:
- Check the pods in the
oceanbase
andoceanbase-system
namespaces to ensure all components are running. - Check the status of the
OBCluster
andOBTenant
custom resources.
Accessing the Database
Once all the applications are Synced
and Healthy
, the oceanbase-stack
provides a fully functional OceanBase tenant that is compatible with MySQL. You can connect to this database instance from other applications within your Kubernetes cluster.
Connection Details:
- Host:
obproxy.oceanbase.svc.cluster.local
- Port:
2883
- Username:
root@obtenant
- Password: The password is automatically generated and stored in a Kubernetes secret.
To retrieve the password, run the following command:
kubectl get secret tenant-root-password -n oceanbase -o jsonpath='{.data.password}' | base64 -d
You can use these details to configure any MySQL-compatible client or application to connect to your OceanBase tenant.
Troubleshooting
Sync Failures due to Network Issues:
The ArgoCD server needs to be able to connect to the Git repository and the Helm repository. If you see Unknown
sync statuses or errors like context deadline exceeded
, it indicates a network problem between your ArgoCD instance and the internet. Ensure that firewalls, proxies, and network policies are configured to allow this traffic.