K3S部署

2024-06-15 08:20
文章标签 部署 k3s

本文主要是介绍K3S部署,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

k3s官网

一个server端、一个Agent端,
Kubernetes control plane 组件的操作都封装在单个二进制文件和进程中

requirements

  • 最低1U 512MB K3s 的性能取决于数据库的性能。
  • 为确保最佳速度,我们建议尽可能使用 SSD K3s 服务器
  • 需要端口 6443 才能被所有节点访问2379,2380。

脚本方式安装

curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
  • kubeconfig 文件位于/etc/rancher/k3s/k3s.yaml

加载镜像(所有节点都需要操作)

github上找到对应release下载

mkdir -p /var/lib/rancher/k3s/agent/images/
wget https://github.com/k3s-io/k3s/releases/download/v1.30.0%2Bk3s1/k3s-airgap-images-amd64.tar.gz
ctr i import  k3s-airgap-images-amd64.tar

加入节点(如果你想-可选)

K3S_URL 参数会导致安装程序将 K3s 配置为 Agent 而不是 Server。K3s Agent 将注册到在 URL 上监听的 K3s Server。myserver写server IP地址
K3S_TOKEN 使用的值存储在 Server 节点上的 /var/lib/rancher/k3s/server/node-token 中

curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -

=========================================

卸载server(在server上执行)

分别会在各个节点上有相应的卸载脚本

/usr/local/bin/k3s-uninstall.sh

卸载agent(在agent上执行)

/usr/local/bin/k3s-agent-uninstall.sh
#/usr/local/bin/k3s-killall.sh	停止
#systemctl start k3s-agent 启动

=========================================

创建镜像仓库

创建镜像仓库日后在写

没用的东西不看

k3s Installation
Introduction
In this lab we will be installing k3s.Prerequisite
All of our labs are built upon one another. Please make sure all previous labs are completed before starting this lab.Workflow
Hardware
For this lab we are going to need at least two virtual machine or a physical machine to install k3s on. The machines need to be of a particular architecture outlined here:x86_64
armhf
arm64/aarch64
s390x
Each of these machines need the minimum requirements:CPU: 1 core
Ram: 512 MB
Recommended:CPU: 2 cores
RAM: 1 GB
Operating System
K3s will work on most modern Linux system. Note there are differences for CentOS/Red Hat and Raspberry Pi OS.For these labs we will be using openSUSE Leap.k3s Version
In this course we are going to do an upgrade to a newer version of k3s. To do this we are going to need to find the latest version of k3s and take the stable release one minor version back.For example if the latest release of the latest version of k3s is v1.27.4+k3s1 we are going to want to use the v1.26.7+k3s1 of k3s.You can find the latest versions of k3s here.NOTE: don't try this lab with any marked as Pre-release.Server Script Install
One of the easiest ways to install k3s is by the installation script.You will need to ssh in to the server node.The install script lives here https://get.k3s.io/. To run this we are going to use a few flags:curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.26.7+k3s1 INSTALL_K3S_EXEC="server --cluster-init --node-ip 192.168.3.2 --node-external-ip 192.168.3.2" sh -s -
NOTE: the k3s version might not be the one prior to the latest! Check here for the correct version.This setups up the server installation on our server VM.To test to see if everything is running k3s comes with kubectl so while still logged in to our server instance we can do a quick check to make sure all is running:k3s kubectl get pods -A
And you should see the following output:NAMESPACE     NAME                                     READY   STATUS      RESTARTS   AGE
kube-system   local-path-provisioner-957fdf8bc-sd297   1/1     Running     0          107s
kube-system   coredns-77ccd57875-sbrsl                 1/1     Running     0          107s
kube-system   helm-install-traefik-crd-7926x           0/1     Completed   0          107s
kube-system   helm-install-traefik-rswvl               0/1     Completed   1          107s
kube-system   metrics-server-648b5df564-5xbcw          1/1     Running     0          107s
kube-system   svclb-traefik-ea396d7d-4h9f6             2/2     Running     0          53s
kube-system   traefik-64f55bb67d-5cqxm                 1/1     Running     0          53s
Once you see that the system pods are either Running or Completed we need to get the token from the server to do so run the following command:sudo cat /var/lib/rancher/k3s/server/node-token
You will get the token needed for adding the agent (Note: it will not be this exact key):K105b9c68df80752c8f9d498097b764a35f9ba2c0220b2ea8951cef3aca111d9f33::server:2855bde078f38f3964f3f36e6e37dfbb
To logout of the server vm.Agent Script Install
Now we need to install k3s on the agent vm.First let's remote in to our agent vm.Again the install script lives here https://get.k3s.io/. To run this we are going to use a few flags (Note: this will take a few moments.):curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.26.7+k3s1 INSTALL_K3S_EXEC="agent --server https://192.168.3.2:6443 --node-ip 192.168.3.3 --node-external-ip 192.168.3.3" K3S_TOKEN=K105b9c68df80752c8f9d498097b764a35f9ba2c0220b2ea8951cef3aca111d9f33::server:2855bde078f38f3964f3f36e6e37dfbb K3S_NODE_NAME=agent sh -
NOTE: the k3s version might not be the one prior to the latest! Check here for the correct version.NOTE: The K3S_TOKEN is the token we pulled from the server earlier.kubectl Remotely
Just so we don't have to remain logged into the server VM let's copy down the config:ssh server -c "sudo cat /etc/rancher/k3s/k3s.yaml" > k3s.yaml
This will copy down the KUBECONFIG file down from the server.We are going to need to modify the k3s.yaml file:apiVersion: v1
clusters:
- cluster:certificate-authority-data: LS0tLS1CRUserver: https://127.0.0.1:6443name: default
contexts:
- context:cluster: defaultuser: defaultname: default
current-context: default
kind: Config
preferences: {}
users:
- name: defaultuser:client-certificate-data: LS0tLS1CRUclient-key-data: LS0tLS1CRU(Note: the certificate data has been cut down.)We are going to need to change the variable of the server from:server: https://127.0.0.1:6443
To the following:server: https://192.168.3.2:6443
Now we are going to copy this k3s.yaml file to our .kube directory:cp k3s.yaml $HOME/.kube
From there we are going to set the KUBECONFIG variable to the location of the k3s.yaml file:export KUBECONFIG=$HOME/.kube/k3s.yaml
To test to see if this works we can run the following this command:kubectl get nodes
And you should see something like this:NAME     STATUS   ROLES                       AGE    VERSION
agent    Ready    <none>                      21s    v1.26.7+k3s1
server   Ready    control-plane,etcd,master   3m9s   v1.26.7+k3s1

这篇关于K3S部署的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1062920

相关文章

闲置电脑也能活出第二春?鲁大师AiNAS让你动动手指就能轻松部署

对于大多数人而言,在这个“数据爆炸”的时代或多或少都遇到过存储告急的情况,这使得“存储焦虑”不再是个别现象,而将会是随着软件的不断臃肿而越来越普遍的情况。从不少手机厂商都开始将存储上限提升至1TB可以见得,我们似乎正处在互联网信息飞速增长的阶段,对于存储的需求也将会不断扩大。对于苹果用户而言,这一问题愈发严峻,毕竟512GB和1TB版本的iPhone可不是人人都消费得起的,因此成熟的外置存储方案开

阿里开源语音识别SenseVoiceWindows环境部署

SenseVoice介绍 SenseVoice 专注于高精度多语言语音识别、情感辨识和音频事件检测多语言识别: 采用超过 40 万小时数据训练,支持超过 50 种语言,识别效果上优于 Whisper 模型。富文本识别:具备优秀的情感识别,能够在测试数据上达到和超过目前最佳情感识别模型的效果。支持声音事件检测能力,支持音乐、掌声、笑声、哭声、咳嗽、喷嚏等多种常见人机交互事件进行检测。高效推

在 Windows 上部署 gitblit

在 Windows 上部署 gitblit 在 Windows 上部署 gitblit 缘起gitblit 是什么安装JDK部署 gitblit 下载 gitblit 并解压配置登录注册为 windows 服务 修改 installService.cmd 文件运行 installService.cmd运行 gitblitw.exe查看 services.msc 缘起

Solr部署如何启动

Solr部署如何启动 Posted on 一月 10, 2013 in:  Solr入门 | 评论关闭 我刚接触solr,我要怎么启动,这是群里的朋友问得比较多的问题, solr最新版本下载地址: http://www.apache.org/dyn/closer.cgi/lucene/solr/ 1、准备环境 建立一个solr目录,把solr压缩包example目录下的内容复制

Spring Roo 实站( 一 )部署安装 第一个示例程序

转自:http://blog.csdn.net/jun55xiu/article/details/9380213 一:安装 注:可以参与官网spring-roo: static.springsource.org/spring-roo/reference/html/intro.html#intro-exploring-sampleROO_OPTS http://stati

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群 华为云最近正在举办828 B2B企业节,Flexus X实例的促销力度非常大,特别适合那些对算力性能有高要求的小伙伴。如果你有自建MySQL、Redis、Nginx等服务的需求,一定不要错过这个机会。赶紧去看看吧! 什么是华为云Flexus X实例 华为云Flexus X实例云服务是新一代开箱即用、体

部署若依Spring boot项目

nohup和& nohup命令解释 nohup命令:nohup 是 no hang up 的缩写,就是不挂断的意思,但没有后台运行,终端不能标准输入。nohup :不挂断的运行,注意并没有后台运行的功能,就是指,用nohup运行命令可以使命令永久的执行下去,和用户终端没有关系,注意了nohup没有后台运行的意思;&才是后台运行在缺省情况下该作业的所有输出都被重定向到一个名为nohup.o

kubernetes集群部署Zabbix监控平台

一、zabbix介绍 1.zabbix简介 Zabbix是一个基于Web界面的分布式系统监控的企业级开源软件。可以监视各种系统与设备的参数,保障服务器及设备的安全运营。 2.zabbix特点 (1)安装与配置简单。 (2)可视化web管理界面。 (3)免费开源。 (4)支持中文。 (5)自动发现。 (6)分布式监控。 (7)实时绘图。 3.zabbix的主要功能

java计算机毕设课设—停车管理信息系统(附源码、文章、相关截图、部署视频)

这是什么系统? 资源获取方式在最下方 java计算机毕设课设—停车管理信息系统(附源码、文章、相关截图、部署视频) 停车管理信息系统是为了提升停车场的运营效率和管理水平而设计的综合性平台。系统涵盖用户信息管理、车位管理、收费管理、违规车辆处理等多个功能模块,旨在实现对停车场资源的高效配置和实时监控。此外,系统还提供了资讯管理和统计查询功能,帮助管理者及时发布信息并进行数据分析,为停车场的科学

01 Docker概念和部署

目录 1.1 Docker 概述 1.1.1 Docker 的优势 1.1.2 镜像 1.1.3 容器 1.1.4 仓库 1.2 安装 Docker 1.2.1 配置和安装依赖环境 1.3镜像操作 1.3.1 搜索镜像 1.3.2 获取镜像 1.3.3 查看镜像 1.3.4 给镜像重命名 1.3.5 存储,载入镜像和删除镜像 1.4 Doecker容器操作 1.4