What is GitOps?

GitOps, a concept first introduced by Weaveworks in 2017, focuses on continuous deployment (CD) in cloud-native environments, particularly in Kubernetes-based systems. It involves managing all infrastructure configurations and application settings as code and versioning them through a Git repository.

Push-Based Deployment Strategy

The push-based approach operates similarly to traditional CI/CD pipelines, with the following key features and processes:

Build and Deployment Process

  1. Build Phase

    • A CI pipeline is triggered by a developer’s code push
    • The CI server builds and tests the code
    • Container images are built and uploaded to a registry
  2. Deployment Phase

    • A CD pipeline is triggered upon successful CI build
    • The CD tool updates deployment manifests
    • New manifests are applied directly to the cluster
  3. Verification Phase

    • Deployment status is checked
    • Health checks and rollout status are monitored
    • Rollbacks are performed if necessary

Pull-Based Deployment Strategy

The pull-based approach leverages an operator within the cluster, providing a more secure and declarative approach.

Build and Deployment Process

  1. Build Phase

    • Code push and CI pipeline execution occur
    • Tests are run and container images are built
    • Images are pushed to a registry
  2. Manifest Update Phase

    • Manifests in the Git repository are updated with new image information
    • Changes are committed to the config repository
  3. Deployment Phase

    • The GitOps operator detects changes in the Git repository
    • The state of the cluster is compared to the Git-declared state
    • Automatic synchronization is performed
  4. Monitoring Phase

    • Synchronization status is continuously monitored
    • Automatic retries or notifications are made if issues arise
    • Rollbacks are automated if necessary

Key Differences between the Two Approaches

  1. Actor of Deployment

    • Push: External CD tool directly controls the cluster
    • Pull: Operator within the cluster detects and applies changes
  2. State Management

    • Push: State is checked once during deployment time
    • Pull: State is continuously monitored and synchronized
  3. Security

    • Push: CD tool requires access to the cluster
    • Pull: Only the operator within the cluster has access
  4. Error Handling

    • Push: Handled according to CD pipeline definitions
    • Pull: Continuous retries and automated recovery

Conclusion

Both Push and Pull approaches in GitOps have their own advantages and disadvantages. While the Pull approach excels in terms of security and stability, it may have a higher complexity of implementation. On the other hand, the Push approach is simpler and more straightforward to implement, but requires more attention to security management.

The appropriate approach should be chosen based on an organization’s context and requirements, with the most important considerations being the establishment of a consistent deployment process and the assurance of stability in the production environment. Ultimately, GitOps extends the familiar Git workflow for developers into the operations domain, providing an effective DevOps practice for modern cloud-native environments.