k8s1.7.10部署

#我现在用的环境准备脚本

#! /bin/bash
yum install -y wget vim
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache fast
yum install -y epel-release
#添加kubernetes源
touch /etc/yum.repos.d/kubernets.repo
cat > /etc/yum.repos.d/kubernets.repo << EOF
[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 clean all
yum makecache fast
systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config
#关闭swap分区
sed -i 's/^[^#].*swap*/#&/g'  /etc/fstab
#将桥接的ipv4流量传递到iptables的链
cat > /etc/sysctl.d/k8s.conf << EOF

net.bridge.bridge-nf-call-ip6tables = 1

net.bridge.bridge-nf-call-iptables = 1

EOF
#开启转发
echo "1" > /proc/sys/net/ipv4/ip_forward
sysctl -p 
#配置ntp服务器
yum install -y ntp bash-completion
timedatectl set-timezone Asia/Shanghai
sed -i 's/0.centos.pool.ntp.org/ntp1.aliyun.com/g' /etc/ntp.conf
systemctl enable ntpd
#准备docker
yum remove docker                   docker-client                   docker-client-latest                   docker-common                   docker-latest                   docker-latest-logrotate                   docker-logrotate
yum install -y yum-utils   device-mapper-persistent-data   lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl enable docker
#配置docker http代理
#mkdir -p /etc/systemd/system/docker.service.d
#touch /etc/systemd/system/docker.service.d/http-proxy.conf
#cat > /etc/systemd/system/docker.service.d/http-proxy.conf << EOF

#[Service]

#Environment="HTTP_PROXY=http://192.168.2.251:10809"

#EOF
yum install -y kubeadm kubelet kubecli
#修改默认docker的cggroup驱动为system
mkdir /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ],
  "registry-mirrors": ["https://3hbck4tk.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl enable kubelet.service
reboot


#还需要配置以下
##配置/etc/hosts文件,确保node和master之间域名解析正常
##检查docker info的cggroup驱动
##检查swap分区
#使用kubeadm初始化集群

kubeadm init --image-repository registry.aliyuncs.com/google_containers  --kubernetes-version v1.17.0 --pod-network-cidr=10.244.0.0/16

分别指定第三方仓库(这里是aliyun’)指定版本跳过版本检查,,这两点都是因为gfw无法直连谷歌,指定pod网络这里因为我用flannel插件需要指定这个网段
#添加网络插件我用的flannel简单

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

这里多等以下
然后就ok了
#遇到的问题
##token过期,node无法加入到集群
在mster上执行kubeadm token create 得到新的token,然后join即可
kubectl -n kube-system logs
kubectl describe pod

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值