Skip to content

CI/CD: Add EKS deployment pipeline for postgres-operator v0.3.0-alpha.20 #194

Description

@eightynine01

Context

postgres-operator v0.3.0-alpha.20 has passed local e2e testing (kind cluster, PostgreSQL 17.9 verified).
The existing .gitlab-ci.yml handles GitHub → GitLab mirror sync only.

This issue adds a deployment pipeline to deploy the operator to the keiailab EKS cluster (force-msa-dev).

Pipeline Configuration

Add the following stages to .gitlab-ci.yml:

stages:
  - mirror   # existing GitHub sync
  - build
  - deploy
  - verify

# ─── Build Stage ───
build-operator-image:
  stage: build
  image: docker:24
  services:
    - docker:24-dind
  variables:
    IMAGE: ghcr.io/keiailab/postgres-operator
    TAG: "0.3.0-alpha.20"
  script:
    - docker build -t $IMAGE:$TAG .
    - echo "$GHCR_TOKEN" | docker login ghcr.io -u keiailab --password-stdin
    - docker push $IMAGE:$TAG
  rules:
    - if: $DEPLOY == "true"

# ─── Deploy Stage ───
deploy-to-eks:
  stage: deploy
  image: alpine/k8s:1.31.4
  variables:
    KUBECONFIG: /tmp/kubeconfig
    NAMESPACE: postgres-operator
  before_script:
    - aws eks update-kubeconfig --name force-msa-dev --region us-east-1
  script:
    - |
      helm upgrade --install postgres-operator charts/postgres-operator \
        --namespace $NAMESPACE --create-namespace \
        --set image.tag=0.3.0-alpha.20 \
        --wait --timeout 180s
  rules:
    - if: $DEPLOY == "true"

# ─── Verify Stage ───
verify-deployment:
  stage: verify
  image: alpine/k8s:1.31.4
  before_script:
    - aws eks update-kubeconfig --name force-msa-dev --region us-east-1
  script:
    - kubectl get pods -n postgres-operator
    - kubectl logs -n postgres-operator deployment/postgres-operator-controller-manager --tail=10
    - |
      cat <<EOF | kubectl apply -f -
      apiVersion: postgres.keiailab.io/v1alpha1
      kind: PostgresCluster
      metadata:
        name: ci-verify
        namespace: default
      spec:
        postgresVersion: "17"
        shardingMode: none
        shards:
          initialCount: 1
          replicas: 0
          storage:
            size: 5Gi
      EOF
    - sleep 60
    - kubectl get postgrescluster ci-verify -o jsonpath='{.status.phase}'
    - kubectl exec ci-verify-shard-0-0 -- psql -U postgres -tAc "SELECT version();"
  rules:
    - if: $DEPLOY == "true"

Required CI/CD Variables

Variable Scope Value
AWS_ACCESS_KEY_ID Protected EKS service account key
AWS_SECRET_ACCESS_KEY Protected EKS service account secret
AWS_DEFAULT_REGION Protected us-east-1
GHCR_TOKEN Protected GitHub Container Registry push token
DEPLOY Manual trigger true (set when triggering deploy)

Trigger

Run deployment pipeline manually:

# Via GitLab UI: CI/CD → Pipelines → Run pipeline → Set DEPLOY=true
# Via API:
curl -X POST "https://gitlab.keiailab.com/api/v4/projects/71/pipeline" \
  -H "PRIVATE-TOKEN: $GITLAB_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ref": "main", "variables": [{"key": "DEPLOY", "value": "true"}]}'

Success Criteria

  1. build-operator-image: Image pushed to ghcr.io ✅
  2. deploy-to-eks: Helm release deployed, operator Pod 1/1 Running ✅
  3. verify-deployment: PostgresCluster ci-verify reaches Phase=Ready, SELECT version() returns PG17 ✅

Related


GitLab 이관 · 원본 keiailab/upstream/postgres-operator#2 · 작성 @phil · 2026-05-25 · 라벨: ci-cd, deployment, priority::high · 이관 2026-06-03

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions