MicroK8s #
MicroK8s is a small, fast, single-package Kubernetes for developers, IoT and edge.
安装 #
snap install microk8s --classic
snap install kubectl --classic
# snap install microk8s --classic --channel=1.23/stable
# snap install kubectl --classic --channel=1.23/stable
mkdir -p ~/.kube
microk8s config > ~/.kube/config
microk8s enable dns
microk8s enable dashboard ingress
# 拉镜像
microk8s ctr image pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.7
microk8s ctr image tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.7 k8s.gcr.io/pause:3.7
microk8s ctr image tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.7 registry.k8s.io/pause:3.7
microk8s ctr image pull registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.2.0
microk8s ctr image tag registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.2.0 k8s.gcr.io/ingress-nginx/controller:v1.2.0
microk8s ctr image pull registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server:v0.5.2
microk8s ctr image tag registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server:v0.5.2 k8s.gcr.io/metrics-server/metrics-server:v0.5.2
echo "alias k=kubectl" >> ~/.zshrc
echo "export PATH=\$PATH:/snap/bin" >> ~/.zshrc
zsh
安装 kubectl 的另一种方法 #
# install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install kubectl -y
配置镜像源 #
# 先停止
sudo microk8s.stop
sudo vim /var/snap/microk8s/current/args/containerd-template.toml
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = [
"docker.1panel.live",
"hub.rat.dev",
"docker.anyhub.us.kg",
"docker.chenby.cn",
"dockerhub.jobcher.com",
"docker.awsl9527.cn",
"docker.m.daocloud.io"
]
sudo microk8s.start
microk8s.ctr images pull docker.io/library/busybox:latest
microk8s.ctr images pull docker.io/calico/cni:v3.19.1
常用命令 #
microk8s enable dns
安装配置 #
# microk8s kubelet service 配置文件
vi /etc/systemd/system/snap.microk8s.daemon-kubelet.service
# 查看状态
systemctl status snap.microk8s.daemon-kubelet
代理 #
vi /etc/environment
HTTPS_PROXY=http://your-proxy-server:8215
HTTP_PROXY=http://your-proxy-server:8215
NO_PROXY=10.0.0.0/8,172.16.0.0/12,192.168/16
https_proxy=http://your-proxy-server:8215
http_proxy=http://your-proxy-server:8215
no_proxy=10.0.0.0/8,172.16.0.0/12,192.168/16
然后重启
microk8s stop
microk8s start
参考:
叶王 © 2013-2024 版权所有。如果本文档对你有所帮助,可以请作者喝饮料。