CentOS7安装Openshift 3.11(在线安装)
OpenShift是红帽的云开发平台即服务(PaaS)。自由和开放源码的云计算平台使开发人员能够创建、测试和运行他们的应用程序,并且可以把它们部署到云中。本文主要介绍在联网环境下安装Openshift 3.11。一、配置要求VMware Workstations平台上创建3台虚拟机,均采用最小化安装系统Centos7.5 Minimal Install内核3.10.0...
OpenShift是红帽的云开发平台即服务(PaaS)。自由和开放源码的云计算平台使开发人员能够创建、测试和运行他们的应用程序,并且可以把它们部署到云中。
本文主要介绍在联网环境下安装Openshift 3.11。
一、配置要求
VMware Workstations平台上创建3台虚拟机,均采用最小化安装
系统 | Centos7.5 Minimal Install |
---|---|
内核 | 3.10.0-862.el7.x86_64 |
内存 | master:8G node:4G |
处理器 | 2颗 2核 |
磁盘 | 30G |
Openshift集群至少需要3台节点,规划如下
节点信息 | 主机名 | IP |
---|---|---|
openshift1 | master | 192.168.10.1 /24 |
openshift2 | infra_node | 192.168.10.2 /24 |
openshift3 | node | 192.168.10.3 /24 |
二、基础环境配置
1、 每台主机配置主机名
hostnamectl openshift1
echo openshift1 > /etc/hostname
hostnamectl openshift2
echo openshift2 > /etc/hostname
hostnamectl openshift3
echo openshift3 > /etc/hostname
2、 配置hosts文件,每台机器上新增以下内容:
vim /etc/hosts
192.168.10.1 openshift1
192.168.10.2 openshift2
192.168.10.3 openshift3
scp -rp /etc/hosts 192.168.10.2:/etc/hosts
scp -rp /etc/hosts 192.168.10.3:/etc/hosts
3、 配置ssh免密钥登录
ssh-keygen
ssh-copy-id root@192.168.10.1
ssh-copy-id root@192.168.10.2
ssh-copy-id root@192.168.10.3
4、关闭防火墙
systemctl stop firewalld.service;systemctl disable firewalld.service
5、配置SELINUX为permissive
sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
三、基础软件安装
1、配置主机yum源
配置阿里云CentOS7 yun源,安装依赖包
]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
配置阿里云docker-ce yum源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
]#yum makecache fast //建立元数据缓存
以下安装包需自行下载,下载地址:https://developer.aliyun.com/mirror/
origin-3.11.0-1.el7.git.0.62803d0.x86_64
origin-hyperkube-3.11.0-1.el7.git.0.62803d0.x86_64
origin-node-3.11.0-1.el7.git.0.62803d0.x86_64
origin-clients-3.11.0-1.el7.git.0.62803d0.x86_64
ansible-2.6.14-1.el7.ans.noarch.rpm
- 所有主机安装基础软件包
yum install –y wget git ntp vim net-tools bind-utils yum-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct nfs-utils docker NetworkManager python-setuptools unzip tree atomic
yum install -y origin-node-3.11.0 origin-clients-3.11.0 conntrack-tools
5.配置iptables规则(master上配置
cp /etc/sysconfig/iptables /etc/sysconfig/iptables.bak.$(date "+%Y%m%d%H%M%S")
sed -i '/.*--dport 22 -j ACCEPT.*/a\-A INPUT -p tcp -m state --state NEW -m tcp --dport 53 -j ACCEPT' /etc/sysconfig/iptables
sed -i '/.*--dport 22 -j ACCEPT.*/a\-A INPUT -p udp -m state --state NEW -m udp --dport 53 -j ACCEPT' /etc/sysconfig/iptables
sed -i '/.*--dport 22 -j ACCEPT.*/a\-A INPUT -p tcp -m state --state NEW -m tcp --dport 5000 -j ACCEPT' /etc/sysconfig/iptables
sed -i '/.*--dport 22 -j ACCEPT.*/a\-A INPUT -p tcp -m state --state NEW -m tcp --dport 81 -j ACCEPT' /etc/sysconfig/iptables
6.在master节点上允许 8443 for node join
sed -i '/.*--dport 22 -j ACCEPT.*/a\-A INPUT -p tcp -m state --state NEW -m tcp --dport 8443 -j ACCEPT ' /etc/sysconfig/iptables
sed -i '/.*--dport 22 -j ACCEPT.*/a\-A INPUT -p tcp -m state --state NEW -m tcp --dport 8443 -j ACCEPT ' /etc/sysconfig/iptables
systemctl restart iptables;systemctl enable iptables
完成配置后重启所有主机reboot
7. 管理节点上安装
yum install -y origin-3.11.0
8.安装OpenShift源
yum install -y centos-release-openshift-origin311 ceph-common container-selinux epel-release-7-11 python-docker
更新yum源索引
yum makecache
- 配置docker镜像加速
systemctl start docker; systemctl enable docker
vim /etc/docker/daemon.json
{
"insecure-registries": ["172.30.0.0/16"],
"registry-mirrors": ["https://lt2ws3tf.mirror.aliyuncs.com"] //可自行申请阿里云镜像加速
}
systemctl daemon-reload;systemctl enable docker;systemctl restart docker
- 下载好所需要的镜像文件,并导入
docker pull docker.io/cockpit/kubernetes:latest
docker pull docker.io/openshift/origin-haproxy-router:v3.11
docker pull docker.io/openshift/origin-node:v3.11
docker pull docker.io/openshift/origin-control-plane:v3.11
docker pull docker.io/openshift/origin-deployer:v3.11.0
docker pull docker.io/openshift/origin-pod:v3.11.0
docker pull docker.io/openshift/origin-web-console:v3.11
docker pull docker.io/openshift/origin-docker-registry:v3.11
docker pull docker.io/openshift/origin-metrics-server:v3.11
docker pull docker.io/openshift/origin-console:v3.11
docker pull docker.io/openshift/origin-metrics-heapster:v3.11
docker pull docker.io/openshift/origin-metrics-hawkular-metrics:v3.11
docker pull docker.io/openshift/origin-metrics-schema-installer:v3.11
docker pull docker.io/openshift/origin-metrics-cassandra:v3.11
docker pull quay.io/coreos/cluster-monitoring-operator:v0.1.1
docker pull quay.io/coreos/prometheus-config-reloader:v0.23.2
docker pull quay.io/coreos/prometheus-operator:v0.23.2
docker pull docker.io/openshift/prometheus-alertmanager:v0.15.2
docker pull docker.io/openshift/prometheus-node-exporter:v0.16.0
docker pull docker.io/openshift/prometheus:v2.3.2
docker pull docker.io/grafana/grafana:5.2.1
docker pull quay.io/coreos/kube-rbac-proxy:v0.3.1
docker pull quay.io/coreos/etcd:v3.2.22
docker pull quay.io/coreos/kube-state-metrics:v1.3.1
docker pull docker.io/openshift/oauth-proxy:v1.1.0
docker pull quay.io/coreos/configmap-reload:v0.0.1
镜像包可以从下载好的主机上直接导入
批量导出镜像
docker images | awk ‘{print $1}’ > images.txt #获取镜像列表
sed –i ‘1d’ images.txt #删除第一行无用信息
docker save –o openshift.tar cat images.txt
#保存所有镜像到本地
再把镜像文件openshift.tar上传到所有主机,并导入
docker load –i openshift.tar
四、master节点配置
1、安装ansible-2.6.14-1.el7、openshift-ansible
ansible-2.6.14可以在阿里云镜像网站下载https://developer.aliyun.com/mirror/
yum install -y ansible-2.6.14-1.el7.ans.noarch.rpm openshift-ansible
2、 配置ansible的hosts文件
部署时删掉配置文件中带有中文的注释
# cat /etc/ansible/hosts
# all下放所有机器节点的名称
[all]
openshift1
openshift2
openshift3
#这里放openshfit的角色,这里有三个角色,master,node,etcd
[OSEv3:children]
masters
nodes
etcd
#这里是openshfit的安装参数
[OSEv3:vars]
ansible_ssh_user=root #指定ansible使用ssh的用户为root
openshift_deployment_type=origin #指定方式为origin
openshift_release=3.11 #指定版本为3.11
openshift_enable_service_catalog=false
openshift_clock_enabled=true
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider'}]
openshift_disable_check=disk_availability,docker_storage,memory_availability,docker_image_availability
#master角色的机器名称包含
[masters]
openshift1
#etcd角色的机器名称包含
[etcd]
openshift1
#node角色的机器名称包含
[nodes]
openshift1 openshift_node_group_name='node-config- master'
openshift2 openshift_node_group_name='node-config-compute'
openshift3 openshift_node_group_name='node-config-compute'
openshift2 openshift_node_group_name='node-config-infra'
#openshift_enable_service_catalog=false
#openshift_hosted_registry_storage_kind=nfs
#openshift_hosted_registry_storage_access_modes=['ReadWriteMany']
#openshift_hosted_registry_storage_nfs_directory=/data/docker
#openshift_hosted_registry_storage_nfs_options='*(rw,root_squash)'
#openshift_hosted_registry_storage_volume_name=registry
#openshift_hosted_registry_storage_volume_size=20Gi
# openshiftclock_enabled=true
# ansible_service_broker_install=false
检察所有主机连接是否正常
ansbile all –m ping
3、 启动docker
ansible all -a ‘systemctl start docker’;ansible all -a ‘systemctl enable docker’
4、 执行检察
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/prerequisites.yml
5、 安装(所需时间较长)
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/deploy_cluster.yml –vvv
出现以下提示表示安装完成
查看节点状态
6、 安装后配置
htpasswd -cb /etc/origin/master/htpasswd admin Hlro@liu #创建用户和密码
oc adm policy add-cluster-role-to-user cluster-admin
7、 登录访问
通过浏览器访问https://openshift1:8443/ 账户/密码:admin Hlro@liu
Windows系统在C:\Windows\System32\drivers\etc目录下的hosts文件添加
192.168.10.1 openshift1
更多推荐
所有评论(0)