您的位置:首页 > 房产 > 家装 > 设计大神云集的网站是_商标设计一般多少钱_承德网络推广_百度手机助手苹果版

设计大神云集的网站是_商标设计一般多少钱_承德网络推广_百度手机助手苹果版

2024/12/22 21:18:12 来源:https://blog.csdn.net/qq_34777982/article/details/143963076  浏览:    关键词:设计大神云集的网站是_商标设计一般多少钱_承德网络推广_百度手机助手苹果版
设计大神云集的网站是_商标设计一般多少钱_承德网络推广_百度手机助手苹果版

环境说明

master:192.168.100.100

node: 192.168.100.101

kubeadm 1.31.2 (自编译二进制文件,证书有效期100年)

银河麒麟v10 sp2  x86架构

内核版本:5.4.x  编译安装 cgroup v2启用

docker版本:27.x  二进制安装,cgroup v2支持

部署准备

# 关闭防火墙
systemctl disable firewalld --now# 关闭selinux
setenforce 0
sed -i 's/enforcing/disabled/' /etc/selinux/config#关闭swap
swapoff -a 
sed -ri 's/.*swap.*/#&/' /etc/fstab (永久关闭)# 主机名与IP对应关系
vim /etc/hosts
192.168.100.100 k8s-master
192.168.100.101 k8s-node# 添加内核优化参数
cat << EOF > /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
user.max_user_namespaces=28633
EOF# 使其生效
sysctl -p /etc/sysctl.d/99-kubernetes-cri.conf# 配置ipvs转发
yum install -y ipset ipvsadm
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
EOFchmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
# 配置时间同步dnf install chronyd -ycat > /etc/chrony.conf <<EOF
server ntp.aliyun.com iburst
stratumweight 0
driftfile /var/lib/chrony/drift
rtcsync
makestep 10 3
bindcmdaddress 127.0.0.1
bindcmdaddress ::1
keyfile /etc/chrony.keys
commandkey 1
generatecommandkey
logchange 0.5
logdir /var/log/chrony
EOFsystemctl enable chronyd --now

二进制安装docker+cri-docker+cni插件

银河麒麟v10 二进制安装cri-docker+cni插件—— 筑梦之路-CSDN博客

安装kubeadm、kubelet、kubectl

将编译的二进制文件拷贝到/usr/bin/目录下,并授可执行权限

# 安装常用工具和依赖包
yum -y install  wget psmisc vim net-tools nfs-utils telnet yum-utils device-mapper-persistent-data lvm2 git tar curl ipvsadmyum install ipvsadm ipset sysstat conntrack libseccomp -yyum install socat libnetfilter_queue libnetfilter_cttimeout conntrack-tools libnetfilter_cthelper# 生成service文件
cat > /usr/lib/systemd/system/kubelet.service << EOF
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=https://kubernetes.io/docs/home/
Wants=network-online.target
After=network-online.target[Service]
ExecStart=/usr/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10[Install]
WantedBy=multi-user.target
EOFsystemctl daemon-reloadsystemctl enable kubelet
# 拉取所需镜像kubeadm config images pull --cri-socket unix:///var/run/cri-dockerd.sock --image-repository registry.aliyuncs.com/google_containers# 初始化kubeadm init --kubernetes-version=v1.31.2 \
--apiserver-advertise-address=192.168.100.100 \
--pod-network-cidr=10.244.0.0/16 \
--service-cidr=10.96.0.0/12 \
--token-ttl=0 \
--cri-socket unix:///var/run/cri-dockerd.sock \
--image-repository registry.aliyuncs.com/google_containers
接下来在worker节点上执行相关的操作,worker节点与master节点的操作步骤的唯一区别是:master节点执行kubeadm init操作,woker节点执行kubeadm join操作,因此上面的步骤除了kubeadm init步骤之外,其他所有的步骤woker节点同样也需要执行。执行kubeadm init 成功之后输出的 最后一行kubeadm join 命令kubeadm config images pull --cri-socket unix:///var/run/cri-dockerd.sock --image-repository registry.aliyuncs.com/google_containerskubeadm join 192.168.100.100:6443 --token o4zf8w.xxxx --discovery-token-ca-cert-hash sha256:376e215a51620ac6ccc --cri-socket unix:///var/run/cri-dockerd.sock
# 部署flannel插件cat > flannel.yaml << EOF
#---
#kind: Namespace
#apiVersion: v1
#metadata:
#  name: kube-flannel
#  labels:
#    k8s-app: flannel
#    pod-security.kubernetes.io/enforce: privileged
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:labels:k8s-app: flannelname: flannel
rules:
- apiGroups:- ""resources:- podsverbs:- get
- apiGroups:- ""resources:- nodesverbs:- get- list- watch
- apiGroups:- ""resources:- nodes/statusverbs:- patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:labels:k8s-app: flannelname: flannel
roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: flannel
subjects:
- kind: ServiceAccountname: flannelnamespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:labels:k8s-app: flannelname: flannelnamespace: kube-system
---
kind: ConfigMap
apiVersion: v1
metadata:name: kube-flannel-cfgnamespace: kube-systemlabels:tier: nodek8s-app: flannelapp: flannel
data:cni-conf.json: |{"name": "cbr0","cniVersion": "0.3.1","plugins": [{"type": "flannel","delegate": {"hairpinMode": true,"isDefaultGateway": true}},{"type": "portmap","capabilities": {"portMappings": true}}]}net-conf.json: |{"Network": "10.244.0.0/16","EnableNFTables": false,"Backend": {"Type": "vxlan"}}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:name: kube-flannel-dsnamespace: kube-systemlabels:tier: nodeapp: flannelk8s-app: flannel
spec:selector:matchLabels:app: flanneltemplate:metadata:labels:tier: nodeapp: flannelspec:affinity:nodeAffinity:requiredDuringSchedulingIgnoredDuringExecution:nodeSelectorTerms:- matchExpressions:- key: kubernetes.io/osoperator: Invalues:- linuxhostNetwork: truepriorityClassName: system-node-criticaltolerations:- operator: Existseffect: NoScheduleserviceAccountName: flannelinitContainers:- name: install-cni-pluginimage: docker.io/flannel/flannel-cni-plugin:v1.6.0-flannel1command:- cpargs:- -f- /flannel- /opt/cni/bin/flannelvolumeMounts:- name: cni-pluginmountPath: /opt/cni/bin- name: install-cniimage: docker.io/flannel/flannel:v0.26.1command:- cpargs:- -f- /etc/kube-flannel/cni-conf.json- /etc/cni/net.d/10-flannel.conflistvolumeMounts:- name: cnimountPath: /etc/cni/net.d- name: flannel-cfgmountPath: /etc/kube-flannel/containers:- name: kube-flannelimage: docker.io/flannel/flannel:v0.26.1command:- /opt/bin/flanneldargs:- --ip-masq- --kube-subnet-mgrresources:requests:cpu: "100m"memory: "50Mi"securityContext:privileged: falsecapabilities:add: ["NET_ADMIN", "NET_RAW"]env:- name: POD_NAMEvalueFrom:fieldRef:fieldPath: metadata.name- name: POD_NAMESPACEvalueFrom:fieldRef:fieldPath: metadata.namespace- name: EVENT_QUEUE_DEPTHvalue: "5000"volumeMounts:- name: runmountPath: /run/flannel- name: flannel-cfgmountPath: /etc/kube-flannel/- name: xtables-lockmountPath: /run/xtables.lockvolumes:- name: runhostPath:path: /run/flannel- name: cni-pluginhostPath:path: /opt/cni/bin- name: cnihostPath:path: /etc/cni/net.d- name: flannel-cfgconfigMap:name: kube-flannel-cfg- name: xtables-lockhostPath:path: /run/xtables.locktype: FileOrCreate
EOFkubectl apply -f flannel.yaml

检查证书有效期

kubeadm certs check-expiration[check-expiration] Reading configuration from the cluster...
[check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'CERTIFICATE                EXPIRES                  RESIDUAL TIME   CERTIFICATE AUTHORITY   EXTERNALLY MANAGED
admin.conf                 Oct 27, 2124 10:08 UTC   99y             ca                      no      
apiserver                  Oct 27, 2124 10:08 UTC   99y             ca                      no      
apiserver-etcd-client      Oct 27, 2124 10:08 UTC   99y             etcd-ca                 no      
apiserver-kubelet-client   Oct 27, 2124 10:08 UTC   99y             ca                      no      
controller-manager.conf    Oct 27, 2124 10:08 UTC   99y             ca                      no      
etcd-healthcheck-client    Oct 27, 2124 10:08 UTC   99y             etcd-ca                 no      
etcd-peer                  Oct 27, 2124 10:08 UTC   99y             etcd-ca                 no      
etcd-server                Oct 27, 2124 10:08 UTC   99y             etcd-ca                 no      
front-proxy-client         Oct 27, 2124 10:08 UTC   99y             front-proxy-ca          no      
scheduler.conf             Oct 27, 2124 10:08 UTC   99y             ca                      no      
super-admin.conf           Oct 27, 2124 10:08 UTC   99y             ca                      no      CERTIFICATE AUTHORITY   EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED
ca                      Oct 27, 2124 10:08 UTC   99y             no      
etcd-ca                 Oct 27, 2124 10:08 UTC   99y             no      
front-proxy-ca          Oct 27, 2124 10:08 UTC   99y             no 

至此使用自编译的kubeadm,证书有效期100年搭建k8s集群完成,仅供参考。

此种方式搭建k8s集群,仍然使用docker作为runtime运行时,和直接使用containerd作为runtime性能上稍差,相对来说docker生态更加完善,使用习惯不变。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com