【云原生 · Kubernetes】Kubernetes基础环境搭建
接着上次的内容,后续来了!
4.部署Harbor仓库
在master节点执行脚本k8s_harbor_install.sh即可完成harbor仓库的搭建,具体步骤参考如下(1)-(3)步骤。
方法一:
[root@master ~]# k8s_harbor_install.sh
方法二:
(1)安装Docker
Kubernetes默认的容器运行时仍然是Docker,使用的是kubelet中内置dockershim CRI实现。
master节点:
#安装Docker-ce
[root@master ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@master ~]# yum install -y docker-ce
#启动Docker
[root@master ~]# systemctl start docker
[root@master ~]# systemctl enable docker
调整部分docker参数:
[root@master ~]# tee /etc/docker/daemon.json <<-'EOF'
> {
> "insecure-registries" : ["0.0.0.0/0"],
> "registry-mirrors": ["https://5twf62k1.mirror.aliyuncs.com"],
> "exec-opts": ["native.cgroupdriver=systemd"]
> }
> EOF
[root@master ~]# systemctl restart docker
node 节点:
#安装Docker-ce
[root@node ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@node ~]# yum install -y docker-ce
#启动Docker
[root@node ~]# systemctl start docker
[root@node ~]# systemctl enable docker
调整部分docker参数:
[root@node ~]# tee /etc/docker/daemon.json <<-'EOF'
> {
> "insecure-registries" : ["0.0.0.0/0"],
> "registry-mirrors": ["https://5twf62k1.mirror.aliyuncs.com"],
> "exec-opts": ["native.cgroupdriver=systemd"]
> }
> EOF
[root@node ~]# systemctl restart docker
(2)安装docker-compose
master节点:
[root@master k8s]# cp -rfv /opt/k8s/docker-compose/v1.25.5-docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
[root@master k8s]# chmod +x /usr/local/bin/docker-compose
[root@master k8s]# docker-compose version
docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
(3)部署Harbor
master节点:
导入镜像:
docker load -i /opt/images/Kubernetes.tar
解压安装包:
[root@master opt]# cd harbor/
[root@master harbor]# tar -zxvf harbor-offline-installer-v2.1.0.tgz
[root@master harbor]# cd harbor
修改Harbor配置信息:
[root@master harbor]# cp harbor.yml.tmpl harbor.yml
[root@master harbor]# vi harbor.yml
hostname: 192.168.100.10 #将域名修改为本机IP
harbor_admin_password: Harbor12345
#https: # 禁用https
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path
启动Harbor:
./prepare
./install.sh --with-clair
登录Harbor仓库(http://192.168.100.10)
启动、停止Harbor:
[root@master opt]# docker-compose up -d
[root@master opt]# docker-compose stop
[root@master opt]# docker-compose restart
(4)上传镜像
将镜像导入Harbor仓库:
[root@master opt]# cd /opt/images/
[root@master images]# ./k8s_image_push.sh
输入镜像仓库地址(不加http/https): 192.168.100.10
输入镜像仓库用户名: admin
输入镜像仓库用户密码: Harbor12345
您设置的仓库地址为: 192.168.100.10
是否确认(Y/N): Y
进入Harbor仓库library项目查看镜像列表
node 节点:
[root@node ~]# scp master:/opt/k8s_node_install.sh /opt/
[root@node ~]# cd /opt/
[root@node opt]# ./k8s_node_install.sh
期待下次的分享,别忘了三连支持博主呀~
我是 念舒_C.ying ,期待你的关注~💪💪💪