首页 > 其他分享 >kubernetes安装

kubernetes安装

时间:2023-04-03 13:55:05浏览次数:32  
标签:kubernetes -- 安装 etc yum containerd config

环境:

      centos 7.9

 

安装步骤:

一、准备:(1、SELINUX  2、swap off  3、hosts  4、sysctl配置)

setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux

systemctl disable firewalld
systemctl stop firewalld
systemctl disable iptables.service
systemctl stop iptables.service

swapoff -a
sed -i '/centos-swap/d' /etc/fstab

echo '192.168.21.138 master' >> /etc/hosts

cat <<EOF > /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
modprobe br_netfilter

 

二、依赖组件安装

yum install yum-utils device-mapper-persistent-data lvm2

三、安装container

从1.24版本开始,不再依靠docker了,代替由container

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install containerd

systemctl enable containerd
systemctl restart containerd
systemctl status containerd

containerd config default > /etc/containerd/config.toml
sed -i 's#sandbox_image = "registry.k8s.io/pause:3.6"#\
sandbox_image = "registry.aliyuncs.com/google_containers/pause"#g' \
/etc/containerd/config.toml

systemctl daemon-reload
systemctl restart containerd.service

 

四、安装kubernetes(k8s)

定义阿里云镜像的repo

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

执行安装(Node结点只要let/adm即可,不需要ctl

yum install kubelet-1.26.0 kubeadm-1.26.0 kubectl-1.26.0

systemctl enable kubelet

 

五、创建k8s cluster

kubeadm init \
--apiserver-advertise-address=192.168.21.138 \     //这里IP是master的IP地址
--image-repository registry.aliyuncs.com/google_containers \
--kubernetes-version v1.26.0 \
--service-cidr=10.96.0.0/12 \
--pod-network-cidr=192.168.0.0/16

 

Your Kubernetes control-plane 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

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

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/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.21.138:6443 --token 8nzvev.pdlhmdg32ei6di5v \
        --discovery-token-ca-cert-hash sha256:98e42ce458a6259e4922be19e2ba73899a0b85fe89fabbe68743da8fdfc259e0r

 按照上面的提示,执行 

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

查验:kubectl get node

[root@localhost ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
master NotReady control-plane 31m v1.26.0
[root@localhost ~]#

之所以notready,需要安装calico

 

六、安装calico

根据提示的网址进入:

https://kubernetes.io/docs/concepts/cluster-administration/addons/
进入get start项,选择安装,就能看到安装步骤:

crictl config runtime-endpoint unix:///run/containerd/containerd.sock
crictl config image-endpoint unix:///run/containerd/containerd.sock


kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/custom-resources.yaml

watch kubectl get pods -n calico-system

直到全部running,要花点时间.....

 

标签:kubernetes,--,安装,etc,yum,containerd,config
From: https://www.cnblogs.com/peterhu318/p/17282854.html

相关文章

  • Windows 11 如何安装 WSL2
    安装WSL2需要满足以下要求:64位版本的Windows10,包括:家庭版、专业版、企业版或教育版,版本号1903或更高版本,或者WindowsServer2019或更高版本。启用了WSL的选项。至少4GB的RAM在Windows11上安装WSL2的步骤如下:打开WindowsPowerShell作为管理员......
  • anaconda在linux下的安装配置
    首先上Linux官网下载最新对应版本的Anaconda安装包链接:https://www.anaconda.com/products/distribution#Downloads因为我们是在Linux系统下安装Anaconda,所以选择Linux平台的64位版本终端找到安装包当前文件目录用sh命令执行.sh文件,开始安装shAnaconda3-year.mo......
  • Hugo-Eureka 主题安装指南
    前言虽然官方教程已经把主题安装方法说的挺清楚了,但是真正摸上手还是觉得这个主题坑比较多。玩别人的主题的时候,不会随便弄一下就报错,但是这个主题怎么搞都报错。其中一个重要原因就是不管哪种方法都需要为hugo-modules设置代理。下面对这个主题相关的步骤做了一个简单梳理,也......
  • 安装 Stable Diffusion web UI
    AI画图安装首先需要python和gitpython:https://www.python.org/downloads/windows/(建议用3.10.6)git:https://git-scm.com/download/win我的是3.10.7,感觉应该影响不大新建个文件夹,就要AI吧,cmd下cdAI到目录下,执行:gitclonehttps://github.com/AUTOMATIC1111/stable-diff......
  • GreenPlum安装
    GreenPlum安装指南针对Centos7平台[gpadmin@aivmp-bigdata0001~]$cat/etc/centos-releaseCentOSLinuxrelease7.6.1810(Core)机器外网地址121.36.194.125aivmp-bigdata0001124.70.139.178aivmp-bigdata0002124.70.192.187aivmp-bigdata0003121.36.245.248e......
  • akshare库安装及使用
    一:背景作为一个996的加班狗,自己维护的股票分析系统的来源经常进行反爬处理或者干脆停止维护了,换一个来源的话,格式分析脚本也经常需要更换,经过百度之后,发现有大佬维护了一个akshare库,可以获取大量金融相关的数据,并且转换为统一的格式,然后基于从akshare库返回的数据进行加工分......
  • StreamSets单机版安装文档
    StreamSets单机版安装文档解压安装包到opt目录tar-zxvfstreamsets-datacollector-common-3.22.3.tgz-C/opt修改为sdc配置为表单认证cd/opt/streamsets-datacollector-3.22.3/vietc/sdc.propertieshttp.authentication=form后台启动nohup./bin/streamsets......
  • Kerberos 安装
    Kerberos安装1.Kerberos服务端安装服务端重点三个配置文件:/etc/krb5.conf/var/kerberos/krb5kdc/kdc.conf/var/kerberos/krb5kdc/kadm5.acl注意点:防止配置文件格式错误,如编辑过程中导致内容缺失。查询软件对加密算法的支持程度,如降低版本hadoop需要去除掉aes和......
  • npm安装
    npm&&NVM安装nvm安装NVM_DIR="/root/.nvm"NODE_VERSION=17.9.0curl-o-https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh|bash\&&[-s"$NVM_DIR/nvm.sh"]&&\."$NVM_DIR/nvm.sh"\&......
  • Redis6 集群单机安装
    Redis6集群单机安装官网下载https://download.redis.io/releases/redis-6.2.6.tar.gzhttp://download.redis.io/redis-stable.tar.gz文档参考https://redis.io/documentation解压编译#安装编译需要的tclyum-yinstallgcctclrm-rf/data/redismkdir-p/data/re......