如何啟動極狐GitLab 靜態網站Pages功能

极狐GitLab發表於2024-03-26

本文作者:徐曉偉

GitLab 是一個全球知名的一體化 DevOps 平臺,很多人都透過私有化部署 GitLab 來進行原始碼託管。極狐GitLab GitLab 在中國的發行版,專門為中國程式設計師服務。可以一鍵式部署極狐GitLab。

本文主要講述瞭如何使用極狐GitLab 啟用靜態網站,用於展示文件、演示產品、釋出部落格等。

說明

  1. 預設沒有啟用 Pages 功能,管理員可以從儀表盤檢視是否開啟
    file
  2. 或者在專案左側找不到 Pages 導航欄(不同 GitLab 版本導航欄可能會有區別,早期版本可能會存在與專案設定中)
    file

啟用 Pages 功能

  1. 匯出 helm gitlab 配置

    # 將已配置的值匯出到檔案中
    helm -n gitlab-test get values my-gitlab > my-gitlab.yaml
    
  2. 更新配置

    helm upgrade -n gitlab-test --install my-gitlab gitlab/gitlab --timeout 600s -f my-gitlab.yaml --set global.pages.enabled=true --version 7.7.0
    
  3. 等待所有 pod 更新完成

    [root@anolis-7-9 ~]# kubectl -n gitlab-test get pod -o wide
    NAME                                                 READY   STATUS      RESTARTS       AGE     IP                NODE         NOMINATED NODE   READINESS GATES
    cm-acme-http-solver-2ldtp                            1/1     Running     12 (20m ago)   36h     192.168.210.254   anolis-7-9   <none>           <none>
    cm-acme-http-solver-94dv5                            1/1     Running     12 (20m ago)   36h     192.168.210.241   anolis-7-9   <none>           <none>
    cm-acme-http-solver-klkpz                            1/1     Running     12 (20m ago)   36h     192.168.210.214   anolis-7-9   <none>           <none>
    my-gitlab-certmanager-8457bfdc8-w858k                1/1     Running     12 (20m ago)   36h     192.168.240.111   anolis-7-7   <none>           <none>
    my-gitlab-certmanager-cainjector-74df787cf4-j7cfc    1/1     Running     12 (20m ago)   36h     192.168.240.122   anolis-7-7   <none>           <none>
    my-gitlab-certmanager-webhook-7b86db4c96-dhcxl       1/1     Running     12 (20m ago)   36h     192.168.240.101   anolis-7-7   <none>           <none>
    my-gitlab-gitaly-0                                   1/1     Running     12 (20m ago)   35h     192.168.210.253   anolis-7-9   <none>           <none>
    my-gitlab-gitlab-exporter-55dcfcb595-gl6nm           1/1     Running     12 (20m ago)   36h     192.168.210.237   anolis-7-9   <none>           <none>
    my-gitlab-gitlab-pages-7bbbff4f8b-99v8j              1/1     Running     0              6m2s    192.168.240.77    anolis-7-7   <none>           <none>
    my-gitlab-gitlab-runner-5f6ff5994c-wdw5l             1/1     Running     1 (20m ago)    156m    192.168.210.255   anolis-7-9   <none>           <none>
    my-gitlab-gitlab-shell-55fdc9cb9f-52gnr              1/1     Running     12 (20m ago)   35h     192.168.240.79    anolis-7-7   <none>           <none>
    my-gitlab-gitlab-shell-55fdc9cb9f-cfhsh              1/1     Running     12 (20m ago)   36h     192.168.210.194   anolis-7-9   <none>           <none>
    my-gitlab-issuer-31-tj7rc                            0/1     Completed   0              6m1s    192.168.240.118   anolis-7-7   <none>           <none>
    my-gitlab-kas-688dc97ddd-28gr7                       1/1     Running     36 (19m ago)   35h     192.168.240.88    anolis-7-7   <none>           <none>
    my-gitlab-kas-688dc97ddd-tvkvd                       1/1     Running     41 (19m ago)   36h     192.168.210.196   anolis-7-9   <none>           <none>
    my-gitlab-migrations-31-xzstj                        0/1     Completed   0              6m1s    192.168.240.71    anolis-7-7   <none>           <none>
    my-gitlab-minio-66f584f746-t6qwb                     1/1     Running     4 (20m ago)    27h     192.168.210.203   anolis-7-9   <none>           <none>
    my-gitlab-minio-create-buckets-31-l5cgh              0/1     Completed   0              6m1s    192.168.240.66    anolis-7-7   <none>           <none>
    my-gitlab-nginx-ingress-controller-6bdd56c45-ch57n   1/1     Running     12 (20m ago)   36h     192.168.240.114   anolis-7-7   <none>           <none>
    my-gitlab-nginx-ingress-controller-6bdd56c45-cm2lz   1/1     Running     12 (20m ago)   36h     192.168.210.193   anolis-7-9   <none>           <none>
    my-gitlab-postgresql-0                               2/2     Running     24 (20m ago)   35h     192.168.210.219   anolis-7-9   <none>           <none>
    my-gitlab-prometheus-server-646489c599-8mgc9         2/2     Running     24 (20m ago)   35h     192.168.210.248   anolis-7-9   <none>           <none>
    my-gitlab-redis-master-0                             2/2     Running     24 (20m ago)   35h     192.168.210.198   anolis-7-9   <none>           <none>
    my-gitlab-registry-78fc549f8d-d2zjv                  1/1     Running     12 (20m ago)   35h     192.168.240.78    anolis-7-7   <none>           <none>
    my-gitlab-registry-78fc549f8d-xbkvh                  1/1     Running     12 (20m ago)   36h     192.168.210.243   anolis-7-9   <none>           <none>
    my-gitlab-sidekiq-all-in-1-v2-7579854cff-f8pwx       1/1     Running     0              6m2s    192.168.210.199   anolis-7-9   <none>           <none>
    my-gitlab-toolbox-686c4fb549-7lrwl                   1/1     Running     0              5m31s   192.168.240.69    anolis-7-7   <none>           <none>
    my-gitlab-webservice-default-6fc5498c85-2tggm        2/2     Running     0              3m19s   192.168.240.73    anolis-7-7   <none>           <none>
    my-gitlab-webservice-default-6fc5498c85-7v9fp        2/2     Running     0              6m2s    192.168.240.81    anolis-7-7   <none>           <none>
    [root@anolis-7-9 ~]# 
    
  4. 檢視 儀表盤

    預設 webservice-default Deployment 只有兩個副本,請等待 webservice-default Deployment 恢復正常副本數後再檢視, 否則頁面資料在每次重新整理可能結果不同
    file

  5. 檢視專案
    file

  6. 部署 Pages,專案:https://framagit.org/xuxiaowei-com-cn/my-vue-app

    請注意:流水線作業(job)名稱必須是 pages,否則無法觸發
    file
    file

  7. 訪問結果

    注意:域名解析
    file

更多關於極狐GitLab 的最佳實踐,請搜尋關注【極狐GitLab】公眾號或者登入極狐GitLab 官網 https://gitlab.cn 進行學習。

號外號外!
極狐GitLab 正在推出DevSecOps 成熟度測評!連結:https://gitlab.cn/devsecops-assessment/ 測評非常全面並提供了可靠建議,即使不付費買產品,對自己想要落地 DevSecOps 的使用者具有很高的參考意義!快來動手試試吧!

相關文章