升級 DirectPV
kubectl directpv migrate
將舊資源移轉至新的安裝。Kubernetes 在 v1.21 中已棄用 PodSecurityPolicy
功能,然後在 v1.25 中完全移除它。請使用 Pod Security Admission 作為替代方案,如 Kubernetes 文件中所建議。
DirectPV 在 4.0.x 版本中繼續支援 PodSecurityPolicy
。DirectPV 4.1.x 和更新版本已移除對 PodSecurityPolicy
的支援。
將 DirectPV CSI 驅動程式從 4.x.x 版升級至最新版
離線升級
請按照下列步驟執行離線升級
-
解除安裝 DirectPV CSI 驅動程式。
這不會移除任何現有資源。
kubectl directpv uninstall
-
升級 DirectPV 外掛程式。
kubectl krew upgrade directpv
如果您使用二進位檔而非
krew
,請下載適用於您的作業系統和架構的最新二進位檔。
就地升級
請按照下列步驟執行就地升級
-
使用下列命令升級 DirectPV
krew
外掛程式kubectl krew upgrade directpv
如果您使用二進位檔而非
krew
,請下載適用於您的作業系統和架構的最新二進位檔。 -
執行安裝指令碼,並提供您環境所需的適當節點選擇器、容錯設定和
KUBELET_DIR_PATH
環境變數。curl -sfL https://github.com/minio/directpv/raw/master/docs/tools/install.sh | sh -s - apply
保留 PodSecurityPolicy 支援
如果您升級至 4.1.x 版,並希望保留對 PodSecurityPolicy
的支援,請完成下列步驟。
開始升級之前
備份現有的 psp
和 clusterrolebinding
YAML 規格。
kubectl get psp directpv-min-io -o yaml > psp.yaml
kubectl get clusterrolebinding psp-directpv-min-io -o yaml > psp-crb.yaml
套用備份的 YAML
完成其他升級步驟後,套用 psp
和 clusterrolebinding
YAML 備份。
kubectl apply -f psp.yaml
kubectl apply -f psp-crb.yaml
升級舊版 DirectCSI 驅動程式
對於較舊的版本,請先升級到 v3.2.2,然後再升級到最新版本。
在最新版本的 DirectPV 中,CSI sidecar 映像已更新。
-
如果您是從 3.1.0 或更高版本升級,請解除安裝現有的 DirectCSI 驅動程式。
解除安裝 DirectPV 不會移除任何資源。
kubectl directcsi uninstall
如果您是從較舊版本升級,您將在稍後的過程中執行此步驟。
-
升級或安裝最新版本的 DirectPV 外掛程式。
kubectl krew upgrade directpv
如果您尚未從 Direct CSI 升級到 DirectPV,請改用以下步驟
kubectl krew install directpv
-
(選用) 如果您使用自訂儲存類別進行排程且您是從 < v4.0.0 的版本升級,您必須修改儲存類別參數。
在各自的儲存類別參數區段中,將
direct.csi.min.io/access-tier: <您的存取層值>
變更為directpv.min.io/access-tier: <您的存取層值>
。 -
安裝 Direct-CSI 的更新版本。
kubectl directpv install
如需有關安裝程序或自訂安裝方法的更多詳細資訊,請參閱安裝文件。
-
如果您是從舊於 3.1.0 的版本升級,請解除安裝 DirectCSI 驅動程式。
kubectl directcsi uninstall
-
檢查 Pod 是否正在執行。
kubectl get pods -n direct-csi-min-io -w
-
驗證您可以連線到 DirectPV 磁碟機。
kubectl directpv drives ls
升級後清理
較舊的 CRD (directcsidrives
和 directcsivolumes
) 已被棄用,且在 > v4.0.0 的版本中未使用。這些可以在升級後移除。
在升級到最新版本後,使用以下 Bash 指令碼來移除較舊的物件。
#!/usr/bin/env bash
#
# This file is part of MinIO DirectPV
# Copyright (c) 2023 MinIO, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://gnu.dev.org.tw/licenses/>.
#
# This script removes direct-csi drives and volumes after taking backup YAMLs
# to directcsidrives.yaml and directcsivolumes.yaml
#
set -e -C -o pipefail
function init() {
if [[ $# -ne 0 ]]; then
echo "usage: remove-directcsi.sh"
echo
echo "This script removes direct-csi drives and volumes after taking backup YAMLs"
echo "to directcsidrives.yaml and directcsivolumes.yaml"
exit 255
fi
if ! which kubectl >/dev/null 2>&1; then
echo "kubectl not found; please install"
exit 255
fi
}
# usage: unset_object_finalizers <resource>
function unset_object_finalizers() {
kubectl get "${1}" -o custom-columns=NAME:.metadata.name --no-headers | while read -r resource_name; do
kubectl patch "${1}" "${resource_name}" -p '{"metadata":{"finalizers":null}}' --type=merge
done
}
function main() {
kubectl get directcsivolumes -o yaml > directcsivolumes.yaml
kubectl get directcsidrives -o yaml > directcsidrives.yaml
# unset the finalizers
unset_object_finalizers "directcsidrives"
unset_object_finalizers "directcsivolumes"
# delete the resources
kubectl delete directcsivolumes --all
kubectl delete directcsidrives --all
}
init "$@"
main "$@"
從 < v3.2.x 版本升級
如果您使用的是 DirectCSI 版本 < 3.2.2,請先升級到 v3.2.2,然後再升級到最新版本。
-
解除安裝現有的設定。
解除安裝 DirectPV 不會移除任何資源。
kubectl direct-csi uninstall
-
確認 CSI Pod 已刪除。
kubectl get pods -n direct-csi-min-io
DirectPV v4.0.0 及更高版本在建立新的磁碟機或磁碟區時,不會使用
direct-cs-min-io
命名空間。但是,最新版本的 DirectPV 可以繼續使用該命名空間中已存在的資源。 -
從 https://github.com/minio/directpv/releases/tag/v3.2.2 下載 Direct-CSI v3.2.2。
-
載入以下映像
quay.io/minio/csi-provisioner:v2.2.0-go1.18 quay.io/minio/csi-node-driver-registrar:v2.2.0-go1.18 quay.io/minio/livenessprobe:v2.2.0-go1.18
如果您的 Kubernetes 版本低於 v1.20,也請推送
quay.io/minio/csi-provisioner:v2.2.0-go1.18
-
安裝 Direct-CSI 的更新版本。
kubectl direct-csi install
-
檢查 Pod 是否正在執行。
kubectl get pods -n direct-csi-min-io -w
-
驗證您可以連線到 DirectPV 磁碟機。
kubectl direct-csi drives ls
若要使用
krew
升級外掛程式,請使用以下命令。kubectl krew upgrade directpv
若要從二進位檔升級,請依照二進位檔安裝指示進行操作。