Centos 7.x 線上安裝 Kubernetes
安裝依賴包
yum install -y conntrack ntpdate ntp ipvsadm ipset jq iptables curl systat libseccomp wget vim net-tools git iptables-services
關閉防火牆,為iptables設定規則
systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld systemctl start iptables && systemctl enable iptables && iptables -F && service iptables save
關閉SWAP 和 SELINUX
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
調整核心引數,對於k8s
cat > /etc/sysctl.d/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 #禁止使用 swap 空間, 只有當系統 OOM 時才允許使用它 vm.overcommit_memory=1 #不檢查實體記憶體是否夠用 vm.panic_on_oom=0 #開啟OOM 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 #關閉IPV6協議 net.netfilter.nf_conntrack_max=2310720 EOF sysctl -p /etc/sysctl.d/kubernetes.conf
調整系統時區
# 設定系統時區為 中國/上海 timedatectl set-timezone Asia/Shanghai
關閉系統不需要服務,postfix是郵件服務
systemctl stop postfix && systemctl disable postfix
設定rsyslogd 和 systemd journald
# 建立持久化儲存日誌目錄 mkdir -p /var/log/journal # 建立配置檔案存放目錄 mkdir -p /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 # 重啟journald systemctl restart systemd-journald
kube-proxy開啟ipvs的前置條件
modprobe br_netfilter cat > /etc/sysconfig/modules/ipvs.modules << EOF #!/bin/bash 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
安裝 Docker 軟體
# 配置daemon cat > /etc/docker/daemon.json << EOF { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" } } EOF # 重啟docker systemctl daemon-reload && systemctl restart docker
安裝 Kubeadm (主從配置)
# 配置yum源 cat > /etc/yum.repos.d/kubernetes.repo << EOF [kubernetes] name=kubernetes baseurl= enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey= EOF # 安裝 kubeadm 初始化工具,kubectl 命令列管理工具,kubelet yum -y install kubeadm-1.15.1 kubectl-1.15.1 kubelet-1.15.1 # 設定開機自啟 systemctl enable kubelet
初始化主節點
# 列印預設的初始化檔案,列印到kubeadm-init.yaml kubeadm config print init-defaults > kubeadm-init.yaml # 修改 cat > kubeadm-init.yaml << EOF 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: xx.xx.xx.xx # master節點的IP地址 bindPort: 6443 nodeRegistration: criSocket: /var/run/dockershim.sock name: master 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: k8s.gcr.io kind: ClusterConfiguration kubernetesVersion: v1.15.1 networking: dnsDomain: cluster.local podSubnet: 10.244.0.0/16 serviceSubnet: 10.96.0.0/12 scheduler: {} --- apiVersion: kubeproxy.config.k8s.io/v1alpha1 kind: KubeProxyConfiguration featureGates: SupportIPVSProxyMode: true mode: ipvs EOF # 啟動 kubeadm init --config=kubeadm-init.yaml | 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 mkdir -p /root/install-k8s/core mv /root/kubeadm-init.* /root/install-k8s/core
安裝 flannel
mkdir -p /root/install-k8s/plugin/flannel cd /root/install-k8s/plugin/flannel wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml kubectl apply -f /root/install-k8s/plugin/flannel/kube-flannel.yml
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70003733/viewspace-2883981/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Kubernetes: CentOS上如何安裝指定版本的KubernetesCentOS
- CentOS 7.x 安裝MySQL8.0CentOSMySql
- centos 線上安裝 dockerCentOSDocker
- vmware 線上安裝 CentOS7CentOS
- 線上學習安裝Istio和Kubernetes
- CentOS 7.x 安裝SuperMap iServer 10i服務CentOSServer
- CentOS 7.6 使用kubeadm安裝Kubernetes 13CentOS
- CentOS 上安裝 NginxCentOSNginx
- centos上安裝grafanaCentOSGrafana
- Linux(CentOS)軟體管理(2)- yum 線上安裝LinuxCentOS
- RHEL 7.X 或CentOS 7 安裝 11.2.0.4 RAC碰到的問題CentOS
- 在Linux(Redhat/CentOS)下安裝MySQL之yum(rpm)線上安裝方式LinuxRedhatCentOSMySql
- CentOS離線安裝NginxCentOSNginx
- 在CentOS上安裝dockerCentOSDocker
- 在centos上安裝molochCentOS
- 在CentOS上安裝GitCentOSGit
- Kubernetes上安裝Metrics-ServerServer
- centOS 7 離線安裝 MySQL 5.6 完美安裝CentOSMySql
- Centos7上安裝dockerCentOSDocker
- 在CentOS 8.1上安裝 DockerCentOSDocker
- Linux Centos上安裝 MySQL 8.0.16LinuxCentOSMySql
- Centos上安裝Node環境CentOS
- Ubuntu上kubeadm安裝Kubernetes叢集Ubuntu
- 在GCP的Kubernetes上安裝daprGC
- Centos7手工安裝Kubernetes叢集CentOS
- 在Centos7上安裝DockerCentOSDocker
- 教你如何在 CentOS 上安裝RedisCentOSRedis
- centos6.5上安裝mysql 5.7.20CentOSMySql
- 如何在 CentOS 7 上安裝 NginxCentOSNginx
- 如何安裝vmware以及如何在vmware上安裝centOS 7.0CentOS
- RHEL7/CentOS7線上和離線安裝GitLab配置使用實踐CentOSGitlab
- kubernetes 安裝
- 安裝 kubernetes
- Elasticsearch 7.x 安裝及配置指導Elasticsearch
- 如何在 CentOS 7 上安裝 Python 3CentOSPython
- CentOS上安裝Docker Compose-記錄CentOSDocker
- 在CentOS 7.5上安裝和配置ProFTPDCentOSFTP
- 在Red Hat和Centos上安裝MongoDBCentOSMongoDB