利用 raspberry pi 4 在『网络受限』下搭建 k8s 笔记

前提:在我电脑上设备一个 http 代理,这样其它机器可以利用该代理访问外网。

add apt proxy

sudo vim /etc/apt/apt.conf.d/proxy.conf
Acquire::http::Proxy "http://192.168.0.102:41091/";
Acquire::https::Proxy "http://192.168.0.102:41091/";

enable cgroups for memory

sudo vim /boot/firmware/cmdline.txt
insert the header of line
cgroup_enable=memory cgroup_memory=1

reboot

sudo reboot

install docker

sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo   "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
cat <<EOF | sudo tee /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

set proxy for docker

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://192.168.0.102:41091"
Environment="HTTPS_PROXY=http://192.168.0.102:41091"

reboot docker

sudo systemctl daemon-reload
sudo systemctl restart docker

install kubeadm

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg --proxy 192.168.0.102:41091
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
posted @ 2021-06-22 22:28  海鸟  阅读(65)  评论(0编辑  收藏  举报