头图

本分分享如何对 Helm 安装的 Runner 进行升级。整个过程分为三步:1、确定 Runner 最新版本或者想要升级的版本是否存在;2、用 Helm upgrade 命令进行升级;3、升级确认。

极狐GitLab 为 GitLab 的中国发行版,中文版本对中国用户更友好,可以一键私有化部署,安装升级详情可以查看官网

前提

  • 用 Helm 安装且运行正常的 Runner

关于使用 Helm 进行极狐GitLab Runner,可以参考文章如何用 Helm 安装特定版本的 GitLab Runner?,然后查看 Runner 的版本和运行状况:

# 查看 Helm Release 以及 Runner 的版本
helm ls --namespace jh-gitlab-runner
NAME                NAMESPACE           REVISION    UPDATED                                    STATUS      CHART                   APP VERSION
jh-gitlab-runner    jh-gitlab-runner    1           2024-09-11 06:50:17.139514892 +0000 UTC    deployed    gitlab-runner-0.68.0    17.3.0

# 查看 Runner 的运行状态
kubectl -n jh-gitlab-runner get pods
NAME                                              READY   STATUS    RESTARTS   AGE
jh-gitlab-runner-gitlab-runner-5c558fb88b-lnfxm   1/1     Running   0          42h

查找 Runner 版本

升级的前提是确定想要升级到哪个版本,使用 Helm 安装的话,可以用 helm search命令来查找版本:

# 查找 Repo
helm repo list
NAME         URL
jh-gitlab    https://charts.gitlab.cn

# 查找最近的 5 个版本
helm search repo jh-gitlab/gitlab-runner -l | head -5
NAME                       CHART VERSION    APP VERSION    DESCRIPTION
jh-gitlab/gitlab-runner    0.68.1           17.3.1         GitLab Runner
jh-gitlab/gitlab-runner    0.68.0           17.3.0         GitLab Runner
jh-gitlab/gitlab-runner    0.67.0           17.2.0         GitLab Runner
jh-gitlab/gitlab-runner    0.66.0           17.1.0         GitLab Runner

可以看到最新的版本是 17.3.1,而当前安装的是 17.3.0。接下来就准备升级到 17.3.1

Runner 的升级

执行 helm upgrade即可完成升级,升级过程中可以使用 --version执行想要升级的版本

helm upgrade --namespace jh-gitlab-runner -f values.yaml jh-gitlab-runner jh-gitlab/gitlab-runner --version 0.68.1
W0913 01:41:09.427151  715889 warnings.go:70] unknown field "spec.template.spec.containers[0].securityContext.fsGroup"
Release "jh-gitlab-runner" has been upgraded. Happy Helming!
NAME: jh-gitlab-runner
LAST DEPLOYED: Fri Sep 13 01:41:08 2024
NAMESPACE: jh-gitlab-runner
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
Your GitLab Runner should now be registered against the GitLab instance reachable at: "http://jhma.jihulab.net"

Runner namespace "jh-gitlab-runner" was found in runners.config template.

#############################################################################################
## WARNING: You enabled `rbac` without specifying if a service account should be created.  ##
## Please set `serviceAccount.create` to either `true` or `false`.                         ##
## For backwards compatibility a service account will be created.                          ##
#############################################################################################

可以看到 Runner pod 的状态变化

kubectl -n jh-gitlab-runner get pods -w
NAME                                              READY   STATUS    RESTARTS   AGE
jh-gitlab-runner-gitlab-runner-5c558fb88b-lnfxm   1/1     Running   0          42h
jh-gitlab-runner-gitlab-runner-b444666d-fn7l9     0/1     Running   0          26s
jh-gitlab-runner-gitlab-runner-b444666d-fn7l9     1/1     Running   0          70s
jh-gitlab-runner-gitlab-runner-5c558fb88b-lnfxm   1/1     Terminating   0          42h 

Runner 升级确认

用 helm ls确认 Runner 的版本信息

helm ls --namespace jh-gitlab-runner
NAME                NAMESPACE           REVISION    UPDATED                                    STATUS      CHART                   APP VERSION
jh-gitlab-runner    jh-gitlab-runner    2           2024-09-13 01:41:08.757879746 +0000 UTC    deployed    gitlab-runner-0.68.1    17.3.1

可以看到版本从 17.3.0 升级到了 17.3.1。可以在 Runner 管理界面再次确认

file

在界面上同样可以看到 Runner 到了 17.3.1


极狐GitLab
64 声望36 粉丝

极狐(GitLab) 以“核心开放”为原则,面向中国市场,提供开箱即用的开放式一体化安全DevOps平台——极狐GitLab。通过业界领先的优先级管理、安全、风险和合规性功能,实现产品、开发、QA、安全和运维团队间的高效协同...