首页 > 其他分享 >K8S污点容忍案例

K8S污点容忍案例

时间:2023-02-25 14:58:51浏览次数:39  
标签:容忍 kubelet pre74 repo lecode 污点 docker K8S root

[root@lecode-pre74 ~]# setenforce 0
setenforce: SELinux is disabled
[root@lecode-pre74 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@lecode-pre74 ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            30G        392M         30G        8.6M        205M         30G
Swap:            0B          0B          0B
[root@lecode-pre74 ~]# cat <<EOF | tee /etc/modules-load.d/k8s.conf
> br_netfilter
> EOF
br_netfilter
[root@lecode-pre74 ~]# cat <<EOF | tee /etc/sysctl.d/k8s.conf
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
[root@lecode-pre74 ~]# sysctl --system
[root@lecode-pre74 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@lecode-pre74 ~]# curl -o /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
[root@lecode-pre74 ~]# sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
[root@lecode-pre74 ~]# yum -y install epel-release docker-ce-20.10.18
[root@lecode-pre74 ~]# mkdir -p /etc/docker
[root@lecode-pre74 ~]# vim /etc/docker/daemon.json
[root@lecode-pre74 ~]# systemctl enable --now docker && systemctl status docker
[root@lecode-pre74 ~]# cat  > /etc/yum.repos.d/kubernetes.repo <<EOF
> [kubernetes]
> name=Kubernetes
> baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
> enabled=1
> gpgcheck=0
> repo_gpgcheck=0
> EOF
[root@lecode-pre74 ~]# yum -y install  kubeadm-1.20.9  kubelet-1.20.9  kubectl-1.20.9
Complete!

[root@lecode-pre74 ~]# systemctl enable --now kubelet && systemctl status kubelet


#在master节点查询加入节点的命令
[root@lecode-pre55 ~]# kubeadm token create --print-join-command
kubeadm join 172.17.1.55:6443 --token 75t3w8.qldcspscavh916h6     --discovery-token-ca-cert-hash sha256:6e936ed6fac759c490345cde62f35c42a7ed4337a9881a133fe74cef3991f1cf 

#在新节点执行
[root@lecode-pre74 ~]# kubeadm join 172.17.1.55:6443 --token 75t3w8.qldcspscavh916h6     --discovery-token-ca-cert-hash sha256:6e936ed6fac759c490345cde62f35c42a7ed4337a9881a133fe74cef3991f1cf
[preflight] Running pre-flight checks
	[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.18. Latest validated version: 19.03
	[WARNING Hostname]: hostname "lecode-pre74" could not be reached
	[WARNING Hostname]: hostname "lecode-pre74": lookup lecode-pre74 on 100.125.1.250:53: no such host
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

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 control-plane to see this node join the cluster.


#在主节点给新节点打上污点
[root@lecode-pre55 ~]# kubectl get no
NAME            STATUS   ROLES                  AGE     VERSION
lecode-pre210   Ready    <none>                 50d     v1.20.9
lecode-pre217   Ready    <none>                 48d     v1.20.9
lecode-pre55    Ready    control-plane,master   50d     v1.20.9
lecode-pre7     Ready    <none>                 50d     v1.20.9
lecode-pre71    Ready    <none>                 50d     v1.20.9
lecode-pre74    Ready    <none>                 4m40s   v1.20.9
lecode-pre79    Ready    <none>                 48d     v1.20.9

#给新节点打上污点
[root@lecode-pre55 ~]# kubectl taint node lecode-pre74 service=dap:NoSchedule
node/lecode-pre74 tainted


#修改服务yaml文件,添加污点容忍和节点选择
spec:
...
    spec:
      nodeName: lecode-pre74
      tolerations:
      - key: service
        value: dap
        effect: NoSchedule

#检查效果
[root@lecode-pre55 ~]# kubectl get po -n lecode-pre -o wide |grep dap
lecode-dap-8457d4c4fc-cj2b8                 1/1     Running   0          3m7s    10.244.6.2     lecode-pre74    <none>           <none>
lecode-dap-8457d4c4fc-m5qmq                 1/1     Running   0          98s     10.244.6.4     lecode-pre74    <none>           <none>
lecode-dap-8457d4c4fc-nrjvx                 1/1     Running   0          2m17s   10.244.6.3     lecode-pre74    <none>           <none>

49. mysql代理

[root@zhyly-pre-003 4-layer-conf.d]# cat mysql.conf
upstream mysql {
    server 192.168.2.6:3306;
}

server {
     listen  8083;
     proxy_pass mysql;
}

[root@zhyly-pre-003 4-layer-conf.d]# /usr/local/nginx/sbin/nginx  -s reload


stream {
	upstream rds {
		server 10.27.166.107:33086 max_fails=3 fail_timeout=30s; 
	}
	server {
		listen 8085;
		proxy_connect_timeout 2s;  #后端服务器连接的超时时间_发起握手等候响应超时时间(默认60秒)
		proxy_timeout 900s;  #接收后端响应内容超时
		proxy_pass rds;
	}
}

标签:容忍,kubelet,pre74,repo,lecode,污点,docker,K8S,root
From: https://www.cnblogs.com/anslinux/p/17154395.html

相关文章

  • 收集日志方式1:k8s集群通过ELK收集容器控制台输出日志(logstash方式)
    集群架构:控制台日志,相当于容器的1号进程。或者容器内的日志正确和错误日志重定向到了如下/var/log/nginx/access.log->/dev/stdout /var/log/nginx/error.log->/dev/st......
  • 本地部署一套k8s集群
    我这里准备三台本地vmware虚拟机,版本号centos7.9,一台master节点,一台node1,一台node2kubeadm方式部署。Kubeadm是一个K8s部署工具,提供kubeadminit和kubeadmjoin,用于......
  • k8s的滚动更新
    一、什么是滚动更新当某个服务需要升级时,传统的做法是,先将要更新的服务下线,业务停止后再更新版本和配置,然后重新启动服务。如果业务集群规模较大时,这个工作就变成了一个......
  • k8s-部署Nginx+Keepalived高可用负载均衡器
    本文章是 k8s二进制高可用集群部署 的分支。详细步骤请参考目录。Kubernetes集群高可用性包含以下两个层面的考虑:Etcd数据库的高可用性KubernetesMaster组件......
  • K8S中Pod概念
    一、资源限制Pod是kubernetes中最小的资源管理组件,Pod也是最小化运行容器化应用的资源对象。一个Pod代表着集群中运行的一个进程。kubernetes中其他大多数组件都是......
  • k8s-新增服务端节点
    本文章是 k8s二进制高可用集群部署 的分支。详细步骤请参考目录。1.etcd扩容**如果etcd通过CA生成的证书不包含当前节点的ip,可能etcd集群需要重新生成证书。1......
  • K8SYaml文件详解
    一、K8S支持的文件格式kubernetes支持YAML和JSON文件格式管理资源对象。JSON格式:主要用于api接口之间消息的传递YAML格式:用于配置和管理,YAML是一种简洁的非标记性语言,内......
  • k8s-部署CoreDNS
    本文章是 k8s二进制高可用集群部署 的分支。详细步骤请参考目录。CoreDNS用于集群内部Service名称解析部署CoreDNS需要使用到官方提供的两个文件 deploy.sh 和......
  • k8s orders
    一、资源管理介绍二、陈述式对象管理三、k8s的ip和端口介绍四、项目生命周期一、资源管理介绍1、资源管理概念在kubernetes中,所有的内容都抽象为资源,用户需要通过操......
  • k8s service nodeport
    服务(Service)将运行在一组Pods上的应用程序公开为网络服务的抽象方法。Kubernetes中Service的一个关键目标是让你无需修改现有应用程序就能使用不熟悉的服务发现机制......