如何添加極狐GitLab Runner 信任域名證書

本文作者 徐曉偉

極狐Gitlab Runner 信任實例域名證書,用于注冊注冊極狐 GitLab Runner。

問題

參見 極狐gitlab-runner-host.md

說明

  • 解決方案是使用頒發給域名 gitlab.test.helm.xuxiaowei.cn 的證書,可以使用自己的域名去各大云廠商免費申請,或者使用自己根據域名 gitlab.test.helm.xuxiaowei.cn 生成的證書

    1. 阿里云SSL(https)證書免費申請
    2. 騰訊云SSL(https)證書免費申請
    3. 華為云SSL(https)證書免費申請
    4. 百度云SSL(https)證書免費申請

域名證書解決方案

方案1:重新配置極狐 GitLab,自動生成對應證書并自動配置,然后在極狐 GitLab runner 中信任證書

  1. 問題1:tls: failed to verify certificate: x509: certificate signed by unknown authority

    1. 文檔

      1. runners 部分
      2. 自簽名證書或自定義證書頒發機構
      3. ConfigMap
      4. 配置 Pod 使用 ConfigMap
    2. 根據上述文檔可知,有三種方式可以解決證書信任問題:

      1. 在 極狐GitLab Runner 注冊時配置 --tls-ca-file 參數并指向證書文件
      2. 在配置文件中增加 tls-ca-file 并指向配置文件, 此方式本文不做介紹,可參考 gitlab-runner-kubernetes-host.md ,原理相同
      3. 將證書放在 /etc/gitlab-runner/certs/ 文件夾下,使用域名命名證書,證書后綴名是 .crt由于篇幅限制,這里只介紹這一種方式
    3. 由于 k8s 的 pod 可能隨時會被刪除(故障轉移、主動刪除等),所以直接在 pod 內部配置不是上策

    4. k8s 中的 ConfigMap 可以掛載到 pod 內部,所以可以考慮在 ConfigMap 中配置證書,然后 pod 內部使用 ConfigMap 中的證書

    5. 下載證書

      1. 方式1

        1. 瀏覽器訪問域名 https://gitlab.test.helm.xuxiaowei.cn
        2. 按照圖中操作,下載證書,上傳之服務器,用于后期操作
      2. 方式2

        # 下載證書
        openssl s_client -showcerts -connect gitlab.test.helm.xuxiaowei.cn:443 -servername gitlab.test.helm.xuxiaowei.cn < /dev/null 2>/dev/null | openssl x509 -outform PEM > gitlab.test.helm.xuxiaowei.cn.crt
        
    6. 將證書導入到 k8s 中

      # -n=gitlab-test:指定命名空間
      # create configmap etc-gitlab-runner-certs:創建 ConfigMap 名稱是 etc-gitlab-runner-certs
      # --from-file=gitlab.test.helm.xuxiaowei.cn.crt=gitlab.test.helm.xuxiaowei.cn.crt:配置來自文件,文件名 gitlab.test.helm.xuxiaowei.cn.crt,放入 ConfigMap 中的鍵也是 gitlab.test.helm.xuxiaowei.cn.crt
      kubectl -n=gitlab-test create configmap etc-gitlab-runner-certs --from-file=gitlab.test.helm.xuxiaowei.cn.crt=gitlab.test.helm.xuxiaowei.cn.crt# 查看
      # kubectl -n=gitlab-test get configmap etc-gitlab-runner-certs -o yaml
      
    7. 導出 helm 極狐GitLab 配置

      helm -n gitlab-test get values my-gitlab > my-gitlab.yaml
      
    8. 修改 helm 極狐GitLab 配置

      gitlab-runner:# 掛載卷名稱volumeMounts:# 掛載到 pod 路徑(文件/文件夾)# 此處是在容器內運行的 gitlab runner,由于權限限制等原因,# 所以 配置文件不是在 /etc/gitlab-runner/ 目錄下,而是 /home/gitlab-runner/.gitlab-runner/- mountPath: /home/gitlab-runner/.gitlab-runner/certsname: etc-gitlab-runner-certs-volumes# 卷volumes:# 卷類型- configMap:items:# configMap 中的鍵- key: gitlab.test.helm.xuxiaowei.cn.crt# 掛載的路徑path: gitlab.test.helm.xuxiaowei.cn.crtname: etc-gitlab-runner-certs# 配置 ConfigMap 名稱name: etc-gitlab-runner-certs-volumes
      
    9. 更新 helm 極狐GitLab 配置

      helm upgrade -n gitlab-test --install my-gitlab gitlab/gitlab -f my-gitlab.yaml --timeout 600s --version 7.7.0
      
    10. 查看修改結果

      kubectl -n gitlab-test get deployments.apps my-gitlab-gitlab-runner -o yaml
      
      apiVersion: apps/v1
      kind: Deployment
      metadata:annotations:deployment.kubernetes.io/revision: "5"meta.helm.sh/release-name: my-gitlabmeta.helm.sh/release-namespace: gitlab-testcreationTimestamp: "2023-12-22T05:03:46Z"generation: 7labels:app: my-gitlab-gitlab-runnerapp.kubernetes.io/managed-by: Helmchart: gitlab-runner-0.59.2heritage: Helmrelease: my-gitlabname: my-gitlab-gitlab-runnernamespace: gitlab-testresourceVersion: "30086"uid: 8c46c44a-5b67-44ae-90d0-008daa3fa388
      spec:progressDeadlineSeconds: 600replicas: 1revisionHistoryLimit: 10selector:matchLabels:app: my-gitlab-gitlab-runnerstrategy:rollingUpdate:maxSurge: 25%maxUnavailable: 25%type: RollingUpdatetemplate:metadata:annotations:checksum/configmap: f35865354f043583d0903b0a8350830a486eb0e289d18271cf3f533e7d89c5f7checksum/secrets: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855gitlab.com/prometheus_port: "9252"gitlab.com/prometheus_scrape: "true"creationTimestamp: nulllabels:app: my-gitlab-gitlab-runnerchart: gitlab-runner-0.59.2heritage: Helmrelease: my-gitlabspec:containers:- command:- /usr/bin/dumb-init- --- /bin/bash- /configmaps/entrypointenv:- name: CI_SERVER_URLvalue: https://gitlab.test.helm.xuxiaowei.cn- name: RUNNER_EXECUTORvalue: kubernetes- name: REGISTER_LOCKEDvalue: "false"- name: RUNNER_TAG_LIST- name: KUBERNETES_NAMESPACEvalue: gitlab-testimage: registry.gitlab.com/gitlab-org/gitlab-runner:alpine-v16.6.1imagePullPolicy: IfNotPresentlivenessProbe:exec:command:- /bin/bash- /configmaps/check-livefailureThreshold: 3initialDelaySeconds: 60periodSeconds: 10successThreshold: 1timeoutSeconds: 3name: my-gitlab-gitlab-runnerports:- containerPort: 9252name: metricsprotocol: TCPreadinessProbe:exec:command:- /usr/bin/pgrep- gitlab.*runnerfailureThreshold: 3initialDelaySeconds: 10periodSeconds: 10successThreshold: 1timeoutSeconds: 3resources: {}securityContext:allowPrivilegeEscalation: falsecapabilities:drop:- ALLprivileged: falsereadOnlyRootFilesystem: falserunAsNonRoot: trueterminationMessagePath: /dev/termination-logterminationMessagePolicy: FilevolumeMounts:- mountPath: /secretsname: projected-secrets- mountPath: /home/gitlab-runner/.gitlab-runnername: etc-gitlab-runner- mountPath: /configmapsname: configmaps- mountPath: /home/gitlab-runner/.gitlab-runner/certsname: etc-gitlab-runner-certs-volumesdnsPolicy: ClusterFirsthostAliases:- hostnames:- gitlab.test.helm.xuxiaowei.cnip: 172.25.25.32restartPolicy: AlwaysschedulerName: default-schedulersecurityContext:fsGroup: 65533runAsUser: 100serviceAccount: my-gitlab-gitlab-runnerserviceAccountName: my-gitlab-gitlab-runnerterminationGracePeriodSeconds: 3600volumes:- emptyDir:medium: Memoryname: runner-secrets- emptyDir:medium: Memoryname: etc-gitlab-runner- name: projected-secretsprojected:defaultMode: 420sources:- secret:name: my-gitlab-minio-secret- secret:items:- key: runner-registration-tokenpath: runner-registration-token- key: runner-tokenpath: runner-tokenname: my-gitlab-gitlab-runner-secret- configMap:defaultMode: 420name: my-gitlab-gitlab-runnername: configmaps- configMap:defaultMode: 420items:- key: gitlab.test.helm.xuxiaowei.cn.crtpath: gitlab.test.helm.xuxiaowei.cn.crtname: etc-gitlab-runner-certsname: etc-gitlab-runner-certs-volumes
      status:availableReplicas: 1conditions:- lastTransitionTime: "2023-12-22T07:43:25Z"lastUpdateTime: "2023-12-22T07:43:25Z"message: Deployment has minimum availability.reason: MinimumReplicasAvailablestatus: "True"type: Available- lastTransitionTime: "2023-12-22T05:03:46Z"lastUpdateTime: "2023-12-22T07:43:25Z"message: ReplicaSet "my-gitlab-gitlab-runner-597d6d8f7c" has successfully progressed.reason: NewReplicaSetAvailablestatus: "True"type: ProgressingobservedGeneration: 7readyReplicas: 1replicas: 1updatedReplicas: 1
      
    11. 查看 gitlab runner 日志

      [root@anolis-7-9 ~]# kubectl -n gitlab-test get pod | grep gitlab-runner
      my-gitlab-gitlab-runner-597d6d8f7c-8v466             1/1     Running     0              5m52s
      [root@anolis-7-9 ~]#
      

      根據日志判斷,已經注冊成功了

      [root@anolis-7-9 ~]# kubectl -n gitlab-test logs -f my-gitlab-gitlab-runner-597d6d8f7c-8v466
      Registration attempt 1 of 30
      Runtime platform                                    arch=amd64 os=linux pid=16 revision=f5da3c5a version=16.6.1
      WARNING: Running in user-mode.                     
      WARNING: The user-mode requires you to manually start builds processing:
      WARNING: $ gitlab-runner run                       
      WARNING: Use sudo for system-mode:                 
      WARNING: $ sudo gitlab-runner...Created missing unique system ID                    system_id=r_3WsywNzJqRud
      Merging configuration from template file "/configmaps/config.template.toml"
      WARNING: Support for registration tokens and runner parameters in the 'register' command has been deprecated in GitLab Runner 15.6 and will be replaced with support for authentication tokens. For more information, see https://docs.gitlab.com/ee/ci/runners/new_creation_workflow
      Registering runner... succeeded                     runner=BtGwLEwc
      Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!Configuration (with the authentication token) was saved in "/home/gitlab-runner/.gitlab-runner/config.toml"
      Runtime platform                                    arch=amd64 os=linux pid=7 revision=f5da3c5a version=16.6.1
      Starting multi-runner from /home/gitlab-runner/.gitlab-runner/config.toml...  builds=0 max_builds=0
      WARNING: Running in user-mode.                     
      WARNING: Use sudo for system-mode:                 
      WARNING: $ sudo gitlab-runner...There might be a problem with your config based on jsonschema annotations in common/config.go (experimental feature):
      jsonschema: '/runners/0/kubernetes/pull_policy' does not validate with https://gitlab.com/gitlab-org/gitlab-runner/common/config#/$ref/properties/runners/items/$ref/properties/kubernetes/$ref/properties/pull_policy/$ref/type: expected array, but got nullConfiguration loaded                                builds=0 max_builds=10
      listen_address not defined, metrics & debug endpoints disabled  builds=0 max_builds=10
      [session_server].listen_address not defined, session endpoints disabled  builds=0 max_builds=10
      Initializing executor providers                     builds=0 max_builds=10
      ^C
      [root@anolis-7-9 ~]#
      
    12. 管理員訪問 https://gitlab.test.helm.xuxiaowei.cn/admin/runners 可以看到 pod my-gitlab-gitlab-runner-597d6d8f7c-8v466 已經注冊成了

      1. 如果存在極狐 GitLab Runner Pod 被刪除(故障轉譯、手動刪除等等),這里可能會存在不可用的 Runner

  2. 問題2: tls: failed to verify certificate: x509: certificate is valid for ingress.local, not gitlab.test.helm.xuxiaowei.cn

    1. 訪問的域名與使用的證書補匹配,可通過更換證書、域名來解決此問題(一般情況是更換證書)

    2. 如果要更換證書:

      1. 證書屬于正規機構頒發的(如:上述各大云廠商的證書),請看下方方案2
      2. 如果是自己生成的證書(不受信任),請看下方方案2,并結合上方問題1來解決此問題

方案2:配置正規機構頒發的證書(如:上述各大云廠商的證書),一般無需在 gitlab 配置信任證書,即可正常使用

  1. 正常情況

    1. 要求證書與域名對應
    2. 將證書上傳至服務器,解壓,使用證書文件創建 k8s TLS Secret
    3. 修改 極狐GitLab 配置,使用 上述步驟創建的 k8s TLS Secret
  2. 異常情況:正規機構頒發的證書,在極狐 GitLab Runner 中依然無法正常使用,但是在瀏覽器中可以正常使用

    1. 原因是頒發機構的根證書不在極狐 GitLab Runner 的信任列表中,需要手動添加信任(例如:常見的 Windows 較低版本運行一些軟件時,也是無法執行,顯示證書無法識別,需要在 Windows 導入軟件簽名所使用的證書鏈)

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/713299.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/713299.shtml
英文地址,請注明出處:http://en.pswp.cn/news/713299.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

TG-ADMIN 權限管理系統

項目簡介 該項目是一款基于 SpringBoot + Vue2 + Jwt + ElementUi的 RBAC模型管理系統。 主要以自定義攔截器和jwt結合進行權限驗證 通過自定義指令實現按鈕級別權限,使用經典的RBAC模型 什么是RBAC? 1、RBAC模型概述 RBAC模型(Role-Based Access Control:基于角色的…

Go語言語法基礎入門

目錄 一、開篇二、環境與配置三、Hello, World!四、變量與類型五、條件語句六、循環語句七、函數八、數組與切片九、結構體十、錯誤處理十一、結語 一、開篇 Go語言&#xff0c;作為近年來備受矚目的編程語言&#xff0c;以其高效、簡潔和強大的并發處理能力贏得了眾多開發者的…

面試數據庫篇(mysql)- 03MYSQL支持的存儲引擎有哪些, 有什么區別

存儲引擎就是存儲數據、建立索引、更新/查詢數據等技術的實現方式 。存儲引擎是基于表的&#xff0c;而不是基于庫的&#xff0c;所以存儲引擎也可被稱為表類型。 MySQL體系結構 連接層服務層引擎層存儲層 存儲引擎特點 InnoDB MYSQL支持的存儲引擎有哪些, 有什么區別 ? my…

nginx使用詳解--流控

Nginx可以通過實現流量控制&#xff08;流控&#xff09;來限制對服務器的訪問并保護其免受過載的影響&#xff0c;限流有以下幾種&#xff1a; 正常限制訪問頻率&#xff08;正常流量&#xff09; 突發限制訪問頻率&#xff08;突發流量&#xff09; 限制并發連接數 黑白名單配…

【QT+QGIS跨平臺編譯】之六十:【QGIS_CORE跨平臺編譯】—【錯誤處理:TEST_DATA_DIR】

文章目錄 一、TEST_DATA_DIR宏定義二、解決辦法2.1 方法一2.2 方法二一、TEST_DATA_DIR宏定義 代碼中較多地方引用了TEST_DATA_DIR 但是沒有對其進行定義。 下載的QGIS的目錄 qgis-3.22.8\tests\testdata 有對應的數據資源。 二、解決辦法 2.1 方法一 在 pro 文件的預定義項…

疊氮生物素,Biotin-azide ,含有生物素基團和疊氮基團

您好&#xff0c;歡迎來到新研之家 文章關鍵詞&#xff1a;生物素-疊氮&#xff0c;生物素疊氮&#xff0c;疊氮生物素&#xff0c;Biotin-azide &#xff0c;Azide-Biotin&#xff0c;Biotin-N3&#xff0c;N3-Biotin&#xff0c;908007-17-0 一、基本信息 【產品簡介】&a…

jax可微分編程的筆記(9)

jax可微分編程的筆記(9) 第九章 案例:FAST主動反射面的形態調整 深度學習是可微分編程框架下的一個極為重要的使用場景。 模型&#xff0c;損失函數及優化算法是常見優化問題的3個組成部分。 其概念的外延并不僅僅局限于深度學習。優化問題中的模型 除了神經網絡&#xff0c;…

Tomcat部署及多實例

一、Tomcat簡介 1、簡介 Tomcat 服務器是一個免費的開放源代碼的Web 應用服務器&#xff0c;屬于輕量級應用服務器&#xff0c;在中小型系統和并發訪問用戶不是很多的場合下被普遍使用&#xff0c;是開發和調試JSP 程序的首選。 當在一臺機器上配置好Apache 服務器&#xff0c…

java 基礎上(1)(核心知識搭配代碼)

前言 java的學習分為了上部分以及下部分進行學習&#xff0c;上部分就是對于java的基礎知識&#xff0c;面向對象上&#xff0c;面向對象下&#xff0c;異常操作&#xff0c;javaApi&#xff1b;下部主要是集合&#xff0c;泛型&#xff0c;反射&#xff0c;IO流&#xff0c;J…

BP 神經網絡原理

BP (Back Propagation) 神經網絡是1986年由 Rumelhart 和 McClelland 為首的科學家提出的概念&#xff0c;是一種按照誤差逆向傳播算法訓練的多層前饋神經網絡&#xff0c;是應用最廣泛的神經網絡。 1 BP 神經網絡的結構和傳播規則 BP神經網絡由 輸入層、隱含層&#xff08;也…

【開源】JAVA+Vue.js實現天沐瑜伽館管理系統

目錄 一、摘要1.1 項目介紹1.2 項目錄屏 二、功能模塊2.1 數據中心模塊2.2 瑜伽課程模塊2.3 課程預約模塊2.4 系統公告模塊2.5 課程評價模塊2.6 瑜伽器械模塊 三、系統設計3.1 實體類設計3.1.1 瑜伽課程3.1.2 瑜伽課程預約3.1.3 系統公告3.1.4 瑜伽課程評價 3.2 數據庫設計3.2.…

Qt-QThread與QProcess 線程與進程介紹、對比與使用

目錄 1 線程與進程的區別與聯系1.1 進程定義1.2 線程定義1.3 線程與進程的區別1.4 線程與進程的聯系2 QThread2.1 序言2.2 成員函數2.3 使用流程2.4 注意事項3 QProcess參考鏈接1 線程與進程的區別與聯系 線程和進程是操作系統中兩個重要的概念,它們在計算機系統中扮演著不同…

Java基于微信小程序的房屋租賃、租房小程序,附源碼

博主介紹&#xff1a;?程序員徐師兄、7年大廠程序員經歷。全網粉絲12w、csdn博客專家、掘金/華為云/阿里云/InfoQ等平臺優質作者、專注于Java技術領域和畢業項目實戰? &#x1f345;文末獲取源碼聯系&#x1f345; &#x1f447;&#x1f3fb; 精彩專欄推薦訂閱&#x1f447;…

邏輯漏洞(pikachu)

#水平&#xff0c;垂直越權&#xff0c;未授權訪問 通過個更換某個id之類的身份標識&#xff0c;從而使A賬號獲取&#xff08;修改、刪除&#xff09;B賬號數據 使用低權限身份的賬號&#xff0c;發送高權限賬號才能有的請求&#xff0c;獲得其高權限操作 通過刪除請求中的認…

cocos2d-lua:骨骼動畫的使用

骨骼動畫的使用 spine骨骼動畫的使用Armature骨骼動畫 spine骨骼動畫的使用 -- spine骨骼動畫導出的文件為&#xff1a;xxx.atlas&#xff0c;xxx.json&#xff0c;xxx.png 三個文件需同時存在 local spine sp.SkeletonAnimation:create("xxx.json", "xxx.atl…

消息隊列+更新DB極易引發的DB并發修改bug

背景 我們在生產系統中和其他系統進行交互時一般都會通過消息隊列來解耦生產者和消費者&#xff0c;然后通過每個使用方消費消息隊列的消息的方式來完成消息的消費&#xff0c;并且一般來說我們消費消息后極有可能會操作DB&#xff0c;不過這種方式如果處理不夠仔細&#xff0…

spark sql 轉換字符串數組成多列結構

背景 在平時使用spark sql分析數據時&#xff0c;特別是分析從mysql的表入倉的hive表時&#xff0c;我們會經常和字符串數組的列打交道&#xff0c;而且這種情況下我們一般都需要把一行字符串數組的行數據轉成多列的形式&#xff0c;我們看下怎么寫這個sql spark sql 轉換字符…

《More Effective C++》- 極精簡版 11-20條

本文章屬于專欄《業界Cpp進階建議整理》 繼續上一篇《More Effective C》- 極精簡版 1-10條。本章我會繼續講解我對11-20條的極精簡的理解。 11、不要讓destructor的異常流出 先保障不會拋出異常&#xff0c;如果不能&#xff0c;就使用try catch&#xff0c;這里的注意catch里…

計算機網絡(2)-----數據鏈路層

目錄 一.數據鏈路層的基本概念 二.數據鏈路層的功能概述 功能一:為網絡層提供服務。無確認無連接服務&#xff0c;有確認無連接服務&#xff0c;有確認面向連接服務。 功能二:鏈路管理&#xff0c;即連接的建立、維持、釋放(用于面向連接的服務)。 功能三:組幀 透明傳輸:…

ESU毅速丨不銹鋼材料為什么在金屬3D打印中的廣泛應用

不銹鋼是一種傳統且常見的材料&#xff0c;在金屬3D打印領域應用最廣。那么&#xff0c;為何不銹鋼材料在3D打印中如此受歡迎呢&#xff1f;以下是幾個關鍵原因。 卓越的工藝適應性 金屬3D打印技術&#xff0c;如直接金屬激光燒結&#xff08;DMLS&#xff09;和選擇性激光熔融…