OpenShift 4 をインストールする前に、いくつかの NCP 構成ファイルを更新する必要があります。
まず、次のコマンドを実行して、NSX Container Plugin オペレータの YAML の仕様を取得します。
git clone https://github.com/vmware/nsx-container-plugin-operator.git
これらのファイルは、
nsx-container-plugin-operator/deploy フォルダにあります。
- configmap.yaml – このファイルを NSX-T 情報で更新します。
- operator.yaml – このファイルに NCP イメージの場所を指定します。
- namespace.yaml – オペレータの名前空間の指定。このファイルは編集しないでください。
- role_binding.yaml - オペレータのロール バインドの指定。このファイルは編集しないでください。
- role.yaml – オペレータのロールの指定。このファイルは編集しないでください。
- service_account.yaml - オペレータのサービス アカウントの指定。このファイルは編集しないでください。
- 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.nsx.vmware.com_v1_ncpinstall_cr.yaml - オペレータ所有の顧客リソース。
次の
connfigmap.yaml は基本的な構成例です。詳細オプションについては、
deploy フォルダにある
configmap.yaml を参照してください。環境に応じて、次のパラメータに値を指定してください。
- クラスタ
- 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>
operator.yaml で、
env セクションに NCP イメージの場所を指定する必要があります。
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}"
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