5 啟動設定執行處理
本節描述如何使用區塊鏈平台管理程式佈建 Oracle Blockchain Platform 執行處理。
建立 Oracle Blockchain Platform 執行處理之前
在您佈建 Oracle Blockchain Platform 之前,請先決定開發人員或企業執行個體是否符合您的需求。
決定要使用的佈建資源配置
佈建執行處理時,您可以選擇兩個組態。目前不支援在這些選項之間移轉。
| 組態 | 功能 |
|---|---|
| 開發人員 此入門資源配置建議用於開發和評估。 |
|
| 企業 高度可用的執行處理組態,每個服務都有較高的複本數目。 |
|
使用區塊鏈平台管理程式佈建執行處理
若要在 Blockchain Platform Manager 中建立區塊鏈創辦人或參與者執行處理,請使用「建立新執行處理」精靈。
-
創辦人組織:一個完整的區塊鏈環境,包括參與者日後可以加入的新網路。
-
參與者執行處理:如果已經有想要加入的建立者組織,如果您的證明資料可讓您存取網路,就可以建立參與者執行處理。請注意,參與者無法自行運作。
佈建先決條件
kubectl get virtualservice -n <instance-namespace> -o json | jq -r
.items[].spec.hosts[0]kubectl get virtualservice -n <instance-namespace> -o json | jq -r
.items[].spec.hosts[0]建立 Oracle Blockchain Platform Enterprise Edition 執行處理之後,您必須設定 DNS,才能從 OpenShift 本機網路解析元件的公用主機名稱。
- 執行下列命令。
oc new-project obp-coredns - 執行下列命令,在
obp-coredns命名空間中部署自訂coredns伺服器。
以指令使用下列清單檔案。kubectl apply -f <coredns-deployment-yaml-file>apiVersion: v1 kind: ConfigMap metadata: name: coredns namespace: obp-coredns data: Corefile: |- .:1053 { errors health { lameduck 5s } ready kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } prometheus :9153 forward . /etc/resolv.conf cache 30 loop reload loadbalance } import custom/*.server --- apiVersion: apps/v1 kind: Deployment metadata: labels: app: obp-coredns name: obp-coredns namespace: obp-coredns spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: obp-coredns strategy: type: RollingUpdate template: metadata: labels: app: obp-coredns spec: containers: - args: - -conf - /etc/coredns/Corefile image: docker.io/coredns/coredns:latest imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 5 httpGet: path: /health port: 8080 scheme: HTTP initialDelaySeconds: 60 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 5 name: coredns ports: - containerPort: 1053 name: dns protocol: UDP - containerPort: 1053 name: dns-tcp protocol: TCP - containerPort: 9153 name: metrics protocol: TCP readinessProbe: failureThreshold: 3 httpGet: path: /ready port: 8181 scheme: HTTP periodSeconds: 10 successThreshold: 1 timeoutSeconds: 1 resources: limits: memory: 170Mi requests: cpu: 100m memory: 70Mi securityContext: allowPrivilegeEscalation: false capabilities: add: - NET_BIND_SERVICE drop: - all readOnlyRootFilesystem: true terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /etc/coredns name: config-volume readOnly: true - mountPath: /etc/coredns/custom name: custom-config-volume readOnly: true dnsPolicy: Default restartPolicy: Always schedulerName: default-scheduler securityContext: {} serviceAccount: obp-coredns serviceAccountName: obp-coredns terminationGracePeriodSeconds: 30 volumes: - configMap: defaultMode: 420 items: - key: Corefile path: Corefile name: coredns name: config-volume - configMap: defaultMode: 420 name: coredns-custom optional: true name: custom-config-volume --- apiVersion: v1 kind: Service metadata: labels: app: obp-coredns name: obp-coredns namespace: obp-coredns spec: ports: - name: dns port: 53 protocol: UDP targetPort: 1053 - name: dns-tcp port: 53 protocol: TCP targetPort: 1053 - name: metrics port: 9153 protocol: TCP targetPort: 9153 selector: app: obp-coredns sessionAffinity: None type: ClusterIP --- apiVersion: v1 kind: ServiceAccount metadata: name: obp-coredns namespace: obp-coredns --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: obp-coredns rules: - apiGroups: - "" resources: - endpoints - services - pods - namespaces verbs: - list - watch - apiGroups: - "" resources: - nodes verbs: - get - apiGroups: - discovery.k8s.io resources: - endpointslices verbs: - list - watch --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: obp-coredns roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: obp-coredns subjects: - kind: ServiceAccount name: obp-coredns namespace: obp-coredns - 為您的區塊鏈執行處理建立 YAML 格式的
coredns-custom-configmap檔案。
在上一個範例中,apiVersion: v1 kind: ConfigMap metadata: name: coredns-custom namespace: obp-coredns data: obp.server: |2 <instanceName>.<domain>:1053 { log kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } rewrite stop { name regex (.*)\.<instanceName>\.<domain>\.com istio-ingressgateway.istio-system.svc.cluster.local answer auto } forward . /etc/resolv.conf }<instanceName>是執行處理的名稱,而<domain>是建立執行處理時所傳送的網域。 - 執行下列命令以套用自訂
ConfigMap物件。kubectl apply -f <coredns-custom-configmap-yaml-file> - 執行下列命令以取得叢集 IP 位址。記錄 IP 地址。
kubectl get svc -n obp-coredns - 執行下列命令以編輯 OpenShift DNS 自訂資源。
kubectl edit dnses.operator/default - 請更新 DNS 自訂資源的「區域」區段,以使用您的執行處理和網域名稱,如下列範例所示。
在上一個範例中,## Add the following section to the dns custom resource under spec servers: - forwardPlugin: policy: Random upstreams: - 192.0.2.233 name: obp-server zones: - <instanceName>.<domain><instanceName>是執行處理的名稱,而<domain>是父項網域。 - 若要新增執行處理,請新增項目至
coredns-custom-configmap檔案,然後更新新執行處理網域的 OpenShift DNS 自訂資源,如下列範例所示:
您必須使用區塊鏈平台管理程式停止並重新啟動區塊鏈平台執行處理,讓 DNS 變更生效。apiVersion: v1 kind: ConfigMap metadata: name: coredns-custom namespace: obp-coredns data: obp.server: |2 myobp.example.com:1053 { log kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } rewrite stop { name regex (.*)\.myobp\.example\.com istio-ingressgateway.istio-system.svc.cluster.local answer auto } forward . /etc/resolv.conf } otherobp.example.org:1053 { log kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } rewrite stop { name regex (.*)\.otherobp\.example\.org istio-ingressgateway.istio-system.svc.cluster.local answer auto } forward . /etc/resolv.conf } ## Edit the Openshift's DNS custom resource kubectl edit dnses.operator/default ## Add the new instance domain to the existing .spec.servers.zones servers: - forwardPlugin: policy: Random upstreams: - 192.0.2.233 name: obp-server zones: - myobp.example.com - otherobp.example.org
設定 DNS
建立 Oracle Blockchain Platform Enterprise Edition 執行處理之後,您必須設定 DNS,才能從 OpenShift 本機網路解析元件的公用主機名稱。
- 執行下列命令。
oc new-project obp-coredns - 執行下列命令,在
obp-coredns命名空間中部署自訂coredns伺服器。
以指令使用下列清單檔案。kubectl apply -f <coredns-deployment-yaml-file>apiVersion: v1 kind: ConfigMap metadata: name: coredns namespace: obp-coredns data: Corefile: |- .:1053 { errors health { lameduck 5s } ready kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } prometheus :9153 forward . /etc/resolv.conf cache 30 loop reload loadbalance } import custom/*.server --- apiVersion: apps/v1 kind: Deployment metadata: labels: app: obp-coredns name: obp-coredns namespace: obp-coredns spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: obp-coredns strategy: type: RollingUpdate template: metadata: labels: app: obp-coredns spec: containers: - args: - -conf - /etc/coredns/Corefile image: docker.io/coredns/coredns:latest imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 5 httpGet: path: /health port: 8080 scheme: HTTP initialDelaySeconds: 60 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 5 name: coredns ports: - containerPort: 1053 name: dns protocol: UDP - containerPort: 1053 name: dns-tcp protocol: TCP - containerPort: 9153 name: metrics protocol: TCP readinessProbe: failureThreshold: 3 httpGet: path: /ready port: 8181 scheme: HTTP periodSeconds: 10 successThreshold: 1 timeoutSeconds: 1 resources: limits: memory: 170Mi requests: cpu: 100m memory: 70Mi securityContext: allowPrivilegeEscalation: false capabilities: add: - NET_BIND_SERVICE drop: - all readOnlyRootFilesystem: true terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /etc/coredns name: config-volume readOnly: true - mountPath: /etc/coredns/custom name: custom-config-volume readOnly: true dnsPolicy: Default restartPolicy: Always schedulerName: default-scheduler securityContext: {} serviceAccount: obp-coredns serviceAccountName: obp-coredns terminationGracePeriodSeconds: 30 volumes: - configMap: defaultMode: 420 items: - key: Corefile path: Corefile name: coredns name: config-volume - configMap: defaultMode: 420 name: coredns-custom optional: true name: custom-config-volume --- apiVersion: v1 kind: Service metadata: labels: app: obp-coredns name: obp-coredns namespace: obp-coredns spec: ports: - name: dns port: 53 protocol: UDP targetPort: 1053 - name: dns-tcp port: 53 protocol: TCP targetPort: 1053 - name: metrics port: 9153 protocol: TCP targetPort: 9153 selector: app: obp-coredns sessionAffinity: None type: ClusterIP --- apiVersion: v1 kind: ServiceAccount metadata: name: obp-coredns namespace: obp-coredns --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: obp-coredns rules: - apiGroups: - "" resources: - endpoints - services - pods - namespaces verbs: - list - watch - apiGroups: - "" resources: - nodes verbs: - get - apiGroups: - discovery.k8s.io resources: - endpointslices verbs: - list - watch --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: obp-coredns roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: obp-coredns subjects: - kind: ServiceAccount name: obp-coredns namespace: obp-coredns - 為您的區塊鏈執行處理建立 YAML 格式的
coredns-custom-configmap檔案。
在上一個範例中,apiVersion: v1 kind: ConfigMap metadata: name: coredns-custom namespace: obp-coredns data: obp.server: |2 <instanceName>.<domain>:1053 { log kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } rewrite stop { name regex (.*)\.<instanceName>\.<domain>\ istio-ingressgateway.istio-system.svc.cluster.local answer auto } forward . /etc/resolv.conf }<instanceName>是執行處理的名稱,而<domain>是父項網域。 - 執行下列命令以套用自訂
ConfigMap物件。kubectl apply -f <coredns-custom-configmap-yaml-file> - 執行下列命令以取得叢集 IP 位址。記錄 IP 地址。
kubectl get svc -n obp-coredns - 執行下列命令以編輯 OpenShift DNS 自訂資源。
kubectl edit dnses.operator/default - 請更新 DNS 自訂資源的「區域」區段,以使用您的執行處理和網域名稱,如下列範例所示。
在上一個範例中,## Add the following section to the dns custom resource under spec servers: - forwardPlugin: policy: Random upstreams: - 192.0.2.233 name: obp-server zones: - <instanceName>.<domain><instanceName>是執行處理的名稱,而<domain>是父項網域。 - 若要新增執行處理,請新增項目至
coredns-custom-configmap檔案,然後更新新執行處理網域的 OpenShift DNS 自訂資源,如下列範例所示。
您必須停止並重新啟動執行處理,DNS 變更才會生效。apiVersion: v1 kind: ConfigMap metadata: name: coredns-custom namespace: obp-coredns data: obp.server: |2 myobp.example.com:1053 { log kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } rewrite stop { name regex (.*)\.myobp\.example\.com istio-ingressgateway.istio-system.svc.cluster.local answer auto } forward . /etc/resolv.conf } otherobp.example.org:1053 { log kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } rewrite stop { name regex (.*)\.otherobp\.example\.org istio-ingressgateway.istio-system.svc.cluster.local answer auto } forward . /etc/resolv.conf } ## Edit the Openshift's DNS custom resource kubectl edit dnses.operator/default ## Add the new instance domain to the existing .spec.servers.zones servers: - forwardPlugin: policy: Random upstreams: - 192.0.2.233 name: obp-server zones: - myobp.example.com - otherobp.example.org
kubectl get virtualservice -n <instance-namespace> -o json | jq -r
.items[].spec.hosts[0]新增其他節點至叢集
- 執行下列命令以檢查處於「擱置中」狀態的 Pod:
此外,您還可以檢查是否沒有可用的 Pod:kubectl get pods -n <instancename> | grep Pendingkubectl get pods -n instancename - 接下來,請檢查可用的工作節點:
kubectl get nodes | grep worker - 若要檢查是否有可採用新 Pod 的節點,請對每個工作節點執行下列命令:
其中 <worker_node> 是工作節點的名稱。確定工作節點的容量不超過 100%。kubectl describe node $<worker_node> - 若要新增其他節點,請先取得叢集中的 MachineSets 數目:
oc get machinesets -n openshift-machine-api - 對於少於 2 個節點的任何 MachineSets,請嘗試升級這些節點。
其中 <obpee00-qtthx-worker-eastus2> 是您要向上擴展至 2 個節點之 MachineSet 的範例名稱。oc scale --replicas=2 machineset <obpee00-qtthx-worker-eastus2> -n openshift-machine-api - 再次查詢 MachineSets,直到就緒和可用的節點清單達到您選取的節點數目為止。
- 您現在可以重新部署失敗的執行處理。
建立執行處理並列在「執行處理」清單之後,您就可以從執行處理名稱旁邊的功能表啟動服務主控台。依照使用 Oracle Blockchain Platform 中的主控台是什麼?所述,使用主控台設定您的網路。