CentOS7安裝openshift3.9集群

CentOS7安裝openshift集群

開(kāi)源容器應(yīng)用程序平臺(tái),Origin是支持OpenShift的上游社區(qū)項(xiàng)目嫉父。圍繞Docker容器打包和Kubernetes容器集群管理的核心構(gòu)建,Origin還增加了應(yīng)用程序生命周期管理功能和DevOps工具汗销。Origin提供了一個(gè)完整的開(kāi)源容器應(yīng)用程序平臺(tái)枕面。

安裝OpenShift Origin,它是Red Hat OpenShift的開(kāi)源版本

  • 環(huán)境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

配置群集的一些系統(tǒng)要求

  • 主節(jié)點(diǎn)至少16G的內(nèi)存
  • 在所有節(jié)點(diǎn)上,需要物理卷上的可用空間才能為Docker Direct LVM創(chuàng)建新的卷組徒坡,var目錄至少40G,不然檢測(cè)通不過(guò)

主機(jī)設(shè)置

  • 安裝依賴包,關(guān)閉防火墻瘤缩,禁用selinux喇完,添加sysctl net.ipv4.ip_forward=1,所有節(jié)點(diǎn)均執(zhí)行

詳情見(jiàn):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
  • 在所有節(jié)點(diǎn)上剥啤,安裝OpenShift Origin 3.9存儲(chǔ)庫(kù)和Docker锦溪。 接下來(lái),為Docker Direct LVM創(chuàng)建一個(gè)卷組府怯,以便像下面那樣設(shè)置LVM Thinpool刻诊。
# 以master為例,雖有節(jié)點(diǎn)都必須執(zhí)行
[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 
  • 設(shè)置三個(gè)節(jié)點(diǎn)master節(jié)點(diǎn)與其他節(jié)點(diǎn)ssh免密牺丙。方便執(zhí)行ansible-playbook

# 在master節(jié)點(diǎn)上執(zhí)行:
[root@master ~]# ssh-keygen -t rsa
# 創(chuàng)建免密設(shè)置
[root@master ~]# cat /etc/hosts # 參考筆者h(yuǎn)osts则涯,同步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)

在主節(jié)點(diǎn)上,使用root登錄并運(yùn)行Ansible Playbook以設(shè)置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


# 運(yùn)行deploy_cluster.yml手冊(cè)以啟動(dòng)安裝:
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/deploy_cluster.yml # 此步驟會(huì)很慢亿昏,筆者大概花了2個(gè)多小時(shí)。浮入。龙优。
  • 正常執(zhí)行完成查看狀態(tài)
- 可能會(huì)出現(xiàn)的報(bào)錯(cuò):
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
報(bào)錯(cuò)解決:
[root@master ~]# oc login -u system:admin # 使用admin登錄進(jìn)行查看
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 

創(chuàng)建一個(gè)新用戶用來(lái)登錄openshift

  • 在master節(jié)點(diǎn)上創(chuàng)建用戶:
[root@master ~]# htpasswd /etc/origin/master/.htpasswd aniu # 
  • 用任何操作系統(tǒng)用戶登錄,然后登錄OpenShift群集事秀,只需添加一個(gè)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瀏覽器的客戶端訪問(wèn)管理控制臺(tái)彤断。
    [圖片上傳失敗...(image-ad95d1-1527840854860)]
    [圖片上傳失敗...(image-f92e1c-1527840854860)]
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市易迹,隨后出現(xiàn)的幾起案子宰衙,更是在濱河造成了極大的恐慌,老刑警劉巖睹欲,帶你破解...
    沈念sama閱讀 206,126評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件供炼,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡窘疮,警方通過(guò)查閱死者的電腦和手機(jī)袋哼,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,254評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)闸衫,“玉大人涛贯,你說(shuō)我怎么就攤上這事∥党觯” “怎么了弟翘?”我有些...
    開(kāi)封第一講書(shū)人閱讀 152,445評(píng)論 0 341
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)骄酗。 經(jīng)常有香客問(wèn)我稀余,道長(zhǎng),這世上最難降的妖魔是什么趋翻? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 55,185評(píng)論 1 278
  • 正文 為了忘掉前任睛琳,我火速辦了婚禮,結(jié)果婚禮上嘿歌,老公的妹妹穿的比我還像新娘掸掏。我一直安慰自己,他們只是感情好宙帝,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,178評(píng)論 5 371
  • 文/花漫 我一把揭開(kāi)白布丧凤。 她就那樣靜靜地躺著,像睡著了一般步脓。 火紅的嫁衣襯著肌膚如雪愿待。 梳的紋絲不亂的頭發(fā)上浩螺,一...
    開(kāi)封第一講書(shū)人閱讀 48,970評(píng)論 1 284
  • 那天,我揣著相機(jī)與錄音仍侥,去河邊找鬼要出。 笑死,一個(gè)胖子當(dāng)著我的面吹牛农渊,可吹牛的內(nèi)容都是我干的患蹂。 我是一名探鬼主播,決...
    沈念sama閱讀 38,276評(píng)論 3 399
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼砸紊,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼传于!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起醉顽,我...
    開(kāi)封第一講書(shū)人閱讀 36,927評(píng)論 0 259
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤沼溜,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后游添,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體系草,經(jīng)...
    沈念sama閱讀 43,400評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,883評(píng)論 2 323
  • 正文 我和宋清朗相戀三年唆涝,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了找都。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 37,997評(píng)論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡廊酣,死狀恐怖檐嚣,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情啰扛,我是刑警寧澤,帶...
    沈念sama閱讀 33,646評(píng)論 4 322
  • 正文 年R本政府宣布嗡贺,位于F島的核電站隐解,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏诫睬。R本人自食惡果不足惜煞茫,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,213評(píng)論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望摄凡。 院中可真熱鬧续徽,春花似錦、人聲如沸亲澡。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,204評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)床绪。三九已至客情,卻和暖如春其弊,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背膀斋。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,423評(píng)論 1 260
  • 我被黑心中介騙來(lái)泰國(guó)打工梭伐, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人仰担。 一個(gè)月前我還...
    沈念sama閱讀 45,423評(píng)論 2 352
  • 正文 我出身青樓糊识,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親摔蓝。 傳聞我的和親對(duì)象是個(gè)殘疾皇子赂苗,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,722評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容