服务器信息

在阿里云买了个抢占式的服务器,地区为华南广州,系统为Ubuntu 20.04,8核16GB。

安装Docker

命令如下:

$ apt-get update -y
$ apt-get upgrade -y
$ apt-get install -y docker.io

安装成功后,检查一下版本:

$ docker version
Client:
Version: 20.10.7
API version: 1.41
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu5~20.04.2
Built: Mon Nov 1 00:34:17 2021
OS/Arch: linux/amd64
Context: default
Experimental: true Server:
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu5~20.04.2
Built: Fri Oct 22 00:45:53 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.5-0ubuntu3~20.04.1
GitCommit:
runc:
Version: 1.0.1-0ubuntu2~20.04.1
GitCommit:
docker-init:
Version: 0.19.0
GitCommit:

要修改Docker配置文件,让它可以使用私有的registry:

cat << EOF | sudo tee /etc/docker/daemon.json
{
"insecure-registries" : [ "172.30.0.0/16" ]
}
EOF

然后重启一下Docker即可:

systemctl restart docker

安装OpenShift

下载并解压对应的可执行文件:

# 下载
$ wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz # 解压
$ tar xvf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz # 复制到bin目录
$ cp openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit/oc /usr/local/bin/
$ cp openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit/kubectl /usr/local/bin/ # 检查版本
$ oc version
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO

启动集群,第一次需要比较长的时候,因为需要下载镜像:

$ oc cluster up
Getting a Docker client ...
Checking if image openshift/origin-control-plane:v3.11 is available ...
Creating shared mount directory on the remote host ...
Determining server IP ...
Checking if OpenShift is already running ...
Checking for supported Docker version (=>1.22) ...
Checking if insecured registry is configured properly in Docker ...
Checking if required ports are available ...
Checking if OpenShift client is configured properly ...
Checking if image openshift/origin-control-plane:v3.11 is available ...
Starting OpenShift using openshift/origin-control-plane:v3.11 ...
I0301 22:24:39.111730 51771 flags.go:30] Running "create-kubelet-flags"
I0301 22:24:39.541760 51771 run_kubelet.go:49] Running "start-kubelet"
I0301 22:24:39.624336 51771 run_self_hosted.go:181] Waiting for the kube-apiserver to be ready ...
I0301 22:25:30.631581 51771 interface.go:26] Installing "kube-proxy" ...
I0301 22:25:30.631597 51771 interface.go:26] Installing "kube-dns" ...
I0301 22:25:30.631604 51771 interface.go:26] Installing "openshift-service-cert-signer-operator" ...
I0301 22:25:30.631609 51771 interface.go:26] Installing "openshift-apiserver" ...
I0301 22:25:30.631624 51771 apply_template.go:81] Installing "openshift-apiserver"
I0301 22:25:30.631673 51771 apply_template.go:81] Installing "kube-dns"
I0301 22:25:30.631682 51771 apply_template.go:81] Installing "openshift-service-cert-signer-operator"
I0301 22:25:30.631689 51771 apply_template.go:81] Installing "kube-proxy"
I0301 22:25:31.680155 51771 interface.go:41] Finished installing "kube-proxy" "kube-dns" "openshift-service-cert-signer-operator" "openshift-apiserver"
I0301 22:29:04.695159 51771 run_self_hosted.go:242] openshift-apiserver available
I0301 22:29:04.695183 51771 interface.go:26] Installing "openshift-controller-manager" ...
I0301 22:29:04.695201 51771 apply_template.go:81] Installing "openshift-controller-manager"
I0301 22:29:05.924403 51771 interface.go:41] Finished installing "openshift-controller-manager"
Adding default OAuthClient redirect URIs ...
Adding registry ...
Adding router ...
Adding centos-imagestreams ...
Adding sample-templates ...
Adding persistent-volumes ...
Adding web-console ...
I0301 22:29:05.934015 51771 interface.go:26] Installing "openshift-image-registry" ...
I0301 22:29:05.934027 51771 interface.go:26] Installing "openshift-router" ...
I0301 22:29:05.934034 51771 interface.go:26] Installing "centos-imagestreams" ...
I0301 22:29:05.934039 51771 interface.go:26] Installing "sample-templates" ...
I0301 22:29:05.934045 51771 interface.go:26] Installing "persistent-volumes" ...
I0301 22:29:05.934050 51771 interface.go:26] Installing "openshift-web-console-operator" ...
I0301 22:29:05.934129 51771 interface.go:26] Installing "sample-templates/mongodb" ...
I0301 22:29:05.934141 51771 apply_list.go:67] Installing "centos-imagestreams"
I0301 22:29:05.934172 51771 apply_list.go:67] Installing "sample-templates/mongodb"
I0301 22:29:05.934145 51771 interface.go:26] Installing "sample-templates/mysql" ...
I0301 22:29:05.934296 51771 interface.go:26] Installing "sample-templates/cakephp quickstart" ...
I0301 22:29:05.934306 51771 interface.go:26] Installing "sample-templates/django quickstart" ...
I0301 22:29:05.934315 51771 interface.go:26] Installing "sample-templates/rails quickstart" ...
I0301 22:29:05.934326 51771 interface.go:26] Installing "sample-templates/mariadb" ...
I0301 22:29:05.934335 51771 interface.go:26] Installing "sample-templates/postgresql" ...
I0301 22:29:05.934343 51771 interface.go:26] Installing "sample-templates/dancer quickstart" ...
I0301 22:29:05.934351 51771 interface.go:26] Installing "sample-templates/nodejs quickstart" ...
I0301 22:29:05.934360 51771 interface.go:26] Installing "sample-templates/jenkins pipeline ephemeral" ...
I0301 22:29:05.934375 51771 interface.go:26] Installing "sample-templates/sample pipeline" ...
I0301 22:29:05.934409 51771 apply_list.go:67] Installing "sample-templates/sample pipeline"
I0301 22:29:05.934539 51771 apply_list.go:67] Installing "sample-templates/mysql"
I0301 22:29:05.934635 51771 apply_list.go:67] Installing "sample-templates/cakephp quickstart"
I0301 22:29:05.934722 51771 apply_list.go:67] Installing "sample-templates/dancer quickstart"
I0301 22:29:05.934724 51771 apply_list.go:67] Installing "sample-templates/nodejs quickstart"
I0301 22:29:05.934748 51771 apply_list.go:67] Installing "sample-templates/jenkins pipeline ephemeral"
I0301 22:29:05.934772 51771 apply_list.go:67] Installing "sample-templates/mariadb"
I0301 22:29:05.934796 51771 apply_list.go:67] Installing "sample-templates/django quickstart"
I0301 22:29:05.934815 51771 apply_list.go:67] Installing "sample-templates/rails quickstart"
I0301 22:29:05.934343 51771 apply_template.go:81] Installing "openshift-web-console-operator"
I0301 22:29:05.934826 51771 apply_list.go:67] Installing "sample-templates/postgresql"
I0301 22:29:08.010606 51771 interface.go:41] Finished installing "sample-templates/mongodb" "sample-templates/mysql" "sample-templates/cakephp quickstart" "sample-templates/django quickstart" "sample-templates/rails quickstart" "sample-templates/mariadb" "sample-templates/postgresql" "sample-templates/dancer quickstart" "sample-templates/nodejs quickstart" "sample-templates/jenkins pipeline ephemeral" "sample-templates/sample pipeline"
I0301 22:29:50.500686 51771 interface.go:41] Finished installing "openshift-image-registry" "openshift-router" "centos-imagestreams" "sample-templates" "persistent-volumes" "openshift-web-console-operator"
Login to server ...
Creating initial project "myproject" ...
Server Information ...
OpenShift server started. The server is accessible via web console at:
https://127.0.0.1:8443 You are logged in as:
User: developer
Password: <any value> To login as administrator:
oc login -u system:admin

登陆:

$ oc login -u system:admin

查看命令空间:

 # oc get ns
NAME STATUS AGE
default Active 6m
kube-dns Active 6m
kube-proxy Active 6m
kube-public Active 6m
kube-system Active 6m
myproject Active 2m
openshift Active 3m
openshift-apiserver Active 6m
openshift-controller-manager Active 3m
openshift-core-operators Active 6m
openshift-infra Active 6m
openshift-node Active 3m
openshift-service-cert-signer Active 6m
openshift-web-console Active 3m

发现与kubectl差不多。

查看所有Pods如下:

$ oc get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default docker-registry-1-72zc5 1/1 Running 0 5m
default persistent-volume-setup-75s9s 0/1 Completed 0 6m
default router-1-nglvw 1/1 Running 0 6m
kube-dns kube-dns-zqs5d 1/1 Running 0 9m
kube-proxy kube-proxy-p75mh 1/1 Running 0 9m
kube-system kube-controller-manager-localhost 1/1 Running 0 9m
kube-system kube-scheduler-localhost 1/1 Running 0 9m
kube-system master-api-localhost 1/1 Running 0 8m
kube-system master-etcd-localhost 1/1 Running 0 8m
openshift-apiserver openshift-apiserver-4rwzd 1/1 Running 0 9m
openshift-controller-manager openshift-controller-manager-wvwkw 1/1 Running 0 6m
openshift-core-operators openshift-service-cert-signer-operator-6d477f986b-rkcww 1/1 Running 0 9m
openshift-core-operators openshift-web-console-operator-664b974ff5-vtwm8 1/1 Running 0 6m
openshift-service-cert-signer apiservice-cabundle-injector-8ffbbb6dc-6lkvl 1/1 Running 0 7m
openshift-service-cert-signer service-serving-cert-signer-668c45d5f-qjwkj 1/1 Running 0 7m
openshift-web-console webconsole-c877c8b45-m5hpx 1/1 Running 0 5m $ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default docker-registry-1-72zc5 1/1 Running 0 5m
default persistent-volume-setup-75s9s 0/1 Completed 0 6m
default router-1-nglvw 1/1 Running 0 5m
kube-dns kube-dns-zqs5d 1/1 Running 0 8m
kube-proxy kube-proxy-p75mh 1/1 Running 0 8m
kube-system kube-controller-manager-localhost 1/1 Running 0 9m
kube-system kube-scheduler-localhost 1/1 Running 0 9m
kube-system master-api-localhost 1/1 Running 0 8m
kube-system master-etcd-localhost 1/1 Running 0 8m
openshift-apiserver openshift-apiserver-4rwzd 1/1 Running 0 8m
openshift-controller-manager openshift-controller-manager-wvwkw 1/1 Running 0 6m
openshift-core-operators openshift-service-cert-signer-operator-6d477f986b-rkcww 1/1 Running 0 8m
openshift-core-operators openshift-web-console-operator-664b974ff5-vtwm8 1/1 Running 0 6m
openshift-service-cert-signer apiservice-cabundle-injector-8ffbbb6dc-6lkvl 1/1 Running 0 7m
openshift-service-cert-signer service-serving-cert-signer-668c45d5f-qjwkj 1/1 Running 0 7m
openshift-web-console webconsole-c877c8b45-m5hpx 1/1 Running 0 5m

访问Dashboard

地址为:https://8.134.68.154:8443/console

但是访问会失败,会重定向到127.0.0.1,解决方案如下:

$ oc cluster down
$ rm -rf ./openshift.local.clusterup/
$ oc cluster up --public-hostname=8.134.68.154

重启后,再访问就可以了。

oc常用命令

# 登陆
oc login -u system -p admin https://8.134.68.154:8443
oc login -u developer -p pkslow https://8.134.68.154:8443
oc login -u=<username> -p=<password> --server=<your-openshift-server> --insecure-skip-tls-verify # 切换project
oc project <myproject>
oc login -n <myproject> # 创建资源
oc create -f myobject.yaml -n <myproject> oc create configmap propsfilecm --from-file=application.properties
oc set volumes dc/myapp --add --overwrite=true --name=configmap-volume --mount-path=/data -t configmap --configmap-name=propsfilecm oc create secret generic oia-secret --from-literal=username=myuser --from-literal=password=mypassword
oc set volumes dc/myapp --add --name=secret-volume --mount-path=/opt/app-root/ --secret-name=oia-secret # 更新
oc patch svc mysvc --type merge --patch '{"spec":{"ports":[{"port": 8080, "targetPort": 5000 }]}}' # 调试访问
oc exec <mypod> cat /opt/app-root/myapp.config
oc rsh <mypod
oc debug dc <mydc> # 伸缩
oc scale dc <mydc> --replicas=5
oc autoscale dc/app-cli --min 2 --max 5 --cpu-percent=75 # 其它
oc whoami
oc status
oc logs pod <mypod>
oc get pods --all-namespaces
oc describe pod <mypod>
oc get services --sort-by=.metadata.name
oc delete all -l app=tomcat
oc delete pod <mypod> --grace-period=0
oc export bc,dc,is,svc --as-template=myapp.yaml

用到的Images:

# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
openshift/origin-node v3.11 3f7a62b09e77 3 months ago 1.2GB
openshift/origin-control-plane v3.11 6608ab37a132 3 months ago 839MB
openshift/origin-haproxy-router v3.11 ecaa11886824 3 months ago 417MB
openshift/origin-deployer v3.11 d35bd5080535 3 months ago 390MB
openshift/origin-hyperkube v3.11 0cfb433fadc5 3 months ago 515MB
openshift/origin-cli v3.11 33db4aca59ae 3 months ago 390MB
openshift/origin-hypershift v3.11 9e866d795822 3 months ago 556MB
openshift/origin-pod v3.11 09e1f40f223e 3 months ago 267MB
openshift/origin-docker-registry v3.11 9dffb2abf1dd 3 years ago 310MB
openshift/origin-web-console v3.11 be30b6cce5fa 3 years ago 339MB
openshift/origin-service-serving-cert-signer v3.11 47dadf9d43b6 3 years ago 276MB

在Ubuntu上安装OpenShift并使用的更多相关文章

  1. [异常解决] ubuntu上安装JLink驱动遇到的坑及给后来者的建议

    一.前言 最近将整个电脑格式化,改成了linux操作系统 希望这样能让自己在一个新的世界探索技术.提升自己吧- win上的工具用多了,就不想变化了- 继上一篇<ubuntu上安装虚拟机遇到的问题 ...

  2. Ubuntu上安装Robomongo及添加到启动器

    到目前为止,Robomongo仍是MongoDB最好的客户端管理工具,如需在Ubuntu上安装Robomongo,可直接从官网下载.tar.gz压缩包进行解压,然后直接运行bin目录下的robomon ...

  3. 在 Ubuntu 上安装 Android Studio

    在 Ubuntu 上安装 Android Studio http://www.linuxidc.com/Linux/2013-05/84812.htm 打开terminal,输入以下命令 sudo a ...

  4. Ubuntu上安装Karma失败对策

    在Ubuntu上安装Karma遇到超时 timeout 错误.Google了一下,国外的码农给了一个快捷的解决方案,实测可行,贴在这里: sudo apt-get install npm nodejs ...

  5. 在Ubuntu上安装LAMP服务器

    1.安装Ubuntu上安装LAMP apt-get install lamp-server^ 2.安装过程中设置MySql密码 3.测试 创建index.php var/www/html/index. ...

  6. [译]How to Setup Sync Gateway on Ubuntu如何在ubuntu上安装sync-gateway

    参考文章https://hidekiitakura.com/2015/03/21/how-to-setup-sync-gateway-on-ubuntudigitalocean/ 在此对作者表示感谢 ...

  7. 在Ubuntu上安装JDK、Ant、Jmeter和Jenkins

    一.前期准备 1. 在win7下载VMware.Ubuntu(用迅雷下比较快) 2. 安装完VMware后新建虚拟机,选择iso: 3. 具体配置参考如下,至此Ubantu安装完成 二.在Ubuntu ...

  8. Ubuntu上安装MongoDB(译)

    add by zhj:直接从第四步开始就可以了,而且安装好MongoDB后会自动启动的,不必自己去执行启动命令 原文:https://docs.mongodb.com/manual/tutorial/ ...

  9. Ubuntu上安装ns2-2.34

    Ubuntu上安装ns2-2.34 步骤1 下载ns-allinone-2.34 $ tar zxf ns-allinone-2.34.tar.gz 步骤2 sudo apt-get install ...

  10. ubuntu上安装mysql 编译安装

    为什么要折腾?首先说明的是ubuntu上安装mysql等软件是非常容易简单的,其简单的程度盖过windows上的安装,一句sudo apt-get install就可以搞定.如果想用最简便的方法安装m ...

随机推荐

  1. 【Odoo】Odoo16-性能优化提升

    上海序说科技,专注于基于Odoo项目实施,实现企业数智化,助力企业成长. 老韩头的开发日常,博客园分享(2022年前博文) 10月12日,Odoo16版本正式发布,本文将就Odoo官方在性能方面做的优 ...

  2. Sql Server 数据库分页存储过程书写

    create proc 存储过程名称( @page int, //pageindex @rows int, //pagesize @rowCount int out)as begin--定义字符串变量 ...

  3. SQL--临时表的使用

    临时表的创建 临时表分为:本地临时表和全局临时表 通俗区分: 本地临时表:只能在当前查询页面使用,新开的查询是不能使用它的     #temp 全局临时表:不管开多少查询页面都可以使用  ##temp ...

  4. CF39H

    前言 谁来给我讲讲九九乘法表啊. 以上菲克向. \(\sf{Solution}\) 看题上来就是数据范围 \(2\leq k\leq 10\) ,显然打表可以轻松水过,数据这么小,手算是没问题的啦. ...

  5. Vue router简单配置入门案例

    { 注意驼峰命名法,不然会报错 } 1.在Views文件夹下创建Vue路由文件,例如: <template> </template>  <script> </ ...

  6. 我的Vue之旅 09 数据数据库表的存储与获取实现 Mysql + Golang

    第四期 · 将部分数据存储至Mysql,使用axios通过golang搭建的http服务器获取数据. 新建数据库 DROP DATABASE VUE; create database if not e ...

  7. 使用LabVIEW实现基于pytorch的DeepLabv3图像语义分割

    前言 今天我们一起来看一下如何使用LabVIEW实现语义分割. 一.什么是语义分割 图像语义分割(semantic segmentation),从字面意思上理解就是让计算机根据图像的语义来进行分割,例 ...

  8. LoadRunner11脚本小技能之添加请求头+定义变量+响应内容乱码转换打印+事务拆分

    一.添加请求头 存在一些接口,发送请求时需要进行权限验证.登录验证(不加请求头时运行脚本,接口可能会报401等等),所以需要在脚本中给对应请求添加请求头.注意:请求头需在请求前添加,包含url类.su ...

  9. 【安装文档】TRex流量分析仪保姆级安装指南--基于VMware虚拟机(ubantu18.04@Intel 82545EM)

    前言 既然你已经知道TRex并尝试搜索它的安装教程,这意味着你有一定的基础知识(至少知道自己需要什么).因此本文对于TRex的介绍部分会偏少 本次主要为TRex安装过程的一次记录(版本为v3.0.0) ...

  10. DevOps | 企业内源(内部开源)适合什么样的公司

    框架类是否适合企业内源? 框架类都由公司早期来的一些大佬们负责(相当于技术委员会),更新频率非常低.给框架类提MR的人,多数本身就在技术委员会. 如果公司的人员众多,类似BAT级别,几万人使用的框架, ...