GitOps Platform API Design: Task, Monitoring, and Summary Separation Pattern
A GitOps platform API is not merely a proxy that manipulates Kubernetes resources. It must run asynchronous Workflows, track their progress in real time, and aggregate and present statuses from multiple sources. This article covers a design that separates Task execution, monitoring, and aggregation into three independent services, along with the reasons for doing so.
Deployment Architecture: Separating Roles Across Clusters
Section titled “Deployment Architecture: Separating Roles Across Clusters”Core principles:
- Manage endpoints with Kubernetes Ingress instead of a separate Gateway: Adding a Gateway component only increases failure points and complexity.
- Use Ingress consistently for cross-cluster endpoints: Using Ingress even when crossing cluster boundaries allows TLS and routing policies to be managed in one place.
- Run every cluster-change operation through Argo Workflow: Do not use
kubectl applydirectly. Executing through Workflows leaves a history and enables re-execution and rollback. - Run Workflows primarily through the CLI: The CLI is more stable and easier to keep version-compatible than the REST API. Use the REST API only for features without a CLI.
Task Process: Application Creation, Build, and Deployment Flow
Section titled “Task Process: Application Creation, Build, and Deployment Flow”What asynchronous execution means:
- Workflows and Argo CD execute asynchronously. The
oat the end of an arrow denotes an asynchronous invocation. - A separate API is needed to query the status and results of asynchronous jobs; that is the role of the Monitoring Service.
Monitoring Process: Tracking Asynchronous Job Status
Section titled “Monitoring Process: Tracking Asynchronous Job Status”The Monitoring Service receives status updates from Argo Workflows and Argo CD via Server-Sent Events (SSE). On the Kubernetes side there are two kinds of streams. The service uses follow on the Pod log subresource to stream container logs. It uses the Kubernetes API’s watch to track changes to resources such as Events and Pods. The service can relay both over SSE, but it does not read them from Kubernetes in the same way.
Summary Process: Aggregating Large Volumes of Data
Section titled “Summary Process: Aggregating Large Volumes of Data”Why a Summary Service is necessary:
- The application list screen displays deployment status and execution status at the same time.
- Querying the status of every application through individual REST APIs makes response times too long.
- Pre-aggregating the required data and storing it in Redis makes list queries fast and reliable.
Aggregation targets:
- Watch Workflow events and store final CI/CD statuses.
- Watch Pod statuses and store Run statuses.
Summary of API Design Principles
Section titled “Summary of API Design Principles”| Service | Role | Response Method | Example API |
|---|---|---|---|
| Task Service | Workflow execution and control | JSON | POST /workflows, PUT /workflows/{name}/stop |
| Monitoring Service | Real-time status and log streaming | SSE (text/event-stream) | GET /sse/workflow-log, GET /sse/pod-metric |
| Summary Service | Aggregated data storage | (The Portal queries Redis directly) | - |
This separation pattern clearly divides concerns, isolating both the responsibility and failure scope of each service. Even if the Task Service stops, the Monitoring Service can still stream logs from existing Workflows.
Related Articles
Section titled “Related Articles”- CI/CD Task Automation and Real-Time Monitoring with Argo Workflow: Task types and the SSE flow
- GitOps Repository Structure Design: Helm/Kustomize composition and deployment strategy