Kubeadmin[最新安装步骤]
hostnamectl set-hostname k8s-master01 vim /etc/hosts cat /etc/hosts yum -y install conntrack ntpdate ntp ipvsadm ipset jq iptables curl sysstat libseccomp wget vim net-tools git systemctl stop firewalld && systemctl disable firewalld yum -y install lrzsz #rz上传163源 yum -y install iptables-services systemctl start iptables systemctl enable iptables iptables -F service iptables save swapoff -a sed -i 's/.*swap.*/#&/' /etc/fstab setenforce 0 sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config cat > kubernetes.conf << EOF net.bridge.bridge-nf-call-iptables=1 net.bridge.bridge-nf-call-ip6tables=1 net.ipv4.ip_forward=1 net.ipv4.tcp_tw_recycle=0 vm.swappiness=0 vm.overcommit_memory=1 vm.panic_on_oom=0 fs.inotify.max_user_instances=8192 fs.inotify.max_user_watches=1048576 fs.file-max=52706963 fs.nr_open=52706963 net.ipv6.conf.all.disable_ipv6=1 net.netfilter.nf_conntrack_max=2310720 EOF modprobe br_netfilter cp kubernetes.conf /etc/sysctl.d/kubernetes.conf sysctl -p /etc/sysctl.d/kubernetes.conf mkdir /var/log/journal # 持久化保存日志的目录 mkdir /etc/systemd/journald.conf.d cat > /etc/systemd/journald.conf.d/99-prophet.conf <<EOF [Journal] #持久化保存到磁盘 Storage=persistent # 压缩历史日志 Compress=yes SyncIntervalSec=5m RateLimitInterval=30s RateLimitBurst=1000 # 最大占用空间10G SystemMaxUse=10G # 单日志文件最大200M SystemMaxFileSize=200M # 日志保存时间 2 周 MaxRetentionSec=2week # 不将日志转发到 syslog ForwardToSyslog=no EOF systemctl restart systemd-journald rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm yum --enablerepo=elrepo-kernel install -y kernel-lt grub2-set-default "CentOS Linux (4.4.182-1.el7.elrepo.x86_64) 7 (Core)" reboot uname -r cat > /etc/sysconfig/modules/ipvs.modules << EOF 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 -e nf_conntrack_ipv4 yum -y install yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum -y update && yum -y install docker-ce mkdir /etc/docker cat > /etc/docker/daemon.json << EOF { "exec-opts":["native.cgroupdriver=systemd"], "log-driver":"json-file", "log-opts":{ "max-size":"100m" } } EOF ##重启机器选择 4.4内核: systemctl start docker systemctl enable docker mkdir -p /etc/systemd/system/docker.service.d systemctl daemon-reload && systemctl restart docker && systemctl enable docker 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 yum -y install kubeadm-1.15.1 kubectl-1.15.1 kubelet-1.15.1 systemctl enable kubelet.service ################################# yum -y install kubeadm-1.15.1 kubectl-1.15.1 kubelet-1.15.1 systemctl enable kubelet.service history #上传下载下来的避免fq的镜像 tar zxvf kubeadm-basic.images.tar.gz vim load.images.sh ###脚本如下: [root@k8s-master01 ~]# cat load.images.sh #!/bin/bash ls /root/kubeadm-basic.images > /tmp/image-list.txt cd /root/kubeadm-basic.images for i in $( cat /tmp/image-list.txt ) do docker load -i $i done rm -rf /tmp/image-list.txt ### ./load.images.sh tar zxvf kube kubeadm config print init-defaults > kubeadm-config.yaml vim kubeadm-config.yaml ll ls -al kubeadm config print init-defaults > kubeadm-config.yaml vim kubeadm-config.yaml kubeadm init --config=kubeadm-config.yaml --experimental-upload-certs | tee kubeadm-init.log 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 mkdir install-k8s ls mv kubeadm-init.log kubeadm-config.yaml install-k8s/ cd install-k8s/ ls mkdir core mv * ./core/ ls mkdir plugin cd plugin/ mkdir flannel cd flannel/ wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml kubectl create -f kube-flannel.yml kubectl get pod -n kube-system kubeadm init --kubernetes-version=1.15.1 --apiserver-advertise-address=192.168.175.128 --image-repository registry.aliyuncs.com/google_containers --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16 kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" kubectl get pod -n kube-system kubeadm join 192.168.175.128:6443 --token zgybfp.l2tymi4dnipc2bm7 \ --discovery-token-ca-cert-hash sha256:1be98571382adf5cfe70f3a91242a7beacf5e183d0d698a587ae9b5cc7b65ff3