kubernetes之hyperkube方式安装文档-镜像仓库搭建(二)

说明:使用的是镜像仓库是harbor

系统

[root@i-kwx60d01 ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 

harbor 镜像仓库IP: 10.39.47.22

安装docker docker-compose

yum install epel-release docker -y 
yum install python-pip -y
pip install --upgrade pip
pip install docker-compose

使用镜像加速器

[root@i-kwx60d01 ~]# cat /etc/docker/daemon.json 
{"registry-mirrors": ["http://579fe187.m.daocloud.io","https://pee6w651.mirror.aliyuncs.com"]}

启动docker

[root@i-kwx60d01 ~]# systemctl start docker 
[root@i-kwx60d01 ~]# systemctl status docker 
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2018-06-16 12:51:24 CST; 6s ago
     Docs: http://docs.docker.com
 Main PID: 5079 (dockerd-current)
   CGroup: /system.slice/docker.service
           ├─5079 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt nativ...
           └─5086 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m...

Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.486227778+08:00" level=info msg="Loading containers: start."
Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.509482239+08:00" level=warning msg="Running modprobe bridge br_netfilter failed...
Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.525283690+08:00" level=info msg="Firewalld running: false"
Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.574286378+08:00" level=info msg="Default bridge (docker0) is assigned w...address"
Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.606907255+08:00" level=info msg="Loading containers: done."
Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.608079605+08:00" level=warning msg="Not using native diff for overlay2,... to fix"
Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.612680377+08:00" level=info msg="Daemon has completed initialization"
Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.612702315+08:00" level=info msg="Docker daemon" commit="94f4240/1.13.1"...n=1.13.1
Jun 16 12:51:24 i-kwx60d01 systemd[1]: Started Docker Application Container Engine.
Jun 16 12:51:24 i-kwx60d01 dockerd-current[5079]: time="2018-06-16T12:51:24.623627946+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full

下载harborharbor-offline-installer-v1.5.1.tgz

yum install wget -y 
wget https://storage.googleapis.com/harbor-releases/release-1.5.0/harbor-offline-installer-v1.5.1.tgz
[root@i-kwx60d01 ~]# ls -l
total 844668
-rw-r--r-- 1 root root 864933610 May 31 15:57 harbor-offline-installer-v1.5.1.tgz
[root@i-kwx60d01 harbor]# tar xvf harbor-offline-installer-v1.5.1.tgz

所用的数据库或者redis都是默认的
就修改了hostname

hostname = 10.39.47.22

安装harbor

[root@i-kwx60d01 harbor]# ./install.sh 

[Step 0]: checking installation environment ...

Note: docker version: 1.13.1

Note: docker-compose version: 1.21.2

[Step 1]: loading Harbor images ...
...
...
...
[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-adminserver ... done
Creating registry           ... done
Creating harbor-db          ... done
Creating redis              ... done
Creating harbor-ui          ... done
Creating nginx              ... done
Creating harbor-jobservice  ... done

✔ ----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at http://10.39.47.22. 
For more details, please visit https://github.com/vmware/harbor .

查看所起的容器

[root@i-kwx60d01 harbor]# docker ps 
CONTAINER ID        IMAGE                                  COMMAND                  CREATED              STATUS                        PORTS                                                              NAMES
5b106e94c91b        vmware/harbor-jobservice:v1.5.1        "/harbor/start.sh"       About a minute ago   Up About a minute                                                                                harbor-jobservice
18fdb44298eb        vmware/nginx-photon:v1.5.1             "nginx -g 'daemon ..."   About a minute ago   Up About a minute (healthy)   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp   nginx
3d6268795f45        vmware/harbor-ui:v1.5.1                "/harbor/start.sh"       About a minute ago   Up About a minute (healthy)                                                                      harbor-ui
48dd67264129        vmware/redis-photon:v1.5.1             "docker-entrypoint..."   About a minute ago   Up About a minute             6379/tcp                                                           redis
82976249d71e        vmware/harbor-adminserver:v1.5.1       "/harbor/start.sh"       About a minute ago   Up About a minute (healthy)                                                                      harbor-adminserver
3ceba27e5931        vmware/registry-photon:v2.6.2-v1.5.1   "/entrypoint.sh se..."   About a minute ago   Up About a minute (healthy)   5000/tcp                                                           registry
30b83c2f9b5f        vmware/harbor-db:v1.5.1                "/usr/local/bin/do..."   About a minute ago   Up About a minute (healthy)   3306/tcp                                                           harbor-db
f4cbd7087cae        vmware/harbor-log:v1.5.1               "/bin/sh -c /usr/l..."   About a minute ago   Up About a minute (healthy)   127.0.0.1:1514->10514/tcp                                          harbor-log

访问 http://10.39.47.22
ha

登录默认的密码是admin/Harbor12345
09

docker login 仓库
kubernetes之hyperkube方式安装文档-代码编译(一)之前编译好的镜像上传到harbor
添加Insecure Registries 仓库地址,要不登录不上

[root@i-kwx60d01 harbor]# cat /etc/docker/daemon.json 
{"registry-mirrors": ["http://579fe187.m.daocloud.io","https://pee6w651.mirror.aliyuncs.com"],"insecure-registries":["10.39.47.22"]}
systemctl restart docker

docker info 
...
Insecure Registries:
 10.39.47.22
 127.0.0.0/8
 ...

修改之前编译好的镜像

docker tag staging-k8s.gcr.io/hyperkube-amd64:1.10.4 10.39.47.22/qinzhao/hyperkube-amd64:1.10.4

用admin 登录harbor,登录成功会在~/.docker/config.json下看到自己的登录时的auth

[root@kubernetes-build kubernetes]# docker login 10.39.47.22
Username: admin
Password: 
Login Succeeded

[root@kubernetes-build kubernetes]# cat ~/.docker/config.json 
{
    "auths": {
        "10.39.47.22": {
            "auth": "YWRtaW46SGFyYm9yMTIzNDU="
        },
        "harbor.enncloud.cn": {
            "auth": "YWRtaW46SGFyYm9yMTIzNDU="
        }
    }
}

在harbor上新建一个叫做qinzhao的项目,然后把hyperkube-amd64:1.10.4镜像推送到该项目中

root@kubernetes-build kubernetes]# docker push 10.39.47.22/qinzhao/hyperkube-amd64:1.10.4
The push refers to a repository [10.39.47.22/qinzhao/hyperkube-amd64]
2cc67e28cf6c: Pushed 
152ba9336a12: Pushed 
a7eae75a86e6: Pushed 
98f83f2ef3fb: Pushed 
d26b5c7966ed: Pushed 
3c142675f6ee: Pushed 
cd56a04ed140: Pushed 
582b548209e1: Pushed 
1.10.4: digest: sha256:c022ededf3ee769a907c4010f71b2c2d32a2a84c497e306f36fa5e6b581ff462 size: 1998

推送完成后,在harbor ui 上查看镜像
111

到此镜像仓库已经搭建完成了

接下来就是编译etcd镜像了,敬请期待

参考
installation_guide
how-to-set-up-a-private-docker-registry-on-ubuntu-14-04

猜你喜欢

转载自blog.csdn.net/qq_21816375/article/details/80712274