centos7.9单机版安装K8s

1.安装docker

[root@localhost ~]# hostnamectl set-hostname master
[root@localhost ~]# bash
[root@master ~]# mv /etc/yum.repos.d/* /home  
[root@master ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@master ~]# curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
[root@master ~]# systemctl enable docker --now
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@master ~]# cat /etc/docker/daemon.json 
{
"exec-opts":["native.cgroupdriver=systemd"]
}
[root@master ~]# systemctl daemon-reload &&systemctl restart docker

2.系统调优

#关闭防火墙、设置selinux
[root@master ~]# systemctl stop firewalld&&systemctl disable firewalld&&setenforce 0
[root@master ~]# vim /etc/selinux/config
SELINUX=disabled
#关闭交换分区
[root@master ~]# swapoff -a
[root@master ~]# vim /etc/fstab
#/dev/mapper/centos-swap swap                    swap    defaults        0 0
#配置主机名解析
[root@master ~]# vim /etc/hosts
192.168.1.99 master#转发IPv4并让iptables看到桥接流量
cat >/etc/modules-load.d/k8s.conf <<EOF
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfiltercat >/etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
EOF
sysctl --system

3.安装cri-docker

下载cri-docker,安装容器进行时
[root@master ~]# yum install -y wget
这里国内下载失败,建议挂梯子下载到本地进行上传
[root@master ~]# wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.15/cri-dockerd-0.3.15.amd64.tgz
[root@master ~]# tar zxvf cri-dockerd-0.3.15.amd64.tgz 
ockerd
[root@master ~]# mv cri-dockerd/cri-dockerd /usr/bin/
配置服务文件
[root@master ~]# cat /usr/lib/systemd/system/cri-docker.service
[Unit]
Description=CRI Interface for Docker Application Container Engine
Documentation=https://docs.mirantis.com
After=network-online.target firewalld.service docker.service
Wants=network-online.target
Requires=cri-docker.socket[Service]
Type=notify
ExecStart=/usr/bin/cri-dockerd --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.10
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=alwaysStartLimitBurst=3StartLimitInterval=60sLimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinityTasksMax=infinity
Delegate=yes
KillMode=process[Install]
WantedBy=multi-user.target
[root@master ~]# cat /usr/lib/systemd/system/cri-docker.socket
[Unit]
Description=CRI Docker Socket for the API
PartOf=cri-docker.service[Socket]
ListenStream=%t/cri-dockerd.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker[Install]
WantedBy=sockets.target
[root@master ~]# systemctl daemon-reload 
[root@master ~]# systemctl enable  cri-docker --now &&systemctl status cri-docker

4.配置containerd

[root@master ~]# containerd config default > /etc/containerd/config.toml
[root@master ~]# vim /etc/containerd/config.toml 
SystemdCgroup = true
[root@master ~]# systemctl restart containerd&&systemctl enable containerd
Created symlink from /etc/systemd/system/multi-user.target.wants/containerd.service to /usr/lib/systemd/system/containerd.service.

5.配置k8s yum仓库
 

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.31/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.31/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF
sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable --now kubelet

6.初始化K8s集群

[root@master ~]# kubeadm config print init-defaults  > kubeadm-config.yaml
[root@master ~]# vim kubeadm-config.yaml apiVersion: kubeadm.k8s.io/v1beta4
bootstrapTokens:
- groups:- system:bootstrappers:kubeadm:default-node-tokentoken: abcdef.0123456789abcdefttl: 24h0m0susages:- signing- authentication
kind: InitConfiguration
localAPIEndpoint:advertiseAddress: 192.168.1.99bindPort: 6443
nodeRegistration:criSocket: unix:///var/run/cri-dockerd.sockimagePullPolicy: IfNotPresentimagePullSerial: truename: mastertaints: null
timeouts:controlPlaneComponentHealthCheck: 4m0sdiscovery: 5m0setcdAPICall: 2m0skubeletHealthCheck: 4m0skubernetesAPICall: 1m0stlsBootstrap: 5m0supgradeManifests: 5m0s
---
apiServer: {}
apiVersion: kubeadm.k8s.io/v1beta4
caCertificateValidityPeriod: 87600h0m0s
certificateValidityPeriod: 8760h0m0s
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns: {}
encryptionAlgorithm: RSA-2048
etcd:local:dataDir: /var/lib/etcd
imageRepository: registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: 1.31.0
networking:dnsDomain: cluster.localserviceSubnet: 10.96.0.0/12
proxy: {}
scheduler: {}
[root@master ~]# vim kubeadm-config.yaml 
新增
kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
cgroupDriver: "systemd"
[root@master ~]# systemctl restart kubelet
编辑 /etc/default/grub 文件,添加 systemd.unified_cgroup_hierarchy=0 到 GRUB_CMDLINE_LINUX 行
[root@master ~]# bash
[root@master ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-fb69d0cc8cb44f40959b8de6635f63a0
Found initrd image: /boot/initramfs-0-rescue-fb69d0cc8cb44f40959b8de6635f63a0.img
done
[root@master ~]# reboot
[root@master ~]# systemctl restart containerd
[root@master ~]# systemctl restart kubelet
[root@master ~]# kubeadm init --config  kubeadm-config.yaml 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/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/configAlternatively, if you are the root user, you can run:export KUBECONFIG=/etc/kubernetes/admin.confYou 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.1.99:6443 --token abcdef.0123456789abcdef \--discovery-token-ca-cert-hash sha256:a6ecf61ca34fe2994e17708179990c210ecb954c0a96b4386bd85934f123d43d 
[root@master ~]#   mkdir -p $HOME/.kube
[root@master ~]#   sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@master ~]#   sudo chown $(id -u):$(id -g) $HOME/.kube/config
[root@master ~]# kubectl get nodes
NAME     STATUS     ROLES           AGE   VERSION
master   NotReady   control-plane   36s   v1.31.2

7.安装网络插件

[root@master ~]# cat /etc/docker/daemon.json 
{
"exec-opts":["native.cgroupdriver=systemd"],
"registry-mirrors": ["https://docker.unsee.tech","https://dockerpull.org","https://docker.1panel.live","https://dockerhub.icu"]
}
[root@master ~]# systemctl daemon-reload &&systemctl restart docker
[root@master ~]# docker pull docker.io/calico/cni:master
[root@master ~]# docker pull docker.io/calico/node:master
[root@master ~]# docker pull docker.io/calico/kube-controllers:master
[root@master ~]# curl -o calico.yaml  https://github.com/projectcalico/calico/blob/master/manifests/calico.yaml
[root@master ~]# kubectl apply -f calico.yaml 
[root@master ~]# kubectl get  pods -n kube-system
NAME                                       READY   STATUS    RESTARTS       AGE
calico-kube-controllers-7bcf789c97-vszz9   1/1     Running   0              24s
calico-node-cvspq                          1/1     Running   0              24s
coredns-855c4dd65d-c6mrt                   1/1     Running   0              24m
coredns-855c4dd65d-jdxjb                   1/1     Running   0              24m
etcd-master                                1/1     Running   1 (14m ago)    24m
kube-apiserver-master                      1/1     Running   1 (14m ago)    24m
kube-controller-manager-master             1/1     Running   2 (2m2s ago)   24m
kube-proxy-ll54k                           1/1     Running   1 (14m ago)    24m
kube-scheduler-master                      1/1     Running   1 (14m ago)    24m
[root@master ~]# kubectl get nodes
NAME     STATUS   ROLES           AGE   VERSION
master   Ready    control-plane   25m   v1.31.2

8.k8s命令补全

[root@master ~]# yum -y install bash-completion
[root@master ~]# source /usr/share/bash-completion/bash_completion
[root@master ~]# source <(kubectl completion bash)
[root@master ~]# echo "source <(kubectl completion bash)" >> ~/.bashrc
[root@master ~]# kubectl 
annotate       (更新一个资源的注解)                                                                                   explain        (Get documentation for a resource)
api-resources  (Print the supported API resources on the server)                                                      expose         (Take a replication controller, service, deployment or pod and expose it as a new Kubernetes service)
api-versions   (Print the supported API versions on the server, in the form of "group/version")                       get            (显示一个或多个资源)
apply          (Apply a configuration to a resource by file name or stdin)                                            help           (Help about any command)
attach         (挂接到一个运行中的容器)                                                                               kustomize      (Build a kustomization target from a directory or URL)
auth           (Inspect authorization)                                                                                label          (更新某资源上的标签)
autoscale      (Auto-scale a deployment, replica set, stateful set, or replication controller)                        logs           (打印 Pod 中容器的日志)
certificate    (Modify certificate resources)                                                                         options        (输出所有命令的层级关系)
cluster-info   (Display cluster information)                                                                          patch          (Update fields of a resource)
completion     (Output shell completion code for the specified shell (bash, zsh, fish, or powershell))                plugin         (Provides utilities for interacting with plugins)
config         (修改 kubeconfig 文件)                                                                                 port-forward   (将一个或多个本地端口转发到某个 Pod)
cordon         (标记节点为不可调度)                                                                                   proxy          (运行一个指向 Kubernetes API 服务器的代理)
cp             (Copy files and directories to and from containers)                                                    replace        (Replace a resource by file name or stdin)
create         (Create a resource from a file or from stdin)                                                          rollout        (Manage the rollout of a resource)
debug          (Create debugging sessions for troubleshooting workloads and nodes)                                    run            (在集群上运行特定镜像)
delete         (Delete resources by file names, stdin, resources and names, or by resources and label selector)       scale          (Set a new size for a deployment, replica set, or replication controller)
describe       (显示特定资源或资源组的详细信息)                                                                       set            (为对象设置指定特性)
diff           (Diff the live version against a would-be applied version)                                             taint          (更新一个或者多个节点上的污点)
drain          (清空节点以准备维护)                                                                                   top            (Display resource (CPU/memory) usage)
edit           (编辑服务器上的资源)                                                                                   uncordon       (标记节点为可调度)
events         (List events)                                                                                          version        (输出客户端和服务端的版本信息)
exec           (在某个容器中执行一个命令)                                                                             wait           (Experimental: Wait for a specific condition on one or many resources)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/475543.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

TR3:Pytorch复现Transformer

&#x1f368; 本文为&#x1f517;365天深度学习训练营 中的学习记录博客&#x1f356; 原作者&#xff1a;K同学啊 一、实验目的 从整体上把握Transformer模型&#xff0c;明白它是个什么东西&#xff0c;可以干嘛读懂Transformer的复现代码 二、实验环境 语言环境&#xff1…

【蓝桥杯算法】Java的基础API

1. BigInteger 的使用 1.1. 判素数 package 模板;import java.math.BigInteger; import java.util.Scanner;public class 判素数 {static Scanner in new Scanner(System.in);public static void main(String[] args) {int q in.nextInt();while (q-- > 0) {BigInteger …

跟着问题学2——传统神经网络-多层感知机详解

相关文章 跟着问题学1——传统神经网络-线性回归及代码详解_深度学习中非线性变换代码-CSDN博客 问题 从线性回归到多层感知机 上节我们介绍了最基础的传统神经网络——线性回归&#xff0c;讲述了神经网络最基础的几个部分&#xff0c;模型创建&#xff0c;数据收集&#xf…

如何在Ubuntu当中利用CloudCompare软件进行点云配准拼接?

1.首先需要安装相应的cloudcompare软件&#xff0c;以下有两种方式&#xff1a;第一种直接在ubuntu的软件商店里搜索CloudCompare软件进行install&#xff0c;我这里已经安装完毕。 方式二&#xff1a;可以直接原码安装&#xff1a; github地址&#xff1a; https://github.co…

Vue3、Vite5、Primevue、Oxlint、Husky9 简单快速搭建最新的Web项目模板

Vue3、Vite5、Oxlint、Husky9 简单搭建最新的Web项目模板 特色进入正题创建基础模板配置API自动化导入配置组件自动化导入配置UnoCss接入Primevue接入VueRouter4配置项目全局环境变量 封装Axios接入Pinia状态管理接入Prerttier OXLint ESLint接入 husky lint-staged&#xf…

智能购物时代:AI在电商平台的革命性应用

在当今数字化时代&#xff0c;人工智能&#xff08;AI&#xff09;技术已成为推动电商行业发展的关键力量。AI技术的应用不仅改变了电商的运营模式&#xff0c;还极大地丰富了消费者的购物体验。随着技术的不断进步&#xff0c;AI在电商领域的应用越来越广泛&#xff0c;从个性…

uniapp vue3小程序报错Cannot read property ‘__route__‘ of undefined

在App.vue里有监听应用的生命周期 <script>// 只能在App.vue里监听应用的生命周期export default {onError: function(err) {console.log(AppOnError:, err); // 当 uni-app 报错时触发}} </script>在控制台打印里无意发现 Cannot read property ‘__route__‘ of …

昇思MindSpore第四课---GPT实现情感分类

1. GPT的概念 GPT 系列是 OpenAI 的一系列预训练模型&#xff0c;GPT 的全称是 Generative Pre-Trained Transformer&#xff0c;顾名思义&#xff0c;GPT 的目标是通过Transformer&#xff0c;使用预训练技术得到通用的语言模型。和BERT类似&#xff0c;GPT-1同样采取pre-trai…

解读缓存问题的技术旅程

目录 前言1. 问题的突发与初步猜测2. 缓存的“隐身术”3. 缓存策略的深层优化4. 反思与感悟结语 前言 那是一个普通的工作日&#xff0c;团队例行的早会刚刚结束&#xff0c;我正准备继续优化手头的模块时&#xff0c;突然收到了用户反馈。反馈的内容是部分数据显示异常&#…

WPS 加载项开发说明wpsjs

wpsjs几个常用的CMD命令&#xff1a; 1.打开cmd输入命令测试版本号 npm -v 2.首次安装nodejs&#xff0c;npm默认国外镜像&#xff0c;包下载较慢时&#xff0c;可切换到国内镜像 //下载速度较慢时可切换国内镜像 npm config set registry https://registry.npmmirror.com …

【深度学习】循环神经网络及文本生成模型构建

循环神经网络 词嵌入层 ​ 词嵌入层的作用就是将文本转换为向量。 ​ 词嵌入层首先会根据输入的词的数量构建一个词向量矩阵&#xff0c;例如: 我们有 100 个词&#xff0c;每个词希望转换成 128 维度的向量&#xff0c;那么构建的矩阵形状即为: 100*128&#xff0c;输入的每…

论文阅读:Uni-ISP Unifying the Learning of ISPs from Multiple Cameras

这是 ECCV 2024 的一篇文章&#xff0c;文章作者想建立一个统一的 ISP 模型&#xff0c;以实现在不同手机之间的自由切换。文章作者是香港中文大学的 xue tianfan 和 Gu jinwei 老师。 Abstract 现代端到端图像信号处理器&#xff08;ISPs&#xff09;能够学习从 RAW/XYZ 数据…

ROS2指令总结(跟随古月居教程学习)

​ 博主跟随古月居博客进行ROS2学习&#xff0c;对ROS2相关指令进行了总结&#xff0c;方便学习和回顾。 古月居ROS2博文链接&#xff1a;https://book.guyuehome.com/ 本文会持续进行更新&#xff0c;觉得有帮助的朋友可以点赞收藏。 1. ROS2安装命令 $ sudo apt update &am…

Qt不同类之间参数的传递

一、信号槽方式 1: 在需要发送信号的子类增加一个信号函数 void set_send(double lonx, double laty);sub.h sub.cpp emit set_send(lonx,laty);2: 在需要接收信号的类增加一个槽函数 main.h void set_rece(double lonx, double laty);main.cpp 1&#xff09;引入子类头文…

labview记录系统所用月数和天数

在做项目时会遇到采集系统的记录&#xff0c;比如一个项目测试要跑很久这个时候就需要在软件系统上显示项目运行了多少天&#xff0c;从开始测试开始一共用了多少年多少月。 年的话还好计算只需要把年份减掉就可以了&#xff0c;相比之下月份和天数就比较难确定&#xff0c;一…

机器翻译基础与模型 之一: 基于RNN的模型

一、机器翻译发展历程 基于规则的-->基于实例的-->基于统计方法的-->基于神经网络的 传统统计机器翻译把词序列看作离散空间里的由多个特征函数描述的点&#xff0c;类似 于 n-gram 语言模型&#xff0c;这类模型对数据稀疏问题非常敏感。神经机器翻译把文字序列表示…

WPF Prism框架

一、关于Prism框架 Prism.Core:【Prism.dll】实现MVVM的核心功能&#xff0c;属于一个与平台无关的项目 Prism.Wpf&#xff1a;【Prism.Wpf】包含了DialogService,Region,Module,Navigation,其他的一些WPF的功能 Prism.Unity:【Prism.Unity.Wpf】,IOC容器 Prism.Unity>Pr…

STM32F103系统时钟配置

时钟是单片机运行的基础&#xff0c;时钟信号推动单片机内各个部分执行相应的指令。时钟系统就是CPU的脉搏&#xff0c;决定CPU速率&#xff0c;像人的心跳一样 只有有了心跳&#xff0c;人才能做其他的事情&#xff0c;而单片机有了时钟&#xff0c;才能够运行执行指令&#x…

2024年 Web3开发学习路线全指南

Web3是一个包含了很多领域的概念&#xff0c;不讨论币圈和链圈的划分&#xff0c;Web3包括有Defi、NFT、Game等基于区块链的Dapp应用的开发&#xff1b;也有VR、AR等追求视觉沉浸感的XR相关领域的开发&#xff1b;还有基于区块链底层架构或者协议的开发。 这篇文章给出的学习路…

CTF--php伪协议结合Base64绕过

Base64绕过 在ctf中&#xff0c;base64是比较常见的编码方式&#xff0c;在做题的时候发现自己对于base64的编码和解码规则不是很了解&#xff0c;并且恰好碰到了类似的题目&#xff0c;在翻阅了大佬的文章后记录一下&#xff0c;对于base64编码的学习和一个工具 base64编码是…