从零开始的 Kubernetes 学习笔记(一)
部署Docker For Debian
使用 Kubernetes 对 Docker 容器进行快速编排成为新的微服务时代的部署风潮。
官方仓库目前仅支持 64-bit 的 Debian 及 Raspbian 系统:
Debian 10 (Buster) Debian 9 (Stretch) / Raspbian stretch 官方仅对以下几种架构 amd64(x86_64), armhf, arm64 提供支持。
一、卸载旧版本
# apt remove docker docker-engine docker.io containerd runc
小贴士:/var/lib/docker/ 目录默认存放镜像、容器、配置、数据卷等,若需要完全清理,请删除此目录即可。
二、安装Docker
1. 基础依赖
# apt-get install -y apt-transport-https ca-certificates curl gnupg-agent
2. 添加Docker源
# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | apt-key add - # echo "deb https://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable" | tee -a /etc/apt/sources.list.d/docker-ce.list
3. 安装
# apt-get update # apt list docker-ce -a # apt-get install docker-ce=5:19.03.14~3-0~debian-buster docker-ce-cli=5:19.03.14~3-0~debian-buster
因为目前版本 kubernetes 只支持19.03版本的 Docker ,所以需要指定版本安装。
三、配置优化
1. Cgroup 驱动切换
在使用基于 Systemd 的机器上部署 Kubernetes 和 Docker 时,为了让更好的工作
// Set up the Docker daemon # cat > /etc/docker/daemon.json <<EOF { "registry-mirrors": ["https://hub-mirror.c.163.com"], "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2" } EOF
Hub 镜像仓库加速
上述配置文件使用的是网易的镜像仓库,也可以使用 镜像。 curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
2. 重载配置
# systemctl daemon-reload # systemctl restart docker # docker info
附录
相关链接:
转载:https://www.vvave.net/archives/how-to-setup-kubernetes-production-environment-part-1.html