k8s安装与使用

一、Docker安装

  • 注意docker的版本要和k8s版本对应
    https://blog.csdn.net/Myx74270512/article/details/128235051

二、k8s安装

  1. 更新yum
sudo yum update
  1. 添加Kubernetes的yum源
sudo vi /etc/yum.repos.d/kubernetes.repo

## 添加如下内容
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
  1. 安装Kubernetes组件
sudo yum install kubelet-1.23.1 kubeadm-1.23.1 kubectl-1.23.1 --disableexcludes=kubernetes
  1. 启动Kubernetes服务
sudo systemctl start kubelet
sudo systemctl enable kubelet

三、创建k8s master

sudo kubeadm init  --apiserver-advertise-address=10.0.4.4 \
--image-repository registry.cn-hangzhou.aliyuncs.com/google_containers \ 
--kubernetes-version v1.23.1 \
--service-cidr=10.96.0.0/16 \
--pod-network-cidr=10.244.0.0/16 \ 
--ignore-preflight-errors=all \

四、node加入集群

kubeadm join 1.116.163.254:6443 \
--token mr2027.in8aauluwh5pezdo \
--discovery-token-ca-cert-hash sha256:34d7bd0722ad07cc9688033993509f2b84bbebcb10876feea32c7578da37bf47

你可能感兴趣的:(kubernetes,容器,云原生)