博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[kubernetes] 安装和集群初始化
阅读量:2341 次
发布时间:2019-05-10

本文共 3125 字,大约阅读时间需要 10 分钟。

1. 时钟同步(不同步安装可能会出问题):

// 安装yum install -y chrony// 启用systemctl start chronydsystemctl enable chronyd// 设置亚洲时区timedatectl set-timezone Asia/Shanghai// 启用NTP同步timedatectl set-ntp yes

最后用 date 命令查看时间,应该和本地时间是一致的

2. 安装kubeadm/kebelet/kebectl:

cat <
/etc/yum.repos.d/kubernetes.repo[kubernetes]name=Kubernetesbaseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64enabled=1gpgcheck=1repo_gpgcheck=1gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpgEOFsetenforce 0yum install -y kubelet kubeadm kubectlsystemctl enable kubelet && systemctl start kubelet

Some users on RHEL/CentOS 7 have reported issues with traffic being routed incorrectly due to iptables being bypassed. You should ensure net.bridge.bridge-nf-call-iptables is set to 1 in your sysctl config, e.g.

cat <
/etc/sysctl.d/k8s.confnet.bridge.bridge-nf-call-ip6tables = 1net.bridge.bridge-nf-call-iptables = 1EOFsysctl --system

3. init集群:

  • 一定要先在hosts文件中改所有nodes的名字,不能重复:
vi /etc/hosts//添加ip 与对应的名字10.141.212.22 centos-master10.141.212.23 centos-minion-110.141.212.24 centos-minion-2
  • 先pull下来init需要的镜像,再在master上init集群:
kubeadm config images pullkubeadm init --pod-network-cidr=10.244.0.0/16

(会出现报错提示: running with swap on is not supported. Please disable swap

执行 sudo swapoff -a 即可)

输出:

Your Kubernetes master has initialized successfully!To start using your cluster, you need to run the following as a regular user:  mkdir -p $HOME/.kube  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config  sudo chown $(id -u):$(id -g) $HOME/.kube/configYou should now deploy a pod network to the cluster.Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:  https://kubernetes.io/docs/concepts/cluster-administration/addons/You can now join any number of machines by running the following on each nodeas root:kubeadm join 10.141.212.22:6443 --token j4bq1b.puf0hi7bvabpsfas --discovery-token-ca-cert-hash sha256:6ecfd2d8e3a828202e56170d63d3942ef6cd04657d42b27aa82a1f68ba3a98c6
  • 向master节点的 /etc/profile 添加
vi  /etc/profileexport KUBECONFIG=/etc/kubernetes/admin.confsource /etc/profile
  • 在master节点上Installing a pod network:
sysctl net.bridge.bridge-nf-call-iptables=1kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml
  • 检查(保证kube-dns pod3个都是好的):

    kubectl get pods --all-namespaces

  • 在node节点上:

    先确定docker开启,再执行 sudo swapoff -a

kubeadm join 10.141.212.22:6443 --token j4bq1b.puf0hi7bvabpsfas --discovery-token-ca-cert-hash sha256:6ecfd2d8e3a828202e56170d63d3942ef6cd04657d42b27aa82a1f68ba3a98c6

输出为:

This node has joined the cluster:* Certificate signing request was sent to master and a response  was received.* The Kubelet was informed of the new secure connection details.Run 'kubectl get nodes' on the master to see this node join the cluster.

4. 拆除集群

Talking to the master with the appropriate credentials, run:

kubectl drain [node name] --delete-local-data --force --ignore-daemonsetskubectl delete node [node name]

Then, on the node being removed, reset all kubeadm installed state:

kubeadm reset

转载地址:http://yokvb.baihongyu.com/

你可能感兴趣的文章
人生的康波周期,把握住一次,足以改变命运!
查看>>
互联网公司那些价值观-阿里巴巴
查看>>
去面试快手,问了我很多消息队列的知识!
查看>>
图解LeetCode No.18之四数之和
查看>>
402. Remove K Digits
查看>>
75. Sort Colors
查看>>
获取数组中前K小的数字
查看>>
数组heapify变为堆结构
查看>>
二叉树的非递归遍历
查看>>
218. The Skyline Problem
查看>>
Java PAT (Basic Level) Practice 写出这个数
查看>>
Python PAT (Basic Level) Practice 1016 部分A+B
查看>>
Python PAT (Basic Level) Practice 1006 换个格式输出整数
查看>>
Python PAT (Basic Level) Practice 1009 说反话
查看>>
Python PAT (Basic Level) Practice 1011 A+B 和 C
查看>>
Python PAT (Basic Level) Practice 1017 A除以B
查看>>
Python PAT (Basic Level) Practice 1042 字符统计
查看>>
spring dubbo 2.7.3 zookeeper 项目构建
查看>>
spring dubbo 报错
查看>>
如何在非 bean 对象中注入 dubbo service
查看>>