Assisted Installer または Agent-based Installer を使用してインストールされた OpenShift 4 クラスターの vSphere 設定を変更する
Environment
- Red Hat Openshift Container Platform (RHOCP)
- 4
- Assisted Installer
- Agent-Based Installer
- VMware vSphere
Issue
- プラットフォーム統合機能を有効にし、Assisted Installer または Agent-based Installer を使用してクラスターをインストールする場合、インストールされたクラスターで vSphere 設定を手動で更新する必要があります。これは、インストールが完全に完了し、クラスターが Red Hat Hybrid Cloud Console に接続された後でのみ実行する必要があります。
Resolution
注記:このドキュメントは、Assisted Installer および Agent-based Installer を使用したインストールにのみ適用されます。その他のインストール方法については、modifying the vSphere configuration in RHOCP4 を参照してください。
Assisted Installer または Agent-based Installer を介してインストールされた OpenShift クラスターの vSphere 設定の変更手順
注記:ユーザー名、パスワード、vCenter アドレス、データセンター、データストア (
YOURVCENTERADDRESS、YOURVCENTERDATACENTER、YOURVCENTERDATASTORE、YOURVCENTERUSERVNAME、YOURVCENTERPASSWORD、YOURVCENTERCLUSTER) を変更する必要があります。
1) バックアップを作成します。
# oc get secret vsphere-creds -o yaml -n kube-system > creds_backup.yaml
# oc get cm cloud-provider-config -o yaml -n openshift-config > cloud-provider-config_backup.yaml
OpenShift バージョン 4.13 以降では追加のバックアップが必要です。
# oc get infrastructures.config.openshift.io -o yaml > infrastructures.config.openshift.io.yaml.backup
2) vCenter ユーザーとパスワードの、Base64 でエンコードされたパスワードを生成します。
注記:vSphere ユーザー名の形式には 'USERNAME@DOMAIN' を使用する必要があります。
# echo -n "YOURVCENTERPASSWORD" | base64 -w0
**YOURVCENTERPASSWORD_ENCODED**
# echo -n "YOURVCENTERUSERNAME@YOURVCENTERDOMAIN" | base64 -w0
**YOURVCENTERUSERVNAME_ENCODED**
3) creds.yaml を編集します。
# cp creds_backup.yaml vsphere-creds.yaml
# vi vsphere-creds.yaml
apiVersion: v1
data:
YOURVCENTERADDRESS.password: YOURVCENTERPASSWORD_ENCODED**
YOURVCENTERADDRESS.username: YOURVCENTERUSERVNAME_ENCODED**
kind: Secret
metadata:
annotations:
cloudcredential.openshift.io/mode: passthrough
creationTimestamp: "2022-01-25T17:39:50Z"
name: vsphere-creds
namespace: kube-system
resourceVersion: "2437"
uid: 06971978-e3a5-4741-87f9-2ca3602f2658
type: Opaque
# oc replace -f vsphere-creds.yaml
secret/vsphere-creds replaced
or
# oc edit -f vsphere-creds.yaml --namespace=kube-system
secret/vsphere-creds replaced
4) kube-controller-manager Pod の再デプロイを強制します。
# oc patch kubecontrollermanager cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$( date --rfc-3339=ns )"'"}}' --type=merge
kubecontrollermanager.operator.openshift.io/cluster patched
5) cloud-provider-config.yaml を編集します。
# cp cloud-provider-config_backup.yaml cloud-provider-config.yaml
# vi cloud-provider-config.yaml
apiVersion: v1
data:
config: |
[Global]
secret-name = "vsphere-creds"
secret-namespace = "kube-system"
insecure-flag = "1"
[Workspace]
server = "YOURVCENTERADDRESS"
datacenter = "YOURVCENTERDATACENTER"
default-datastore = "YOURVCENTERDATASTORE"
folder = "/YOURVCENTERDATACENTER/path/to/folder"
[VirtualCenter "YOURVCENTERADDRESS"]
datacenters = "YOURVCENTERDATACENTER"
kind: ConfigMap
metadata:
creationTimestamp: "2022-01-25T17:40:49Z"
name: cloud-provider-config
namespace: openshift-config
resourceVersion: "2070"
uid: 80bb8618-bf25-442b-b023-b31311918507
# 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
OpenShift バージョン 4.13 以降に必要な手順
6) 初期化されていない taint のあるノードを taint します。
各ノードで、
# oc get nodes
NAME STATUS ROLES AGE VERSION
master-0 Ready control-plane,master 45h v1.26.3+379cd9f
master-1 Ready control-plane,master 45h v1.26.3+379cd9f
worker-0 Ready worker 45h v1.26.3+379cd9f
worker-1 Ready worker 45h v1.26.3+379cd9f
master-2 Ready control-plane,master 45h v1.26.3+379cd9f
# oc adm taint node master-1 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
# oc adm taint node master-2 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
# oc adm taint node master-3 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
# oc adm taint node worker-0 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
# oc adm taint node worker-1 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
7) infrastructures.config を更新します。
# cp infrastructures.config.openshift.io.yaml.backup infrastructures.config.openshift.io.yaml
# vi infrastructures.config.openshift.io.yaml
apiVersion: v1
items:
- apiVersion: config.openshift.io/v1
kind: Infrastructure
metadata:
creationTimestamp: "2023-05-07T10:19:55Z"
generation: 1
name: cluster
resourceVersion: "536"
uid: e8a5742c-6d15-44e6-8a9e-064b26ab347d
spec:
cloudConfig:
key: config
name: cloud-provider-config
platformSpec:
type: VSphere
vsphere:
failureDomains:
- name: assisted-generated-failure-domain
region: assisted-generated-region
server: YOURVCENTERADDRESS
topology:
computeCluster: /YOURVCENTERDATACENTER/host/YOURVCENTERCLUSTER
datacenter: YOURVCENTERDATACENTER
datastore: /YOURVCENTERDATACENTER/datastore/YOURVCENTERDATASTORE
folder: "/YOURVCENTERDATACENTER/path/to/folder"
networks:
- "VM Network"
resourcePool: /YOURVCENTERDATACENTER/host/YOURVCENTERCLUSTER/Resources
zone: assisted-generated-zone
nodeNetworking:
external: {}
internal: {}
vcenters:
- datacenters:
- YOURVCENTERDATACENTER
server: YOURVCENTERADDRESS
kind: List
metadata:
resourceVersion: ""
# oc apply -f infrastructures.config.openshift.io.yaml --overwrite=true
Warning: resource infrastructures/cluster 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.
infrastructure.config.openshift.io/cluster configured
Root Cause
Diagnostic Steps
- OpenShift での vSphere 検証手順
1) StorageClass thin-csi が自動的に作成されることを確認します。
# oc get storageclass -o yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: thin-csi
provisioner: csi.vsphere.vmware.com
parameters:
StoragePolicyName: "$openshift-storage-policy-xxxx"
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: false
reclaimPolicy: Delete
2) 接続をテストするために PersistentVolumeClaim と PersistentVolume を作成します。
# vi test-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-pvc
namespace: openshift-config
annotations:
volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/vsphere-volume
finalizers:
- kubernetes.io/pvc-protection
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: thin-csi
volumeMode: Filesystem
# oc create -f test-pvc.yaml
persistentvolumeclaim/my-test-pvc created
# oc get pvc -n openshift-config
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
test-pvc Bound pvc-e91314a3-f225-46b9-9fdb-c2adcea934ad 10Gi RWO thin-csi 2m4s
# oc get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-e91314a3-f225-46b9-9fdb-c2adcea934ad 10Gi RWO Delete Bound openshift-config/test-pvc thin-csi 10m
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments