在kubesphere 中内置了harbor,对比harbor, 个人更喜欢Nexus,比如:可以使用proxy 代理Google cloud registry,非常方便。
同时nexus3提供了Docker, yum, apt, npm, ruby gems, pypi 等诸多类型的仓库功能。
Nextus3仓库都有三种类型
hosted(本地类型) 提交和拉取都基于本地存储
proxy(代理类型) 本地不做数据存储,可以和hosted配合,代理比如Google cloud registry
group(组合类型)可以组合多个hosted和proxy并按顺序,并提供统一访问地址。
首先下载:https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.20.1-01-unix.tar.gz 和 jdk 1.8 https://download.oracle.com/otn/java/jdk/8u231-b11/5b13a193868b4bf28bcb45c792fce896/jdk-8u231-linux-x64.tar.gz?AuthParam=1577416234_421a5996b580b7f5664ab0c629887f12
下载后,先配置java 环境变量。
- 解压jdk
tar zxvf jdk-8u231-linux-x64.tar.gz
mv jdk1.8.0_231 /usr/local/java
- 配置环境变量。
echo PATH=\"$PATH:/usr/local/java/jdk1.8.0_231/bin >> /root/.bashrc
echo JAVA_HOME=/usr/local/java/jdk1.8.0_231 >> /root/.bashrc
echo CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar >> /root/.bashrc
验证java 是否正常。
java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
解压nexus。
tar zxvf nexus-3.20.1-01-unix.tar.gz
启动nexus
cd nexus-3.20.1-01/bin
root@nexus:~/nexus-3.20.1-01/bin# ./nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Starting nexus
web 打开界面,默认端口:8081 ,用户:admin 密码:界面中会提示。
http://xx.xx.xx.xx:8081

首先我们点击增加一个存储。


增加一个docker 仓库


创建完成后,我们测试下。
如果是http 请求,可以在/etc/docker/daemon.json 上加入
{
"insecure-registries": [
"172.16.10.10:5000"
]
}
增加后重启docker
systemctl daemon-reload
systemctl restart docker
检查是否生效。
docker info
Insecure Registries:
172.16.10.10:5000
127.0.0.0/8
推送和拉取镜像测试。
root@master01:~#docker login 172.16.10.10:5000
root@master01:~# docker tag redis:5.0.5-alpine 172.16.10.10:5000/redis:5.0.5-alpine
推送成功
root@master01:~# docker push 172.16.10.10:5000/redis:5.0.5-alpine
The push refers to repository [172.16.10.10:5000/redis]
76ff8be8279a: Pushed
9559709fdf7f: Pushed
b499b26b07f7: Pushed
1ac7839ac772: Pushed
b34cd2e3555a: Pushed
03901b4a2ea8: Pushed
5.0.5-alpine: digest: sha256:a606eaca41c3c69c7d2c8a142ec445e71156bae8526ae7970f62b6399e57761c size: 1571
拉取成功:
root@master01:~# docker pull 172.16.10.10:5000/redis:5.0.5-alpine
5.0.5-alpine: Pulling from redis
Digest: sha256:a606eaca41c3c69c7d2c8a142ec445e71156bae8526ae7970f62b6399e57761c
Status: Image is up to date for 172.16.10.10:5000/redis:5.0.5-alpine
172.16.10.10:5000/redis:5.0.5-alpine
我们去界面上看下:
好了,到这里就可以在kubesphere 上愉快的使用nexus 作为私有镜像仓库了。
另外nexus 也可以以容器的部署部署在kubesphere 平台上。
代理模式下次更新下。