13.3. Nutanix 安装后配置
按照以下步骤完成并验证 OpenShift Container Platform 与 Nutanix 云供应商的集成。
先决条件
- Assisted Installer 成功完成安装集群。
- 集群连接到 console.redhat.com。
- 您可以访问 Red Hat OpenShift Container Platform 命令行界面。
13.3.1. 更新 Nutanix 配置设置
使用 Assisted Installer 在 Nutanix 平台上安装 OpenShift Container Platform 后,您必须手动更新以下 Nutanix 配置设置:
-
<prismcentral_username&
gt; : Nutanix Prism Central username。 -
<prismcentral_password&
gt; : Nutanix Prism Central 密码。 -
<prismcentral_address&
gt; : Nutanix Prism Central 地址。 -
<prismcentral_port>
: Nutanix Prism Central 端口。 -
<prismelement_username&
gt; : Nutanix Prism Element 用户名。 -
<prismelement_password&
gt; : Nutanix Prism Element 密码。 -
<prismelement_address&
gt; : Nutanix Prism Element 地址。 -
<prismelement_port>
: Nutanix Prism Element 端口。 -
<prismelement_clustername>
: Nutanix Prism Element 集群名称。 -
<nutanix_storage_container&
gt; : Nutanix Prism storage 容器。
流程
在 OpenShift Container Platform 命令行界面中,更新 Nutanix 集群配置设置:
$ oc patch infrastructure/cluster --type=merge --patch-file=/dev/stdin <<-EOF { "spec": { "platformSpec": { "nutanix": { "prismCentral": { "address": "<prismcentral_address>", "port": <prismcentral_port> }, "prismElements": [ { "endpoint": { "address": "<prismelement_address>", "port": <prismelement_port> }, "name": "<prismelement_clustername>" } ] }, "type": "Nutanix" } } } EOF
输出示例
infrastructure.config.openshift.io/cluster patched
如需了解更多详细信息,请参阅在 Nutanix 上创建机器集。
创建 Nutanix secret:
$ cat <<EOF | oc create -f - apiVersion: v1 kind: Secret metadata: name: nutanix-credentials namespace: openshift-machine-api type: Opaque stringData: credentials: | [{"type":"basic_auth","data":{"prismCentral":{"username":"${<prismcentral_username>}","password":"${<prismcentral_password>}"},"prismElements":null}}] EOF
输出示例
secret/nutanix-credentials created
安装 OpenShift Container Platform 版本 4.13 或更高版本时,更新 Nutanix 云供应商配置:
获取 Nutanix 云供应商配置 YAML 文件:
$ oc get cm cloud-provider-config -o yaml -n openshift-config > cloud-provider-config-backup.yaml
创建配置文件的备份:
$ cp cloud-provider-config_backup.yaml cloud-provider-config.yaml
打开配置 YAML 文件:
$ vi cloud-provider-config.yaml
编辑配置 YAML 文件,如下所示:
kind: ConfigMap apiVersion: v1 metadata: name: cloud-provider-config namespace: openshift-config data: config: | { "prismCentral": { "address": "<prismcentral_address>", "port":<prismcentral_port>, "credentialRef": { "kind": "Secret", "name": "nutanix-credentials", "namespace": "openshift-cloud-controller-manager" } }, "topologyDiscovery": { "type": "Prism", "topologyCategories": null }, "enableCustomLabeling": true }
应用配置更新:
$ oc apply -f cloud-provider-config.yaml
输出示例
Warning: resource configmaps/cloud-provider-config is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by oc apply. oc apply should only be used on resources created declaratively by either oc create --save-config or oc apply. The missing annotation will be patched automatically. configmap/cloud-provider-config configured
13.3.2. 创建 Nutanix CSI Operator 组
为 Nutanix CSI Operator 创建 Operator 组。
有关 operator 组和相关概念的描述,请参阅附加资源 中的常见 Operator Framework 术语。
流程
打开 Nutanix CSI Operator Group YAML 文件:
$ vi openshift-cluster-csi-drivers-operator-group.yaml
编辑 YAML 文件,如下所示:
apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: generateName: openshift-cluster-csi-drivers namespace: openshift-cluster-csi-drivers spec: targetNamespaces: - openshift-cluster-csi-drivers upgradeStrategy: Default
创建 Operator 组:
$ oc create -f openshift-cluster-csi-drivers-operator-group.yaml
输出示例
operatorgroup.operators.coreos.com/openshift-cluster-csi-driversjw9cd created
13.3.3. 安装 Nutanix CSI Operator
Kubernetes 的 Nutanix Container Storage Interface (CSI) Operator 部署和管理 Nutanix CSI 驱动程序。
有关通过 Red Hat OpenShift Container Platform 执行此步骤的步骤,请参阅附加资源 中的 Nutanix CSI Operator 文档中的 安装 Operator 部分。
流程
获取 Nutanix CSI Operator YAML 文件的参数值:
检查 Nutanix CSI Operator 是否存在:
$ oc get packagemanifests | grep nutanix
输出示例
nutanixcsioperator Certified Operators 129m
将 Operator 的默认频道分配给 BASH 变量:
$ DEFAULT_CHANNEL=$(oc get packagemanifests nutanixcsioperator -o jsonpath={.status.defaultChannel})
将 Operator 的起始集群服务版本(CSV)分配给 BASH 变量:
$ STARTING_CSV=$(oc get packagemanifests nutanixcsioperator -o jsonpath=\{.status.channels[*].currentCSV\})
将订阅的目录源分配给 BASH 变量:
$ CATALOG_SOURCE=$(oc get packagemanifests nutanixcsioperator -o jsonpath=\{.status.catalogSource\})
将 Nutanix CSI Operator 源命名空间分配给 BASH 变量:
$ SOURCE_NAMESPACE=$(oc get packagemanifests nutanixcsioperator -o jsonpath=\{.status.catalogSourceNamespace\})
使用 BASH 变量创建 Nutanix CSI Operator YAML 文件:
$ cat << EOF > nutanixcsioperator.yaml apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: nutanixcsioperator namespace: openshift-cluster-csi-drivers spec: channel: $DEFAULT_CHANNEL installPlanApproval: Automatic name: nutanixcsioperator source: $CATALOG_SOURCE sourceNamespace: $SOURCE_NAMESPACE startingCSV: $STARTING_CSV EOF
创建 CSI Nutanix Operator:
$ oc apply -f nutanixcsioperator.yaml
输出示例
subscription.operators.coreos.com/nutanixcsioperator created
运行以下命令,直到 Operator 订阅状态更改为
AtLatestKnown
。这表明已创建了 Operator 订阅,可能需要一些时间。$ oc get subscription nutanixcsioperator -n openshift-cluster-csi-drivers -o 'jsonpath={..status.state}'
13.3.4. 部署 Nutanix CSI 存储驱动程序
Kubernetes 的 Nutanix Container Storage Interface (CSI)驱动程序为有状态应用程序提供可扩展和持久性存储。
有关执行 Red Hat OpenShift Container Platform 的步骤,请参阅附加资源 中的使用 Nutanix CSI Operator 文档中的使用 Operator 安装 CSI Driver 部分。
流程
创建
NutanixCsiStorage
资源来部署驱动程序:$ cat <<EOF | oc create -f - apiVersion: crd.nutanix.com/v1alpha1 kind: NutanixCsiStorage metadata: name: nutanixcsistorage namespace: openshift-cluster-csi-drivers spec: {} EOF
输出示例
snutanixcsistorage.crd.nutanix.com/nutanixcsistorage created
为 CSI 存储驱动程序创建一个 Nutanix secret YAML 文件:
$ cat <<EOF | oc create -f - apiVersion: v1 kind: Secret metadata: name: ntnx-secret namespace: openshift-cluster-csi-drivers stringData: # prism-element-ip:prism-port:admin:password key: <prismelement_address:prismelement_port:prismcentral_username:prismcentral_password> 1 EOF
注意- 1
- 使用实际值替换这些参数,同时保持相同的格式。
输出示例
secret/nutanix-secret created
13.3.5. 验证安装后配置
运行以下命令以验证配置。
流程
验证您可以创建一个存储类:
$ cat <<EOF | oc create -f - kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: nutanix-volume annotations: storageclass.kubernetes.io/is-default-class: 'true' provisioner: csi.nutanix.com parameters: csi.storage.k8s.io/fstype: ext4 csi.storage.k8s.io/provisioner-secret-namespace: openshift-cluster-csi-drivers csi.storage.k8s.io/provisioner-secret-name: ntnx-secret storageContainer: <nutanix_storage_container> 1 csi.storage.k8s.io/controller-expand-secret-name: ntnx-secret csi.storage.k8s.io/node-publish-secret-namespace: openshift-cluster-csi-drivers storageType: NutanixVolumes csi.storage.k8s.io/node-publish-secret-name: ntnx-secret csi.storage.k8s.io/controller-expand-secret-namespace: openshift-cluster-csi-drivers reclaimPolicy: Delete allowVolumeExpansion: true volumeBindingMode: Immediate EOF
注意- 1
- 从 Nutanix 配置中获取 <nutanix_storage_container>,例如 SelfServiceContainer。
输出示例
storageclass.storage.k8s.io/nutanix-volume created
验证您可以创建 Nutanix 持久性卷声明(PVC):
创建持久性卷声明(PVC):
$ cat <<EOF | oc create -f - kind: PersistentVolumeClaim apiVersion: v1 metadata: name: nutanix-volume-pvc namespace: openshift-cluster-csi-drivers annotations: volume.beta.kubernetes.io/storage-provisioner: csi.nutanix.com volume.kubernetes.io/storage-provisioner: csi.nutanix.com finalizers: - kubernetes.io/pvc-protection spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi storageClassName: nutanix-volume volumeMode: Filesystem EOF
输出示例
persistentvolumeclaim/nutanix-volume-pvc created
验证持久性卷声明(PVC)状态为 Bound:
$ oc get pvc -n openshift-cluster-csi-drivers
输出示例
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE nutanix-volume-pvc Bound nutanix-volume 52s