安装 openssh-server,提供远程连接
sudo apt install -y openssh-server sudo apt-get remove vim-common apt-get install vim sudo vi /etc/ssh/sshd_config sudo systemctl restart ssh
sudo echo k8s-node-2 > /etc/hostname sudo vim /etc/hosts sudo ufw enable sudo ufw allow 6443 sudo ufw status sudo swapoff -a && sudo sed -i 's/^\/swap.img\(.*\)$/#\/swap.img \1/g' /etc/fstab && free
安装docker
sudo apt-get remove docker docker-engine docker.io containerd runc sudo apt-get update sudo apt-get install -y ca-certificates curl gnupg lsb-release sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ jammy stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo chmod a+r /etc/apt/keyrings/docker.gpg sudo apt-get update sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin sudo systemctl list-unit-files | grep docker sudo systemctl stop containerd.service sudo cp /etc/containerd/config.toml /etc/containerd/config.toml.bak sudo containerd config default > $HOME/config.toml sudo cp $HOME/config.toml /etc/containerd/config.toml sudo sed -i "s#registry.k8s.io/pause#registry.cn-hangzhou.aliyuncs.com/google_containers/pause#g" /etc/containerd/config.toml sudo sed -i "s#SystemdCgroup = false#SystemdCgroup = true#g" /etc/containerd/config.toml sudo systemctl restart docker.service #开机自启 sudo systemctl enable docker.service #开机自启 sudo systemctl enable --now containerd.service systemctl list-unit-files | grep docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://hnkfbj7x.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=systemd"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker sudo docker info
安装 k8s 1.25.3 所需依赖
sudo apt-get update && sudo apt-get install -y apt-transport-https curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add - sudo vim /etc/apt/sources.list.d/kubernetes.list deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main sudo apt-get update sudo apt-get install -y kubelet=1.25.3-00 kubeadm=1.25.3-00 kubectl=1.25.3-00 sudo systemctl daemon-reload sudo systemctl restart kubelet sudo systemctl enable kubelet sudo systemctl status kubelet
#该命令执行完会输出一条join命令,需要node节点执行,需要复制保存下载 sudo kubeadm init --image-repository=registry.aliyuncs.com/google_container
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config kubectl cluster-info
一些查看命令
#查看集群信息 kubectl cluster-info #查看pod信息 kubectl get pods --all-namespaces -o wide #查看节点信息 kubectl get nodes #查看cs信息 kubectl get cs
配置网络
标签:简洁,get,sudo,apt,etc,systemctl,docker,k8s,安装
From: https://www.cnblogs.com/excellencesy/p/17024863.html