发布时间:2023-04-17 18:00
关闭交换分区:
https://blog.csdn.net/u013271384/article/details/125155464
hostnamectl set-hostname master --static
192.168.12.141 master
iptables -F (清空防火墙,不要关闭)
iptables -t nat -F (清空net表防火墙)
setenforce 0 (临时关闭selinux,没安装不运行)
sed -i '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config (永久关闭selinux)
方法1
# sysctl params required by setup, params persist across reboots
cat <| sudo tee /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
EOF
sudo sysctl --system
方法2
修改/etc/sysctl.conf,添加
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
保存后执行
sysctl -p
方法1(通用)
cat <| sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
sudo modprobe ip_vs
sudo modprobe ip_vs_rr
sudo modprobe ip_vs_wrr
sudo modprobe ip_vs_sh
sudo modprobe nf_conntrack
方法2 (centos7)
cat > /etc/sysconfig/modules/ipvs.modules << EOF
#!/bin/bash
modprobe -- overlay
modprobe -- br_netfilter
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules
bash /etc/sysconfig/modules/ipvs.modules
lsmod | grep -E "ip_vs|nf_conntrack_ipv4"
ps:使用命令: lsmod | grep br_netfilter 可以查看br_netfilter模块是否加载,使用sudo modprobe br_netfilter可以执行加载。
nf_conntrack_ipv4如果不存在换成nf_conntrack试试
https://blog.csdn.net/u013271384/article/details/125355087
sudo apt-get install kubeadm kubelet kubectl
或
安装指定版本,aliyun仓库可能没有同步最新版本的apiserver,以此推荐安装指定版本
apt install kubeadm=1.23.8-00 kubelet=1.23.8-00 kubectl=1.23.8-00
yum insatll -y kubeadm kubelet kubectl
yum insatll -y kubeadm-1.23.8 kubelet-1.23.8 kubectl-1.23.8
kubectl version --client --output=yaml
kubeadm init --kubernetes-version 1.23.8 --image-repository registry.cn-hangzhou.aliyuncs.com/google_containers --service-cidr 10.96.0.0/16 --pod-network-cidr 10.244.0.0/16
参数说明
--kubernetes-version 指定安装kubernetes版本
--image-repository 指定容器镜像拉取地址,默认地址: k8s.gcr.io
--service-cidr service的ip段. (默认 "10.96.0.0/12")
--pod-network-cidr pod运行时分配的ip,flannel配置指定10.244.0.0/16 (Specify range of IP addresses for the pod network. If set, the control plane will automatically allocate CIDRs for every node.)
默认情况下kube-apiserver,kube-scheduler,kube-controller-manager,kube-proxy,etcd以镜像形式安装
报错(可忽略):
https://blog.csdn.net/u013271384/article/details/125531746
运行结果(可忽略):
rk-cidr 10.244.0.0/16
[init] Using Kubernetes version: v1.23.8
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local master] and IPs [10.96.0.1 192.168.12.144]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [localhost master] and IPs [192.168.12.144 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [localhost master] and IPs [192.168.12.144 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 8.005424 seconds
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config-1.23" in namespace kube-system with the configuration for the kubelets in the cluster
NOTE: The "kubelet-config-1.23" naming of the kubelet ConfigMap is deprecated. Once the UnversionedKubeletConfigMap feature gate graduates to Beta the default name will become just "kubelet-config". Kubeadm upgrade will handle this transition transparently.
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node master as control-plane by adding the labels: [node-role.kubernetes.io/master(deprecated) node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node master as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
[bootstrap-token] Using token: i8qo0l.2ksy6x7hwit6m641
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.12.144:6443 --token i8qo0l.2ksy6x7hwit6m641 \
--discovery-token-ca-cert-hash sha256:4ea11d592fe94958816f58cd67893bbec7c713c3ed393e6282719b71ae77daaf
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get nodes
kubectl get pods -n kube-system
相关命令:
https://blog.csdn.net/u013271384/article/details/125463578
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
或将kube-flannel.yml下载至本地
地址1: https://download.csdn.net/download/u013271384/85836583
地址2:https://github.com/flannel-io/flannel Documentation目录下
kubectl apply -f kube-flannel.yml
kubectl get nodes
kubectl get pods -n kube-system
安装好kubeadm kubelet kubectl 之后,运行下面命令
kubeadm join 192.168.12.144:6443 --token i8qo0l.2ksy6x7hwit6m641 \
--discovery-token-ca-cert-hash sha256:4ea11d592fe94958816f58cd67893bbec7c713c3ed393e6282719b71ae77daaf
上面的命令来自kubeadm init后生成的,如果不记得,可以运行下面的命令生成:
kubeadm token create --print-join-command
kubelet清理
systemctl stop kubelet
rm -rf /var/lib/kubelet /etc/kubernetes
apt remove kubelet 或 rpm -e kubelet --nodeps
集群重置
kubeadm reset
rm -rf /etc/kubernetes
深度剖析 VS Code JavaScript Debugger 功能及实现原理
android高德地图上加自定义菜单,自定义UI控件-UI界面定制-开发指南-Android 导航SDK | 高德地图API...
ACL 2022 | 基于Prompt的自动去偏:有效减轻预训练语言模型中的偏见
YOLOv3 -> YOLOv4 -> YOLOv5的改进(tricks)
Spss Modeler关联规则Apriori模型、Carma算法分析超市顾客购买商品数据挖掘实例
RuntimeError: one of the variables needed for gradient computation has been modified by an...
C语言常用字符串函数——头文件 <string.h> 到底有什么?
yolov4训练自己的数据 灰度图像_【AI实战】手把手教你深度学习文字识别(文字检测篇:基于MSER, CTPN, SegLink, EAST等方法)...
机器人手眼标定原理介绍(含详细推导过程)使用Tsai-Lenz算法
python相机标定流程图_相机标定——OpenCV-Python Tutorials
[ROC-RK3568-PC] [Firefly-Android] 10min带你了解UART的使用