OpenShift 4 をインストールする前に、いくつかの NCP 設定ファイルを更新する必要があります。
download.vmware.com から取得した NCP ダウンロード ファイルに YAML ファイルが含まれています。https://github.com/vmware/nsx-container-plugin-operator/releasesに移動して、対応する Operator リリース(v3.1.1 など)を検索し、openshift4.tar.gz をダウンロードすることもできます。
- configmap.yaml – このファイルを NSX-T 情報で更新します。
- operator.yaml – このファイルに NCP イメージの場所を指定します。
- namespace.yaml – Operator の名前空間の指定。このファイルは編集しないでください。
- role_binding.yaml - Operator のロール バインドの指定。このファイルは編集しないでください。
- role.yaml – Operator のロールの指定。このファイルは編集しないでください。
- service_account.yaml - Operator のサービス アカウントの指定。このファイルは編集しないでください。
- lb-secret.yaml - デフォルトの NSX-T ロード バランサ証明書のシークレット。
- nsx-secret.yaml - NSX-T に対する証明書ベースの認証で使用するシークレット。configmap.yaml の nsx_api_user と nsx_api_password の代わりに使用されます。
- operator.nsx.vmware.com_ncpinstalls_crd.yaml - Operator 所有の顧客リソース定義。
- operator.nsx.vmware.com_v1_ncpinstall_cr.yaml - Operator 所有の顧客リソース。
- クラスタ
- nsx_api_managers
- nsx_api_user
- nsx_api_password
- external_ip_pools
- tier0_gateway
- overlay_tz
- edge_cluster
- apiserver_host_ip
- apiserver_host_port
kind: ConfigMap
metadata:
name: nsx-ncp-operator-config
namespace: nsx-system-operator
data:
ncp.ini: |
[vc]
[coe]
# Container orchestrator adaptor to plug in.
adaptor = openshift4
# Specify cluster name.
cluster = ocp
[DEFAULT]
[nsx_v3]
policy_nsxapi = True
# Path to NSX client certificate file. If specified, the nsx_api_user and
# nsx_api_password options will be ignored. Must be specified along with
# nsx_api_private_key_file option
#nsx_api_cert_file = <None>
# Path to NSX client private key file. If specified, the nsx_api_user and
# nsx_api_password options will be ignored. Must be specified along with
# nsx_api_cert_file option
#nsx_api_private_key_file = <None>
nsx_api_managers = 10.114.209.10,10.114.209.11,10.114.209.12
nsx_api_user = admin
nsx_api_password = VMware1!
# Do not use in production
insecure = True
# Choices: ALL DENY <None>
log_firewall_traffic = DENY
external_ip_pools = 10.114.17.0/25
#top_tier_router = <None>
tier0_gateway = t0a
single_tier_topology = True
overlay_tz = 3efa070d-3870-4eb1-91b9-a44416637922
edge_cluster = 3088dc2b-d097-406e-b9de-7a161e8d0e47
[ha]
[k8s]
# Kubernetes API server IP address.
apiserver_host_ip = api-int.ocp.yasen.local
# Kubernetes API server port.
apiserver_host_port = 6443
client_token_file = /var/run/secrets/kubernetes.io/serviceaccount/token
# Choices: <None> allow_cluster allow_namespace
baseline_policy_type = allow_cluster
enable_multus = False
process_oc_network = False
[nsx_kube_proxy]
[nsx_node_agent]
ovs_bridge = br-int
# The OVS uplink OpenFlow port
ovs_uplink_port = ens192
[operator]
# The default certificate for HTTPS load balancing.
# Must be specified along with lb_priv_key option.
# Operator will create lb-secret for NCP based on these two options.
#lb_default_cert = <None>
# The private key for default certificate for HTTPS load balancing.
# Must be specified along with lb_default_cert option.
#lb_priv_key = <None>
kind: Deployment
metadata:
name: nsx-ncp-operator
namespace: nsx-system-operator
spec:
replicas: 1
selector:
matchLabels:
name: nsx-ncp-operator
template:
metadata:
labels:
name: nsx-ncp-operator
spec:
hostNetwork: true
serviceAccountName: nsx-ncp-operator
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
- effect: NoSchedule
key: node.kubernetes.io/not-ready
containers:
- name: nsx-ncp-operator
# Replace this with the built image name
image: vmware/nsx-container-plugin-operator:latest
command: ["/bin/bash", "-c", "nsx-ncp-operator --zap-time-encoding=iso8601"]
imagePullPolicy: Always
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "nsx-ncp-operator"
- name: NCP_IMAGE
value: "{NCP Image}"
Operator イメージの場合は、インストールする NCP バージョンを指定します。たとえば、NCP 3.1.1 の場合、Operator イメージは vmware/nsx-container-plugin-operator:v3.1.1 です。
レート制限ポリシーのため、本番環境で dockerhub を直接プルすることはおすすめしません。dockerhub からプルしたイメージはローカル レジストリにプッシュできますが、同じ場所に使用可能な NCP イメージが存在する可能性があります。
download.vmware.com から Operator イメージ ファイルを含む NCP ダウンロード ファイルを取得し、このイメージをローカル レジストリにインポートすることもできます。このイメージは、VMware の dockerhub で公開されているものと同じです。
CNI の MTU 値を設定するには、Operator ConfigMap の [nsx-node-agent] セクションで mtu パラメータを変更します。すべてのノードで CNI 設定ファイルが適切に更新されるように、Operator が nsx-ncp-boostrap ポッドの再作成をトリガします。また、ノードの MTU も適宜更新する必要があります。ノードとポッドの MTU が一致していないと、ノードとポッド間の通信で問題が発生する可能性があります。たとえば、TCP の稼動状態と準備状態の検証に影響する可能性があります。
ノードのインターフェイスで MTU を更新するには、ovs-vsctl set Interface <interface-name> mtu_request=<mtu-value> コマンドを実行します。interface-name は、OVS インターフェイスか、nsx-node-agent ポッドで実行されている nsx-ovs コンテナの物理インターフェイスのいずれかです。例:oc -n nsx-system exec -it nsx-node-agent-dqqm9 -c nsx-ovs -- ovs-vsctl set Interface ens192 mtu_request=9000。
注: デフォルトでは、ncpReplicas パラメータが 1 に設定されているため、Operator ConfigMap で HA を有効にすると、単一の NCP ポッドが作成されます。3 つの NCP ポッドを作成するには、この値を 3 に変更します。クラスタがインストールされたら、oc edit ncpinstalls ncp-install -n nsx-system コマンドで NCP レプリカの数を変更できます。
apiVersion: operator.nsx.vmware.com/v1
kind: NcpInstall
metadata:
name: ncp-install
namespace: nsx-system-operator
spec:
ncpReplicas: 1
# Note that if one node has multiple attached VirtualNetworkInterfaces, this function is not supported and should be set to false
addNodeTag: true
nsx-ncp:
# Uncomment below to add user-defined nodeSelector for NCP Deployment
#nodeSelector:
#<node_label_key>: <node_label_value>
tolerations:
# Please don't modify below default tolerations for NCP Deployment
- key: node-role.kubernetes.io/master
effect: NoSchedule
- key: node.kubernetes.io/network-unavailable
effect: NoSchedule
# Uncomment below to add user-defined tolerations for NCP Deployment
#<toleration_specification>
nsx-node-agent:
tolerations:
# Please don't modify below default tolerations
# for nsx-ncp-bootstrap and nsx-node-agent DaemonSet
- key: node-role.kubernetes.io/master
effect: NoSchedule
- key: node.kubernetes.io/not-ready
effect: NoSchedule
- key: node.kubernetes.io/unreachable
effect: NoSchedule
- operator: Exists
effect: NoExecute
# Uncomment below to add user-defined tolerations for nsx-ncp-bootstrap and nsx-node-agent DaemonSet
#<toleration_specification>
NSX-T に対するプリンシパル ID を使用した証明書ベース認証の設定
本番環境では、configmap.yaml の nsx_api_user と nsx_api_password パラメータに管理者の認証情報を公開しないことをおすすめめします。次の手順では、プリンシパル ID を作成し、NCP が認証に証明書を使用できるようにする方法について説明します。
- 証明書とキーを生成します。
- NSX Manager で、 の順に移動し、 の順にクリックします。プリンシパル ID を追加し、手順 1 で生成された証明書を貼り付けます。
- base64 エンコードの証明書とキーの値を nsx-secret.yaml に追加します。
- configmap.yaml の [nsx_v3] セクションに証明書とキー ファイルの場所を設定します。
nsx_api_cert_file = /etc/nsx-ujo/nsx-cert/tls.crt nsx_api_private_key_file = /etc/nsx-ujo/nsx-cert/tls.key
注: すでにブートストラップされているクラスタで認証方法を変更することはできません。
(オプション)デフォルトの NSX-T ロード バランサ証明書の設定
NSX-T ロード バランサでは、OpenShift HTTPS ルート オブジェクトを実装し、OCP HAProxy をオフロードできます。これを行うには、デフォルトの証明書が必要です。デフォルトの証明書を設定するには、次の手順を行います。
- base64 エンコードの証明書とキーの値を lb-secret.yaml に追加します。
- configmap.yaml の [nsx_v3] セクションに証明書とキーの場所を設定します。
lb_default_cert_path = /etc/nsx-ujo/lb-cert/tls.crt lb_priv_key_path = /etc/nsx-ujo/lb-cert/tls.key
(オプション)NSX Manager の証明書ベースの認証の設定
ConfigMap で insecure = False を設定した場合は、NSX Manager クラスタにある 3 つのすべてのマネージャの証明書サムプリントを指定する必要があります。手順は次のとおりです。
3 つのすべての NSX Manager の証明書をファイルにコピーします。
ssh -l admin 10.114.209.10 -f 'get certificate api' > nsx1.crt
ssh -l admin 10.114.209.11 -f 'get certificate api' > nsx2.crt
ssh -l admin 10.114.209.12 -f 'get certificate api' > nsx3.crt
NSX1=`openssl x509 -in nsx1.crt -fingerprint -noout|awk -F"=" '{print $2}'`
NSX2=`openssl x509 -in nsx2.crt -fingerprint -noout|awk -F"=" '{print $2}'`
NSX3=`openssl x509 -in nsx3.crt -fingerprint -noout|awk -F"=" '{print $2}'`
THUMB="$NSX1,$NSX2,$NSX3"
echo $THUMB
ConfigMap を編集し、[nsx_v3] セクションにサムプリントを追加します。
oc edit cm nsx-ncp-operator-config -n nsx-system-operator
nsx_api_managers = 10.114.209.10,10.114.209.11,10.114.209.12
nsx_api_user = admin
nsx_api_password = VMwareVMware1!
insecure = False
thumbprint = E0:A8:D6:06:88:B9:65:7D:FB:F8:14:CF:D5:E5:23:98:C9:43:10:71,A7:B0:26:B5:B2:F6:72:2B:39:86:19:84:E6:DD:AB:43:16:0E:CE:BD,52:9B:99:90:88:4C:9F:9B:83:5E:F7:AF:FC:60:06:50:BE:9E:32:08