当前位置: 首页 > news >正文

记录一下:成功部署k8s集群(部分)

前提条件

  •         安装了containerd、docker
  •         关闭了firewalld、selinux
  •         配置了时间同步服务 chronyd
  •         关闭swap分区等

1、在控制节点、工作节点,安装kubelet、kubeadm、kubectl

yum install -y kubelet-1.26.0 kubeadm-1.26.0 kubectl-1.26.0 --nogpgcheck

注意:若遇到如下错误,加上--nogpgcheck,跳过GPG检查。

2、启动kubelet服务

systemctl start kubelet ; systemctl enable kublet

#注意:如果启动kubelet失败,问题自己查阅、搜索下解决方案。

3、kubeadm 生成初始化k8s集群的配置文件、并修改

kubeadm config print init-defaults > kubeadm.yaml

[root@103 ~]# vim kubeadm.yaml 

apiVersion: kubeadm.k8s.io/v1beta3
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 192.168.1.103    ## 指定ip
bindPort: 6443
nodeRegistration:
criSocket: unix:///run/containerd/containerd.sock
imagePullPolicy: IfNotPresent
name: node
taints: null
---
apiServer:
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta3
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns: {}
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers   ## 更改镜像源
kind: ClusterConfiguration
kubernetesVersion: 1.26.0
networking:
dnsDomain: cluster.local
serviceSubnet: 10.96.0.0/12
podSubnet: 10.244.0.0/12        ##  添加pod子网
scheduler: {}
---
apiVersion: kubeproxy.config.k8s.io/v1alpha1    ## 添加代理模式 ipvs
kind: KubeProxyConfiguration    ##
mode: ipvs ##
--- 
apiVersion: kubelet.config.k8s.io/v1beta1  ## 更改cgroup驱动
kind: KubeletConfiguration  ##
cgroupDriver: systemd  ##

4、初始化k8s集群

kubeadm init --config kubeadm.yaml --ignore-preflight-errors=SystemVerification

sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
net.ipv4.ip_forward = 1
[root@103 ~]# 
[root@103 ~]# modprobe br_netfilter
[root@103 ~]# vim /etc/sysctl.d/k8s.conf
[root@103 ~]# 
[root@103 ~]# sysctl -p /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
[root@103 ~]# 
[root@103 ~]# kubeadm init --config kubeadm.yaml --ignore-preflight-errors=SystemVerification
[init] Using Kubernetes version: v1.26.0
[preflight] Running pre-flight checks
[WARNING FileExisting-tc]: tc not found in system path
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local node] and IPs [10.96.0.1 192.168.1.103]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [localhost node] and IPs [192.168.1.103 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [localhost node] and IPs [192.168.1.103 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 7.002941 seconds
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration for the kubelets in the cluster
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node node as control-plane by adding the labels: [node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node node as control-plane by adding the taints [node-role.kubernetes.io/control-plane:NoSchedule]
[bootstrap-token] Using token: abcdef.0123456789abcdef
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

# 当你看到 succesfully ,恭喜你已经成功初始化了该台机器

按照下面的提示,逐步操作即可。(其他的控制节点、工作节点操作大致如上。)

仅简单记录一下,开心!

如果要转载,请附上原文链接
http://www.dtcms.com/a/270626.html

相关文章:

  • 【音视频】TS协议介绍
  • 搭建商城系统
  • 【Java】【力扣】3.无重复字符的最长字串
  • Flutter基础(前端教程⑧-数据模型)
  • Elasticsearch RESTful API入门:基础搜索与查询DSL
  • C#项目 在Vue/React前端项目中 使用使用wkeWebBrowser引用并且内部使用iframe网页外链 页面部分白屏
  • 数据管理新范式:基于Docker的私有云存储系统构建指南
  • 十一、K8s细粒度权限管理RBAC
  • 异步进阶:C#的Task.WhenAll——如何开启多个异步任务
  • ReactNative【实战系列教程】我的小红书 6 -- 购物(含商品搜索、商品分类、商品列表)
  • 编写产品需求文档:黄历日历小程序
  • [Leetcode] 预处理 | 多叉树bfs | 格雷编码 | static_cast | 矩阵对角线
  • React面试高频考点解析
  • LeetCode Hot 100 搜索二维矩阵 II
  • langchain从入门到精通(四十一)——基于ReACT架构的Agent智能体设计与实现
  • [附源码+数据库+毕业论]基于Spring Boot+mysql+vue结合内容推荐算法的学生咨询系统
  • RedisCommandExecutionException: ERR unknown command ‘LPOS‘
  • 树莓派5-系统 Debian 12 开启VNC远程访问踩坑记录
  • vue3面试题(个人笔记)
  • uniapp AndroidiOS 定位权限检查
  • ragflow_多模态文档解析与正文提取策略
  • 《设计模式之禅》笔记摘录 - 5.代理模式
  • Flutter基础(前端教程⑨-图片)
  • Robot之眼CMOS传感器静电防护指南
  • LeetCode热题100—— 32. 最长有效括号 (hard)
  • 零基础上手 Amazon DynamoDB:NoSQL 数据库服务的核心概念与快速搭建指南
  • Android-重学kotlin(协程源码第二阶段)新学习总结
  • 安全管理协议(SMP):配对流程、密钥生成与防中间人攻击——蓝牙面试核心考点精解
  • Qt自定义控件(9)——径向渐变QRadialGradient、圆锥渐变QConicalGradient
  • 华为OD机试_2025 B卷_观看文艺汇演问题(Python,100分)(附详细解题思路)