【智簡聯接,萬物互聯】華為云·云享專家董昕:Serverless和微服務下, IoT的變革蓄勢待發
875
2025-04-04
五 本地運行
在開發中本地運行 Velero
在本地運行 Velero 服務器可以加速迭代開發。這樣就無需在每次更改時重建 Velero 服務器映像并將其重新部署到集群中。
5.1 使用遠程集群在本地運行 Velero
Velero 以 Kubernetes API 服務器作為端點(根據 kubeconfig 配置)運行,因此 Velero 服務器和客戶機使用相同的客戶機-go 與 Kubernetes 進行通信。這意味著 Velero 服務器可以像在遠程集群中運行一樣在本地運行。
5.2 先決條件
在運行 Velero 時,您需要確保設置以下所有權限:
從源集群和名稱空間讀取所有數據的訪問權限
對來自源集群和命名空間的所有數據的讀取權限
寫訪問目標集群和命名空間
寫訪問目標集群和命名空間
對卷的讀/寫訪問
對備份數據的對象存儲進行讀/寫訪問
BackupStorageLocationVelero 服務器的對象定義
可選VolumeSnapshotLocation Velero 服務器的對象定義,用于拍攝 PV 快照
5.3 步驟
5.3.1 安裝velero
請參閱有關如何在某些特定提供商中安裝 Velero 的文檔:Install overview
5.3.2 將部署規模縮小到零
使用 velero install 命令將 Velero 安裝到集群中后,您將 Velero 部署縮小到 0,這樣它就不會同時在遠程集群上運行,并可能導致事情不同步:
kubectl scale --replicas=0 deployment velero -n velero
5.3.3 在本地啟動Velero服務器
要在本地運行服務器,請根據所需的二進制文件使用完整路徑。例如,如果您使用 Mac,并使用 AWS 作為提供程序,下面是如何使用完整路徑運行從源代碼構建的二進制文件: AWS_SHARED_CREDENTIALS_FILE=
啟動服務器:velero 服務器 [CLI 標志]。以下 CLI 標志可能有助于自定義,但請參閱 velero server --help 以獲取完整詳細信息:
–log-level:設置 Velero 服務器的日志級別(默認信息,使用 debug 進行最多的日志記錄)
–kubeconfig:設置 Velero 服務器用來與 Kubernetes apiserver 通信的 kubeconfig 文件的路徑(默認為 $ KUBECONFIG)
–namespace:Velero 服務器應在其中查找備份、計劃、恢復的集合命名空間(默認 velero)
–plugin-dir:設置Velero服務器查找插件的目錄(默認/plugins)
–plugin-dir 標志要求插件二進制文件存在于本地,并應設置為包含此構建二進制文件的目錄。
–metrics-address:設置暴露 Prometheus 指標的綁定地址和端口(默認:8085)
六 代碼標準
6.1 打卡一個pr
當開啟拉取請求時,請填寫提供模板的清單。這將幫助其他人正確地分類和審查您的拉請求。
6.2 添加更新日志
velero/changelogs/unreleased <- folder 000-username <- file
將其添加到 PR 中。
如果 PR 不保證更改日志,則可以通過在 PR 上應用 changelog-not-required 標簽來跳過對更改日志的 CI 檢查。
6.3 版權頭部
6.4 代碼
日志消息大寫。
錯誤消息保持小寫。
僅對從非 velero 代碼直接返回的錯誤(例如對 Kubernetes 服務器的 API 調用)包裝/添加堆棧。
errors.WithStack(err)
更喜歡使用 Kubernetes 包集中的實用程序。
k8s.io/apimachinery/pkg/util/sets
6.5 導包
對于導入,我們使用以下約定:
Example
import ( corev1api "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" corev1client "k8s.io/client-go/kubernetes/typed/core/v1" corev1listers "k8s.io/client-go/listers/core/v1" velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" velerov1client "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" )
6.6 Mocks
我們使用一個包來為我們的接口生成模擬。
示例:如果你想改變這個模擬:https://github.com/vmware-tanzu/velero/blob/v1.5.1/pkg/restic/mocks/restorer.go
運行:
go get github.com/vektra/mockery/.../ cd pkg/restic mockery -name=Restorer
可能需要運行 make update 來更新導入。
6.7 Kubernetes 標簽
在生成標簽值時,請確保將它們傳遞到標簽中。GetValidName () helper 函數。這將有助于確保值是要存儲和查詢的適當長度和格式。一般來說,uid 作為標簽值持久存在是安全的。此函數與沒有限制的注釋值無關。
6.8 DCO Sign off
要在你的作品上簽名,只需要在提交消息的末尾加上這樣一行:
Signed-off-by: Joe Beda
這可以通過 git commit 的 --signoff 選項輕松完成。
通過這樣做,您聲明您可以證明以下內容:(from https://developercertificate.org/):
Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 1 Letterman Drive Suite D4700 San Francisco, CA, 94129 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.
六 網站引導
6.1 本地運行
對網站進行更改時,請在提交 PR 之前在本地運行該網站并手動驗證您的更改。 在項目的根目錄,運行:
make serve-docs
這會在容器中運行所有 Hugo 依賴項。 或者,為了快速加載網站,在 velero/site/ 目錄下運行:
hugo serve
有關如何在本地運行網站的更多信息,請參閱我們的 Hugo documentation。
6.2 添加博客文章
要添加博客文章,請在 /site/content/posts/ 文件夾中創建一個新的 Markdown (.MD) 文件。一篇博客文章需要以下前言。
title: "Title of the blog" excerpt: Brief summary of thee blog post that appears as a preview on velero.io/blogs author_name: Jane Smith slug: URL-For-Blog # Use different categories that apply to your blog. This is used to connect related blogs on the site categories: ['velero','release'] # Image to use for blog. The path is relative to the site/static/ folder image: /img/posts/example-image.jpg # Tag should match author to drive author pages. Tags can have multiple values. tags: ['Velero Team', 'Nolan Brubaker']
理想情況下,每個博客都有一個獨特的圖像可以在博客主頁上使用,但如果您不包含圖像,則將使用默認的 Velero 徽標。使用小于 70KB 的圖像并將其添加到 /site/static/img/posts 文件夾。
七 文檔風格
參考:https://velero.io/docs/v1.5/style-guide/
參考鏈接
https://github.com/tilt-dev/tilt
https://tilt.dev/
https://velero.io/docs/v1.5/tilt/
Kubernetes 網站
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。