1.2、k8s pv的自动供给,这里当然也可以使用Ceph持久化存储,由于我的测试环境配置不够,先拿NFS对有状态的应用实现自动的PV供给。
先准备一台NFS服务器为K8S提供存储支持
[root@k8s-node3 ~]
# yum -y install nfs-utils
创建共享的目录
[root@k8s-node3 ~]
# mkdir /ifi/kubernetes -p
[root@k8s-node3 ~]
# cat /etc/exports
/ifi/kubernetes
10.4.7.0/
24(rw,no_root_squash)
[root@k8s-node3 kubernetes]
# systemctl start nfs
[root@k8s-node3 ~]
# systemctl enable nfs
并且要在每个Node上安装nfs-utils包,用于mount挂载时用。
[root@k8s-master1 ~]
# mount -t nfs 10.4.7.22:/ifi/kubernetes /mnt
由于K8S不支持NFS动态供给,还需要先安装nfs-client-provisioner插件
修改nfs的服务端地址和挂载的目录,这是我nfs-client的地址,如果借鉴的需要将id_rsa.pub给我
git clone git@gitee.com:zhaocheng172/nfs-client.git
[root@k8s-master1 nfs-client]
# kubectl get pod
NAME
READY STATUS RESTARTS AGE
busybox
1/
1
Running
0
35m
nfs-client-provisioner
-86dff449dd
-68ngn
1/
1
Running
0
106s
2、镜像仓库Harbor
2.1安装docker与docker-compose
# wget CentOS/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
# yum install docker-ce -y
# systemctl start docker
# systemctl enable docker
docker-compose的下载地址:
https:/
/docs.docker.com/compose/install/
curl -L
https:/
/github.com/docker/compose/releases/download/1.25.
0/docker-compose-
`uname -s`-
`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
2.2 解压离线包部署
下载地址:https://github.com/goharbor/harbor
# tar zxvf harbor-offline-installer-v1.10.1.tgz
# cd harbor
# vi harbor.yml
hostname: harbor.zhaocheng.com
# ./prepare
# ./install.sh --with-chartmuseum
# docker-compose ps
--with-chartmuseum 参数表示启用Charts存储功能。
进行访问:
这个已经启动chart功能
2.3 配置Docker可信任
由于habor未配置https,还需要在node节点上的docker配置可信任。
# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"https://38vve9ja.mirror.aliyuncs.com"],
"insecure-registries": [
"harbor.zhaocheng.com"]
}
# systemctl restart docker
3、helm-v3 工具
3.1安装helm工具
[root@k8s-master1 helm]
# wget https://get.helm.sh/helm-v3.0.0-linux-amd64.tar.gz
[root@k8s-master1 helm]
# tar xf helm-v3.0.0-linux-amd64.tar.gz
[root@k8s-master1 helm]
# mv linux-amd64/helm /usr/bin/
[root@k8s-master1 helm]
# helm --help
3.2 安装push插件
# git clone https://gitee.com/zhaocheng172/helm-push.git
# tar zxvf helm-push_0.7.1_linux_amd64.tar.gz
# mkdir -p /root/.local/share/helm/plugins/helm-push
# chmod +x bin/*
# mv bin plugin.yaml /root/.local/share/helm/plugins/helm-push
3.3 添加repo
# helm repo add --username admin --password Harbor12345 myrepo