storage-operator組件用於管理儲存群組件的生命週期。您可以通過修改ConfigMap來修改storage-operator組件的配置資訊,進行儲存群組件的部署與升級操作,降低容器研發和營運的複雜性。本文介紹如何在ACK叢集中配置組件資訊及部署storage-operator組件。
組件介紹
storage-operator在ACK叢集中部署為Deployment,依賴自身鏡像中的預設組件配置和通過ConfigMap自訂的組件配置,進行儲存群組件的部署與升級操作。
storage-operator組件僅支援在ACK叢集中使用。
預設組件配置:每個發布的storage-operator組件都有對應的預設配置。
通過ConfigMap自訂配置:通過ConfigMap自訂群組件配置,可配置版本資訊、是否部署組件等資訊。
storage-operator會優先使用自訂的組件配置,只有沒有指定具體配置時,才使用鏡像預設配置。
storage-operator鏡像發布時,都會有預設儲存群組件設定檔。
storage-operator運行時,會掛載一個對儲存群組件配置的ConfigMap檔案,且讀取該配置。
storage-operator會整合自訂配置和預設配置,綜合判斷是否部署與升級組件。
步驟一:配置組件資訊
方式一:鏡像預設配置
目前預設的儲存群組件有:storage-snapshot-manager、storage-analyzer、storage-auto-expander及storage-monitor。
每個版本的storage-operator都有預設的組件配置,以v1.18.8.0版本為例,配置樣本如下:
{
"storage-snapshot-manager": {
"install": "true",
"imageTag": "v1.18.8.0-81508da-aliyun",
"imageRep": "acs/storage-snapshot-manager",
"template": "/acs/templates/storage-snapshot-manager/install.yaml"
},
"storage-analzyer": {
"install": "false",
"imageTag": "v1.18.8.0-06c5560-aliyun",
"imageRep": "acs/storage-analyzer",
"template": "/acs/templates/storage-analyzer/install.yaml"
},
"storage-auto-expander": {
"install": "false",
"imageTag": "v1.18.8.0-4852fd4-aliyun",
"imageRep": "acs/storage-auto-expander",
"crdTmpl": "/acs/templates/storage-auto-expander/crd.yaml",
"template": "/acs/templates/storage-auto-expander/install.yaml"
},
"storage-monitor": {
"install": "true",
"imageTag": "v1.18.8.0-c4744b6-aliyun",
"imageRep": "acs/storage-monitor",
"template": "/acs/templates/storage-monitor/install.yaml",
"svcTmpl": "/acs/templates/storage-monitor/service.yaml"
}
}
預設配置中各組件定義的參數說明如下:
參數 | 說明 |
install | 表示該組件是否需要部署,預設為 |
imageTag | 表示如果部署該組件,預設使用的鏡像版本。 |
imageRep | 表示如果部署該組件,預設使用的鏡像名。 |
crdTmpl | 表示是否需要部署CRD,該值表示CRD模板地址。為空白時表示不部署CRD。 |
svcTmpl | 表示是否需要部署Service,該值表示Service模板地址。 |
template | 表示該組件的部署模板地址。 |
各組件的參數可以在配置(ConfigMap)中修改。
方式二:自訂配置(ConfigMap)
ConfigMap樣本模板如下:
kind: ConfigMap
apiVersion: v1
metadata:
name: storage-operator
namespace: kube-system
data:
storage-snapshot-manager: |
# deploy config
install: false
imageTag: v1.16.aaaa
imageRep: acs/storage-snapshot-manager
template: /acs/templates/storage-snapshot-manager/install.yaml
# env config
SNAPSHOT_INTERVAL: 30
storage-analyzer: |
# deploy config
install: false
imageTag: v1.16.bbbb
imageRep: acs/storage-analyzer
template: /acs/templates/storage-analyzer/install.yaml
# env config
LOOP_INTERVAL: 30
storage-auto-expander: |
# deploy config
install: false
imageTag: v1.16.3adsadfs
imageRep: acs/storage-auto-expander
crdTmpl: /acs/templates/storage-auto-expander/crd.yaml
template: /acs/templates/storage-auto-expander/install.yaml
# env config
POLLING_INTERVAL_SECONDS: 60
自訂配置需要注意以下幾點:
若自訂了部署配置部分的值,將覆蓋預設配置中的對應值。
每個組件的配置分為兩部分:
部署配置參數,即樣本中deploy config部分參數,是定義該組件是否部署及部署的版本資訊等。storage_operator根據該部分資訊安裝、升級組件。
環境配置參數,即樣本中env config部分參數,是給對應的儲存群組件使用。例如:
SNAPSHOT_INTERVAL
配置為storage-snapshot-manager的環境變數。
部署配置參數是組件部署配置保留欄位,不能用作環境變數。
可針對於相應組件的特定參數自訂配置。
步驟二:部署storage-operator組件
執行以下命令部署storage-operator組件。
kubectl apply -f storage_operator.yaml
部署storage-operator組件的樣本模板storage_operator.yaml如下所示:
apiVersion: apps/v1 kind: Deployment metadata: name: storage-operator namespace: kube-system labels: app: storage-operator spec: selector: matchLabels: app: storage-operator template: metadata: labels: app: storage-operator spec: tolerations: - operator: "Exists" priorityClassName: system-node-critical serviceAccount: storage-operator-admin containers: - name: storage-operator image: registry.cn-hangzhou.aliyuncs.com/acs/storage-operator:v1.18.8.28-18cca7b-aliyun imagePullPolicy: Always volumeMounts: - mountPath: /acs/configmap/ name: storage-operator restartPolicy: Always volumes: - configMap: name: storage-operator name: storage-operator
執行以下命令查看storage-operator組件是否啟動。
kubectl get pods -nkube-system | grep storage-operator
預期輸出:
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES storage-operator-*** 1/1 Running 0 6d20h 192.168.XX.XX virtual-kubelet <none> <none>