Kubernetes学习笔记-Part.08 安装k8s环境
将下载好的rpm文件上传至master01的/opt/kubernetes下,并创建repo的镜像源。通过ansible的yum模块安装kubelet、kubeadm和kubectl。在外网服务器上,配置kubernetes的yum源。为所有节点创建repo文件。下载相关安装包及依赖包。
·
目录
Part.01 Docker介绍
Part.02 Kubernets与Docker的关系
Part.03 Kubernetes原理
Part.04 资源规划
Part.05 基础环境准备
Part.06 Docker安装
Part.07 Harbor搭建
Part.08 K8s环境安装
Part.09 K8s集群构建
Part.10 容器回退
第八章 K8s环境安装
8.1.准备安装文件
在外网服务器上,配置kubernetes的yum源
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
下载相关安装包及依赖包
yum clean all
yum makecache fast
mkdir /opt/k8s
cd /opt/k8s/
yumdownloader --resolve kubelet-1.23.5 kubeadm-1.23.5 kubectl-1.23.5
8.2.制作repo文件
将下载好的rpm文件上传至master01的/opt/kubernetes下,并创建repo的镜像源
cp -r /opt/kubernetes/ /var/www/html/
createrepo /var/www/html/kubernetes/
为所有节点创建repo文件
ansible all -m yum_repository -a 'name="kubernetes" description="kubernetes" baseurl="http://master01.k8s.local/kubernetes" enabled=yes gpgcheck=no'
ansible all -m shell -a 'yum clean all'
ansible all -m shell -a 'yum update -y'
8.3.安装k8s环境
通过ansible的yum模块安装kubelet、kubeadm和kubectl
ansible master,worker -m yum -a 'name=kubelet,kubeadm,kubectl state=present'
查看版本
[root@master01 ansible]# kubelet --version
Kubernetes v1.23.5
[root@master01 ansible]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5", GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", BuildDate:"2022-03-16T15:57:37Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"linux/amd64"}
[root@master01 ansible]# kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5", GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", BuildDate:"2022-03-16T15:58:47Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
更多推荐
已为社区贡献7条内容
所有评论(0)