当前位置:网站首页>Complete and detailed installation steps for kubeneter version 1.7

Complete and detailed installation steps for kubeneter version 1.7

2022-06-21 14:34:00 Internet Walker

Use kubeadm install kuberneters1.17.3
  
 # System environment preparation
  Use 3 platform centos7.2 operating system , The roles of the machine are master,worknode,worknode
 1、 Set host name
 hostnamectl set-hostname master
 2、 edit /etc/hosts
 cat <<EOF >>/etc/hosts
 10.10.10.1 master
 10.10.10.2 node1
 10.10.10.3 node2
 EOF
 3、 Turn off firewall , No exchange swap
 systemctl stop firewalld
 systemctl disable firewalld
 setenforce 0
 sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
 swapoff -a
 sed -i 's/.*swap.*/#&/' /etc/fstab
  The above operations are generally not required for virtual machines , Swap memory is turned off by default , Turn off firewall .
 4、 Configure kernel parameters ,IPv4 Flow to iptables On the chain
 cat > /etc/sysctl.d/k8s.conf <<EOF
 net.bridge.bridge-nf-call-ip6tables = 1
 net.bridge.bridge-nf-call-iptables = 1
 net.ipv4.ip_forward = 1
 EOF
 sysctl --system
  If you encounter /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1
  Solution :
 echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
 echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables
 5、 Add domestic Kubernetes Source
 cat <<EOF > /etc/yum.repos.d/kubernetes.repo
 [kubernetes]
 name=Kubernetes
 baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
 enabled=1
 gpgcheck=1
 repo_gpgcheck=1
 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
 EOF
 6、 add to docker Source
 cat <<EOF > /etc/yum.repos.d/docker.repo
 [docker-ce-stable]
 name=Docker CE Stable - $basearch
 baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
 enabled=1
 gpgcheck=1
 gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
 EOF
 k8s install
 7、 Each machine is equipped with
 yum install kubelet kubeadm kubectl
 systemctl enable kubelet
  
 # k8s install
 1、 Deploy master node
  stay master Node initialization
 kubeadm init --kubernetes-version=1.17.3 --apiserver-advertise-address=10.192.126.118 --image-repository registry.aliyuncs.com/google_containers --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16
  If appear
 detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd"
  terms of settlement :
  Modify or create /etc/docker/daemon.json, Add the following :
 {
 "exec-opts": ["native.cgroupdriver=systemd"]
 }
 [ERROR DirAvailable--var-lib-etcd]: /var/lib/etcd is not empty
  terms of settlement :
 rm -rf /var/lib/etcd
  After successful installation, the following information should be kept in mind
 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
  
 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 10.192.126.118:6443 --token cjcepg.zlpbj2advlh0k5e5 \
 --discovery-token-ca-cert-hash sha256:825f8a4ebe2da9187cde8351805df71e099a81c2a9f9d33f7456eb3fbf4cae0c
  
  If you encounter kubectl get nodes And so on error: the server doesn't have a resource type "nodes"
  This is because of the permission problem , Need to use sudo, Now it's root Account number also needs sudo function , You can try to run sudo -s
  
 1、 Use... After creation kubectl get pods --all-namespaces see pod Health of , In practice, I encountered
 kube-system coredns-9d85f5447-mk9cq 0/1 ContainerCreating 0 12m
 kube-system coredns-9d85f5447-wjpk7 0/1 ContainerCreating 0 12m
  Yes, it is kubectl describe pod coredns-9d85f5447-mk9cq -n kube-system see pod Information , The main mistake is
 network: error getting ClusterInformation,https://10.43.0.1:443/apis/crd.projectcalico.org/v1/clusterinformations/default
  This is generally an analysis netowrkplugin, Profile path /etc/cni/net.d, My situation is because of the previous machine CNI The plug-in doesn't have
  Clean up , The current selection is canal, So you need to delete 10-calico.conflist, modify 10-canal.yaml Content .
  Revision reference https://docs.projectcalico.org/reference/cni-plugin/configuration
  
 2、 Log view journalctl -f -u kubelet |grep -i error -C 500
  
 # k8s Cluster uninstall
 kubeadm reset -f
 modprobe -r ipip
 lsmod
 rm -rf ~/.kube/
 rm -rf /etc/kubernetes/
 rm -rf /etc/systemd/system/kubelet.service.d
 rm -rf /etc/systemd/system/kubelet.service
 rm -rf /usr/bin/kube*
 rm -rf /etc/cni
 rm -rf /opt/cni
 rm -rf /var/lib/etcd
 rm -rf /var/etcd
 ifconfig flannel.1 down
 ip link delete flannel.1
 yum clean all
  
  
  Use the configuration file for cluster initialization
 1、kubeadm config print init-defaults ClusterConfiguration >kubeadm-config.conf
 2、 modify kubeadm-config.conf
 kubeadm init --config kubeadm-config.yaml
  
 apiVersion: kubeadm.k8s.io/v1beta2
 bootstrapTokens:
 - groups:
 - system:bootstrappers:kubeadm:default-node-token
 token: abcdef.0123456789abcdef
 ttl: 24h0m0s
 usages:
 - signing
 - authentication
 kind: InitConfiguration
 localAPIEndpoint:
 advertiseAddress: 10.192.126.118
 bindPort: 6443
 nodeRegistration:
 criSocket: /var/run/dockershim.sock
 name: test4.leapmotor.com
 taints:
 - effect: NoSchedule
 key: node-role.kubernetes.io/master
 ---
 apiServer:
 timeoutForControlPlane: 4m0s
 apiVersion: kubeadm.k8s.io/v1beta2
 certificatesDir: /etc/kubernetes/pki
 clusterName: kubernetes
 controllerManager: {}
 dns:
 type: CoreDNS
 etcd:
 local:
 dataDir: /var/lib/etcd
 imageRepository: registry.aliyuncs.com/google_containers
 kind: ClusterConfiguration
 kubernetesVersion: v1.17.0
 networking:
 dnsDomain: cluster.local
 serviceSubnet: 10.96.0.0/12
 podSubnet: 10.244.0.0/16
 scheduler: {}
  
 3、 modify kubelet Start parameter of
 vim /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
 ExecStart=/usr/bin/kubelet --logtostderr=false --log-dir=/var/log/kubernetes( Make sure /var/log/kubernetes The path is correct )
 systemctl daemon-reload
原网站

版权声明
本文为[Internet Walker]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221423318926.html