k8s_node_install_v2.sh

本文提供了一个用于自动化安装Kubernetes (K8s) 节点的Shell脚本示例。该脚本包括禁用SELinux、关闭防火墙、安装NTP同步时间、安装Kubernetes节点组件等步骤,并配置了必要的kubelet参数及flanneld网络。
摘要由CSDN通过智能技术生成
 1 #!/bin/bash
 2 #by zhangjia
 3 #2019年3月30日22:17:14
 4 #shell auto install k8s
 5 ##############################################3333
 6 set -e
 7 apiserver_id=192.168.134.131
 8 network_name=eth0
 9 node_ip=`ifconfig ${network_name} | grep inet |grep netmask|awk '{print $2}'`
10 
11 k8s_node_step2() {
12     setenforce 0 && sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
13     systemctl stop firewalld && systemctl disable firewalld
14     yum -y install ntp && ntpdate pool.ntp.org || true 
15     systemctl start ntpd && systemctl enable ntpd
16     #install kubernetes-node etcd docker flannel *rhsm
17     yum install kubernetes-node etcd docker flannel *rhsm* -y
18     #配置文件/etc/kubernetes/kubelet
19     sed -i "/KUBELET_ADDRESS/ s/127.0.0.1/0\.0\.0\.0/g" /etc/kubernetes/kubelet
20     sed -i "/KUBELET_PORT/ s/#//g" /etc/kubernetes/kubelet 
21     sed -i "s#KUBELET_HOSTNAME.*#KUBELET_HOSTNAME=\"--hostname-override=${node_ip}\"#g" /etc/kubernetes/kubelet
22     sed -i "s#KUBELET_API_SERVER.*#KUBELET_API_SERVER=\"--api-servers=http://${apiserver_id}:8080\"#g" /etc/kubernetes/kubelet 
23     sed -i 's/\ //g' /etc/kubernetes/kubelet
24     #配置文件/etc/kubernetes/config
25     sed -i "/KUBE_ALLOW_PRIV/ s/false/true/g" /etc/kubernetes/config
26     sed -i "s#KUBE_MASTER.*#KUBE_MASTER=\"--master=http://${apiserver_id}:8080\"#g" /etc/kubernetes/config
27     #启动 kube-proxy  kubelet  docker
28     for  I  in  kube-proxy  kubelet  docker;do systemctl  restart  $I ;systemctl  enable  $I ;systemctl status $I;done
29     iptables -P FORWARD ACCEPT
30 }
31 
32 flanneld_step4() {
33     #k8s_master的/etc/sysconfig/flanneld
34     sed -i "s#FLANNEL_ETCD_ENDPOINTS.*#FLANNEL_ETCD_ENDPOINTS=\"http://${apiserver_id}:2379\"#g" /etc/sysconfig/flanneld
35     systemctl restart flanneld ; systemctl enable flanneld
36     docker load < pod-infrastructure.tgz
37     docker tag $(docker images|grep none|awk '{print $3}') registry.access.redhat.com/rhel7/pod-infrastructure
38     docker load < kubernetes-dashboard-amd64.tgz
39     docker tag $(docker images|grep none|awk '{print $3}') bestwu/kubernetes-dashboard-amd64:v1.6.3
40 }
41 
42 
43 
44 k8s_node_step2
45 #flanneld_step4

 

转载于:https://www.cnblogs.com/zhj5551/p/11198305.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值