ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

部署Kubernetes Cluster

2022-01-03 11:04:49  阅读:247  来源: 互联网

标签:00 kubernetes Kubernetes 部署 repo Cluster -- docker kubeadm


中文学习网站:https://www.kubernetes.org.cn/doc-16

部署docker服务

所有节点部署docker服务
curl -sSL https://get.daocloud.io/docker | sh
systemctl start docker
echo '{"registry-mirrors":["https://reg-mirror.qiniu.com/"]}' >>/etc/docker/daemon.json
systemctl daemon-reload
systemctl restart docker

自己的yum安装没有镜像源,需要配置源

[root@mcw7 ~]$ systemctl stop  firewalld.service
[root@mcw7 ~]$ yum install -y kubelet kubeadm kubectl
Loaded plugins: fastestmirror
base                                                                                                                                                       | 3.6 kB  00:00:00     
epel                                                                                                                                                       | 4.7 kB  00:00:00     
extras                                                                                                                                                     | 2.9 kB  00:00:00     
updates                                                                                                                                                    | 2.9 kB  00:00:00     
(1/3): epel/x86_64/updateinfo                                                                                                                              | 1.0 MB  00:00:01     
(2/3): epel/x86_64/primary_db                                                                                                                              | 7.0 MB  00:00:07     
(3/3): updates/7/x86_64/primary_db                                                                                                                         |  13 MB  00:00:08     
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
No package kubelet available.
No package kubeadm available.
No package kubectl available.
Error: Nothing to do
[root@mcw7 ~]$ ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Base.repo.backup  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo  epel.repo

配置阿里kubernetes镜像源以及yum安装kubelet/kubeadm/kubectl

所有节点都要安装kubelet/kubeadm/kubectl
阿里云kubernetes镜像源添加指导:https://developer.aliyun.com/mirror/kubernetes?spm=a2c6h.13651102.0.0.3e221b11Ki4Wu1
直接去阿里云镜像源找kubernetes,进行操作

CentOS / RHEL / Fedora


cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
setenforce 0
yum install -y kubelet kubeadm kubectl用
systemctl enable kubelet && systemctl start kubelet

用kubeadm创建集群

官网:https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/

主机规划

主机名   节点类型   ip          
mcw7      master    10.0.0.137
mcw8      node1     10.0.0.138
mcw9      node2     10.0.0.139

初始化Master

[root@mcw7 ~]$ kubeadm init --apiserver-advertise-address 10.0.0.137 --pod-network-cidr=10.244.0.0/24
......
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
, error: exit status 1
    [ERROR Service-Docker]: docker service is not active, please run 'systemctl start docker.service'
    [ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables does not exist
    [ERROR FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
    [ERROR SystemVerification]: error verifying Docker info: "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher  #运行报错,这是因为docker daemon没起

[root@mcw7 ~]$ systemctl start docker.service  #启动docker daemon ,然后初始化Master
[root@mcw7 ~]$ kubeadm init --apiserver-advertise-address 10.0.0.137 --pod-network-cidr=10.244.0.0/24


[root@mcw7 ~]$ kubeadm init --apiserver-advertise-address 10.0.0.137 --pod-network-cidr=10.244.0.0/24
[init] Using Kubernetes version: v1.23.1
[preflight] Running pre-flight checks
    [WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
    [WARNING Swap]: swap is enabled; production deployments should disable swap unless testing the NodeSwap feature gate of the kubelet
    [WARNING Hostname]: hostname "mcw7" could not be reached
    [WARNING Hostname]: hostname "mcw7": lookup mcw7 on 10.0.0.2:53: no such host 
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
    [ERROR Mem]: the system RAM (976 MB) is less than the minimum 1700 MB
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

再次运行报错:
可用CPU 1的数量小于所需的2可用CPU 1的数量小于所需的2
系统RAM(976 MB)小于最小1700 MB

我的vmware创建的虚拟机是1G的,看来不够

修改虚拟机配置

 

 

 

 

 

 

 

 

 

标签:00,kubernetes,Kubernetes,部署,repo,Cluster,--,docker,kubeadm
来源: https://www.cnblogs.com/machangwei-8/p/15759077.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有