Kubernetes 入门(3)集群安装

1. kubeadm简介

kubeadm 是 Kubernetes 官方提供的一个 CLI 工具,可以很方便的搭建一套符合官方最佳实践的最小化可用集群。当我们使用 kubeadm 搭建集群时,集群可以通过 K8S 的一致性测试,并且 kubeadm 还支持其他的集群生命周期功能,比如升级/降级等。

2. 安装kebeadm

2.1 安装前准备

  • 禁用 swap

我们知道每个节点上都有个必须的组件,名为 kubelet,自 K8S 1.8 开始,启动 kubelet 时,需要禁用 swap 。或者需要更改 kubelet 的启动参数 --fail-swap-on=false。

  • cat /proc/swaps

  • swapoff -a

  • 将 /etc/fstab 中和上一条命令中输出的,和 swap 相关的挂载点都删掉
    image.png

  • 确保要搭建集群的所有节点的 product_uuid和Mac 地址 均不相同

 /sys/class/dmi/id/product_uuid ip a
  • 确保需要的端口没被占用
netstat -ntlp |grep -E '6443|23[79,80]|1025[0,1,2]'
  • 部署docker
[root@slave ~]# yum install -y wget && wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
[root@slave ~]# yum -y install docker-ce-18.06.1.ce-3.el7
[root@slave ~]# systemctl enable docker && systemctl start docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

2.2 正式安装

  1. 安装kubeadm
[root@slave ~]# curl -sSL https://dl.k8s.io/release/v1.11.3/bin/linux/amd64/kubeadm > /usr/bin/kubeadm
[root@slave ~]# chmod a+rx /usr/bin/kubeadm
[root@slave ~]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.3", GitCommit:"a4529464e4629c21224b3d52edfe0ea91b072862", GitTreeState:"clean", BuildDate:"2018-09-09T17:59:42Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
  1. 安装kubelet
[root@slave ~]# cat > /etc/yum.repos.d/kubernetes.repo << EOF
> 
> [kubernetes]
> name=Kubernetes
> baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
> enabled=1
> gpgcheck=0
> repo_gpgcheck=0
> gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
[root@slave ~]# yum install -y kubelet-1.15.0 kubeadm-1.15.0 kubectl-1.15.0
[root@slave ~]# systemctl enable kubelet
Created symlink from /etc/systemd/system/multi-user.target.wants/kubelet.service to /usr/lib/systemd/system/kubelet.service.
  1. 开启集群
[root@slave ~]# kubeadm init --apiserver-advertise-address=192.168.211.130 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.15.0 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16

2.3 安装踩坑总结

  1. [ERROR FileContent–proc-sys-net-bridge-bridge-nf-call-iptables]:/proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1
[root@slave ~]# kubeadm init
W0427 21:22:15.098333    7591 version.go:98] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get https://storage.googleapis.com/kubernetes-release/release/stable-1.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
W0427 21:22:15.098507    7591 version.go:99] falling back to the local client version: v1.15.0
[init] Using Kubernetes version: v1.15.0
[preflight] Running pre-flight checks[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

解决方案

echo "1" >/proc/sys/net/bridge/bridge-nf-call-iptables
  1. [ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-controller-manager:v1.15.0
[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.15.0: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-controller-manager:v1.15.0: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-scheduler:v1.15.0: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-proxy:v1.15.0: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1[ERROR ImagePull]: failed to pull image k8s.gcr.io/pause:3.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1[ERROR ImagePull]: failed to pull image k8s.gcr.io/etcd:3.3.10: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1[ERROR ImagePull]: failed to pull image k8s.gcr.io/coredns:1.3.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

解决方案

kubeadm init --apiserver-advertise-address=192.168.211.130 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.15.0 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16

  1. [ERROR ImagePull]: failed to pull image registry.aliyuncs.com/google_containers/kube-apiserver:v1.15.0: output: v1.15.0: Pulling from google_containers/kube-apiserver

解决方案

docker pull registry.aliyuncs.com/google_containers/kube-apiserver:v1.15.0
  1. The connection to the server localhost:8080 was refused - did you specify the right host or port?
[root@slave ~]# kubectl cluster-infoTo further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server localhost:8080 was refused - did you specify the right host or port?

解决方案

[root@slave ~]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile
[root@slave ~]# source /etc/profile
[root@slave ~]# kubectl get nodes
NAME    STATUS     ROLES    AGE     VERSION
slave   NotReady   master   8m39s   v1.15.0

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391223.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Angular Material 攻略 04 Icon

Icon 网页系统中的Icon虽然说很简单&#xff0c;但是其中的学问还是有很多的&#xff0c;我们常用的Icon库有FontAwesome、Iconfont等&#xff0c;我们选择了Angular Material这个组件库&#xff0c;就介绍Material Icons吧。 对Icon感兴趣的同学可以看一下这里 Material Desig…

【9303】平面分割

Time Limit: 10 second Memory Limit: 2 MB 问题描述 同一平面内有n&#xff08;n≤500&#xff09;条直线&#xff0c;已知其中p&#xff08;p≥2&#xff09;条直线相交与同一点&#xff0c;则这n条直线最多能将平面分割成多少个不同的区域&#xff1f; Input 两个整数n&am…

简述yolo1-yolo3_使用YOLO框架进行对象检测的综合指南-第一部分

简述yolo1-yolo3重点 (Top highlight)目录&#xff1a; (Table Of Contents:) Introduction 介绍 Why YOLO? 为什么选择YOLO&#xff1f; How does it work? 它是如何工作的&#xff1f; Intersection over Union (IoU) 联合路口(IoU) Non-max suppression 非最大抑制 Networ…

django:资源网站汇总

Django REST framework官网 http://www.sinodocs.cn/ django中文网 https://www.django.cn/ 转载于:https://www.cnblogs.com/gcgc/p/11542068.html

Kubernetes 入门(4)集群配置

1. 集群配置 报错&#xff1a; message: ‘runtime network not ready: NetworkReadyfalse reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized’ 原因&#xff1a;cni未被初始化&#xff08;CNI 是 Container Network In…

【例9.8】合唱队形

【例9.8】合唱队形 链接&#xff1a;http://ybt.ssoier.cn:8088/problem_show.php?pid1264 时间限制: 1000 ms 内存限制: 65536 KB【题目描述】 N位同学站成一排&#xff0c;音乐老师要请其中的(N-K)位同学出列&#xff0c;使得剩下的K位同学排成合唱队形。 合唱队形是…

scrum流程 规划 冲刺_Scrum –困难的部分2:更快地冲刺

scrum流程 规划 冲刺In the first part, I presented my favorite list of Scrums hard parts and how to work around them. In the second part, I offer you a colorful bouquet of workarounds as well. Have fun!在第一部分中 &#xff0c;我介绍了我最喜欢的Scrum困难部分…

JAVA基础知识|lambda与stream

lambda与stream是java8中比较重要两个新特性&#xff0c;lambda表达式采用一种简洁的语法定义代码块&#xff0c;允许我们将行为传递到函数中。之前我们想将行为传递到函数中&#xff0c;仅有的选择是使用匿名内部类&#xff0c;现在我们可以使用lambda表达式替代匿名内部类。在…

数据库:存储过程_数据科学过程:摘要

数据库:存储过程Once you begin studying data science, you will hear something called ‘data science process’. This expression refers to a five stage process that usually data scientists perform when working on a project. In this post I will walk through ea…

901

901 转载于:https://www.cnblogs.com/Forever77/p/11542129.html

leetcode 137. 只出现一次的数字 II(位运算)

给你一个整数数组 nums &#xff0c;除某个元素仅出现 一次 外&#xff0c;其余每个元素都恰出现 三次 。请你找出并返回那个只出现了一次的元素。 示例 1&#xff1a; 输入&#xff1a;nums [2,2,3,2] 输出&#xff1a;3 示例 2&#xff1a; 输入&#xff1a;nums [0,1,0,…

【p081】ISBN号码

Time Limit: 1 second Memory Limit: 50 MB 【问题描述】 每一本正式出版的图书都有一个ISBN号码与之对应&#xff0c;ISBN码包括9位数字、1位识别码和3位分隔符&#xff0c;其规定格式如“x-xxx-xxxxx-x”&#xff0c;其中符号“-”是分隔符&#xff08;键盘上的减号&#xff…

gitlab bash_如何编写Bash一线式以克隆和管理GitHub和GitLab存储库

gitlab bashFew things are more satisfying to me than one elegant line of Bash that automates hours of tedious work. 没有什么比让Bash自动完成数小时繁琐工作的Bash优雅系列令我满意的了。 As part of some recent explorations into automatically re-creating my la…

寒假学习笔记(4)

2018.2.11 类中的常成员 关键字const&#xff0c;在类定义中声明数据成员使用关键字限定&#xff0c;声明时不能初始化。初始化列表&#xff0c;类中的任何函数都不能对常数据成员赋值&#xff0c;包括构造函数。为构造函数添加初始化列表是对常数据成员进行初始化的唯一途径。…

svm和k-最近邻_使用K最近邻的电影推荐和评级预测

svm和k-最近邻Recommendation systems are becoming increasingly important in today’s hectic world. People are always in the lookout for products/services that are best suited for them. Therefore, the recommendation systems are important as they help them ma…

Oracle:时间字段模糊查询

需要查询某一天的数据&#xff0c;但是库里面存的是下图date类型 将Oracle中时间字段转化成字符串&#xff0c;然后进行字符串模糊查询 select * from CAINIAO_MONITOR_MSG t WHERE to_char(t.CREATE_TIME,yyyy-MM-dd) like 2019-09-12 转载于:https://www.cnblogs.com/gcgc/p/…

cogs2109 [NOIP2015] 运输计划

cogs2109 [NOIP2015] 运输计划 二分答案树上差分。 STO链剖巨佬们我不会&#xff08;太虚伪了吧 首先二分一个答案&#xff0c;下界为0,上界为max{路径长度}。 然后判断一个答案是否可行&#xff0c;这里用到树上差分。 &#xff08;阔以理解为前缀和&#xff1f;&#xff1f;&…

leetcode 690. 员工的重要性(dfs)

给定一个保存员工信息的数据结构&#xff0c;它包含了员工 唯一的 id &#xff0c;重要度 和 直系下属的 id 。 比如&#xff0c;员工 1 是员工 2 的领导&#xff0c;员工 2 是员工 3 的领导。他们相应的重要度为 15 , 10 , 5 。那么员工 1 的数据结构是 [1, 15, [2]] &#x…

组件分页_如何创建分页组件

组件分页The theme for week #17 of the Weekly Coding Challenge is:每周编码挑战第17周的主题是&#xff1a; 分页 (Pagination) A Pagination Component is used on websites where you have more content available than you want to display at one time to the user so …

web-项目管理

总结 目的是 1.可查询 2.方便团队管理 每个成员都可以看到任何东西 项目 需求 计划 bug 按模板来 1.问题描述 2.原因分析 3.解决方法 开发 提交代码 按模板来 1.问题描述 2.原因分析 3.解决方法 打包 更新说明文件.txt 按模板来 一、更新说明 1.问题描述 1&#xff09;计划号 2…