CentOS7安装openshift3.9集群

CentOS7安装openshift集群

开源容器应用程序平台,Origin是支持OpenShift的上游社区项目。围绕Docker容器打包和Kubernetes容器集群管理的核心构建,Origin还增加了应用程序生命周期管理功能和DevOps工具。Origin提供了一个完整的开源容器应用程序平台。

安装OpenShift Origin,它是Red Hat OpenShift的开源版本

  • 环境CentOS7:
Hostname Role IP
master.aniu.so Master, etcd, and node 192.168.0.111
node1.aniu.so Computer Node 192.168.0.114
node2.aniu.so Computer Node 192.168.0.115

集群配置参考:https://docs.openshift.org/latest/install_config/install/planning.html

配置群集的一些系统要求

  • 主节点至少16G的内存
  • 在所有节点上,需要物理卷上的可用空间才能为Docker Direct LVM创建新的卷组,var目录至少40G,不然检测通不过

主机设置

  • 安装依赖包,关闭防火墙,禁用selinux,添加sysctl net.ipv4.ip_forward=1,所有节点均执行

详情见:https://github.com/openshift/origin/blob/master/docs/cluster_up_down.md#prerequisites
参考:https://docs.openshift.org/latest/install_config/install/host_preparation.html#install-config-install-host-preparation

yum install wget git net-tools bind-utils yum-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct -y
yum install ansible pyOpenSSL -y
  • 在所有节点上,安装OpenShift Origin 3.9存储库和Docker。 接下来,为Docker Direct LVM创建一个卷组,以便像下面那样设置LVM Thinpool。
# 以master为例,虽有节点都必须执行
[root@master ~]# yum -y install centos-release-openshift-origin37 docker
[root@master ~]# vgcreate centos /dev/sdb1  #笔者vgname为centos
Volume group "centos" successfully created
[root@master ~]# echo VG=centos >> /etc/sysconfig/docker-storage-setup 
[root@master ~]# systemctl start docker 
[root@master ~]# systemctl enable docker 
  • 设置三个节点master节点与其他节点ssh免密。方便执行ansible-playbook

# 在master节点上执行:
[root@master ~]# ssh-keygen -t rsa
# 创建免密设置
[root@master ~]# cat /etc/hosts # 参考笔者hosts,同步hosts到node1,node2
127.0.0.1   localhost localhost.localdomain pinpoint
###########################################
## openshift
192.168.0.113 master.aniu.so
192.168.0.114 node1.aniu.so
192.168.0.115 node2.aniu.so
[root@master ~]# ssh-copy-id master.aniu.so
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
                (if you think this is a mistake, you may want to use -f option)

[root@master ~]# ssh-copy-id node1.aniu.so 
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
                (if you think this is a mistake, you may want to use -f option)

[root@master ~]# ssh-copy-id node2.aniu.so
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
                (if you think this is a mistake, you may want to use -f option)

在主节点上,使用root登录并运行Ansible Playbook以设置OpenShift群集。

yum -y install atomic-openshift-utils

配置ansible的hosts如下:

[root@master ~]# cat /etc/ansible/hosts 
# add follows to the end
[OSEv3:children]
masters
nodes
etcd

[OSEv3:vars]
# admin user created in previous section
ansible_ssh_user=root
openshift_deployment_type=origin

# use HTPasswd for authentication
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/.htpasswd'}]
openshift_master_default_subdomain=apps.test.aniu.so

# allow unencrypted connection within cluster
openshift_docker_insecure_registries=172.30.0.0/16

[masters]
master.aniu.so openshift_schedulable=true containerized=false

[etcd]
master.aniu.so

[nodes]
# set labels [region: ***, zone: ***] (any name you like)
master.aniu.so openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node1.aniu.so openshift_node_labels="{'region': 'primary', 'zone': 'east'}" openshift_schedulable=true
node2.aniu.so openshift_node_labels="{'region': 'primary', 'zone': 'west'}" openshift_schedulable=true


# 运行deploy_cluster.yml手册以启动安装:
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/deploy_cluster.yml # 此步骤会很慢,笔者大概花了2个多小时。。。
  • 正常执行完成查看状态
- 可能会出现的报错:
Error from server (Forbidden): nodes is forbidden: User "system:anonymous" cannot list nodes at the cluster scope: User "system:anonymous" cannot list all nodes in the cluster
报错解决:
[root@master ~]# oc login -u system:admin # 使用admin登录进行查看
Logged into "https://master.aniu.so:8443" as "system:admin" using existing credentials.

You have access to the following projects and can switch between them with 'oc project <projectname>':

  * default
    kube-public
    kube-system
    logging
    management-infra
    openshift
    openshift-infra
    openshift-node
    openshift-web-console

Using project "default".
[root@master ~]# oc get nodes            
NAME             STATUS    ROLES     AGE       VERSION
master.aniu.so   Ready     master    4h        v1.9.1+a0ce1bc657
node1.aniu.so    Ready     <none>    4h        v1.9.1+a0ce1bc657
node2.aniu.so    Ready     <none>    4h        v1.9.1+a0ce1bc657
[root@master ~]# oc get nodes --show-labels=true 
NAME             STATUS    ROLES     AGE       VERSION             LABELS
master.aniu.so   Ready     master    4h        v1.9.1+a0ce1bc657   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=master.aniu.so,node-role.kubernetes.io/master=true,region=infra,zone=default
node1.aniu.so    Ready     <none>    4h        v1.9.1+a0ce1bc657   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node1.aniu.so,region=primary,zone=east
node2.aniu.so    Ready     <none>    4h        v1.9.1+a0ce1bc657   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node2.aniu.so,region=primary,zone=west 

创建一个新用户用来登录openshift

  • 在master节点上创建用户:
[root@master ~]# htpasswd /etc/origin/master/.htpasswd aniu # 
  • 用任何操作系统用户登录,然后登录OpenShift群集,只需添加一个HTPasswd用户
[root@master ~]# oc login
Authentication required for https://master.aniu.so:8443 (openshift)
Username: aniu
Password: 
Login successful.

You don't have any projects. You can try to create a new project, by running

    oc new-project <projectname>
[root@master ~]# oc whoami
aniu
[root@master ~]# oc logout
Logged "aniu" out on "https://master.aniu.so:8443"
  • 可以从任何使用Web浏览器的客户端访问管理控制台。
    [图片上传失败...(image-ad95d1-1527840854860)]
    [图片上传失败...(image-f92e1c-1527840854860)]
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,053评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,527评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,779评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,685评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,699评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,609评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,989评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,654评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,890评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,634评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,716评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,394评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,976评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,950评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,191评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,849评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,458评论 2 342

推荐阅读更多精彩内容