当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 2

jiaolong / k8s_deploy
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
3_kubeadm_init.sh 1.75 KB
一键复制 编辑 原始数据 按行查看 历史
jiaolong 提交于 2018-08-08 09:33 . 可以正常部署并启动单节点
#!/usr/bin/bash
#
#"""
#-------------------------------------------------
# File Name: ${NAME}
# Description:
# Project Name: rsync_cfg
# Ide Name: PyCharm
# Author: pulw
# date: 2018/7/18 17:40
#-------------------------------------------------
# Change Activity:
# 2018/7/18 17:40:
#-------------------------------------------------
#"""
#set -x
set -e
#-------------------------------------------------
LOGS(){
echo "[$(date +%Y%m%d_%H:%M:%S) $$] $* | tee -a logs.txt"
}
#-------------------------------------------------
# Reset firstly if ran kubeadm init before
kubeadm reset
LOGS "检查是否有安装cni"
[[ $(ip link | awk -F ':' '/flannel.*:/{print substr($2,1)}') ]] || \
[[ $(ip link | awk -F ':' '/cni.*:/{print substr($2,1)}') ]] &&
{
ip link del $(ip link | awk -F ':' '/flannel.*:/{print substr($2,1)}')
ip link del $(ip link | awk -F ':' '/cni.*:/{print substr($2,1)}')
}
# kubeadm init with flannel network
LOGS "kubeadm init with flannel network"
kubeadm init --kubernetes-version=v1.10.3 --pod-network-cidr=192.168.202.0/16
# regular user
user[0]="root:/root"
user[1]="k8s:/home/k8s"
user[2]="docker:/home/docker"
for user in ${user[@]};do
#set $(echo ${user} | set 's/:/ /g')
user_name=$(echo ${user%%:*})
user_home=$(echo ${user##*:})
LOGS "${user_name}:${user_home}"
mkdir -p ${user_home}/.kube
cp /etc/kubernetes/admin.conf ${user_home}/.kube/config
chown -R $(id -u ${user_name}):$(id -g ${user_name}) ${user_home}/.kube/
cp -p ${user_home}/.bash_profile ${user_home}/.bash_profile.bak_$(date +"%Y%m%d_%H%M%S")
echo "export KUBECONFIG=${user_home}/.kube/config" >> ${user_home}/.bash_profile
source ${user_home}/.bash_profile
done
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/jaolong/k8s_deploy.git
git@gitee.com:jaolong/k8s_deploy.git
jaolong
k8s_deploy
k8s_deploy
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891