1.主机规划

#master节点(etcd/apiserver/scheduler/controller manager)
master.example.com
eth0: 192.168.0.135
eth1: 192.168.1.53 #node1
node1.example.com
eth0: 192.168.0.136
eth1: 192.168.1.54 #node2
node2.example.com
eth0: 192.168.0.137
eth1: 192.168.1.55

2.安装kubeadm

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

yum install -y kubelet kubeadm kubectl kubernetes-cni
systemctl enable kubelet && systemctl start kubelet

3.下载镜像并更新tag

#coding:utf8
import os S_registry = 'registry.cn-hangzhou.aliyuncs.com/bubblelin/'
D_registry = 'k8s.gcr.io/' master_image = ['kube-apiserver:v1.12.0','kube-controller-manager:v1.12.0',
'kube-scheduler:v1.12.0','kube-proxy:v1.12.0','pause:3.1',
'etcd:3.2.24','coredns:1.2.2'] def PullImage(registry,images):
print("一共%s个镜像" %(len(images),))
index = 1
for image in images:
print("开始下载第[%d]个镜像 ---> [%s]" %(index,image))
cmd = "docker pull " + registry + image
os.system(cmd)
print("done!")
index +=1 def TagImage(sregistry,dregistry,images):
print("一共%s个镜像" %(len(images),))
index = 1
for image in images:
print("开始tag第[%d]个镜像 ---> [%s] --->[%s]" %(index,sregistry+image,dregistry+image))
cmd = "docker tag " + sregistry+image + " " + dregistry + image
os.system(cmd)
print("done!")
index +=1 if __name__ == '__main__':
#PullImage(S_registry,master_image)
TagImage(S_registry,D_registry,master_image)

4.初始化

[root@master ~]# kubeadm init --kubernetes-version=v1.12.0 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.0.135
[init] using Kubernetes version: v1.12.0
[preflight] running pre-flight checks
[WARNING Firewalld]: firewalld is active, please ensure ports [6443 10250] are open or your cluster may not function correctly
[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 ca certificate and key.
[certificates] Generated apiserver certificate and key.
[certificates] apiserver serving cert is signed for DNS names [master.example.com kubernetes kubernetes.default kubernetes.default.svc kubern
etes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.0.135][certificates] Generated apiserver-kubelet-client certificate and key.
[certificates] Generated front-proxy-ca certificate and key.
[certificates] Generated front-proxy-client certificate and key.
[certificates] Generated etcd/ca certificate and key.
[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.example.com localhost] and IPs [127.0.0.1 ::1]
[certificates] Generated etcd/peer certificate and key.
[certificates] etcd/peer serving cert is signed for DNS names [master.example.com localhost] and IPs [192.168.0.135 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 40.010009 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.example.com as master by adding the label "node-role.kubernetes.io/master=''"
[markmaster] Marking the node master.example.com 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.example.com" as an annotation
[bootstraptoken] using token: 33x3h7.tejszerd0znwtjum
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credential
s[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.0.135:6443 --token 33x3h7.tejszerd0znwtjum --discovery-token-ca-cert-hash sha256:2d790600988cf71dda1a5f2ea2e798918acf5
4584ff3ffe1dca006ec8a4c80a6

5.验证

[root@master ~]# export KUBECONFIG=/etc/kubernetes/admin.conf
[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master.example.com NotReady master 11m v1.12.3
[root@master ~]# kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-576cbf47c7-6mvtt / Pending 11m
kube-system coredns-576cbf47c7-djzgn / Pending 11m
kube-system etcd-master.example.com / Running 10m
kube-system kube-apiserver-master.example.com / Running 11m
kube-system kube-controller-manager-master.example.com / Running 10m
kube-system kube-proxy-wj62f / Running 11m
kube-system kube-scheduler-master.example.com / Running 11m

6.网络配置

wget https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml

docker pull registry.cn-hangzhou.aliyuncs.com/kubernetes1112images/flannel:v0.10.0-amd64
docker tag registry.cn-hangzhou.aliyuncs.com/kubernetes_containers/flannel:v0.10.0-amd64 quay.io/coreos/flannel:v0.10.0-amd64
[root@master ~]# vim kube-flannel.yml
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:v0.10.0-amd64
command:
- /opt/bin/flanneld
args:
- --ip-masq
- --kube-subnet-mgr
- --iface=ens33 #指定网卡 [root@master ~]# kubectl apply -f kube-flannel.yml

7.添加节点

下载镜像

#coding:utf8
import os S_registry = 'registry.cn-hangzhou.aliyuncs.com/bubblelin/'
D_registry = 'k8s.gcr.io/' node_image = [ 'kube-proxy:v1.12.0','pause:3.1',] def PullImage(registry,images):
print("一共%s个镜像" %(len(images),))
index = 1
for image in images:
print("开始下载第[%d]个镜像 ---> [%s]" %(index,image))
cmd = "docker pull " + registry + image
os.system(cmd)
print("done!")
index +=1 def TagImage(sregistry,dregistry,images):
print("一共%s个镜像" %(len(images),))
index = 1
for image in images:
print("开始tag第[%d]个镜像 ---> [%s] --->[%s]" %(index,sregistry+image,dregistry+image))
cmd = "docker tag " + sregistry+image + " " + dregistry + image
os.system(cmd)
print("done!")
index +=1 if __name__ == '__main__':
PullImage(S_registry,node_image)
TagImage(S_registry,D_registry,node_image)

2.kubeadm添加

[root@node1 ~]# kubeadm join 192.168.0.135: --token 33x3h7.tejszerd0znwtjum --discovery-token-ca-cert-hash sha256:2d790600988cf71dda1a5f2
ea2e798918acf54584ff3ffe1dca006ec8a4c80a6[preflight] running pre-flight checks
[WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are no
t loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]you can solve this problem with following methods:
. Run 'modprobe -- ' to load missing kernel modules;
. Provide the missing builtin kernel ipvs support [WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
[discovery] Trying to connect to API Server "192.168.0.135:6443"
[discovery] Created cluster-info discovery client, requesting info from "https://192.168.0.135:6443"
[discovery] Requesting info from "https://192.168.0.135:6443" again to validate TLS against the pinned public key
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "192.168.0.
:"[discovery] Successfully established connection with API Server "192.168.0.135:"
[kubelet] Downloading configuration for the kubelet from the "kubelet-config-1.12" ConfigMap in the kube-system namespace
[kubelet] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[preflight] Activating the kubelet service
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...
[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "node1.example.com" as an annotation This node has joined the cluster:
* Certificate signing request was sent to apiserver 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.

8.FAQ

1.发现coredns出现问题,pod状态一直是pendding状态。

kubectl descripe pod xxxx -n kube-system

Warning  FailedScheduling  21m (x243 over 61m)   default-scheduler  0/1 nodes are available: 1 node(s) had taints that the pod didn't toler
ate. Warning FailedScheduling 4m47s (x61 over 14m) default-scheduler 0/1 nodes are available: 1 node(s) had taints that the pod didn't toler
ate.

正常: 百度taints 污点,应为没有添加node节点导致。 默认不会给master节点分配pod。

[root@master ~]# kubectl describe node master.example.com |grep -E '(Roles|Taints)'
Roles: master
Taints: node-role.kubernetes.io/master:NoSchedule

2.防火墙问题

经过telnet 发现no route tohost  。 关闭防火墙即可。

info: dial tcp 192.168.0.135:6443: connect: no route to host][discovery] Failed to request cluster info, will try again: [Get https://192.168.0.135:6443/api/v1/namespaces/kube-public/configmaps/cluster-
info: dial tcp 192.168.0.135:6443: connect: no route to host]

参考链接:https://www.cnblogs.com/cocowool/p/kubeadm_install_kubernetes.html

Kubernetes-v1.12.0基于kubeadm部署的更多相关文章

  1. 关于Kubernetes v1.14.0的 kube-controller-manager部署

    1. kube-controller-manager准备 默认kube-controller-manager 部署在kube-apiserver部署的服务器上面服务器的配置等在这就不在列出来 二进制文 ...

  2. kubernetes之Kubeadm快速安装v1.12.0版

    通过Kubeadm只需几条命令即起一个单机版kubernetes集群系统,而后快速上手k8s.在kubeadm中,需手动安装Docker和kubeket服务,Docker运行容器引擎,kubelet是 ...

  3. 使用kubeadm 安装 kubernetes 1.12.0

    目录 简介: 架构说明: 系统配置: 1.1 关闭防火墙 1.2 禁用SELinux 1.3 关闭系统Swap 1.4 安装docker 使用kubeadm部署Kubernetes: 2.1 安装ku ...

  4. 使用 kubeadm 安装 kubernetes v1.16.0

    近日通过kubeadm 安装 kubernetes v1.16.0,踩过不少坑,现记录下安装过程. 安装环境: 系           统:CentOS Linux release 7.6 Docke ...

  5. Kubernetes v1.12/v1.13 二进制部署集群(HTTPS+RBAC)

    官方提供的几种Kubernetes部署方式 minikube Minikube是一个工具,可以在本地快速运行一个单点的Kubernetes,尝试Kubernetes或日常开发的用户使用.不能用于生产环 ...

  6. Kubeadm搭建高可用(k8s)Kubernetes v1.24.0集群

    文章转载自:https://i4t.com/5451.html 背景 Kubernetes 1.24新特性 从kubelet中移除dockershim,自1.20版本被弃用之后,dockershim组 ...

  7. 从零到一,利用kubeadm在ubuntu server 16.04 64位系统离线安装kubernetes v1.10.0

    说明 初步接触kubernets,记录学习过程 本教程目的利用kubeadm在ubuntu server 16.04 64位系统离线安装kubernets v1.10.0 环境信息 节点IP地址 角色 ...

  8. 基于Kubernetes v1.24.0的集群搭建(三)

    1 使用kubeadm部署Kubernetes 如无特殊说明,以下操作可以在所有节点上进行. 1.1 首先我们需要配置一下阿里源 cat <<EOF > /etc/yum.repos ...

  9. 使用睿云智合开源 Breeze 工具部署 Kubernetes v1.12.3 高可用集群

    一.Breeze简介 Breeze 项目是深圳睿云智合所开源的Kubernetes 图形化部署工具,大大简化了Kubernetes 部署的步骤,其最大亮点在于支持全离线环境的部署,且不需要FQ获取 G ...

随机推荐

  1. java源文件与类

    一个源文件可以包含多个类, 编译的时候,每一个类生成一个字符码文件, 源文件名可以和类名不一致,但字符码文件与类名一致, 如果类是public(公共类),源文件名必须与类名一致 命名规则:源文件的路径 ...

  2. python之成员(面向对象)

    1. 成员 在类中你能写的所有内容都是类的成员 class Person: def __init__(self, name, gender): self.name = name # 成员 self.g ...

  3. 1145.cn 百度MIP适配实例

    MIP,全称Mobile Instant Pages(移动端即时页面),是百度推出的一套移动端网页开放技术标准.网站移动端页面统计MIP改造,能实现页面缓存,从而达到移动网页加速效果. 百度官方已经明 ...

  4. Android View体系(二)实现View滑动的六种方法

    1.View的滑动简介 View的滑动是Android实现自定义控件的基础,同时在开发中我们也难免会遇到View的滑动的处理.其实不管是那种滑动的方式基本思想都是类似的:当触摸事件传到View时,系统 ...

  5. 取消Eclipse等号、分号、空格代码自动补全

      本文主要参考了以下文章 http://www.cnblogs.com/a-zx/p/3388041.html 本文基于 Eclipse Java EE IDE for Web Developers ...

  6. [OTA] 系统加密后Recovery是如何读取OTA升级包的

    目前很多Android手机采用的FUSE方案,也就是内部SD卡不单独占用一个文件系统而实际上占用的是userdata的空间. 当系统加密后,解密需要VOLD的参于.而在Recovery模式下,是没有V ...

  7. AJAX的优点 个人理解记录

    1:对网站性能的提高.例如我只需要刷新页面中购物车的数据,使用ajax时不需要请求整个页面的数据,对于客户端和服务器的压力都会降低, 减少了ISP的负担,服务器的空间和带宽压力都会降低. 2:用户体验 ...

  8. Android、IOS文字居中偏离的解决方案

    前言 移动端开发,经常会遇到的问题,就是文字居中.一般都只能往css方向去fix这个问题. 自己以前也用过position:relative;top:-*px的方式去解决.

  9. Linux 小知识翻译 - 「X Window系统」

    X Window System是给Unix系的OS提供的一套窗口管理软件或者说是组件.X Window System已经成为了在Linux上使用GUI环境的不可或缺的东西了. X Window Sys ...

  10. 服务器出现大量的127.0.0.1:3306 TIME_WAIT连接 解决方法 [转载]

    netstat -an 192.168.12.13:3306      192.168.12.12:30443      TIME_WAIT 192.168.12.13:3306      192.1 ...