金鱼哥RHCA回忆录:DO280OpenShift安装与部署--安装步骤说明

简介: 第二章 OpenShift安装与部署--安装步骤说明
🎹 个人简介:大家好,我是 金鱼哥,CSDN运维领域新星创作者,华为云·云享专家,阿里云社区·专家博主
📚个人资质: CCNA、HCNP、CSNA(网络分析师),软考初级、中级网络工程师、RHCSA、RHCE、RHCA、RHCI、ITIL😜
💬格言:努力不一定成功,但要想成功就必须努力🔥

🎈支持我:可点赞👍、可收藏⭐️、可留言📝


📜安装步骤说明

📑1. 安装步骤

安装准备完成后正式安装包括四个步骤:

  • 编写一个目录文件来描述所需的集群特性和体系结构;
  • 执行prerequisites.yml的playbook;
  • 执行deploy_cluster,yml的playbook;
  • 验证安装。

📑2. 安装和配置节点

OpenShift Inventory定义了以下主机组。

  • master:对于OpenShift,这是必须的组,定义了OpenShift集群中哪些主机充当master节点;
  • node:对于OpenShift,这是必须的组,它定义了OpenShift集群中哪些主机充当node节点;
  • etcd:[master]部分中列出的所有主机也应属于etcd;
  • nfs:这个组是可选的,应该只包含一个主机。如果Inventory文件中存在特定的变量,OpenShift playbook将在这台机器上安装并配置NFS;
  • OSEv3:这个组包含任何属于OpenShift集群的机器。安装剧本引用这个组来运行在集群全范围内的任务。
[student@workstation install-prepare]$ cat inventory 
[workstations]
workstation.lab.example.com

[nfs]
services.lab.example.com

[masters]
master.lab.example.com

[etcd]
master.lab.example.com

[nodes]
master.lab.example.com
node1.lab.example.com
node2.lab.example.com

[OSEv3:children]
masters
etcd
nodes
nfs

#Variables needed by the prepare_install.yml playbook.
[nodes:vars]
registry_local=registry.lab.example.com
use_overlay2_driver=true
insecure_registry=false
run_docker_offline=true
docker_storage_device=/dev/vdb

需要添加的内容说明:

  • 安装所需版本的OpenShift容器平台;
  • 用户使用htpasswd身份验证对集群进行身份验证;
  • DNS条目apps.lab.example.com用作OpenShift应用程序的子域;
  • NFS存储用于OpenShift etcd服务和OpenShift 内部仓库;
  • classroom container registry用作仓库。

变量说明:

OpenShift安装变量记录在Inventory的[OSEv3:vars]部分。安装变量用于配置多个OpenShift组件,例如:

  • 一个内部容器仓库;
  • Gluster、Ceph等以便于提供持久性存储;
  • 集群日志;
  • 自定义集群证书。

📑3. 配置OpenShift版本

可通过在[OSEv3:vars]中指定如下配置确定OpenShift所安装的版本:

openshift_deployment_type=openshiftenterprise
openshift_release=v3.9

指定OpenShift部署类型,可选值为openshift-enterprise和origin。

openshift_image_tag=v3.9.14
openshift_disable_check=disk_availability,docker_storage,memory_availability

容器化的OpenShift服务使用带有“v3.9.14”标记的镜像。这将阻止集群自动升级到更新的容器镜像;

对于非生产集群,可以禁用对系统需求的检查。


📑4. 配置验证

OpenShift容器平台身份验证基于OAuth, OAuth提供了一个基于HTTP的APl,用于对交互式和非交互式客户端进行身份验证。

OpenShift master运行一个OAuth服务器,OpenShift可以支持多种Provider,这些Provider可以与特定于组织的身份管理产品集成。支持的OpenShift身份验证的Provider:

  • HTTP Basic,外部单点登录(SSO)系统;
  • 使用GitHub和GitLab帐号;
  • OpenID连接,使用OpenID-compatible SSO和谷歌帐户;
  • OpenStack Keystone v3;
  • LDAP v3服务器。

OpenShift安装程序使用默认的安全方法,DenyAllPasswordIdentityProvider是缺省提供程序。使用此Provider,表示只有master主机上的root用户才能使用OpenShift客户端命令和API。


📑5. 配置htpasswd验证

OpenShift HTPasswdPasswordIdentityProvider根据Apache HTTPD htpasswd程序生成的文件验证用户和密码。

htpasswd程序将用户名和密码保存在纯文本文件中,每行一条记录,字段用冒号分隔。密码使用MD5散列。如果将此文件添加或删除用户,或更改用户密码,OpenShift OAuth服务器将自动重新读取该文件。

要将OpenShift master配置使用HTPasswdPasswordIdentityProvider,需要配置openshift_master_identity_providers。

openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', #配置后端驱动
'filename': '/etc/origin/master/htpasswd'}] #制定master主机上的本地文件

也支持在配置文件中直接指定初始的用户名和密码。

openshift_master_htpasswd_users="{'user1':'$apr1$.NHMsZYc$MdmfWN5DM3q280/W7c51c/',
'user2':'$apr1$.NHMsZYc$MdmfWN5DM3q280/W7c51c/'}"

生产hash密码可参考如下:

[student@workstation ~]$ htpasswd -nb admin redhat
admin:$apr1$.NHMsZYc$MdmfWN5DM3q280/W7c51c/ 

[student@workstation ~]$ openssl passwd -apr1 redhat
$apr1$A05Inu1A$IXdpq6d/m7mxondHEy6zC1

📑6. 网络要求

集群节点的通配符DNS条目允许任何新创建的路由自动路由到subdomain的集群。通配符DNS条目必须存在于唯一的子域中,例如apps.mycluster.com,并解析为主机名或集群节点的IP地址。inventory文件中通配符DNS条目是通过变量openshift_master_default_subdomain进行设置 。

openshift_master_default_subdomain=apps.mycluster.com

📑7. master服务端口

主服务端口openshift_master_api_port变量定义主API的监听端口。缺省端口8443,当master使用SSL时,也可以使用443端口。从而在连接的时候省略端口号。

master console端口由openshift_master_console_port变量的值设置,默认端口是8443。master console端口也可以设置为443,从而在连接的时候省略端口号。


📑8. 防火墙

OpenShift节点上的默认防火墙服务是iptables。若要在所有节点上使用firewalld作为防火墙服务,需要将操作系统防火墙使用firewalld变量设置为true,即os_firewall_use_firewalld=true。


📜配置持久化存储

📑持久存储配置

默认情况下,容器数据是临时的,并且在容器被销毁时丢失。Kubernetes持久卷框架为容器请求和使用持久存储提供了一种机制。为了避免数据丢失,这些服务被配置为使用持久卷。

OpenShift支持多个插件,使用各种存储技术创建持久卷。可以使用NFS、iSCSI、GlusterFS、Ceph或其他商业云存储。

本环境中,OpenShift容器registry和OpenShift Ansible Broker服务被配置为使用NFS持久性存储。

提示:生产环境默认OpenShift不支持NFS持久存储集群,要允许NFS在非生产集群上持久存储,需要配置openshift_enable_unsupported_configurations=true。


📑container仓库

要为OpenShift容器registry配置NFS持久性存储,请将以下内容添加到Inventory文件中:

openshift_hosted_registry_storage_kind=nfs
openshift_hosted_registry_storage_nfs_directory=/exports
openshift_hosted_registry_storage_volume_name=registry
openshift_hosted_registry_storage_nfs_options='*(rw,root_squash)'
openshift_hosted_registry_storage_volume_size=40Gi
openshift_hosted_registry_storage_access_modes=['ReadWriteMany']

📑OpenShift Ansible Broker

OpenShift Ansible Broker(OAB)是一个容器化的OpenShift服务,部署自己的etcd服务。持久Etcd存储所需的配置与registry所需的配置类似。

openshift_hosted_etcd_storage_kind=nfs
openshift_hosted_etcd_storage_nfs_directory=/exports
openshift_hosted_etcd_storage_volume_name=etcdvol2
openshift_hosted_etcd_storage_nfs_options="*(rw,root_squash,sync,no_wdelay)"
openshift_hosted_etcd_storage_volume_size=1G
openshift_hosted_etcd_storage_access_modes=["ReadWriteOnce"]
openshift_hosted_etcd_storage_labels={'storage': 'etcd'}

📜OpenShift其他配置

📑配置离线本地registry

本环境OpenShift使用容器仓库为registry.lab.example.com,要将集群配置为从内部仓库pull image,需要在Inventory中进行如下配置:

#Modifications Needed for a Disconnected Install
oreg_url=registry.lab.example.com/openshift3/ose-${component}:${version} 

\#可访问image仓库的位置,必须以ose-${component}:${version}结尾。

openshift_examples_modify_imagestreams=true

\#OpenShift安装了用于部署示例应用程序的模板。这个变量指示playbook修改所有示例的IS,使其指向私有仓库,而不是registry.access.redhat.com。

openshift_docker_additional_registries=registry.lab.example.com

\#此变量用于将本地可访问仓库添加到每个节点上的docker配置中。

openshift_docker_blocked_registries=registry.access.redhat.com,docker.io

\#此变量用于在OpenShift节点上配置docker的blocked_registries。

#Image Prefix Modifications
openshift_web_console_prefix=registry.lab.example.com/openshift3/ose-
openshift_cockpit_deployer_prefix='registry.lab.example.com/openshift3/'
openshift_service_catalog_image_prefix=registry.lab.example.com/openshift3/ose-
template_service_broker_prefix=registry.lab.example.com/openshift3/ose-
ansible_service_broker_image_prefix=registry.lab.example.com/openshift3/ose-
ansible_service_broker_etcd_image_prefix=registry.lab.example.com/rhel7/

\#通过在容器image名称前面加上registry.lab.example.com以确保OpenShift服务的容器image可以从私有内部仓库下载。


📑配置NODE labels

节点label是分配给每个节点的任意key/value描述。node label通常用于区分地理数据中心或标识节点上的可用资源的有意义的描述。

应用程序可以在其deployment中根据node lables配置一个选择器。如果匹配到,应用程序的pod必须部署在其符合node labels的节点上。

使用主机变量openshift_node_tags在Inventory文件中设置节点标签。

[nodes]
...output omitted...
nodeX.example.com openshift_node_labels="{'zone':'west', 'gpu':'true'}"
...output omitted...

如上所示配置给nodeX.example.com配置两个labels,zone=west和gpu=true。

OpenShift集群的一个常见架构是区分master、infrastructure node和compute node。在此架构中,infrastructure node承载OpenShift Pod的registry和路由器,而compute node承载来自用户项目的应用程序pod。master节点不承载应用程序或infrastructure pod。

可使用 node label 来标识特定节点的角色,通常master node label 为 node-role.kubernetes.io/master=true,infrastructure node label 为 region=infra,compute node label 为 node-role.kubernetes.io/compute=true。

[nodes]
master.lab.example.com
node1.lab.example.com openshift_node_labels="{'region':'infra'}"
node2.lab.example.com

如果一个节点设计为同时承载infrastructure 和 application pods,则必须显式定义两个节点标签。

[nodes]
...
nodeX.example.com openshift_node_labels="{'region':'infra', 'node-role.kubernetes.io/compute':'true'}"
...

📜执行剧本

📑剧本说明

安装OpenShift需要执行prerequisites.yml 和deploy_cluster.yml,由 atomic-openshift-utils

软件包安装。

首先执行 prequisites.yml playbook 检查所有主机能够满足OpenShift 的部署,同时尝试修改主机以满足部署需求。然后执行doploy_cluster.yml playbook 开始正式集群部署


📑验证OpenShift

部署完成后,可访问:https://master.lab.example.com 进行验证。


💡总结

RHCA认证需要经历5门的学习与考试,还是需要花不少时间去学习与备考的,好好加油,可以噶🤪。

以上就是【金鱼哥】对 第二章 OpenShift安装与部署--安装步骤说明 的简述和讲解。希望能对看到此文章的小伙伴有所帮助。

💾 红帽认证专栏系列:
RHCSA专栏: 戏说 RHCSA 认证
RHCE专栏: 戏说 RHCE 认证
此文章收录在RHCA专栏: RHCA 回忆录

如果这篇【文章】有帮助到你,希望可以给【金鱼哥】点个赞👍,创作不易,相比官方的陈述,我更喜欢用【通俗易懂】的文笔去讲解每一个知识点。

如果有对【运维技术】感兴趣,也欢迎关注❤️❤️❤️ 【金鱼哥】❤️❤️❤️,我将会给你带来巨大的【收获与惊喜】💕💕!

目录
相关文章
|
Web App开发 消息中间件 存储
|
JSON 运维 负载均衡
金鱼哥RHCA回忆录:DO280管理应用部署--RC
第七章 DO280管理应用部署--RC
216 0
金鱼哥RHCA回忆录:DO280管理应用部署--RC
|
存储 运维 监控
金鱼哥RHCA回忆录:DO280管理和监控OpenShift平台--OCP升级
第九章 管理和监控OpenShift平台–OCP升级
141 0
金鱼哥RHCA回忆录:DO280管理和监控OpenShift平台--OCP升级
|
运维 监控 Kubernetes
金鱼哥RHCA回忆录:DO280管理和监控OpenShift平台--使用probes监视应用
第九章 管理和监控OpenShift平台--使用probes监视应用
215 0
金鱼哥RHCA回忆录:DO280管理和监控OpenShift平台--使用probes监视应用
|
运维 Kubernetes 监控
金鱼哥RHCA回忆录:DO280管理和监控OpenShift平台--资源限制
第九章 管理和监控OpenShift平台--资源限制
168 0
金鱼哥RHCA回忆录:DO280管理和监控OpenShift平台--资源限制
|
存储 Kubernetes 监控
金鱼哥RHCA回忆录:DO280安装和配置Metric系统
第八章 安装和配置Metric系统
222 0
 金鱼哥RHCA回忆录:DO280安装和配置Metric系统
|
运维 Linux 数据安全/隐私保护
金鱼哥RHCA回忆录:DO280OpenShift安装与部署--安装部署与验证
第二章 OpenShift安装与部署--安装部署与验证
229 0
金鱼哥RHCA回忆录:DO280OpenShift安装与部署--安装部署与验证
|
存储 运维 Linux
金鱼哥RHCA回忆录:DO280OpenShift安装与部署--安装前准备
第二章 OpenShift安装与部署--安装前准备
174 0
金鱼哥RHCA回忆录:DO280OpenShift安装与部署--安装前准备
|
运维 关系型数据库 Linux
金鱼哥RHCA回忆录:DO280OpenShift命令及故障排查--常见故障排除和章节实验
第四章 OpenShift命令及故障排查--常见故障排除和章节实验
351 0
金鱼哥RHCA回忆录:DO280OpenShift命令及故障排查--常见故障排除和章节实验
|
运维 Kubernetes 负载均衡
金鱼哥RHCA回忆录:DO280OpenShift网络--平台网络实现
第三章 OpenShift网络--平台网络实现
190 0
金鱼哥RHCA回忆录:DO280OpenShift网络--平台网络实现

热门文章

最新文章