LoginSignup
16
8

More than 1 year has passed since last update.

OCP 4.2で専用のInfra nodeを作成してルーター、内部レジストリー、モニタリング、ロギングを移動する

Last updated at Posted at 2019-12-21

この投稿はOpenShift Advent Calendar 2019の21日目の記事です。

OCP 3.11では、OCPのインストール時のAnsibleのインベントリーファイルで、nodeの変数としてopenshift_node_group_name='node-config-infra'を指定することで、専用のインフラストラクチャーノード(以降infra node)をインストール時に構成することができました。
(OCP 3.11 Docs / クラスターのインストール / 4. インベントリーファイルの設定)

専用のinfra nodeを構成することで、ルーター、内部レジストリー、モニタリング、ロギングなどのサービスを、master nodeや、worker nodeのアプリケーションPodとは分離して稼働させることができます。

一方、OCP 4.2では、IPIでもUPIでも、インストール時にはmaster nodeとworker nodeのみ構成され、インストール時に専用のinfra nodeを作成することはそのままでは多分できないのではと思います。
デフォルトでは、上述のルーター、内部レジストリー、モニタリングなどのサービスは、worker node上で稼働します。

但し、OCP4.2でもインストール後に専用のinfra nodeを構成してルーター、内部レジストリー、モニタリングなどのサービスを移動させる手順がOCP 4.2のドキュメントに記載されていましたので、今回はこれを試してみたいと思います。

なお、上述はIPIでインストールした場合に、Machinesetでinfra node用のノードラベルを付与するやり方のようです。
但し、UPIだとMachinesetはありませんので、今回はUPIでインストールした後に手動でinfra node用のノードラベルを付与して専用のinfra nodeを構成する方法をやってみたいと思います。

(2022/06/02追記)
以下のリンク先でOCP 4.10でMachine Config Poolを使用してInfra nodeを作成する方法をこちらに記載しました。こちらではアプリケーションPodをinfra nodeで稼働させない方法も記載しているのでこちらもご参照いただくと良いかなと思います。
Qiita / OpenShiftでMachine Config Pool (MCP) を使用してInfra nodeを作成する

前提の環境

今回試した環境では、以下の赤帽ブログを参考にして、インターネット非接続環境でベアメタルのUPIの方法でOCP4.2を導入しました。

もし、infra node用のworker nodeをまだ追加していなかった場合は、以下の方法でworker nodeを追加できます。

また、cluster-adminロールの管理者ユーザーを事前に作成しています。今後の作業はこのユーザーでクラスターにログインして実施します。

今回のinfra nodeの構成の目標

専用のinfra nodeを作成する場合は、そのnodeにnode-role.kubernetes.io/infra: ""というノードラベルを付与します。
その後、ルーター、内部レジストリー、モニタリング、ロギングなどのリソース設定の nodeSelectorでこのノードラベルを指定してinfra node上で動作させるように指定します。
この場合は、以下のようにノードラベルを修正します。

node名 ノードの役割 ノードラベル(default) ノードラベル(修正後)
master-0[1-3] master node-role.kubernetes.io/master: "" (修正無し)
worker-0[1-2] worker node-role.kubernetes.io/worker: "" (修正無し)
infra-0[1-3] infra node-role.kubernetes.io/worker: "" node-role.kubernetes.io/infra: ""

専用のinfra nodeを作成するだけではなく、その中でもロギングやモニタリングの負荷を考えて、以下のようにinfra nodeの中でもロギングやモニタリング専用のnodeを作りたい場合もあるかもしれません。

  • infra node (ルーター、内部レジストリー)
  • infra node (ロギング)
  • infra node (モニタリング)

これを実現するために、今回は追加でこれらの色分けをするノードラベルも付与してみます。
従って、今回は最初に作成した各worker nodeから以下のようにノードラベルを修正します。
(ラベル名はなんでもいいかと思いますが今回はinfra-roleというラベルにinfra、monitoring、loggingなどのような値を設定してみました。)

node名 ノードの役割 ノードラベル(default) ノードラベル(修正後) 備考
master-0[1-3] master node-role.kubernetes.io/master: "" (修正無し)
worker-0[1-2] worker node-role.kubernetes.io/worker: "" (修正無し)
infra-0[1-3] infra node-role.kubernetes.io/worker: "" node-role.kubernetes.io/infra: ""
infra-role: "infra"
ルーター、内部レジストリー用とわかるラベルも追加で付与
infra-mon-0[1-3] infra (monitoring) node-role.kubernetes.io/worker: "" node-role.kubernetes.io/infra: ""
infra-role: "monitoring"
モニタリング用とわかるラベルも追加で付与
infra-log-0[1-3] infra (logging) node-role.kubernetes.io/worker: "" node-role.kubernetes.io/infra: ""
infra-role: "logging"
ロギング用とわかるラベルも追加で付与

(*)ロギング(EFK)のコンポーネントは、インストール後に導入する必要があり、今回はまだ導入していなかったので、以降の手順では実際にはルーター、内部レジストリー、モニタリングだけinfra nodeに移動させてます。)

手順

現状の確認

ノードラベルの確認

現状では、master nodeは3台、worker nodeは、この後infra nodeにする予定のものも含めて11台デプロイしています。
worker-0[1-2]と同様に、infra-0[1-3]、infra-log-0[1-3]、infra-mon-0[1-3]も、UPIインストール時にはignitionファイルのworker.ignを指定して導入し、[ROLES]列は「worker」となっています。

[user01@bastion-1 ~]$ oc get nodes
NAME           STATUS   ROLES    AGE   VERSION
infra-01       Ready    worker   11d   v1.14.6+31a56cf75
infra-02       Ready    worker   11d   v1.14.6+31a56cf75
infra-03       Ready    worker   11d   v1.14.6+31a56cf75
infra-log-01   Ready    worker   11d   v1.14.6+31a56cf75
infra-log-02   Ready    worker   11d   v1.14.6+31a56cf75
infra-log-03   Ready    worker   11d   v1.14.6+31a56cf75
infra-mon-01   Ready    worker   21h   v1.14.6+31a56cf75
infra-mon-02   Ready    worker   21h   v1.14.6+31a56cf75
infra-mon-03   Ready    worker   21h   v1.14.6+31a56cf75
master-01      Ready    master   11d   v1.14.6+31a56cf75
master-02      Ready    master   11d   v1.14.6+31a56cf75
master-03      Ready    master   11d   v1.14.6+31a56cf75
worker-01      Ready    worker   11d   v1.14.6+31a56cf75
worker-02      Ready    worker   11d   v1.14.6+31a56cf75
[user01@bastion-1 ~]$

ノードラベルは、master nodeでは、node-role.kubernetes.io/master: ""が設定されています。

[user01@bastion-1 ~]$ oc describe node master-01 | grep -A 7 Labels
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=master-01
                    kubernetes.io/os=linux
                    node-role.kubernetes.io/master=
                    node.openshift.io/os_id=rhcos
Annotations:        machineconfiguration.openshift.io/currentConfig: rendered-master-23006f9b3b8e4d5acb43064bf6daec83
[user01@bastion-1 ~]$

その他のnodeではnode-role.kubernetes.io/worker: ""が設定されています。

[user01@bastion-1 ~]$ oc describe node infra-01 | grep -A 7 Labels
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=infra-01
                    kubernetes.io/os=linux
                    node-role.kubernetes.io/worker=
                    node.openshift.io/os_id=rhcos
Annotations:        machineconfiguration.openshift.io/currentConfig: rendered-worker-9ff3e82f6d9dfcf8b8946e89bbe92849
[user01@bastion-1 ~]$

ルーター、内部レジストリー、モニタリングの配置の確認

まず初期状態で、ルーター、内部レジストリー、モニタリングがどのnode上で動作しているか確認します。

ルーター

router-defaultのPodが、ROLESが「worker」の任意のnode上に配置されています。
(以下の例ではworker-02とinfra-01で稼働しています。)

[user01@bastion-1 ~]$ oc get pod -n openshift-ingress -o wide
NAME                              READY   STATUS    RESTARTS   AGE   IP              NODE        NOMINATED NODE   READINESS GATES
router-default-69cb577c78-clx2r   1/1     Running   0          11d   172.16.10.111   worker-02   <none>           <none>
router-default-69cb577c78-zn4t7   1/1     Running   0          11d   172.16.10.104   infra-01    <none>           <none>
[user01@bastion-1 ~]$

(ingress-operatorはmaster nodeで稼働しています。)

[user01@bastion-1 ~]$ oc get pod -n openshift-ingress-operator -o wide
NAME                                READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES
ingress-operator-5c9cb77967-ds6j9   1/1     Running   0          11d   10.128.0.27   master-03   <none>           <none>
[user01@bastion-1 ~]$
内部レジストリー

image-registryのPodが、ROLESが「worker」の任意のnode上に配置されています。
(以下の例では、infra-log-01で稼働しています。)
(cluster-image-registry-operatorはmaster nodeで稼働しています。)

[user01@bastion-1 ~]$ oc get pod -n openshift-image-registry -o wide
NAME                                               READY   STATUS    RESTARTS   AGE   IP            NODE           NOMINATED NODE   READINESS GATES
cluster-image-registry-operator-6945d997c9-gwq4l   2/2     Running   0          11d   10.130.0.27   master-02      <none>           <none>
image-registry-78884df965-rn8pc                    1/1     Running   0          11d   10.129.4.4    infra-log-01   <none>           <none>
node-ca-4f9mz                                      1/1     Running   0          11d   10.131.2.6    infra-01       <none>           <none>
node-ca-dw2xk                                      1/1     Running   0          11d   10.129.4.3    infra-log-01   <none>           <none>
node-ca-fv4q9                                      1/1     Running   0          24h   10.131.4.3    infra-mon-01   <none>           <none>
node-ca-g5vjm                                      1/1     Running   0          11d   10.128.0.51   master-03      <none>           <none>
node-ca-gnfg7                                      1/1     Running   0          11d   10.128.4.4    infra-02       <none>           <none>
node-ca-hlgmb                                      1/1     Running   0          24h   10.129.6.3    infra-mon-03   <none>           <none>
node-ca-hqnr8                                      1/1     Running   0          11d   10.131.0.7    worker-02      <none>           <none>
node-ca-jjf8v                                      1/1     Running   0          11d   10.130.4.3    infra-03       <none>           <none>
node-ca-mszjp                                      1/1     Running   0          11d   10.129.0.46   master-01      <none>           <none>
node-ca-qzps7                                      1/1     Running   0          24h   10.128.6.2    infra-mon-02   <none>           <none>
node-ca-v4xln                                      1/1     Running   0          11d   10.130.0.44   master-02      <none>           <none>
node-ca-v9d8t                                      1/1     Running   0          11d   10.128.2.5    infra-log-02   <none>           <none>
node-ca-xbpzn                                      1/1     Running   0          11d   10.130.2.3    worker-01      <none>           <none>
node-ca-xnntv                                      1/1     Running   0          11d   10.129.2.6    infra-log-03   <none>           <none>
[user01@bastion-1 ~]$
モニタリング

prometheusgrafanaalertmanager関連のPodが、ROLESが「worker」の任意のnode上に配置されています。

[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep prometheus | grep -v operator
prometheus-adapter-7d69f8c6fc-2xsrr            1/1     Running   0          11d   10.130.4.4      infra-03       <none>           <none>
prometheus-adapter-7d69f8c6fc-wl7wm            1/1     Running   0          11d   10.129.2.8      infra-log-03   <none>           <none>
prometheus-k8s-0                               6/6     Running   1          11d   10.128.2.4      infra-log-02   <none>           <none>
prometheus-k8s-1                               6/6     Running   1          11d   10.131.2.4      infra-01       <none>           <none>
[user01@bastion-1 ~]$
[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep grafana
grafana-57896d6f8d-86prh                       2/2     Running   0          11d   10.131.2.3      infra-01       <none>           <none>
[user01@bastion-1 ~]$
[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep alertmanager
alertmanager-main-0                            3/3     Running   0          11d   10.129.2.5      infra-log-03   <none>           <none>
alertmanager-main-1                            3/3     Running   0          11d   10.131.2.5      infra-01       <none>           <none>
alertmanager-main-2                            3/3     Running   0          11d   10.128.4.3      infra-02       <none>           <none>
[user01@bastion-1 ~]$
[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep node-exporter
node-exporter-4vgwd                            2/2     Running   0          11d   172.16.10.102   master-02      <none>           <none>
node-exporter-65wfj                            2/2     Running   0          24h   172.16.10.112   infra-mon-01   <none>           <none>
node-exporter-6w2t5                            2/2     Running   0          11d   172.16.10.103   master-03      <none>           <none>
node-exporter-9fwtb                            2/2     Running   0          11d   172.16.10.105   infra-02       <none>           <none>
node-exporter-bcwxh                            2/2     Running   0          11d   172.16.10.107   infra-log-01   <none>           <none>
node-exporter-f5vng                            2/2     Running   0          11d   172.16.10.111   worker-02      <none>           <none>
node-exporter-hjf86                            2/2     Running   0          11d   172.16.10.108   infra-log-02   <none>           <none>
node-exporter-mwgdx                            2/2     Running   0          11d   172.16.10.104   infra-01       <none>           <none>
node-exporter-n66w5                            2/2     Running   0          11d   172.16.10.106   infra-03       <none>           <none>
node-exporter-nwvpk                            2/2     Running   0          11d   172.16.10.109   infra-log-03   <none>           <none>
node-exporter-rq4h5                            2/2     Running   0          24h   172.16.10.114   infra-mon-03   <none>           <none>
node-exporter-shgxx                            2/2     Running   0          11d   172.16.10.110   worker-01      <none>           <none>
node-exporter-td7ln                            2/2     Running   0          11d   172.16.10.101   master-01      <none>           <none>
node-exporter-w5wwm                            2/2     Running   0          24h   172.16.10.113   infra-mon-02   <none>           <none>
[user01@bastion-1 ~]$

(cluster-monitoring-operatorprometheus-operatorはmaster node上で稼働しています。)

[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep operator
cluster-monitoring-operator-7dc89b7798-lh529   1/1     Running   0          11d   10.128.0.24     master-03      <none>           <none>
prometheus-operator-7d55749fc6-zhs2j           1/1     Running   0          11d   10.129.0.33     master-01      <none>           <none>
[user01@bastion-1 ~]$
ロギング

(今回はまだ導入していないので割愛します。)

ノードラベルの付与

ノードラベルの付与の仕方は以下に記載があります。

今回はOCPをUPIでインストールしたのでMachinesetはありません。
ですので、infra nodeにしようと思っているnodeに対して上述の今回のinfra nodeの構成の目標で検討したラベルをoc label nodeコマンドか、oc edit nodeコマンドで直接付与します。

infra nodeにノードラベルの付与

infra-0[1-3]のnodeに対して、以下のようにラベルを設定します。

  • node-role.kubernetes.io/worker: ""を削除
  • node-role.kubernetes.io/infra: ""を追加
  • infra-role: "infra"を追加

(ノードラベル修正前のmetadata.labels)

[user01@bastion-1 ~]$ oc get node infra-01 -o yaml | grep -A 8 labels
  labels:
    beta.kubernetes.io/arch: amd64
    beta.kubernetes.io/os: linux
    kubernetes.io/arch: amd64
    kubernetes.io/hostname: infra-01
    kubernetes.io/os: linux
    node-role.kubernetes.io/worker: ""
    node.openshift.io/os_id: rhcos
  name: infra-01
[user01@bastion-1 ~]$

(oc label nodeまたはoc edit nodeコマンドでノードラベルを修正)

[user01@bastion-1 ~]$ oc edit node infra-01
node/infra-01 edited
[user01@bastion-1 ~]$

(ノードラベル修正後のmetadata.labels)

[user01@bastion-1 ~]$ oc get node infra-01 -o yaml | grep -A 9 labels
  labels:
    beta.kubernetes.io/arch: amd64
    beta.kubernetes.io/os: linux
    infra-role: infra
    kubernetes.io/arch: amd64
    kubernetes.io/hostname: infra-01
    kubernetes.io/os: linux
    node-role.kubernetes.io/infra: ""
    node.openshift.io/os_id: rhcos
  name: infra-01
[user01@bastion-1 ~]$

これを、infra-0[1-3]の3つのnodeで繰り返し実施します。

infra node(monitoring)にノードラベルの付与

infra-mon-0[1-3]のnodeに対して、以下のようにラベルを設定します。

  • node-role.kubernetes.io/worker: ""を削除
  • node-role.kubernetes.io/infra: ""を追加
  • infra-role: "monitoring"を追加

(ノードラベル修正前のmetadata.labels)

[user01@bastion-1 ~]$ oc get node infra-mon-01 -o yaml | grep -A 8 labels
  labels:
    beta.kubernetes.io/arch: amd64
    beta.kubernetes.io/os: linux
    kubernetes.io/arch: amd64
    kubernetes.io/hostname: infra-mon-01
    kubernetes.io/os: linux
    node-role.kubernetes.io/worker: ""
    node.openshift.io/os_id: rhcos
  name: infra-mon-01
[user01@bastion-1 ~]$

(oc label nodeまたはoc edit nodeコマンドでノードラベルを修正)

[user01@bastion-1 ~]$ oc edit node infra-mon-01
node/infra-mon-01 edited
[user01@bastion-1 ~]$

(ノードラベル修正後のmetadata.labels)

[user01@bastion-1 ~]$ oc get node infra-mon-01 -o yaml | grep -A 9 labels
  labels:
    beta.kubernetes.io/arch: amd64
    beta.kubernetes.io/os: linux
    infra-role: monitoring
    kubernetes.io/arch: amd64
    kubernetes.io/hostname: infra-mon-01
    kubernetes.io/os: linux
    node-role.kubernetes.io/infra: ""
    node.openshift.io/os_id: rhcos
  name: infra-mon-01
[user01@bastion-1 ~]$

これを、infra-mon-0[1-3]の3つのnodeで繰り返し実施します。

infra node(logging)にノードラベルの付与

infra-log-0[1-3]のnodeに対して、以下のようにラベルを設定します。

  • node-role.kubernetes.io/worker: ""を削除
  • node-role.kubernetes.io/infra: ""を追加
  • infra-role: "logging"を追加

(ノードラベル修正前のmetadata.labels)

[user01@bastion-1 ~]$ oc get node infra-log-01 -o yaml | grep -A 8 labels
  labels:
    beta.kubernetes.io/arch: amd64
    beta.kubernetes.io/os: linux
    kubernetes.io/arch: amd64
    kubernetes.io/hostname: infra-log-01
    kubernetes.io/os: linux
    node-role.kubernetes.io/worker: ""
    node.openshift.io/os_id: rhcos
  name: infra-log-01
[user01@bastion-1 ~]$

(oc label nodeまたはoc edit nodeコマンドでノードラベルを修正)

[user01@bastion-1 ~]$ oc edit node infra-log-01
node/infra-log-01 edited
[user01@bastion-1 ~]$

(ノードラベル修正後のmetadata.labels)

[user01@bastion-1 ~]$ oc get node infra-log-01 -o yaml | grep -A 9 labels
  labels:
    beta.kubernetes.io/arch: amd64
    beta.kubernetes.io/os: linux
    infra-role: logging
    kubernetes.io/arch: amd64
    kubernetes.io/hostname: infra-log-01
    kubernetes.io/os: linux
    node-role.kubernetes.io/infra: ""
    node.openshift.io/os_id: rhcos
  name: infra-log-01
[user01@bastion-1 ~]$

これを、infra-log-0[1-3]の3つのnodeで繰り返し実施します。

ノードラベルの確認

ノードラベルを確認します。
infra-0[1-3]、infra-mon-0[1-3]、infra-log-0[1-3]で、[ROLES]列の値がinfraに変更され、[INFRA-ROLE]として、それぞれinframonitoringloggingという値が設定されました。

[user01@bastion-1 ~]$ oc get nodes -L infra-role
NAME           STATUS   ROLES    AGE   VERSION             INFRA-ROLE
infra-01       Ready    infra    11d   v1.14.6+31a56cf75   infra
infra-02       Ready    infra    11d   v1.14.6+31a56cf75   infra
infra-03       Ready    infra    11d   v1.14.6+31a56cf75   infra
infra-log-01   Ready    infra    11d   v1.14.6+31a56cf75   logging
infra-log-02   Ready    infra    11d   v1.14.6+31a56cf75   logging
infra-log-03   Ready    infra    11d   v1.14.6+31a56cf75   logging
infra-mon-01   Ready    infra    25h   v1.14.6+31a56cf75   monitoring
infra-mon-02   Ready    infra    25h   v1.14.6+31a56cf75   monitoring
infra-mon-03   Ready    infra    25h   v1.14.6+31a56cf75   monitoring
master-01      Ready    master   11d   v1.14.6+31a56cf75
master-02      Ready    master   11d   v1.14.6+31a56cf75
master-03      Ready    master   11d   v1.14.6+31a56cf75
worker-01      Ready    worker   11d   v1.14.6+31a56cf75
worker-02      Ready    worker   11d   v1.14.6+31a56cf75
[user01@bastion-1 ~]$

ルーターの移動

ルーターのinfra-0[1-3]への移動は以下を参考に実施します。

まず、ルーターOperatorのIngressControllerカスタムリソースを表示して内容を確認します。

[user01@bastion-1 ~]$ oc get ingresscontroller default -n openshift-ingress-operator -o yaml
apiVersion: operator.openshift.io/v1
kind: IngressController
metadata:
  creationTimestamp: "2019-12-07T08:06:22Z"
  finalizers:
  - ingresscontroller.operator.openshift.io/finalizer-ingresscontroller
  generation: 1
  name: default
  namespace: openshift-ingress-operator
  resourceVersion: "302181"
  selfLink: /apis/operator.openshift.io/v1/namespaces/openshift-ingress-operator/ingresscontrollers/default
  uid: 75153d2a-18c8-11ea-837a-000c298096f7
spec:
  replicas: 2
status:
  availableReplicas: 2
  conditions:
  - (略)
  domain: apps.test.example.local
  endpointPublishingStrategy:
    type: HostNetwork
  selector: ingresscontroller.operator.openshift.io/deployment-ingresscontroller=default
[user01@bastion-1 ~]$

ingresscontrollerリソースを編集し、nodeSelectorをinfra-0[1-3]のnodeに先ほど付与したノードラベルを使用するように変更します。

[user01@bastion-1 ~]$ oc edit ingresscontroller default -n openshift-ingress-operator -o yaml

具体的には、以下の部分を編集しました。

(修正前)

spec:
  replicas: 2

(修正後)

spec:
  nodePlacement:
    nodeSelector:
      matchLabels:
        infra-role: infra
        node-role.kubernetes.io/infra: ""
  replicas: 2

router-defaultのPodが、infra-0[1-3]のnode上に移動したことを確認します。

[user01@bastion-1 ~]$ oc get pod -n openshift-ingress -o wide
NAME                             READY   STATUS    RESTARTS   AGE     IP              NODE       NOMINATED NODE   READINESS GATES
router-default-6c58d8548-9tsmv   1/1     Running   0          3m20s   172.16.10.105   infra-02   <none>           <none>
router-default-6c58d8548-djgql   1/1     Running   0          3m42s   172.16.10.106   infra-03   <none>           <none>
[user01@bastion-1 ~]$
[user01@bastion-1 ~]$

内部レジストリーの移動

内部レジストリーのinfra-0[1-3]への移動は以下を参考に実施します。

まずconfig/instanceオブジェクトを表示して内容を確認します。

[user01@bastion-1 ~]$ oc get config/cluster -o yaml
apiVersion: imageregistry.operator.openshift.io/v1
kind: Config
metadata:
  creationTimestamp: "2019-12-07T08:06:19Z"
  finalizers:
  - imageregistry.operator.openshift.io/finalizer
  generation: 2
  name: cluster
  resourceVersion: "313901"
  selfLink: /apis/imageregistry.operator.openshift.io/v1/configs/cluster
  uid: 738d36aa-18c8-11ea-b66e-000c29c2141b
spec:
  defaultRoute: false
  disableRedirect: false
  httpSecret: d2723c301c0aa08e19552f3690c31425b517233c4a86fe7133a21069d941eb3e84b8a6000dc5f196d880b40ca3f7d9784085c1f2fb5d6680be713c1818b3be4c
  logging: 2
  managementState: Managed
  proxy:
    http: ""
    https: ""
    noProxy: ""
  readOnly: false
  replicas: 1
  requests:
    read:
      maxInQueue: 0
      maxRunning: 0
      maxWaitInQueue: 0s
    write:
      maxInQueue: 0
      maxRunning: 0
      maxWaitInQueue: 0s
  storage:
    emptyDir: {}
status:
(略)

config/instanceオブジェクトを編集します。

[user01@bastion-1 ~]$ oc edit config/cluster
config.imageregistry.operator.openshift.io/cluster edited
[user01@bastion-1 ~]$

具体的には、spec以下にnodeSelectorの行を追加しました。

(修正後)

spec:
  nodeSelector:
    node-role.kubernetes.io/infra: ""
    infra-role: "infra"

image-registryのPodがinfra-0[1-3]のnode上に移動したことを確認します。

[user01@bastion-1 ~]$ oc get pod -n openshift-image-registry -o wide
NAME                                               READY   STATUS    RESTARTS   AGE     IP            NODE           NOMINATED NODE   READINESS GATES
cluster-image-registry-operator-6945d997c9-gwq4l   2/2     Running   0          11d     10.130.0.27   master-02      <none>           <none>
image-registry-787575d57-hrw57                     1/1     Running   0          2m46s   10.130.4.5    infra-03       <none>           <none>
node-ca-4f9mz                                      1/1     Running   0          11d     10.131.2.6    infra-01       <none>           <none>
node-ca-dw2xk                                      1/1     Running   0          11d     10.129.4.3    infra-log-01   <none>           <none>
node-ca-fv4q9                                      1/1     Running   0          25h     10.131.4.3    infra-mon-01   <none>           <none>
node-ca-g5vjm                                      1/1     Running   0          11d     10.128.0.51   master-03      <none>           <none>
node-ca-gnfg7                                      1/1     Running   0          11d     10.128.4.4    infra-02       <none>           <none>
node-ca-hlgmb                                      1/1     Running   0          25h     10.129.6.3    infra-mon-03   <none>           <none>
node-ca-hqnr8                                      1/1     Running   0          11d     10.131.0.7    worker-02      <none>           <none>
node-ca-jjf8v                                      1/1     Running   0          11d     10.130.4.3    infra-03       <none>           <none>
node-ca-mszjp                                      1/1     Running   0          11d     10.129.0.46   master-01      <none>           <none>
node-ca-qzps7                                      1/1     Running   0          25h     10.128.6.2    infra-mon-02   <none>           <none>
node-ca-v4xln                                      1/1     Running   0          11d     10.130.0.44   master-02      <none>           <none>
node-ca-v9d8t                                      1/1     Running   0          11d     10.128.2.5    infra-log-02   <none>           <none>
node-ca-xbpzn                                      1/1     Running   0          11d     10.130.2.3    worker-01      <none>           <none>
node-ca-xnntv                                      1/1     Running   0          11d     10.129.2.6    infra-log-03   <none>           <none>
[user01@bastion-1 ~]$

モニタリングの移動

モニタリングのinfra-mon-0[1-3]への移動は以下を参考に実施します。

デフォルトでは、Prometheus、Grafana、および AlertManager が含まれる Prometheus Cluster Monitoring スタックはクラスターモニタリングをデプロイするためにデプロイされます。これは Cluster Monitoring Operator によって管理されます。このコンポーネント異なるマシンに移行するには、カスタム ConfigMap を作成し、これを適用します。

以下のConfigMap定義をcluster-monitoring-configmap.yamlファイルとして保存します。

[user01@bastion-1 ~]$ vi cluster-monitoring-configmap.yaml
[user01@bastion-1 ~]$ cat cluster-monitoring-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-monitoring-config
  namespace: openshift-monitoring
data:
  config.yaml: |+
    alertmanagerMain:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
        infra-role: "monitoring"
    prometheusK8s:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
        infra-role: "monitoring"
    prometheusOperator:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
        infra-role: "monitoring"
    grafana:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
        infra-role: "monitoring"
    k8sPrometheusAdapter:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
        infra-role: "monitoring"
    kubeStateMetrics:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
        infra-role: "monitoring"
    telemeterClient:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
        infra-role: "monitoring"
[user01@bastion-1 ~]$

このConfigMapを実行すると、モニタリングのコンポーネントがnodeSelectorで指定したnodeに再デプロイされます。

上述のcluster-monitoring-configmap.yamlファイルから新規のConfigMapを作成します。

[user01@bastion-1 ~]$ oc create -f cluster-monitoring-configmap.yaml
configmap/cluster-monitoring-config created
[user01@bastion-1 ~]$

ConfigMapが作成されたことを確認します。

[user01@bastion-1 ~]$ oc get configmap -n openshift-monitoring cluster-monitoring-config
NAME                        DATA   AGE
cluster-monitoring-config   1      85s
[user01@bastion-1 ~]$

prometheusgrafanaalertmanager関連のPodが、infra-mon-0[1-3]のnodeに移動したことを確認します。

[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep prometheus | grep -v operator
prometheus-adapter-7d96d74f85-fg5gm            1/1     Running   0          3m58s   10.128.6.4      infra-mon-02   <none>           <none>
prometheus-adapter-7d96d74f85-km6n4            1/1     Running   0          3m48s   10.129.6.5      infra-mon-03   <none>           <none>
prometheus-k8s-0                               6/6     Running   1          3m18s   10.129.6.7      infra-mon-03   <none>           <none>
prometheus-k8s-1                               6/6     Running   1          3m39s   10.131.4.6      infra-mon-01   <none>           <none>
[user01@bastion-1 ~]$
[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep grafana
grafana-9d88cb7cb-5znqd                        2/2     Running   0          4m8s    10.131.4.5      infra-mon-01   <none>           <none>
[user01@bastion-1 ~]$
[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep alertmanager
alertmanager-main-0                            3/3     Running   0          3m45s   10.131.4.7      infra-mon-01   <none>           <none>
alertmanager-main-1                            3/3     Running   0          4m1s    10.129.6.6      infra-mon-03   <none>           <none>
alertmanager-main-2                            3/3     Running   0          4m17s   10.128.6.5      infra-mon-02   <none>           <none>
[user01@bastion-1 ~]$
[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep node-exporter
node-exporter-4vgwd                            2/2     Running   0          12d     172.16.10.102   master-02      <none>           <none>
node-exporter-65wfj                            2/2     Running   0          25h     172.16.10.112   infra-mon-01   <none>           <none>
node-exporter-6w2t5                            2/2     Running   0          12d     172.16.10.103   master-03      <none>           <none>
node-exporter-9fwtb                            2/2     Running   0          11d     172.16.10.105   infra-02       <none>           <none>
node-exporter-bcwxh                            2/2     Running   0          11d     172.16.10.107   infra-log-01   <none>           <none>
node-exporter-f5vng                            2/2     Running   0          11d     172.16.10.111   worker-02      <none>           <none>
node-exporter-hjf86                            2/2     Running   0          11d     172.16.10.108   infra-log-02   <none>           <none>
node-exporter-mwgdx                            2/2     Running   0          11d     172.16.10.104   infra-01       <none>           <none>
node-exporter-n66w5                            2/2     Running   0          11d     172.16.10.106   infra-03       <none>           <none>
node-exporter-nwvpk                            2/2     Running   0          11d     172.16.10.109   infra-log-03   <none>           <none>
node-exporter-rq4h5                            2/2     Running   0          25h     172.16.10.114   infra-mon-03   <none>           <none>
node-exporter-shgxx                            2/2     Running   0          11d     172.16.10.110   worker-01      <none>           <none>
node-exporter-td7ln                            2/2     Running   0          12d     172.16.10.101   master-01      <none>           <none>
node-exporter-w5wwm                            2/2     Running   0          25h     172.16.10.113   infra-mon-02   <none>           <none>
[user01@bastion-1 ~]$
[user01@bastion-1 ~]$ oc get pod -n openshift-monitoring -o wide | grep operator
cluster-monitoring-operator-7dc89b7798-lh529   1/1     Running   0          12d     10.128.0.24     master-03      <none>           <none>
prometheus-operator-787689f886-zrq97           1/1     Running   0          5m30s   10.129.6.4      infra-mon-03   <none>           <none>
[user01@bastion-1 ~]$

ロギングの移動

ロギングのinfra-log-0[1-3]への移動は以下を参考に実施します。

(ロギング(EFK)のコンポーネントはインストール時にデフォルトで導入されるわけではなく、インストール後に導入する必要があり、今回はまだ導入していなかったので実施しませんでした。)

まとめ

OCP 4.2ではインストール時に専用のinfra nodeを指定することはできませんが、インストール後に専用のinfra nodeを構成する方法がOCP 4.2のドキュメントに記載されており、やってみたところうまくできました。

追記

昨日2019/12/20(Fri)に開催されたOpenShift.Runのイベントにも参加させて頂きました。
セッションやLT内容も素晴らしかったですが、実際にいつも参考にさせていただいているAdvent Calendarやブログを書かれている方やセッション登壇者の方にも色々お話をお伺いすることができ非常に有益で楽しかったです。
今後もこのような場での情報収集をさせて頂きつつ、私自身も(せっかくQiita初投稿したことですし)今後はなんらかの情報発信をしていければなと思っています。

16
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
8