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

相关文章

在Ubuntu上部署SpringBoot应用的操作步骤

《在Ubuntu上部署SpringBoot应用的操作步骤》随着云计算和容器化技术的普及,Linux服务器已成为部署Web应用程序的主流平台之一,Java作为一种跨平台的编程语言,具有广泛的应用场景,本... 目录一、部署准备二、安装 Java 环境1. 安装 JDK2. 验证 Java 安装三、安装 mys

Jenkins中自动化部署Spring Boot项目的全过程

《Jenkins中自动化部署SpringBoot项目的全过程》:本文主要介绍如何使用Jenkins从Git仓库拉取SpringBoot项目并进行自动化部署,通过配置Jenkins任务,实现项目的... 目录准备工作启动 Jenkins配置 Jenkins创建及配置任务源码管理构建触发器构建构建后操作构建任务

若依部署Nginx和Tomcat全过程

《若依部署Nginx和Tomcat全过程》文章总结了两种部署方法:Nginx部署和Tomcat部署,Nginx部署包括打包、将dist文件拉到指定目录、配置nginx.conf等步骤,Tomcat部署... 目录Nginx部署后端部署Tomcat部署出现问题:点击刷新404总结Nginx部署第一步:打包

Nginx、Tomcat等项目部署问题以及解决流程

《Nginx、Tomcat等项目部署问题以及解决流程》本文总结了项目部署中常见的four类问题及其解决方法:Nginx未按预期显示结果、端口未开启、日志分析的重要性以及开发环境与生产环境运行结果不一致... 目录前言1. Nginx部署后未按预期显示结果1.1 查看Nginx的启动情况1.2 解决启动失败的

闲置电脑也能活出第二春?鲁大师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实例云服务是新一代开箱即用、体