Openshift 节点添加和删除
1.节点添加
在新节点上编辑yum源/etc/yum.repo.d/ocp.repo
/etc/hosts在主和节点上都加上相应信息
编辑host文件,加入
[OSEv3:children] masters nodes etcd new_nodes [new_nodes] node3.example.com openshift_node_group_name='node-config-compute'
然后运行
cd /usr/share/ansible/openshift-ansible
ansible-playbook playbooks/openshift-node/scaleup.yml
机器资源不够,添加到最后审批阶段不通过,一看master 8443端口都不响应了,去掉infra节点后再来居然可以了。:-(
TASK [Approve node certificates when bootstrapping] ***************************************************************************************************** Monday 03 December 2018 16:47:44 +0800 (0:00:00.416) 0:06:43.233 ******* FAILED - RETRYING: Approve node certificates when bootstrapping (30 retries left). FAILED - RETRYING: Approve node certificates when bootstrapping (29 retries left). FAILED - RETRYING: Approve node certificates when bootstrapping (28 retries left). FAILED - RETRYING: Approve node certificates when bootstrapping (27 retries left). FAILED - RETRYING: Approve node certificates when bootstrapping (26 retries left). FAILED - RETRYING: Approve node certificates when bootstrapping (25 retries left). FAILED - RETRYING: Approve node certificates when bootstrapping (24 retries left). FAILED - RETRYING: Approve node certificates when bootstrapping (23 retries left). FAILED - RETRYING: Approve node certificates when bootstrapping (22 retries left).
PLAY RECAP ********************************************************************************************************************************************** localhost : ok=22 changed=0 unreachable=0 failed=0 master.example.com : ok=62 changed=1 unreachable=0 failed=0 node3.example.com : ok=129 changed=18 unreachable=0 failed=0 INSTALLER STATUS **************************************************************************************************************************************** Initialization : Complete (0:03:42) Node Bootstrap Preparation : Complete (0:01:29) Node Join : Complete (0:03:22)
Monday 03 December 2018 16:51:24 +0800 (0:00:00.471) 0:10:22.945 *******
===============================================================================
Approve node certificates when bootstrapping --------------------------------------------------------------------------------------------------- 185.53s
Run variable sanity checks ---------------------------------------------------------------------------------------------------------------------- 55.58s
Gathering Facts --------------------------------------------------------------------------------------------------------------------------------- 53.54s
container_runtime : Fixup SELinux permissions for docker ---------------------------------------------------------------------------------------- 22.34s
get openshift_current_version -------------------------------------------------------------------------------------------------------------------- 8.66s
Detecting Operating System from ostree_booted ---------------------------------------------------------------------------------------------------- 8.30s
Gather Cluster facts ----------------------------------------------------------------------------------------------------------------------------- 7.91s
openshift_sanitize_inventory : Check for usage of deprecated variables --------------------------------------------------------------------------- 7.17s
openshift_sanitize_inventory : set_stats --------------------------------------------------------------------------------------------------------- 4.83s
Ensure openshift-ansible installer package deps are installed ------------------------------------------------------------------------------------ 4.74s
openshift_node : Update journald setup ----------------------------------------------------------------------------------------------------------- 4.05s
openshift_sanitize_inventory : include_tasks ----------------------------------------------------------------------------------------------------- 3.85s
Initialize openshift.node.sdn_mtu ---------------------------------------------------------------------------------------------------------------- 3.66s
openshift_manage_node : Wait for sync DS to set annotations on all nodes ------------------------------------------------------------------------- 3.41s
tuned : Ensure files are populated from templates ------------------------------------------------------------------------------------------------ 3.12s
set_fact openshift_portal_net if present on masters ---------------------------------------------------------------------------------------------- 2.79s
Gathering Facts ---------------------------------------------------------------------------------------------------------------------------------- 2.76s
openshift_manage_node : Set node schedulability -------------------------------------------------------------------------------------------------- 2.54s
openshift_sanitize_inventory : include_tasks ----------------------------------------------------------------------------------------------------- 2.54s
tuned : Restart tuned service -------------------------------------------------------------------------------------------------------------------- 2.45s
[root@master openshift-ansible]# oc get nodes NAME STATUS ROLES AGE VERSION master.example.com Ready master 3d v1.11.0+d4cacc0 node1.example.com NotReady infra 3d v1.11.0+d4cacc0 node2.example.com Ready compute 3d v1.11.0+d4cacc0 node3.example.com Ready compute 16m v1.11.0+d4cacc0
2.删除节点
- 目前已经调度的pod
[root@master openshift-ansible]# oc get pods --all-namespaces -o wide | grep node3 openshift-monitoring node-exporter-r2qrs 2/2 Running 0 17m 192.168.56.106 node3.example.com <none> openshift-node sync-n4c7l 1/1 Running 0 17m 192.168.56.106 node3.example.com <none> openshift-sdn ovs-jnqjc 1/1 Running 0 17m 192.168.56.106 node3.example.com <none> openshift-sdn sdn-cc8zb 1/1 Running 0 17m 192.168.56.106 node3.example.com
<none>
也可以通过
[root@master openshift-ansible]# oc adm manage-node node3.example.com --list-pods Listing matched pods on node: node3.example.com NAMESPACE NAME READY STATUS RESTARTS AGE openshift-monitoring node-exporter-r2qrs 2/2 Running 0 18m openshift-node sync-n4c7l 1/1 Running 0 18m openshift-sdn ovs-jnqjc 1/1 Running 0 18m openshift-sdn sdn-cc8zb 1/1 Running 0 18m
- 禁止调度
oc adm cordon node3.example.com
- 驱逐pod
[root@master openshift-ansible]# oc adm drain node3.example.com --force=true node/node3.example.com already cordoned error: unable to drain node "node3.example.com", aborting command... There are pending nodes to be drained: node3.example.com error: DaemonSet-managed pods (use --ignore-daemonsets to ignore): node-exporter-r2qrs, sync-n4c7l, ovs-jnqjc, sdn-cc8zb
- 删除节点
[root@master openshift-ansible]# oc delete nodes node3.example.com node "node3.example.com" deleted