在Mac上搭建Openshift3.9开发环境

概述

本文介绍如何在本地搭建openshift3.9开发环境,开发环境里面容器的进程均是以容器的方式运行,编译源代码可以生成二进制、rpm包和镜像。我们以Mac为本地环境。

正文

安装git

brew install git

安装docker

具体安装方法请参照Google,安装好后需要到右上角docker图标里的Preferences,把docker里面的内存参数调整为4G或以上(默认是2G),因为如果内存太小的话在编译的时候会出现out of memory错误

安装golang

go的版本要求是1.9, 不能是1.10

下载goland IDE

IDE用于编辑源代码的,这里用Intellij系列的Goland

创建开发环境目录

mkdir -p /go/src/github.com/openshift

因为go语言项目必须要放在src目录下,所以以上目录是必须的

下载openshift origin, origin-web-console-server, origin-web-console, origin-web-catalog, origin-web-common源代码

openshift origin的主要代码库是origin,origin-web-console是UI的代码库,origin-web-console-server是UI后端的代码库,origin-web-catalog和origin-web-common是UI代码库的依赖库。

cd /go/src/github.com/openshift

git clone https://github.com/openshift/origin.git
git clone https://github.com/openshift/origin-web-console-server.git
git clone https://github.com/openshift/origin-web-console.git
git clone https://github.com/openshift/origin-web-catalog.git
git clone https://github.com/openshift/origin-web-common.git

进入以上每个项目,把分支切换为release-3.9 或者enterprise-3.9

git checkout release-3.9
git checkout enterprise-3.9

用Goland打开项目/go/src/github.com/openshift,并设置GOROOT和GOPATH

生成openshift/origin-base , openshift/origin-source和openshift/origin-release三个镜像

cd origin
hack/env hack/build-base-images.sh

生成二进制文件,rpm包和各种镜像

cd origin
hack/env make release

生成origin web console的二进制文件,rpm包和镜像

cd origin-web-console-server
make
OS_BUILD_ENV_PRESERVE=_output/local/bin hack/env make build-images

查看镜像的tag

docker images

修改生成的web-console的镜像的tag,和其他的镜像的tag保持一致

之前生成的origin-web-console的镜像的tag和其他的镜像的tag不同,需要修改成一样的,不然后面启动容器集群的时候会报错,下面的tag需要换成真实的

docker tag openshift/origin-web-console:b02b6d7  openshift/origin-web-console:71543b2

删除镜像是 tagged的镜像

docker rmi $(docker images | grep "^<none>" | awk "{print $3}")

本地下载二进制文件oc或者在本地编译生成oc

把oc的路径加入到PATH以便于调用

cd origin
$ export PATH="$( source hack/lib/init.sh; echo "${OS_OUTPUT_BINPATH}/$( os::build::host_platform )/" ):${PATH}"

启动openshift集群

oc cluster up --version="71543b2"

成功后会出现以下输出:

Deleted existing OpenShift container
Using Docker shared volumes for OpenShift volumes
Using 127.0.0.1 as the server IP
Starting OpenShift using openshift/origin:71543b2 ...
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

在浏览器打开https://127.0.0.1:8443, 用developer登陆,密码为空

更多容器技术请关注公众号:

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值