由于常用软件源中的 docker 都比较老了,所以需要添加 docker-ce 的源
# 设置仓库
# 安装软件包以允许 apt 通过 HTTPS 使用存储库
apt-get update && apt-get install \\
apt-transport-https ca-certificates curl software-properties-common
# 新增 Docker 的 官方 GPG 秘钥
curl -fsSL <https://download.docker.com/linux/ubuntu/gpg> | apt-key add -
# 添加 Docker apt 仓库
add-apt-repository \\
"deb [arch=amd64] <https://download.docker.com/linux/ubuntu> \\
$(lsb_release -cs) \\
stable"
# 安装 Docker CE
apt-get update && apt-get install \\
containerd.io \\
docker-ce \\
docker-ce-cli -y
# 设置 daemon
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["<https://registry.docker-cn.com>"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
# 重启 docker.
systemctl daemon-reload
systemctl restart docker
# 设置仓库
# 安装软件包以允许 apt 通过 HTTPS 使用存储库
yum install -y yum-utils
yum-config-manager \\
--add-repo \\
<https://download.docker.com/linux/centos/docker-ce.repo>
# 安装 Docker CE
yum install docker-ce docker-ce-cli containerd.io
# 设置 cgroup 驱动
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["<https://registry.docker-cn.com>"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
# 重启 docker.
systemctl daemon-reload
systemctl restart docker
apt-get update && apt-get install -y apt-transport-https
curl <https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg> | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb <https://mirrors.aliyun.com/kubernetes/apt/> kubernetes-xenial main
EOF
swapoff -a
# use "free -m" to see if we successfully unable the swap
free -m
apt-get update
apt-get install -y kubelet kubeadm kubectl
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
<http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg>
EOF
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
由于 gcp 仓库被国内限制了访问,因此需配置代理或使用阿里云的源,这里建议配置代理,因为阿里云的源不是很全。
需自身拥有代理服务器,具体操作请自行查找