在OCP 4.2中,创建一个专用的基础设施节点,将路由器、内部注册表、监控和日志移到该节点上
这篇文章是OpenShift Advent Calendar 2019的第21天的贴子。
在OCP 3.11版本中,通过在OCP安装时的Ansible清单文件中指定节点的变量openshift_node_group_name=’node-config-infra’,可以在安装时配置专用的基础设施节点(以下简称为infra节点)。(OCP 3.11文档/集群安装/4. 清单文件设置)
通过配置专用的基础设施节点,可以实现将路由器、内部注册表、监控、日志记录等服务与主节点和工作节点的应用程序Pod分离并运行。
在OCP 4.2中,无论使用IPI还是UPI进行安装,只会配置主节点和工作节点,不能直接创建专用的基础设施节点。默认情况下,路由器、内部注册表、监控等服务会在工作节点上运行。
然而,在OCP4.2中,安装后还需要按照OCP 4.2的文档配置专用的基础设施节点,并将路由器、内部注册表、监控等服务迁移到该节点上。所以,我想尝试这个步骤。
-
- OCP 4.2 Docs / マシン管理 / 5. インフラストラクチャー MachineSet の作成
- OCP 4.2 Docs / マシン管理 / 5.3. リソースのインフラストラクチャー MachineSet への移行
此外,根据前述的说法,这似乎是在使用IPI进行安装时为基础设施节点添加节点标签的方法。
然而,由于使用UPI时没有Machineset,所以这次我想尝试在使用UPI安装后手动为基础设施节点添加节点标签来配置专用的基础设施节点的方法。
(2022/06/02更新)
我在以下链接中介绍了如何在OCP 4.10中使用Machine Config Pool创建Infra节点的方法。由于还在这里介绍了不在Infra节点上运行应用程序Pod的方法,所以建议您也参考一下这里。
Qiita / OpenShift上使用Machine Config Pool(MCP)创建Infra节点
前提条件的环境
我們在本次測試的環境中參考了以下的赤帽博客,在沒有網絡連接的環境中,使用裸機的UPI方法成功部署了OCP4.2。
-
- 赤帽ブログ / OpenShift 4.2におけるネットワーク制限環境下でのインストール
- 赤帽ブログ / OpenShift 4.1をベアメタルへUPIインストールする
如果您尚未为基础设施节点添加工作节点,您可以按照以下方法添加工作节点。
- 赤帽ブログ / OCP4/UPIインストールにおけるWorkerノードの追加(RHCOS編)
另外,我们会提前创建一个拥有cluster-admin角色的管理用户。以后的工作将由该用户登录集群并执行。
本次infra node的目标是构建
如果要创建专用的 infra node,则需要为该节点添加 node-role.kubernetes.io/infra: “” 的节点标签。
然后,在资源设置中的路由器、内部注册表、监控和日志等资源的 nodeSelector 中指定这个节点标签,以指定在 infra node 上运行。
在这种情况下,需要修改节点标签如下所示。
node-role.kubernetes.io/master: ""(修正無し)worker-0[1-2]workernode-role.kubernetes.io/worker: ""(修正無し)infra-0[1-3]infranode-role.kubernetes.io/worker: ""node-role.kubernetes.io/infra: ""除了创建专用的 infra 节点之外,还需要考虑日志记录和监控的负载。有时也可能需要在 infra 节点中创建专用于日志记录和监控的节点。
-
- infra node (ルーター、内部レジストリー)
-
- infra node (ロギング)
- infra node (モニタリング)
为了实现这一点,我们将为这些分开的节点标签添加额外的节点标签。
因此,本次我们将修改每个首次创建的工作节点的节点标签如下。
(标签名称可以随意设置,但本次我们将其设置为infra-role,将值设置为infra、monitoring、logging等。)
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)组件,需要在安装后进行引入。由于此次尚未进行引入,因此在后续的步骤中,实际上只将路由器、内部注册表和监视器移动到基础设施节点。
操作步骤
确认目前的状况
确认节点标签
目前,我们部署了3个主节点和11个工作节点,其中包括计划将来用作基础设施节点的节点。与worker-0 [1-2]类似,infra-0 [1-3],infra-log-0 [1-3]和infra-mon-0 [1-3]也在UPI安装过程中使用worker.ign ignition文件进行部署,[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 ~]$
在主节点上,节点标签为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-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 ~]$
确认路由器、内部注册表和监控的配置。
首先,在初始状态下,确认路由器、内部注册表和监控在哪个节点上运行。
路由器
router-default的Pod被部署在任意一个拥有”worker”角色的节点上。
(例如,在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 ~]$
(操作员正在主节点上运行。)
[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”的节点上。
(在此示例中,它正在infra-log-01上运行。)
cluster-image-registry-operator正在主节点上运行。
[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 ~]$
监测
Prometheus、Grafana和Alertmanager相关的Pod被部署在任意一个节点上,其节点的ROLES为”worker”。
[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-operator和prometheus-operator在主节点上运行。
[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 4.2 Docs / ノード / 1.8. ノードセレクターの使用による特定ノードへの Pod の配置
因为这次是使用UPI在OCP上安装,所以没有Machineset。
因此,根据之前确定好的infra node的配置目标,我们打算直接使用oc label node命令或oc edit node命令为将作为infra node的节点打上相应的标签。
给 infra node 添加节点标签
将标签分配给infra-0[1-3]的节点,如下所示。
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 ~]$
(修改后的元数据标签中的节点标签)
[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-01、infra-02和infra-03的3个节点上重复执行。
给基础设施节点(监控)添加节点标签
对于 infra-mon-0[1-3] 的节点,设置如下标签。
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 ~]$
(元数据标签在节点标签修正后)
[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]的三個節點上重複執行這個操作。
为infra节点添加节点标签(logging)。
对于 infra-log-0[1-3] 的节点,可以按照以下方式设置标签。
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”命令来修改节点标签。(Modify the node label using the “oc label node” or “oc edit node” command.)
[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]的三个节点重复执行这个操作。
确认节点标签
确认节点标签。
infra-0[1-3],infra-mon-0[1-3],infra-log-0[1-3]节点的[ROLES]列的值已更改为infra,并在[INFRA-ROLE]列中设置为infra、monitoring、logging分别设置的值。
[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]将按照下面的参考进行实施。
- OCP 4.2 Docs / マシン管理 / 5.3.1. ルーターの移動
首先,我们查看并确认Router 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]节点上。
[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] 的节点上。
[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]。
- OCP 4.2 Docs / マシン管理 / 5.3.2. デフォルトレジストリーの移行
首先,查看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]节点上。
[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]。
- OCP 4.2 Docs / マシン管理 / 5.3.3. モニタリングソリューションの移動
默认情况下,Prometheus Cluster Monitoring Stack 包含 Prometheus、Grafana和AlertManager,用于部署集群监控。这由 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的节点上重新部署。
从上述的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 ~]$
确认 Prometheus、Grafana 和 Alertmanager 相关的 Pod 已经迁移到 infra-mon-01至03 的节点上。
[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],请按照以下参考进行操作。
- OCP 4.2 Docs / マシン管理 / 5.3.4. クラスターロギングリソースの移動
“安装 Elastic Fluentd Kibana (EFK) 组件不是默认的,需要在安装后手动引入。由于本次尚未引入,因此我们没有进行这个操作。”
总结
在OCP 4.2中,安装时无法指定专用的 infra 节点,但在安装后,可以按照 OCP 4.2 文档中的说明来配置专用的 infra 节点,并且经过试验可以成功实现。
追加记录
我也参加了昨天2019年12月20日(星期五)举行的OpenShift.Run活动。会议和LT的内容也非常棒,实际上,我一直在参考的Advent Calendar、写博客的人以及演讲者也很多,我有机会和他们交流了许多非常有益和有趣的话题。今后,在这样的场合继续收集信息的同时,我也想自己进行一些信息发布(毕竟我刚刚在Qiita上首次发布了一篇文章),希望能有所贡献。