Skip to content

Instantly share code, notes, and snippets.

@owlwalks
Last active February 24, 2021 22:06
Show Gist options
  • Save owlwalks/877c9f8b19ffd157033033a60aec1df2 to your computer and use it in GitHub Desktop.
Save owlwalks/877c9f8b19ffd157033033a60aec1df2 to your computer and use it in GitHub Desktop.
Gitlab + Kubernetes (gitlab-managed-apps) + S3 cache

Make cache (S3) works with Gitlab and K8S (gitlab-managed-apps)

  1. Add secret carries your aws keys:
kubectl create secret generic runner-secrets --from-literal=CACHE_S3_ACCESS_KEY="" --from-literal=CACHE_S3_SECRET_KEY="" -n gitlab-managed-apps
  1. Specify cache env vars:

kubectl edit deploy runner-gitlab-runner -n gitlab-managed-apps then add:

        - name: CACHE_TYPE
          value: s3
        - name: CACHE_SHARED
          value: "true"
        - name: CACHE_S3_SERVER_ADDRESS
          value: s3.amazonaws.com
        - name: CACHE_S3_BUCKET_LOCATION
          value: us-east-1          
        - name: CACHE_S3_ACCESS_KEY
          valueFrom:
            secretKeyRef:
              key: CACHE_S3_ACCESS_KEY
              name: runner-secrets
        - name: CACHE_S3_SECRET_KEY
          valueFrom:
            secretKeyRef:
              key: CACHE_S3_SECRET_KEY
              name: runner-secrets
        - name: CACHE_S3_BUCKET_NAME
          value: your-s3-bucket
        - name: CACHE_S3_INSECURE
          value: "false"
  1. restart
kubectl rollout restart deployment/runner-gitlab-runner -n gitlab-managed-apps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment