# How GitOps Workflow Integrates with Kubernetes Operators and Controllers for Automated Infrastructure Management

> Discover how GitOps workflow integrates with Kubernetes operators and controllers for automated infrastructure and application lifecycle management using version control, Argo CD, and Custom Resources.

- Repository: [Arie Bregman/devops-exercises](https://github.com/bregman-arie/devops-exercises)
- Tags: architecture
- Published: 2026-02-28

---

**GitOps workflow integrates with Kubernetes operators and controllers by storing declarative infrastructure manifests in version control, enabling tools like Argo CD to detect changes and invoke the Kubernetes API while domain-specific operators reconcile Custom Resources to automate complex application lifecycle management.**

The **bregman-arie/devops-exercises** repository provides comprehensive documentation on how GitOps workflow integrates with Kubernetes operators and controllers, demonstrating how declarative version control combines with Kubernetes-native automation to manage infrastructure and application lifecycles automatically.

## Declarative Desired State in Git

In a GitOps workflow, the entire desired state of the cluster—including platform components, **CustomResourceDefinitions (CRDs)**, and corresponding **Custom Resources (CRs)**—is stored in a dedicated GitOps repository. According to [`topics/devops/README.md`](https://github.com/bregman-arie/devops-exercises/blob/main/topics/devops/README.md), this repository contains all Kubernetes manifests that describe how the system should be built and run, while explicitly excluding the application source code itself.

The repository structure typically separates base configurations from environment-specific overlays, allowing teams to manage complex deployments across development, staging, and production environments using tools like Kustomize or Helm.

## Kubernetes Operators as Specialized Controllers

A **Kubernetes Operator** is a specialized controller that watches a specific CR type and implements a custom control loop to drive the cluster toward the desired state declared in those CRs. As documented in [`topics/kubernetes/README.md`](https://github.com/bregman-arie/devops-exercises/blob/main/topics/kubernetes/README.md), operators are packaged as containers and installed via the **Operator Lifecycle Manager (OLM)**, enabling them to manage complex stateful workloads such as databases and message queues.

These operators automate tasks including provisioning, upgrades, backups, and scaling by continuously reconciling the actual state of the cluster with the spec defined in Custom Resources stored in the GitOps repository.

## Argo CD as the GitOps Reconciliation Engine

**Argo CD** serves as the declarative GitOps CD tool that bridges the Git repository and the Kubernetes cluster. As described in [`topics/argo/README.md`](https://github.com/bregman-arie/devops-exercises/blob/main/topics/argo/README.md), Argo CD continuously monitors the configured Git repository, detects changes to manifests, and invokes the Kubernetes API to apply updated configurations automatically.

When a developer pushes a new version of a manifest—such as updating an image tag in a `Deployment`—Argo CD syncs the cluster to guarantee that the live state reflects the Git state. The tool also provides automated drift detection and self-healing capabilities to maintain consistency.

## End-to-End Integration Workflow

The complete integration between GitOps workflow, Argo CD, and Kubernetes operators follows a continuous reconciliation loop:

1. **Commit and Review**: Engineers update manifests or Custom Resources in the GitOps repository and submit pull requests. The changes undergo CI checks including linting and policy enforcement, as exemplified in [`.github/workflows/ci_workflow.yml`](https://github.com/bregman-arie/devops-exercises/blob/main/.github/workflows/ci_workflow.yml).

2. **Merge and Detect**: Upon merging to the main branch, Argo CD detects the new commit through its polling or webhook mechanisms.

3. **Sync and Reconcile**: Argo CD pulls the updated manifests and applies them to the cluster via the Kubernetes API. Simultaneously, any operators watching affected CRs receive notifications from the API server and initiate their reconciliation loops—such as executing database schema migrations or resizing Redis clusters.

4. **Observe and Remediate**: Monitoring tools surface the health of the reconciliation process. If configuration drift occurs, Argo CD automatically re-syncs the cluster or raises alerts to maintain the desired state.

Because both Argo CD and custom operators react to the same Git source of truth, the entire infrastructure stack—from underlying platform components to application workloads—remains automatically consistent.

## Practical Implementation Examples

### GitOps Repository Structure

A typical GitOps repository organizes manifests to support multiple environments and operator-managed resources:

```text
gitops-repo/
├─ base/
│   ├─ namespaces.yaml
│   ├─ postgres/
│   │   ├─ crd.yaml           # PostgresOperator CRD

│   │   └─ postgres.yaml      # CustomResource instance

│   └─ app/
│       └─ deployment.yaml
└─ overlays/
    ├─ dev/
    │   └─ kustomization.yaml
    └─ prod/
        └─ kustomization.yaml

```

### Argo CD Application Manifest

The following Argo CD Application resource connects the GitOps repository to the cluster with automated sync policies:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-service
spec:
  project: default
  source:
    repoURL: https://github.com/your-org/gitops-repo.git
    targetRevision: HEAD
    path: overlays/prod
  destination:
    server: https://kubernetes.default.svc
    namespace: my-service-ns
  syncPolicy:
    automated:
      prune: true          # delete resources removed from Git

      selfHeal: true       # auto-fix drift

```

### Operator CustomResource Definitions and Instances

When deploying operator-managed services through GitOps, you define both the infrastructure and the high-level service specifications:

**CustomResourceDefinition (installed by the operator):**

```yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: redisclusters.cache.example.com
spec:
  group: cache.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                size:
                  type: integer
  scope: Namespaced
  names:
    plural: redisclusters
    singular: rediscluster
    kind: RedisCluster

```

**CustomResource managed via GitOps:**

```yaml
apiVersion: cache.example.com/v1
kind: RedisCluster
metadata:
  name: prod-redis
spec:
  size: 3

```

When the GitOps repository updates the `size` field, the Redis Operator's controller detects the change and creates or deletes Pods to match the desired replica count.

### CI Pipeline Integration

To enforce quality gates before GitOps synchronization, extend [`.github/workflows/ci_workflow.yml`](https://github.com/bregman-arie/devops-exercises/blob/main/.github/workflows/ci_workflow.yml) to trigger Argo CD syncs after successful validation:

```yaml
name: ci-sync-argo
on:
  push:
    branches: [ main ]
jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger Argo CD
        run: |
          curl -X POST -H "Authorization: Bearer ${{ secrets.ARGO_TOKEN }}" \
          https://argocd.example.com/api/v1/applications/my-service/sync

```

## Summary

- **GitOps workflow** stores all Kubernetes manifests—including CRDs and operator-managed Custom Resources—in version control as the single source of truth.
- **Argo CD** continuously monitors the GitOps repository and automatically applies changes to the cluster, ensuring live state matches declared state.
- **Kubernetes operators** implement domain-specific control loops that reconcile Custom Resources, automating complex lifecycle tasks like database upgrades and backup management.
- **Integration** between generic GitOps controllers and specialized operators creates a fully automated pipeline where infrastructure and application changes flow from Git to production without manual intervention.

## Frequently Asked Questions

### What distinguishes a GitOps controller from a Kubernetes operator?

A **GitOps controller** like Argo CD manages the delivery layer by synchronizing general Kubernetes manifests from Git to the cluster, while a **Kubernetes operator** is a domain-specific controller that manages the lifecycle of complex applications through Custom Resources. The GitOps controller ensures the cluster matches the Git repository, whereas operators handle application-specific logic such as database failover or cache cluster resizing.

### How does Argo CD detect configuration drift in the cluster?

Argo CD continuously compares the live cluster state against the desired state stored in the GitOps repository using the `syncPolicy` configuration. When `selfHeal` is enabled in the Application manifest, Argo CD automatically re-applies manifests from Git if it detects drift—such as manual changes made directly to the cluster—ensuring the system maintains the declarative state defined in [`topics/argo/README.md`](https://github.com/bregman-arie/devops-exercises/blob/main/topics/argo/README.md).

### Can multiple operators manage resources deployed through GitOps?

Yes, multiple operators can simultaneously manage resources deployed by GitOps workflows. When Argo CD applies a Custom Resource to the cluster, any installed operator watching that CRD will trigger its reconciliation loop. This enables composable infrastructure where one operator manages databases while another handles caching, all coordinated through the same GitOps repository structure documented in [`topics/kubernetes/README.md`](https://github.com/bregman-arie/devops-exercises/blob/main/topics/kubernetes/README.md).

### What role does the Operator Lifecycle Manager play in GitOps workflows?

The **Operator Lifecycle Manager (OLM)** installs and manages operator components themselves within the cluster. In a GitOps workflow, OLM ensures that the necessary operators are available to reconcile the Custom Resources stored in Git. According to [`topics/kubernetes/README.md`](https://github.com/bregman-arie/devops-exercises/blob/main/topics/kubernetes/README.md), operators packaged via OLM can be deployed and updated through the same GitOps mechanisms, treating operator lifecycles as part of the declarative infrastructure stack.