kubeadm安装k8s 1.13版本

一:环境初始化

1.关闭selinux,iptables

2.做好本地的dns解析,我这里用的是/etc/hosts

3.做一下免密传输

4.

master:10.0.18.210
node1:10.0.18.211
node2:10.0.18.212

 

二:配置yum源

[root@master yum.repos.d]# vim kuberbetes.repo 

[kubernetes]name=Kubernetes Repobaseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/gpgcheck=1gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpgenabled=1
[root@master yum.repos.d]# cat docker-ce.repo 
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[root@master yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.huaweicloud.com* epel: mirrors.yun-idc.com* extras: mirrors.huaweicloud.com* updates: mirrors.huaweicloud.com
repo id                                           repo name                                                              status
!base/7/x86_64                                    CentOS-7 - Base                                                        10,019
!docker-ce-stable/x86_64                          Docker CE Stable - x86_64                                                  39
*!epel/x86_64                                     Extra Packages for Enterprise Linux 7 - x86_64                         13,041
!extras/7/x86_64                                  CentOS-7 - Extras                                                         385
!kubernetes                                       Kubernetes Repo                                                           336
!rsyslog_v8/7/x86_64                              Adiscon CentOS-7 - local packages for x86_64                            2,015
!updates/7/x86_64                                 CentOS-7 - Updates                                                      1,493
!zabbix/x86_64                                    Zabbix Official Repository - x86_64                                       183
!zabbix-non-supported/x86_64                      Zabbix Official Repository non-supported - x86_64                           4
repolist: 27,515

安装kubeadm kubelet kubectl docker-ce

yum -y install docker-ce kubeadm-1.13.2-0 kubectl-1.13.2-0 kubelet-1.13.2-0

将yum源文件拷贝到node1和node2上,同时在node1和node2上安装docker-ce kubeadm-1.13.2-0 kubelet-1.13.2-0

[root@master yum.repos.d]# scp kuberbetes.repo docker-ce.repo node1:/etc/yum.repos.d/
[root@master yum.repos.d]# scp kuberbetes.repo docker-ce.repo node2:/etc/yum.repos.d/

三:master初始化

1.因一些不可抗拒的因素,我们在初始化的时候会报错不能pull images ,此时需要翻墙,此处我提前下载好了需要的docker image,我们需要在初始化前把这些镜像文件导入到docker中(docker load < 文件名):

链接:https://pan.baidu.com/s/1rkwYyeShXF05OswhweNCAw
提取码:gs0c

 
[root@master images]# docker load < coredns.tar 
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@master images]# systemctl start docker
[root@master images]# docker load < coredns.tar 
9198eadacc0a: Loading layer [==================================================>]  542.2kB/542.2kB
30a6f49aa944: Loading layer [==================================================>]  39.74MB/39.74MB
Loaded image: k8s.gcr.io/coredns:1.2.6
[root@master images]# docker load < etcd.tar 
f9d9e4e6e2f0: Loading layer [==================================================>]  1.378MB/1.378MB
7882cc107ed3: Loading layer [==================================================>]  195.1MB/195.1MB
43f7b6974634: Loading layer [==================================================>]  23.45MB/23.45MB
Loaded image: k8s.gcr.io/etcd:3.2.24
[root@master images]# docker load < kube-apiserver.tar 
5fe6d025ca50: Loading layer [==================================================>]  43.87MB/43.87MB
c248e3e3678b: Loading layer [==================================================>]  138.6MB/138.6MB
Loaded image: k8s.gcr.io/kube-apiserver:v1.13.2
[root@master images]# docker load < kube-controller-manager.tar 
0184d92152bd: Loading layer [==================================================>]  103.9MB/103.9MB
Loaded image: k8s.gcr.io/kube-controller-manager:v1.13.2
[root@master images]# docker load < kube-proxy.tar 
e5a609b37e16: Loading layer [==================================================>]  3.403MB/3.403MB
3155f3c58fe7: Loading layer [==================================================>]  34.84MB/34.84MB
Loaded image: k8s.gcr.io/kube-proxy:v1.13.2
[root@master images]# docker load < kube-scheduler.tar 
ee29d41ee5b0: Loading layer [==================================================>]   37.3MB/37.3MB
Loaded image: k8s.gcr.io/kube-scheduler:v1.13.2
[root@master images]# docker load < pause.tar 
e17133b79956: Loading layer [==================================================>]  744.4kB/744.4kB
Loaded image: k8s.gcr.io/pause:3.1

 


2.初始化前的准备:

[root@master ~]#systemctl start docker
[root@master ~]#systemctl enable docker
[root@master ~]#systemctl enable kubelet

我们需要关闭swap

[root@master ~]# vim /etc/sysconfig/kubelet

KUBELET_EXTRA_ARGS="--fail-swap-on=false"

 

初始化:

[root@master images]# kubeadm  init --kubernetes-version=v1.13.2 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
[init] Using Kubernetes version: v1.13.2
[preflight] Running pre-flight checks[WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'[WARNING Swap]: running with swap on is not supported. Please disable swap[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 18.09.4. Latest validated version: 18.06[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Activating the kubelet service
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [hd04 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.0.21
3][certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [hd04 localhost] and IPs [192.168.0.213 127.0.0.1 ::1]
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [hd04 localhost] and IPs [192.168.0.213 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 23.503218 seconds
[uploadconfig] storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config-1.13" in namespace kube-system with the configuration for the kubelets in the cluster
[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "hd04" as an annotation
[mark-control-plane] Marking the node hd04 as control-plane by adding the label "node-role.kubernetes.io/master=''"
[mark-control-plane] Marking the node hd04 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
[bootstrap-token] Using token: 07huya.1nhbzzu3lu6j54o2
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstraptoken] creating the "cluster-info" ConfigMap in the "kube-public" namespace
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxyYour Kubernetes master has initialized successfully!To start using your cluster, you need to run the following as a regular user:mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo 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 node
as root:kubeadm join 192.168.0.210:6443 --token 4vtrh8.mepwl6gl0s1mlt3j --discovery-token-ca-cert-hash sha256:83ad166dc9a8805d827b95112f5437c1e547c95482fb92d7176ddd6f55a9cc79

其中红色部分需要在master上执行一下,黄色部分需要记录下来保存住,这是以后我们node加入k8s集群需要执行的命令

[root@master images]# mkdir -p $HOME/.kube
[root@master images]# 
[root@master images]# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@master images]# 
[root@master images]# kubectl get node
NAME   STATUS     ROLES    AGE    VERSION
hd04   NotReady   master   7m3s   v1.13.2

此处可以看出我们已经获取到了node节点,但是状态是NotReady,因为此时我们还没有安装网络,接下来我们安装flannel:

[root@master ~]# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

此刻马上去get node可能也是notready状态,因为此时系统还没有下载完flannel的镜像,需要稍等一下:

[root@master ~]# kubectl get node
NAME   STATUS   ROLES    AGE     VERSION
hd01   Ready    master   22h     v1.13.2

到这里我们就安装好了master,面安装node:

[root@node1 ~]#systemctl start docker
[root@node1 ~]#systemctl enable docker
[root@node1 ~]#systemctl enable kubelet
[root@node1 ~]#cat /etc/sysconfig/kubelet

  KUBELET_EXTRA_ARGS="--fail-swap-on=false"

 
[root@node1 ~]#kubeadm join 192.168.0.210:6443 --token 4vtrh8.mepwl6gl0s1mlt3j --discovery-token-ca-cert-hash sha256:83ad166dc9a8805d827b95112f5437c1e547c95482fb92d7176ddd6f55a9cc79

此时node就已经加入到集群中了,node2同样的操作

在master上:

[root@master ~]# kubectl get node
NAME   STATUS   ROLES    AGE     VERSION
hd01   Ready    master   22h     v1.13.2
hd02   Ready    <none>   5h38m   v1.13.2
hd03   Ready    <none>   4h54m   v1.13.2
[root@master ~]# kubectl get pod -n kube-system
NAME                           READY   STATUS    RESTARTS   AGE
coredns-86c58d9df4-57gcl       1/1     Running   0          5h21m
coredns-86c58d9df4-rkfzg       1/1     Running   0          5h21m
etcd-hd01                      1/1     Running   1          22h
kube-apiserver-hd01            1/1     Running   1          22h
kube-controller-manager-hd01   1/1     Running   0          22h
kube-flannel-ds-amd64-kw99x    1/1     Running   0          5h27m
kube-flannel-ds-amd64-nktsr    1/1     Running   0          4h55m
kube-flannel-ds-amd64-r442w    1/1     Running   0          5h27m
kube-proxy-5dlm5               1/1     Running   0          5h38m
kube-proxy-lnj7f               1/1     Running   0          4h55m
kube-proxy-nvc8p               1/1     Running   0          22h
kube-scheduler-hd01            1/1     Running   1          22h

 

转载于:https://www.cnblogs.com/yangxiaochu/p/10683951.html

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

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

相关文章

MyBastis 三种批量插入方式的性能比较

数据库使用的是MySQL&#xff0c;JDK版本1.8&#xff0c;运行在SpringBoot环境下 本文章源代码&#xff1a;https://github.com/runbeyondmove/mybatis-batch-demo 对比3种可用的方式 1、反复执行单条插入语句2、xml拼接sql3、批处理执行 先说结论&#xff1a;少量插入请使用反…

JS对象与jQuery对象

JS对象大致可以分为三种&#xff0c;如下图&#xff1a; JS常用内置对象&#xff08;JS自身所持有的对象&#xff0c;不需要创建&#xff0c;直接可用&#xff09;&#xff1a; String&#xff1a;API跟java的字符串API大致相同 两种创建对象的方式&#xff1a;String s1 “…

Vue-router 中hash模式和history模式的区别

Vue-router 中hash模式和history模式的关系 在vue的路由配置中有mode选项 最直观的区别就是在url中 hash 带了一个很丑的 # 而history是没有#的 mode:"hash"; mode:"history"; hash模式和history模式的不同 对于vue这类渐进式前端开发框架&#xff0…

Nginx Slab内存管理

L38 Slub内存管理适用 ngx_http_limit_conn_module、ngx_http_limit_req_module 模块场景 我们可以用阿里第三方模块Slab_Stat模块 并且用add-module 方式编译进openresty中 转载于:https://www.cnblogs.com/jackey2015/p/10684151.html

day2---while else

# -*- coding:utf-8 -*-while 条件&#xff1a;循环体终止循环 else&#xff1a; while else 解释&#xff1a;当循环体中没有被break打断则会运行else&#xff0c;打断则不会运行else# 例子 a 0 while a < 5:print(a)a 1break else:print(循环结束) # 0 转载于:https:/…

jQuery中this与$(this)的区别总结

https://www.cnblogs.com/gfl123/p/8080484.html

2019前端必会黑科技之PWA

一、背景 从2018年到现在&#xff0c;作为号称下一代web应用模型的PWA&#xff0c;逐渐成为了一个各大前端厂商争先恐后进行涉足&#xff0c;布局的一个新的技术&#xff0c; 其主要的对标物Native app&#xff0c;作为现在最主流的mobile端应用&#xff0c;它的安全&#xff…

Tcpdump抓包工具的使用

# Tcpdump抓包工具的使用## 简介tcpdump是linux下最常用的命令行抓包工具&#xff0c;可以在线安装## 安装- sudo apt install tcpdump## 查看网卡- ip addr查看网卡名称## 简单的使用示例- sudo tcpdump -i enp032 抓取指定网卡的数据包&#xff0c;并- sudo tcpdump -i enp03…

Node.js异步库async

async的使用需要安装第三方包 1.串行无关联 async.series 函数依次执行,后面不需要调前面步骤的结果 程序执行时间为所有步骤之和 2.并行无关联 async.paraller 某步出错不影响其他步骤执行 程序执行时间为最长的那个时间 3.串行有关联 async.waterfall 函数依次执行,后面需要…

Java技术栈---语言基础

基础语法 面向对象 接口 容器 异常 泛型 反射 注解 I/O

Mongodb 查询时间类型

$where: this.CreateDate.toJSON().slice(0,13) "2019-04-04T05"转载于:https://www.cnblogs.com/kevin1988/p/10685075.html

vue prop不同数据类型(数组,对象..)设置默认值

vue prop 会接收不同的数据类型&#xff0c;这里列出了 常用的数据类型的设置默认值的写法,其中包含&#xff1a; Number, String, Boolean, Array, Function, Object refAge: { type: Number, default: 0 }, refName: { type: String, default: }, hotDataLoading: { typ…

正则表达式——基础

正则表达式的基本符号使用&#xff1a; 1。基本符号&#xff1a; a . 匹配任意单个字符&#xff0c;如&#xff1a;.000就可以匹配到1000&#xff0c;2000&#xff0c;3000&#xff0c;a000,b000等。 b | 匹配满足其中一个条件&#xff0c;如&#xff1a; 1000|2000|3000 可以…

谈一谈并查集QAQ(上)

最近几日理了理学过的很多oi知识。。。发现不知不觉就有很多的知识忘记了。。。 在聊聊并查集的时候顺便当作巩固吧。。。。 什么是并查集呢? ( Union Find Set ) 是一种用于处理分离集合的抽象数据结构类型。 具体一点: 当我们给出两个元素的一个无序对&#xff08;a,b&#…

vue的双向绑定原理及实现

前言 使用vue也好有一段时间了&#xff0c;虽然对其双向绑定原理也有了解个大概&#xff0c;但也没好好探究下其原理实现&#xff0c;所以这次特意花了几晚时间查阅资料和阅读相关源码&#xff0c;自己也实现一个简单版vue的双向绑定版本&#xff0c;先上个成果图来吸引各位&a…

python后端将svc文件数据读入数据库具体实现

如何用python将svc文件的数据读入到MySQL数据库里&#xff0c;在此直接上代码了&#xff0c;感兴趣的朋友可以贴代码测试&#xff1a; import pandas as pd import os from sqlalchemy import create_engine # 初始化数据库连接&#xff0c;使用pymysql模块 # MySQL的用户&…

作业——8

这个作业属于哪个课程C语言程序设计Ⅱ这个作业的要求在哪里C语言作业评价标准我在这个课程的目标是指针与字符串这个作业在哪个具体方面帮助我实现目标使用指针与字符串参考文献指针和字符串&#xff08;基础知识&#xff09;第七周作业 一 1 、使用函数删除字符串中的字符 输入…

Vue实现组件props双向绑定解决方案

注意&#xff1a; 子组件不能直接修改prop过来的数据&#xff0c;会报错 方案一&#xff1a; 用data对象中创建一个props属性的副本 watch props属性 赋予data副本 来同步组件外对props的修改 watch data副本&#xff0c;emit一个函数 通知到组件外 HelloWorld组件代码如下…

统计词频问题

adict{} xinput().lower() #把单词大写字母改为小写字母 for i in x:if i in [,,.,"",",!]:xx[:x.index(i)]x[x.index(i)1:] #把句子中的非字母字符用切片操作删掉 asetset(x.split( )) #集合的好处在于不重复 alstx.split( ) for n in aset:tempdict{n:alst.…

正则表达式常用函数

<?php //preg_match("正则表达式","字符串")用于在字符串中查找匹配项 $email "987044391qq.com"; if (preg_match("/^([a-zA-Z0-9])([.a-zA-Z0-9_-])*([.a-zA-Z0-9_-])([.a-zA-Z0-9_-])([.a-zA-Z0-9_-])$/",$email)){ echo 匹…