🪣 Bitbucket → Docker → EKS

Pipeline builds image and deploys to Kubernetes using your Bitbucket repos. · ~40 min

Reviewed: ·Tested on: Kubernetes 1.29, Terraform 1.8, Ubuntu 22.04

If you're on Kubernetes 1.27 or older

  • Ingress: networking.k8s.io/v1 is required — v1beta1 removed in 1.22+
  • Pod Security: PodSecurityPolicy removed in 1.25 — use Pod Security Admission (PSA) labels
  • HPA v2 autoscaling/v2 is stable — check API version in manifests

If you're on Kubernetes 1.28

  • Sidecar containers (1.29+) change init-container ordering — review sidecar docs before upgrade
  • Verify metrics-server and HPA after control plane bump

If you're on Terraform 1.7 or older

  • S3 native locking (use_lockfile) differs from DynamoDB — don't mix backends mid-migration
  • Provider version constraints: run terraform init -upgrade after bump
  • terraform test (1.6+) replaces some external test harness patterns

1. Enable Bitbucket Pipelines

bitbucket-pipelines.yml at repo root.

2. Pipeline: build + push + deploy

image: atlassian/default-image:3
pipelines:
  branches:
    main:
      - step:
          services:
            - docker
          script:
            - docker build -t myapp .
            - docker push registry.example.com/myapp:$BITBUCKET_COMMIT
            - pipe: atlassian/aws-eks-kubectl-run:2.2.0
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                CLUSTER_NAME: my-eks
                KUBECTL_COMMAND: apply -f k8s/

3. Repository variables

AWS keys, cluster name, registry credentials in Bitbucket → Repository settings → Pipelines → Variables.

4. Verify rollout + prod delta

kubectl get pods -n <ns>
kubectl rollout status deploy/<name> -n <ns>