kubenetes_V1.14.0 安装部署
k8s的安装有多种方式,如yum安装,kubeadm安装,kubemini安装,二进制安装(生产环境多采用此方式精确控制安装)等。本文是入门系列验证,之前进行过yum安装,可以查看文章《k8s入门系列之集群yum安装篇》 。这里进行kubeadm安装一次了解安装过程,真正的学习、测试环境和生产环境都不建议此方法,都建议yum安装或者二进制安装,这样才可以详细了解到k8s的工作原理和工作过程
平台 :CentOS Linux release 7.6.1810 (Core)

master: 192.168.122.220
node1: 192.168.122.221
node2: 192.168.122.222
一,三台机器前期工作准备
1,关闭防火墙服务,避免与docker容器的防火墙规则冲突。
systemctl stop firewalld
systemctl disable firewalld
2,关闭selinux:
修改/etc/selinux/config为SELINUX=disabled
重启后配置生效。不建议临时关闭(setenfore 0),防止机器重启失效。
3,关闭swap:
临时关闭:
- swapoff -a
永久关闭:
- sed -i 's/.*swap.*/#&/' /etc/fstab
4,host定向,将机器内部主机名通信打通:
vi /etc/hosts
192.168.122.220 master
192.168.122.221 node01
192.168.122.222 node02
5,master机器设置免密钥登陆其他两个node
- ssh-keygen #生成密钥对
- cd /root/.ssh/
- ssh-copy-id -i id_rsa.pub node01
- ssh-copy-id -i id_rsa.pub node02
6,配置ntp:
- yum install ntpdate -y
- systemctl enable ntpdate.service
- systemctl start ntpdate.service
- 临时同步:ntpdate time7.aliyun.com
- 设置任务计划crontab -e:
- */30 * * * * /usr/sbin/ntpdate time7.aliyun.com >/dev/null 2>&1
7,设置内核,建议安装标准系统初始化进行(部分厂商的机器已经进行了默认参数优化)
- echo "* soft nofile 65536">> /etc/security/limits.conf
- echo "* hard nofile 65536" >> /etc/security/limits.conf
- echo "* soft nproc 65536" >> /etc/security/limits.conf
- echo "* hard nproc 65536" >> /etc/security/limits.conf
- echo "* soft memlock unlimited" >> /etc/security/limits.conf
- echo "* hard memlock unlimited" >> /etc/security/limits.conf
修正转发:
- modprobe br_netfilter
- cat < < EOF > /etc/sysctl.d/k8s.conf
- net.bridge.bridge-nf-call-ip6tables = 1
- net.bridge.bridge-nf-call-iptables = 1
- EOF
- sysctl -p /etc/sysctl.d/k8s.conf
8,设置yum源
- epel源:
- yum install -y epel-release
- #kubenetes yum源 ,采用阿里云
- cat < /etc/yum.repos.d/kubernetes.repo
- [kubernetes]
- name=Kubernetes
- baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
- enabled=1
- gpgcheck=0
- repo_gpgcheck=0
- gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
- EOF
- ---------------------
- #docker yum源 采用阿里云
- wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- yum clean all && yum makecache fast
9,安装依赖包
- yum install -y yum-utils device-mapper-persistent-data lvm2 net-tools conntrack-tools wget vim ntpdate libseccomp libtool-ltdl
二,进行kubeadm 集群安装部署
1,组件安装
master节点安装etcd:
- yum install etcd -y
- systemctl enable etcd
由于采用外部 etcd,所以要在 master 节点安装 etcd服务,这里也是etcd是单节点。不管是etcd集群还是单机,或者是 http, https都可以,只要在 kubeadm 中配置好就行。
master和其他node:
- yum install docker-ce kubelet kubeadm kubectl ipvsadm -y
- systemctl restart kubelet
- systemctl restart docker
- systemctl enable kubelet
- systemctl enable docker
2,kubeadm安装配置 kubenetes 1.12.2集群
- kubeadm init --kubernetes-version=v1.12.2 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.1.14.12
这里由于我的虚拟机都设置了科学上网,所以可以直接去下载。 没有配置科学上网的,建议采用阿里云的镜像下载后更改tag处理再kubeadm安装。
安装完信息如下,则说明初始化成功:
[root@master docker]# kubeadm init --kubernetes-version=v1.12.2 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.1.14.12
[init] using Kubernetes version: v1.12.2
[preflight] running pre-flight checks
[WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
[preflight/images] Pulling images required for setting up a Kubernetes cluster
[preflight/images] This might take a minute or two, depending on the speed of your internet connection
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'
[kubelet] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[preflight] Activating the kubelet service
[certificates] Generated front-proxy-ca certificate and key.
[certificates] Generated front-proxy-client certificate and key.
[certificates] Generated ca certificate and key.
[certificates] Generated apiserver certificate and key.
[certificates] apiserver serving cert is signed for DNS names [master kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.14.12]
[certificates] Generated apiserver-kubelet-client certificate and key.
[certificates] Generated etcd/ca certificate and key.
[certificates] Generated etcd/peer certificate and key.
[certificates] etcd/peer serving cert is signed for DNS names [master localhost] and IPs [10.1.14.12 127.0.0.1 ::1]
[certificates] Generated etcd/healthcheck-client certificate and key.
[certificates] Generated apiserver-etcd-client certificate and key.
[certificates] Generated etcd/server certificate and key.
[certificates] etcd/server serving cert is signed for DNS names [master localhost] and IPs [127.0.0.1 ::1]
[certificates] valid certificates and keys now exist in "/etc/kubernetes/pki"
[certificates] Generated sa key and public key.
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/admin.conf"
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf"
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/controller-manager.conf"
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/scheduler.conf"
[controlplane] wrote Static Pod manifest for component kube-apiserver to "/etc/kubernetes/manifests/kube-apiserver.yaml"
[controlplane] wrote Static Pod manifest for component kube-controller-manager to "/etc/kubernetes/manifests/kube-controller-manager.yaml"
[controlplane] wrote Static Pod manifest for component kube-scheduler to "/etc/kubernetes/manifests/kube-scheduler.yaml"
[etcd] Wrote Static Pod manifest for a local etcd instance to "/etc/kubernetes/manifests/etcd.yaml"
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory "/etc/kubernetes/manifests"
[init] this might take a minute or longer if the control plane images have to be pulled
[apiclient] All control plane components are healthy after 39.007740 seconds
[uploadconfig] storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config-1.12" in namespace kube-system with the configuration for the kubelets in the cluster
[markmaster] Marking the node master as master by adding the label "node-role.kubernetes.io/master=''"
[markmaster] Marking the node master as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]
[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "master" as an annotation
[bootstraptoken] using token: wzh9es.gaz6xloz7omrswvs
[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-proxy 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/config You 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.122.220:6443 --token ry7iaa.ysxah86uu9erif9v \
--discovery-token-ca-cert-hash sha256:9b7b17fd3da2e16925a3a729a362d04b19c0a3d73a2f2f1b13d44134db3166af
里边的信息量很大,可以多仔细看两遍,其中最后将node加入集群的命令可以记录一下。
按照提示,在开始使用集群之前,执行如下命令(提示信息直接贴过来即可):
- mkdir -p $HOME/.kube
- sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
- sudo chown $(id -u):$(id -g) $HOME/.kube/config
配置完毕以后查看node信息:
- [root@master ~]# kubectl get node
- NAME STATUS ROLES AGE VERSION
- master NotReady master 8m5s v1.12.2
原因是flannel没有配置,配置flannel:
- kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
- kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
重新查看:
- [root@master ~]# kubectl get node
- NAME STATUS ROLES AGE VERSION
- master Ready master 16m v1.12.2
- [root@master ~]# kubectl get pods --all-namespaces
- NAMESPACE NAME READY STATUS RESTARTS AGE
- kube-system coredns-576cbf47c7-ftvc8 1/1 Running 0 15m
- kube-system coredns-576cbf47c7-rtm6f 1/1 Running 0 15m
- kube-system etcd-master 1/1 Running 0 75s
- kube-system kube-apiserver-master 1/1 Running 0 66s
- kube-system kube-controller-manager-master 1/1 Running 0 77s
- kube-system kube-flannel-ds-amd64-488hv 1/1 Running 0 99s
- kube-system kube-proxy-d4v7j 1/1 Running 0 15m
- kube-system kube-scheduler-master 1/1 Running 0 77s
- [root@master ~]# kubectl get cs
- NAME STATUS MESSAGE ERROR
- scheduler Healthy ok
- controller-manager Healthy ok
- etcd-0 Healthy {"health": "true"}
3,node节点配置
node01和node02分别执行之前的命令提示,将node01 node02加入到集群:
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
swapoff -a
sed -i 's/.*swap.*/#&/' /etc/fstab
yum install ntpdate -y
systemctl enable ntpdate.service
systemctl start ntpdate.service
echo "* soft nofile 65536">> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf
echo "* soft nproc 65536" >> /etc/security/limits.conf
echo "* hard nproc 65536" >> /etc/security/limits.conf
echo "* soft memlock unlimited" >> /etc/security/limits.conf
echo "* hard memlock unlimited" >> /etc/security/limits.conf
cat << EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl -p /etc/sysctl.d/k8s.conf
yum install docker-ce kubelet kubeadm kubectl ipvsadm -y
yum install -y epel-release
cd /etc/yum.repos.d/
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y yum-utils device-mapper-persistent-data lvm2 net-tools conntrack-tools wget vim ntpdate libseccomp libtool-ltdl
yum install etcd -y
systemctl enable etcd
yum install docker-ce kubelet kubeadm kubectl ipvsadm -y
systemctl restart kubelet
systemctl restart docker
systemctl enable kubelet
systemctl enable docker
kubeadm join 192.168.122.220:6443 --token ry7iaa.ysxah86uu9erif9v --discovery-token-ca-cert-hash sha256:9b7b17fd3da2e16925a3a729a362d04b19c0a3d73a2f2f1b13d44134db3166af

kubenetes_V1.14.0 安装部署的更多相关文章
- zabbix3.0安装部署文档
zabbix v3.0安装部署 摘要: 本文的安装过程摘自http://www.ttlsa.com/以及http://b.lifec-inc.com ,和站长凉白开的<ZABBIX从入门到精通v ...
- centos 7.2 下 nginx 1.14.1 安装部署
Nginx1.14.1安装部署 1.环境: 所有源码在跳板机kx的/web/soft下 2.安装依赖: [root@bogon src]# yum install -y libxml2 openssl ...
- [转帖]VMware Vsphere 6.0安装部署 (三) vCenter Server安装
VMware Vsphere 6.0安装部署 (三) vCenter Server安装 2016年08月29日 14:59:14 dAng1r0Us 阅读数:72942 版权声明:本文为博主原创文 ...
- zabbix v3.0安装部署
这篇文章没有写明init的部分要注意 zabbix v3.0安装部署 摘要: 本文的安装过程摘自http://www.ttlsa.com/以及http://b.lifec-inc.com ,和站长凉白 ...
- CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-总目录
CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-总目录: 0.Windows 10本机下载Xshell,以方便往Linux主机上上传大文件 1.CentOS7+CDH5.14.0安 ...
- Elasticsearch学习之ElasticSearch 5.0.0 安装部署常见错误或问题
ElasticSearch 5.0.0 安装部署常见错误或问题 问题一: [--06T16::,][WARN ][o.e.b.JNANatives ] unable to install syscal ...
- CentOS 下 MySQL 8.0 安装部署,超详细!
点击上方"开源Linux",选择"设为星标" 回复"学习"获取独家整理的学习资料! Mysql8.0安装 (YUM方式) 首先删除系统默认或 ...
- CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-8CDH5安装和集群配置
Cloudera Manager Server和Agent都启动以后,就可以进行CDH5的安装配置了. 准备文件 从 http://archive.cloudera.com/cdh5/par ...
- CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-7主节点CM安装子节点Agent配置
主节点安装cloudera manager 准备工作:下载CM和mysql连接驱动包: CM各版本下载地址:http://archive.cloudera.com/cm5/cm/5/ 从里面选择:ht ...
随机推荐
- [题解]N 皇后问题总结
N 皇后问题(queen.cpp) [题目描述] 在 N*N 的棋盘上放置 N 个皇后(n<=10)而彼此不受攻击(即在棋盘的任一行,任一列和任一对角线上不能放置 2 个皇后) ,编程求解所有的 ...
- SpringCloud-Ribbon服务调用(三)
SpringCloud-Ribbon服务调用(三) https://www.cnblogs.com/qdhxhz/p/9568481.html 一.商品中心服务端 创建商品中心服务端:服务提供方(被调 ...
- VUE如何实现切换页面时的过渡动画?
最近再写页面的时候,感觉页面之间的切换有点生硬,所以查了一下文档看见了transition这个组建,很实用,故此在这里跟大家分享一下 --------------------------------- ...
- varnish与squid缓存效率对比实例
前提:安装varnish.squid.webbench(压测工具) 注:varnish和squid机都未安装其他多余服务,服务器绑定域名为www.dannylinux.top (为同一台服务器,测试 ...
- Vue.js 2.x笔记:路由Vue Router(6)
1. Vue Router简介与安装 1.1 Vue Router简介 Vue Router 是 Vue.js 官方的路由管理器.它和 Vue.js 的核心深度集成,构建单页面应用. Vue Rout ...
- react-native-echarts在打包时出现的坑
react-native-echarts目前是RN开发中使用echarts图表最好的插件了,用法与Echarts完全一致,默认提供了三个属性: option (object): The option ...
- codeforces8A
Train and Peter CodeForces - 8A Peter likes to travel by train. He likes it so much that on the trai ...
- Java定义三个点Object...
从Java 5开始,Java语言对方法参数支持一种新写法,叫 可变长度参数列表,其语法就是类型后跟...,表示此处接受的参数为0到多个Object类型的对象,或者是一个Object[]. public ...
- 「NOI2013」树的计数 解题报告
「NOI2013」树的计数 这什么神题 考虑对bfs重新编号为1,2,3...n,然后重新搞一下dfs序 设dfs序为\(dfn_i\),dfs序第\(i\)位对应的节点为\(pos_i\) 一个暴力 ...
- Linux安装NodeJS
Linux中安装nodejs 去官网下载和自己系统匹配的文件: 英文网址:https://nodejs.org/en/download/ 中文网址:http://nodejs.cn/download/ ...