首页 > 解决方案 > 在 Kubernetes 中使用 GitLab Managed Runner 管理缓存

问题描述

如何在 gitlab 管理的 Kubernetes 集群中管理 runner 缓存

多亏了托管的 kubernetes,我正在运行我的 CI 的运行器。我通过 gitlab 面板安装了 gitlab 运行器。

我想放置缓存,所以我知道我需要将它外部化到一些 blobStorage。

我已经阅读了这个tocket(https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1906)但是如何配置我的跑步者,因为它是通过gitlab客户端安装的?

$ kubectl 描述 pod xxx --namespace=gitlab-managed-apps

Namespace:    gitlab-managed-apps
Priority:     0
Node:         xxx
Start Time:   Thu, 24 Sep 2020 10:15:35 +0200
Labels:       app=runner-gitlab-runner
              chart=gitlab-runner-0.21.0
              heritage=Tiller
              pod-template-hash=xx
              release=runner
Annotations:  checksum/configmap: xxx
              checksum/secrets: xxx
              prometheus.io/port: 9252
              prometheus.io/scrape: true
Status:       Running
IP:           xxx
IPs:
  IP:           xxx
Controlled By:  ReplicaSet/runner-gitlab-runner-67b599d94
Init Containers:
  configure:
    Container ID:  docker://xxx
    Image:         gitlab/gitlab-runner:alpine-v13.4.0
    Image ID:      docker-pullable://gitlab/gitlab-runner@sha256:xxx
    Port:          <none>
    Host Port:     <none>
    Command:
      sh
      /config/configure
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Thu, 24 Sep 2020 10:15:46 +0200
      Finished:     Thu, 24 Sep 2020 10:15:46 +0200
    Ready:          True
    Restart Count:  0
    Environment:
      CI_SERVER_URL:                                    https://gitlab.com/
      CLONE_URL:                                        
      RUNNER_REQUEST_CONCURRENCY:                       1
      RUNNER_EXECUTOR:                                  kubernetes
      REGISTER_LOCKED:                                  true
      RUNNER_TAG_LIST:                                  
      RUNNER_OUTPUT_LIMIT:                              4096
      KUBERNETES_IMAGE:                                 ubuntu:16.04
      KUBERNETES_PRIVILEGED:                            true
      KUBERNETES_NAMESPACE:                             gitlab-managed-apps
      KUBERNETES_POLL_TIMEOUT:                          180
      KUBERNETES_CPU_LIMIT:                             
      KUBERNETES_CPU_LIMIT_OVERWRITE_MAX_ALLOWED:       
      KUBERNETES_MEMORY_LIMIT:                          
      KUBERNETES_MEMORY_LIMIT_OVERWRITE_MAX_ALLOWED:    
      KUBERNETES_CPU_REQUEST:                           
      KUBERNETES_CPU_REQUEST_OVERWRITE_MAX_ALLOWED:     
      KUBERNETES_MEMORY_REQUEST:                        
      KUBERNETES_MEMORY_REQUEST_OVERWRITE_MAX_ALLOWED:  
      KUBERNETES_SERVICE_ACCOUNT:                       
      KUBERNETES_SERVICE_CPU_LIMIT:                     
      KUBERNETES_SERVICE_MEMORY_LIMIT:                  
      KUBERNETES_SERVICE_CPU_REQUEST:                   
      KUBERNETES_SERVICE_MEMORY_REQUEST:                
      KUBERNETES_HELPER_CPU_LIMIT:                      
      KUBERNETES_HELPER_MEMORY_LIMIT:                   
      KUBERNETES_HELPER_CPU_REQUEST:                    
      KUBERNETES_HELPER_MEMORY_REQUEST:                 
      KUBERNETES_HELPER_IMAGE:                          
      KUBERNETES_PULL_POLICY:                           
    Mounts:
      /config from scripts (ro)
      /init-secrets from init-runner-secrets (ro)
      /secrets from runner-secrets (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from runner-gitlab-runner-token-t8ft2 (ro)
Containers:
  runner-gitlab-runner:
    Container ID:  docker://xxx
    Image:         gitlab/gitlab-runner:alpine-v13.4.0
    Image ID:      docker-pullable://gitlab/gitlab-runner@sha256:xxx
    Port:          9252/TCP
    Host Port:     0/TCP
    Command:
      /bin/bash
      /scripts/entrypoint
    State:          Running
      Started:      Thu, 24 Sep 2020 10:15:46 +0200
    Ready:          True
    Restart Count:  0
    Liveness:       exec [/bin/bash /scripts/check-live] delay=60s timeout=1s period=10s #success=1 #failure=3
    Readiness:      exec [/usr/bin/pgrep gitlab.*runner] delay=10s timeout=1s period=10s #success=1 #failure=3
    Environment:
      CI_SERVER_URL:                                    https://gitlab.com/
      CLONE_URL:                                        
      RUNNER_REQUEST_CONCURRENCY:                       1
      RUNNER_EXECUTOR:                                  kubernetes
      REGISTER_LOCKED:                                  true
      RUNNER_TAG_LIST:                                  
      RUNNER_OUTPUT_LIMIT:                              4096
      KUBERNETES_IMAGE:                                 ubuntu:16.04
      KUBERNETES_PRIVILEGED:                            true
      KUBERNETES_NAMESPACE:                             gitlab-managed-apps
      KUBERNETES_POLL_TIMEOUT:                          180
      KUBERNETES_CPU_LIMIT:                             
      KUBERNETES_CPU_LIMIT_OVERWRITE_MAX_ALLOWED:       
      KUBERNETES_MEMORY_LIMIT:                          
      KUBERNETES_MEMORY_LIMIT_OVERWRITE_MAX_ALLOWED:    
      KUBERNETES_CPU_REQUEST:                           
      KUBERNETES_CPU_REQUEST_OVERWRITE_MAX_ALLOWED:     
      KUBERNETES_MEMORY_REQUEST:                        
      KUBERNETES_MEMORY_REQUEST_OVERWRITE_MAX_ALLOWED:  
      KUBERNETES_SERVICE_ACCOUNT:                       
      KUBERNETES_SERVICE_CPU_LIMIT:                     
      KUBERNETES_SERVICE_MEMORY_LIMIT:                  
      KUBERNETES_SERVICE_CPU_REQUEST:                   
      KUBERNETES_SERVICE_MEMORY_REQUEST:                
      KUBERNETES_HELPER_CPU_LIMIT:                      
      KUBERNETES_HELPER_MEMORY_LIMIT:                   
      KUBERNETES_HELPER_CPU_REQUEST:                    
      KUBERNETES_HELPER_MEMORY_REQUEST:                 
      KUBERNETES_HELPER_IMAGE:                          
      KUBERNETES_PULL_POLICY:                           
    Mounts:
      /home/gitlab-runner/.gitlab-runner from etc-gitlab-runner (rw)
      /scripts from scripts (rw)
      /secrets from runner-secrets (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from runner-gitlab-runner-token-t8ft2 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  runner-secrets:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     Memory
    SizeLimit:  <unset>
  etc-gitlab-runner:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     Memory
    SizeLimit:  <unset>
  init-runner-secrets:
    Type:                Projected (a volume that contains injected data from multiple sources)
    SecretName:          runner-gitlab-runner
    SecretOptionalName:  <nil>
  scripts:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      runner-gitlab-runner
    Optional:  false
  runner-gitlab-runner-token-t8ft2:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  runner-gitlab-runner-token-t8ft2
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

标签: cachingkubernetesgitlab-ci

解决方案


推荐阅读