Skip to content

Quick Start

Get up and running with the Git Change Operator in just a few minutes.

Prerequisites

  • Kubernetes cluster (v1.19+)
  • kubectl configured to access your cluster
  • Helm 3.x installed
  • GitHub personal access token or Git credentials

Installation

1. Install the Operator

Using Helm (recommended):

# Add the repository
helm repo add git-change-operator https://raw.githubusercontent.com/mihaigalos/git-change-operator/helm-chart/
helm repo update

# Install the operator
helm install git-change-operator git-change-operator/git-change-operator

Or install from source:

# Clone the repository
git clone https://github.com/mihaigalos/git-change-operator.git
cd git-change-operator

# Install using Helm
helm install git-change-operator ./helm/git-change-operator/

2. Verify Installation

# Check if the operator is running
kubectl get pods -l app=git-change-operator

# Expected output:
# NAME                                     READY   STATUS    RESTARTS   AGE
# git-change-operator-xxx-xxx             1/1     Running   0          1m

3. Set Up Authentication

Create a Kubernetes Secret with your Git credentials:

# Create secret with GitHub personal access token
kubectl create secret generic git-token \
  --from-literal=token=ghp_your_github_token_here \
  --from-literal=username=your-github-username
# Create secret with username/password
kubectl create secret generic git-token \
  --from-literal=username=your-git-username \
  --from-literal=password=your-git-password

Tip

For GitHub, ensure your personal access token has the following scopes:

  • repo (for repository access)
  • pull_requests:write (for creating pull requests)

Your First GitCommit

Let's create a simple GitCommit that adds a configuration file to a Git repository.

1. Create a Test GitCommit

Save this as first-commit.yaml:

apiVersion: gco.galos.one/v1
kind: GitCommit
metadata:
  name: my-first-commit
  namespace: default
spec:
  repository: https://github.com/your-username/test-repo.git
  branch: main
  commitMessage: "Add configuration from Kubernetes operator"
  authSecretRef: git-token
  files:
    - path: config/app-settings.yaml
      content: |
        # Application Configuration
        # Generated by Git Change Operator
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: app-settings
        data:
          environment: production
          log_level: info
          database_host: postgres.example.com
          feature_flags: |
            feature_a: true
            feature_b: false

2. Apply the GitCommit

kubectl apply -f first-commit.yaml

3. Check the Status

# Check the GitCommit status
kubectl get gitcommits my-first-commit

# Get detailed status
kubectl get gitcommits my-first-commit -o yaml

You should see output like:

NAME              REPOSITORY                                   BRANCH   PHASE      COMMIT HASH
my-first-commit   https://github.com/your-username/test-repo   main     Committed  abc123def456

4. Verify in Git

Check your Git repository - you should see a new commit with the file config/app-settings.yaml.

Your First PullRequest

Now let's create a PullRequest resource:

apiVersion: gco.galos.one/v1
kind: PullRequest
metadata:
  name: my-first-pr
  namespace: default
spec:
  repository: https://github.com/your-username/test-repo.git
  baseBranch: main
  headBranch: feature/operator-config
  title: "Add configuration via Git Change Operator"
  body: |
    This PR was created automatically by the Git Change Operator.

    Changes:
    - Added application configuration
    - Set up production settings
  authSecretRef: git-token
  files:
    - path: config/database.yaml
      content: |
        apiVersion: v1
        kind: Secret
        metadata:
          name: database-config
        type: Opaque
        stringData:
          host: postgres.example.com
          port: "5432"
          database: myapp

Apply it:

kubectl apply -f first-pr.yaml

Check the status:

kubectl get pullrequests my-first-pr

Working with Existing Resources

One of the most powerful features is referencing existing Kubernetes resources:

apiVersion: gco.galos.one/v1
kind: GitCommit
metadata:
  name: export-configmap
  namespace: default
spec:
  repository: https://github.com/your-username/k8s-configs.git
  branch: main
  commitMessage: "Export ConfigMap: {{ .ResourceName }}"
  authSecretRef: git-token
  resourceRefs:
    - name: app-config
      kind: ConfigMap
      strategy:
        type: dump
        path: exported-configs

This will: 1. Find the app-config ConfigMap in the default namespace 2. Export it as YAML to exported-configs/app-config.yaml 3. Commit it to the Git repository

Next Steps

🎉 Congratulations! You've successfully set up the Git Change Operator and created your first automated Git operations.

Learn More

Common Next Tasks

  1. Set up monitoring: Add Prometheus metrics collection
  2. Configure RBAC: Limit operator permissions to required resources
  3. Automate workflows: Create GitCommit/PullRequest resources from CI/CD pipelines
  4. Export cluster state: Set up regular backups of important configurations

Getting Help

  • Check the troubleshooting section for common issues
  • Review operator logs: kubectl logs -l app=git-change-operator