本次openshift安装使用最简单便捷的单节点安装,适用于本地开发及测试
1、关闭防火墙和selinux
$ sed -i "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config
$ systemctl stop firewalld
$ systemctl disable firewalld
2、安装docker
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装 Docker 引擎
# 默认安装最新版
yum install docker-ce docker-ce-cli containerd.io
配置docker私有仓库地址
因为openshift安装成功后,会自行启动一个registry的私有仓库镜像以便使用,为了之后不用重新配置后还要重启docker,所以在此先行配置
集群自动启动的registry仓库地址就是172.30.x.x,所以如下配置
检查 /etc/docker 目录是否存在
不存在则创建 mkdir -p /etc/docker
# 存在
$ vi /etc/docker/daemon.json
{
"insecure-registries": ["172.30.0.0/16"]
}
$ systemctl daemon-reload
$ systemctl start docker
$ systemctl enable docker
3、安装openshift
openshift的GitHub项目中下载:https://github.com/openshift/origin/releases

$ cd /opt/
$ wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-server-v3.11.0-0cbc58b-linux-64bit.tar.gz
解压及修改目录名称
$ tar -zxvf openshift-origin-server-v3.11.0-0cbc58b-linux-64bit.tar.gz
$ mv openshift-origin-server-v3.11.0-0cbc58b-linux-64bit /opt/openshift-server-v3.11.0
修改/etc/profile,加入环境变量
PATH=$PATH:/opt/openshift-server-v3.11.0/
$ source /etc/profile
4、启动集群
这里有一点需要注意:启动集群会在当前目录下创建集群配置文件等信息,所以要确保执行启动命令时,所在目录是你想要的目录(相当于安装目录了)
$ cd /opt/
$ oc cluster up --skip-registry-check=true --public-hostname="192.168.23.158" --no-proxy="192.168.23.158"
参数介绍:
- –skip-registry-check 代表是否跳过Docker守护进程注册表什么的检查
- –public-hostname 代表暴露在外部供访问的地址
- –no-proxy 代表哪些地址不需要转发(如果不加这个,有可能部署成功后访问地址会转发到 localhost 127.0.0.1)
启动成功的最后会有这个输出

访问测试
http://主机IP:8443

openshift默认用户:
- system:admin 使用密钥,无密码
- developer/developer
- admin/admin
到这里一个简单的openshift集群已经完成了!
设置开机启动
如果需要开机自启,则可以在/etc/rc.d/rc.local中添加上面集群启动时的命令,就可以实现了
(注意不同环境下需要修改oc命令所在路径和服务器IP)
测试使用,未生效
/opt/openshift-server-v3.11.0/oc cluster up --skip-registry-check=true --public-hostname="192.168.23.158" --no-proxy="192.168.23.158"
参考以及其他后续使用内容,请参考 https://blog.csdn.net/weixin_43860781/article/details/109388365
作者:joker.liu 创建时间:2022-09-29 11:37
最后编辑:admin 更新时间:2022-10-22 20:22
最后编辑:admin 更新时间:2022-10-22 20:22