$ kubectl cluster-info Kubernetes master is running at https://10.151.30.11:6443 KubeDNS is running at https://10.151.30.11:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debugand diagnose cluster problems, use 'kubectl cluster-info dump'.
注意:在向 ConfigMap 添加新选项后,需要删除 GitLab CI Runner Pod。因为我们是使用 envFrom来注入上面的这些环境变量而不是直接使用env的(envFrom 通过将环境变量放置到ConfigMaps或Secrets来帮助减小清单文件。
另外如果要添加其他选项的话,我们可以在 Pod 中运行gitlab-ci-multi-runner register --help命令来查看所有可使用的选项,只需为要配置的标志添加 env 变量即可,如下所示:
1 2 3 4 5 6 7 8 9 10
gitlab-runner@gitlab-ci-runner-0:/$ gitlab-ci-multi-runner --help [...] --kubernetes-cpu-limit value The CPU allocation given to build containers (default: "1") [$KUBERNETES_CPU_LIMIT] --kubernetes-memory-limit value The amount of memory allocated to build containers (default: "4Gi") [$KUBERNETES_MEMORY_LIMIT] --kubernetes-service-cpu-limit value The CPU allocation given to build service containers (default: "1") [$KUBERNETES_SERVICE_CPU_LIMIT] --kubernetes-service-memory-limit value The amount of memory allocated to build service containers (default: "1Gi") [$KUBERNETES_SERVICE_MEMORY_LIMIT] --kubernetes-helper-cpu-limit value The CPU allocation given to build helper containers (default: "500m") [$KUBERNETES_HELPER_CPU_LIMIT] --kubernetes-helper-memory-limit value The amount of memory allocated to build helper containers (default: "3Gi") [$KUBERNETES_HELPER_MEMORY_LIMIT] --kubernetes-cpu-request value The CPU allocation requested for build containers [$KUBERNETES_CPU_REQUEST] [...]
除了上面的一些环境变量相关的配置外,还需要一个用于注册、运行和取消注册 Gitlab CI Runner 的小脚本。只有当 Pod 正常通过 Kubernetes(TERM信号)终止时,才会触发转轮取消注册。 如果强制终止 Pod(SIGKILL信号),Runner 将不会注销自身。必须手动完成对这种被杀死的 Runner 的清理,配置清单文件如下:(runner-scripts-cm.yaml)
$ ls gitlab-ci-token-secret.yaml runner-cm.yaml runner-rbac.yaml runner-scripts-cm.yaml runner-statefulset.yaml $ kubectl create -f . secret "gitlab-ci-token" created configmap "gitlab-ci-runner-cm" created serviceaccount "gitlab-ci" created role.rbac.authorization.k8s.io"gitlab-ci" created rolebinding.rbac.authorization.k8s.io"gitlab-ci" created configmap "gitlab-ci-runner-scripts" created statefulset.apps"gitlab-ci-runner" created
创建完成后,可以通过查看 Pod 状态判断 Runner 是否运行成功:
1 2 3 4 5 6
$ kubectl get pods -n kube-ops NAME READY STATUS RESTARTS AGE gitlab-7bff969fbc-k5zl4 1/1 Running 04d gitlab-ci-runner-01/1 Running 03m gitlab-ci-runner-11/1 Running 03m ......