Razee 是一個由 IBM 開發的開源項目,用於自動化和管理跨集群、環境和雲端提供者的 Kubernetes 資源部署,並可視化資源的部署信息,以便您可以監控部署過程並查找部署問題更快。
請參閱以下連結開始使用 Razee:
請參閱 Razee 的主要功能以及如何利用它們來管理叢集的 Kubernetes 資源部署。
Razee 由 RazeeDash、RazeeDeployables 和 RazeeDeploy 三個模組組成,這些模組鬆散耦合且可以獨立使用。透過 RazeeDash,您可以動態建立 Kubernetes 資源的即時清單,並使用強大的過濾器和警報功能來視覺化設定資訊並更快地解決部署過程中的問題。 RazeeDeploy 元件旨在透過模板化 Kubernetes 資源、對資源和叢集進行分組以及為這些分組定義規則來簡化多叢集部署,以便您可以建立跨叢集、環境和雲端實施的靈活配置。
成分 | 描述 |
---|---|
守望者 | Watch Keeper 負責檢索 Kubernetes 資源的設定資訊並將該資料傳送到 RazeeDash API。要使用 Watch Keeper,只需在叢集中安裝此元件並將razee/watch-resource 標籤新增至您要監控的所有資源即可。新增標籤後,Watch Keeper 會從 Kubernetes API 伺服器檢索設定訊息,並立即將此資料傳送到 RazeeDash API。這個過程每小時重複一次。此外,Watch Keeper 會為您的資源新增 Kubernetes 事件觀察程序,以便當您的資源配置發生變更時,Kubernetes 會通知 Watch Keeper。 |
RazeeDash API | RazeeDash API 是一項從 Watch Keeper 接收 Kubernetes 資源配置和資源定義的服務。傳送到 RazeeDash API 的資料會自動儲存在 MongoDB 中。 |
拉茲達什 | RazeeDash 視覺化 Watch Keeper 檢索到的數據,並動態建立叢集中 Kubernetes 資源的清單。您可以使用智慧篩選和警報功能來分析這些資料並快速識別和解決部署過程中的問題。 |
集群訂閱 | ClusterSubscription 是 Razee 部署,用於監視 Razee 中的訂閱以檢查叢集的活動訂閱是否存在。如果找到訂閱,則會從 Razee 中提取關聯版本的 Kubernetes 資源並自動套用到叢集中。 |
成分 | 描述 |
---|---|
Razee部署核心 | RazeeDeploy Core 是一個在叢集中運行的持續交付工具,您可以使用它來設定 RazeeDeploy 元件的CustomResourceDefinitions (CRD)、Kubernetes 控制器和相依性。 |
RazeeDeploy Delta | RazeeDeploy Delta 是 RazeeDeploy Core 的元件,它在叢集中運行,並使 RazeeDeploy 元件的自訂資源定義和 Kubernetes 控制器保持最新。 |
遠端資源和遠端資源 S3 | RemoteResource 和 RemoteResourceS3 是自訂資源定義和控制器,可用於自動部署儲存在來源儲存庫中的 Kubernetes 資源。每次進行更新時,無需在每個叢集、環境或跨雲端中手動套用這些 YAML 文件,只需在遠端資源中定義來源儲存庫並在叢集中建立遠端資源即可。遠端資源控制器自動連接到您的來源儲存庫,下載 Kubernetes 設定檔並將該檔案套用到您的叢集。 |
小鬍子模板 | MustacheTemplate 是一個自訂資源定義和控制器,用於定義環境變量,可用於替換其他 Kubernetes YAML 檔案中的 YAML 檔案片段。例如,使用 Mustache 範本的環境變數來建立遠端資源的 URL,以便您可以指向要部署的應用程式版本。 |
特徵標誌集LD | FeatureFlagSetLD 是一個自訂資源定義和控制器,用於自動從 Launch Darkly 擷取功能標誌值。透過功能標誌,您可以控制將哪些程式碼部署到集群,並跨集群、環境或雲端管理多個版本的 Kubernetes 資源。 |
管理集 | ManagedSet 是一個自訂資源定義和控制器,用於將要建立的 Kubernetes 資源分組並同時套用於叢集。 |
Kubernetes 實用程式 | Kubernetes 實用程式是一個npm 包,可用於簡化與 Kubernetes 的通訊。 |
要在叢集中部署 Razee,您的叢集必須滿足以下要求:
首先透過執行以下指令在叢集中安裝 razeedeploy-delta:
kubectl apply -f https://github.com/razee-io/Razee/releases/latest/download/razeedeploy.yaml
輸出範例:
namespace/razeedeploy created
serviceaccount/razeedeploy-sa created
clusterrole.rbac.authorization.k8s.io/razeedeploy-admin-cr configured
clusterrolebinding.rbac.authorization.k8s.io/razeedeploy-rb configured
job.batch/razeedeploy-job created
kubectl get deploy -n razeedeploy
NAME READY UP-TO-DATE AVAILABLE AGE
remoteresource-controller 1/1 1 1 56s
在叢集中安裝 RazeeDash 元件。若要儲存傳送到 RazeeDash API 的數據,您必須設定 MongoDB 實例。您可以選擇使用提供的razeedash-all-in-one.yaml
檔案來設定 RazeeDash 和單一 MongoDB 實例,或使用叢集中執行的現有 MongoDB 實例來設定 RazeeDash。注意:如果您的某個叢集中已經有正在執行的 RazeeDash 實例,而只想將另一個叢集新增至清單清單中,則可以跳過此步驟並繼續在叢集中安裝 Watchkeeper 元件。
要安裝 RazeeDash 和單一 MongoDB 實例:
kubectl apply -f https://github.com/razee-io/Razee/releases/latest/download/razeedash-all-in-one.yaml
輸出範例:
persistentvolume/mongo-pv-volume created
persistentvolumeclaim/mongo-pv-claim created
deployment.apps/mongo created
service/mongo created
secret/razeedash-secret created
remoteresource.deploy.razee.io/razeedash created
service/razeedash-lb created
service/razeedash-api-lb created
要使用現有的 MongoDB 實例:
為 mongo_url 建立 razeedash 金鑰。將下面的命令替換為實際的使用者名稱和密碼以及 mongo-0、mongo-1 和 mongo-3 的 3 個主機實例以及正確的連接埠。確保 mongo URL 的末尾有/razeedash?ssl=true
。
例 :
kubectl -n razee create secret generic razeedash-secret --from-literal " mongo_url=mongodb://username:password@mongo‑0:27017,mongo‑1:27017,mongo‑2:27017/razeedash?ssl=true "
kubectl apply -f https://github.com/razee-io/Razee/releases/latest/download/razeedash.yaml
等待razeedash-api
部署完成。如果您選擇使用上一個步驟中提供的razeedash-all-in-one.yaml
檔案建立 RazeeDash,則會在叢集中建立 MongoDB 實例並連接到 RazeeDash API 實例。 MongoDB 的設定需要幾分鐘才能完成,並且可能會導致 RazeeDash API 部署中出現間歇性MongoNetworkError
錯誤。當 MongoDB 完全設定完畢後,Kubernetes 會自動完成 RazeeDash API 實例的設定。
kubectl logs deploy/razeedash-api -n razee
如果 MongoDB 尚未設置,則輸出範例:
> [email protected] start /usr/src
> node app/index.js
(node:16) UnhandledPromiseRejectionWarning: MongoNetworkError: getaddrinfo
ENOTFOUND mongo
at Socket. < anonymous > (/usr/src/node_modules/mongodb-core/lib/connection/connect.js:287:16)
at Object.onceWrapper (events.js:284:20)
at Socket.emit (events.js:196:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at processTicksAndRejections (internal/process/task_queues.js:84:9)
(node:16) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch (). (rejection id: 1)
(node:16) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
RazeeDash API 完全設定後的輸出範例:
> [email protected] start /usr/src
> node app/index.js
{ " name " : " apollo/subscription " , " parseUA " :false, " excludes " :[ " referer " , " url " , " body " , " short-body " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " Apollo streaming servic e is configured on redisUrl: redis://redis-service:6379/0 " , " time " : " 2020-06-03T21:57:16.021Z " , " v " :0}
{ " name " : " apollo/subscription " , " parseUA " :false, " excludes " :[ " referer " , " url " , " body " , " short-body " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " Apollo streaming is ena bled on redis endpoint redis-service:6379 " , " time " : " 2020-06-03T21:57:17.062Z " , " v " :0}
{ " name " : " / " , " parseUA " :false, " excludes " :[ " referer " , " url " , " body " , " short-body " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " Created new collection users index users " , " time " : " 2020-06-03T21:57:17.222Z " , " v " :0}
{ " name " : " / " , " parseUA " :false, " excludes " :[ " referer " , " url " , " body " , " short-body " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " Created new View clusterStatsView " , " time " : " 2020-06-03T21:57:17.239Z " , " v " :0}
{ " name " : " / " , " parseUA " :false, " excludes " :[ " referer " , " url " , " body " , " short-body " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " Created new View resourceStatsView " , " time " : " 2020-06-03T21:57:17.241Z " , " v " :0}
{ " name " : " apollo/models " , " parseUA " :false, " excludes " :[ " referer " , " url " , " body " , " short-body " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " SetupDistributedCollections r eceived modelName=resources for DB mongodb://mongo:27017/razeedash " , " time " : " 2020-06-03T21:57:17.284Z " , " v " :0}
{ " name " : " apollo/models " , " parseUA " :false, " excludes " :[ " referer " , " url " , " body " , " short-body " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " SetupDistributedCollections r eceived modelName=orgs for DB mongodb://mongo:27017/razeedash " , " time " : " 2020-06-03T21:57:17.295Z " , " v " :0}
{ " name " : " apollo/models " , " parseUA " :false, " excludes " :[ " referer " , " url " , " body " , " short-body " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " SetupDistributedCollections:c lusters - received modelName=clusters for DB mongodb://mongo:27017/razeedash " , " time " : " 2020-06-03T21:57:17.297Z " , " v " :0}
{ " name " : " apollo " , " parseUA " :false, " excludes " :[ " referer " , " url " , " short-body " , " user-agent " , " req " , " res " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " Initialize apollo application for default auth " , " time " : " 2020-06-03T21:57:17.298Z " , " v " :0}
{ " name " : " apollo " , " parseUA " :false, " excludes " :[ " referer " , " url " , " short-body " , " user-agent " , " req " , " res " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " [] Apollo server c ustom plugin are loaded. " , " time " : " 2020-06-03T21:57:17.299Z " , " v " :0}
{ " name " : " razeedash-api " , " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " ? razeedash-api listening on port 3333/api " , " time " : " 2020-06-03T21:57:17.723Z " , " v " :0}
{ " name " : " apollo " , " parseUA " :false, " excludes " :[ " referer " , " url " , " short-body " , " user-agent " , " req " , " res " ], " hostname " : " razeedash-api-7bd66669b7-jj2vj " , " pid " :17, " level " :30, " msg " : " ? Apollo server listening on http://[::]:3333/graphql " , " time " : " 2020-06-03T21:57:17.734Z " , " v " :0}
檢索在 RazeeDash API 設定期間自動建立的razeedash-lb
和razeedash-api-lb
負載平衡器服務的外部 IP 位址。 razeedash-lb
充當 RazeeDash 實例的公共端點, razeedash-api-lb
充當 RazeeDash API 實例的公共端點。透過使用指派的公用 IP 位址,您可以建立用於存取 RazeeDash 和 RazeeDash API 元件的公用 URL。要完成 RazeeDash 的設置,這兩個 URL 必須儲存在 RazeeDash 配置映射中。使用下列 Bash 命令檢索公用 IP 位址、建立公用 URL 並將 URL 儲存在 RazeeDash 設定映射中。您也可以執行 Bash 腳本bin/kc_create_razeedash_config.sh
。請注意,您必須在 RazeeDash 配置映射中的root_url
和razeedash_api_url
末尾添加尾隨/
。
# Amazon EKS uses host names, IBM Cloud Kubernetes Service uses Ingress IP addresses. This handle both.
RAZEEDASH_LB_IP= $( kubectl get service razeedash-lb -n razee -o jsonpath= " {.status.loadBalancer.ingress[*].ip} " )
RAZEEDASH_API_LB_IP= $( kubectl get service razeedash-api-lb -n razee -o jsonpath= " {.status.loadBalancer.ingress[*].ip} " )
RAZEEDASH_LB_HOSTNAME= $( kubectl get service razeedash-lb -n razee -o jsonpath= " {.status.loadBalancer.ingress[*].hostname} " )
RAZEEDASH_API_LB_HOSTNAME= $( kubectl get service razeedash-api-lb -n razee -o jsonpath= " {.status.loadBalancer.ingress[*].hostname} " )
RAZEEDASH_LB= ${RAZEEDASH_LB_HOSTNAME} && [[ " ${RAZEEDASH_LB_IP} " != " " ]] && RAZEEDASH_LB= ${RAZEEDASH_LB_IP}
RAZEEDASH_API_LB= ${RAZEEDASH_API_LB_HOSTNAME} && [[ " ${RAZEEDASH_API_LB_IP} " != " " ]] && RAZEEDASH_API_LB= ${RAZEEDASH_API_LB_IP}
kubectl create configmap razeedash-config -n razee
--from-literal=root_url=http:// " ${RAZEEDASH_LB} " :8080/
--from-literal=razeedash_api_url=http:// " ${RAZEEDASH_API_LB} " :8081/
驗證所有 Razee 元件均已部署並在 CLI 輸出的READY列中顯示1/1
。
kubectl get deployments -n razee
輸出範例:
NAME READY UP-TO-DATE AVAILABLE AGE
featureflagsetld-controller 1/1 1 1 53m
managedset-controller 1/1 1 1 53m
mongo 1/1 1 1 34m
mustachetemplate-controller 1/1 1 1 53m
razeedash 1/1 1 1 25m
razeedash-api 1/1 1 1 25m
razeedeploy-delta 1/1 1 1 53m
remoteresource-controller 1/1 1 1 53m
remoteresources3-controller 1/1 1 1 53m
開啟 RazeeDash 歡迎畫面。
open http:// " ${RAZEEDASH_LB} " :8080
在 GitHub、GitHub Enterprise 或 Bitbucket 中為 RazeeDash 建立OAuth
應用程式。
從 RazeeDash 歡迎畫面中,選擇要建立OAuth
應用程式的工具磁貼。
按照彈出視窗中的說明建立OAuth
應用程式。
按一下「儲存配置」 。
在 RazeeDash 歡迎畫面中,按一下使用 <integration_tool> 登入。
請依照彈出視窗中的指示授予 RazeeDash 存取您選擇的整合工具的權限。
如果您需要重設任何OAuth
憑證,那麼您可以透過開啟執行個體的 mongo shell 並執行來重新開始
> use razeedash
> db.meteor_accounts_loginServiceConfiguration.remove({})
在要監控的每個叢集中安裝 Watch Keeper。安裝 Watch Keeper 的叢集可以與安裝 RazeeDash 的叢集不同。
在 RazeeDash 控制台中,點選註冊。
按一下“管理” 。
複製安裝 Razee Agent kubectl
指令。
在要監控的叢集中執行命令來建立 Watch Keeper 元件。如果您在安裝 RazeeDash 的同一群集中安裝 Watch Keeper,您會看到一些訊息,表示叢集中已存在某些 Watch Keeper 元件。您可以忽略這些訊息。
kubectl create -f http:// < razeedash-api-lb_external_IP > :8081/api/install/cluster ? orgKey=orgApiKey- < org_api_key >
安裝 RazeeDash 的叢集的範例輸出:
deployment.apps/remoteresource-controller created
configmap/watch-keeper-config created
secret/watch-keeper-secret created
remoteresource.deploy.razee.io/watch-keeper-rr created
Error from server (AlreadyExists): error when creating
" http://4e0ef59e-us-south.lb.appdomain.cloud:8081/api/install/cluster?
orgKey=orgApiKey-d52b52fc-38ae-4da0-b187-6e097e5bfe5c " : namespaces
" razee " already exists
Error from server (AlreadyExists): customresourcedefinitions.
apiextensions.k8s.io " remoteresources.deploy.razee.io " already exists
Error from server (AlreadyExists): error when creating
" http://4e0ef59e-us-south.lb.appdomain.cloud:8081/api/install/cluster?
orgKey=orgApiKey-d52b52fc-38ae-4da0-b187-6e097e5bfe5c " : namespaces
" razee " already exists
Error from server (AlreadyExists): error when creating
" http://4e0ef59e-us-south.lb.appdomain.cloud:8081/api/install/cluster?
orgKey=orgApiKey-d52b52fc-38ae-4da0-b187-6e097e5bfe5c " : serviceaccounts
" razeedeploy-sa " already exists
Error from server (AlreadyExists): error when creating
" http://4e0ef59e-us-south.lb.appdomain.cloud:8081/api/install/cluster?
orgKey=orgApiKey-d52b52fc-38ae-4da0-b187-6e097e5bfe5c " : clusterroles.
rbac.authorization.k8s.io " razeedeploy-admin-cr " already exists
Error from server (AlreadyExists): error when creating
" http://4e0ef59e-us-south.lb.appdomain.cloud:8081/api/install/cluster?
orgKey=orgApiKey-d52b52fc-38ae-4da0-b187-6e097e5bfe5c " :
clusterrolebindings.rbac.authorization.k8s.io " razeedeploy-rb " already exists
Error from server (AlreadyExists): error when creating
" http://4e0ef59e-us-south.lb.appdomain.cloud:8081/api/install/cluster?
orgKey=orgApiKey-d52b52fc-38ae-4da0-b187-6e097e5bfe5c " : configmaps
" razeedeploy-delta-resource-uris " already exists
Error from server (AlreadyExists): error when creating
" http://4e0ef59e-us-south.lb.appdomain.cloud:8081/api/install/cluster?
orgKey=orgApiKey-d52b52fc-38ae-4da0-b187-6e097e5bfe5c " : deployments.apps
" razeedeploy-delta " already exists
未安裝 RazeeDash 的叢集的範例輸出:
configmap/watch-keeper-config created
secret/watch-keeper-secret created
clusterrole.rbac.authorization.k8s.io/cluster-reader created
serviceaccount/watch-keeper-sa created
clusterrolebinding.rbac.authorization.k8s.io/watch-keeper-rb created
networkpolicy.networking.k8s.io/watch-keeper-deny-ingress created
deployment.apps/watch-keeper created
Error from server (AlreadyExists): namespaces " razee " already exists
等待 Watch Keeper 部署完成。
kubectl get deployment -n razee | grep watch-keeper
輸出範例:
watch-keeper 1/1 1 1 2m5s
在 RazeeDash 控制台中,按一下RazeeDash開啟 RazeeDash 詳細資料頁面並驗證您是否可以看到 Watch Keeper Pod 的部署資訊。
透過在叢集中設定 Watch Keeper,您可以檢索要監控的其他 Kubernetes 資源的部署資訊。資料會自動傳送到 RazeeDash API,您可以使用 RazeeDash 存取、監控和分析這些資料。
透過在以下資訊詳細層級中進行選擇來確定您希望 Watch Keeper 檢索哪些資訊:
lite
:檢索 Kubernetes 資源配置的metadata
和status
部分。detail
:檢索 Kubernetes 資源的所有配置數據,但忽略環境變數以及配置映射和機密的data
部分。debug
:檢索 Kubernetes 資源的所有配置數據,包括環境變數和data
。配置映射和秘密部分。此資訊可能包含敏感資訊,因此請謹慎使用此選項。將razee/watch-resource
標籤新增至要監控的所有 Kubernetes 資源的標籤部分,並指定資訊詳細程度。例如,如果您想要監控 Kubernetes 部署,請使用下列命令。將標籤新增至資源後,Watch Keeper 會自動掃描您的資源並將資料傳送至 RazeeDash API。然後,您的資源每小時掃描一次。此外,Watch Keeper 會為您的資源新增 Kubernetes 事件觀察程序,以便當您的資源配置發生變更時,Kubernetes 會通知 Watch Keeper。
kubectl edit deployment < deployment_name >
YAML 檔案範例:
apiVersion : extensions/v1beta1
kind : Deployment
metadata :
annotations :
deployment.kubernetes.io/revision : " 1 "
kubectl.kubernetes.io/last-applied-configuration : |
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"myapp"},"name":"expandpvc","namespace":"default"},"spec":{"selector":{"matchLabels":{"app":"myapp"}},"template":{"metadata":{"labels":{"app":"myapp"}},"spec":{"con