K3S 系列文章-RHEL7.8 离线有代理条件下安装 K3S
一 基础信息
1.1 前提
- 本次安装的为 k3s 1.21.7+k3s1
- VM 版本为 RHEL 7.8, 7.9 或 8.2, 8.3, 8.4(K3s 官网要求)
- VM YUM 仓库:已配置对应版本的 RHEL 和 EPEL YUM 仓库
- VM 提供 root 权限
- 已配置 ntp(防止因为时间不一致导致的诡异问题)
- 提供 Proxy 访问互联网 K3s 相关域名;
- 端口要求,为了正常运行,K3s 需要在 K3s 节点和下游 Kubernetes 集群节点上开放一些端口。端口需求列出了不同集群类型的 K3s 和下游集群的所有必要端口。具体如下表:
K3S
| 协议 | 端口 | 源 | 目的 | 描述 |
|---|---|---|---|---|
| TCP | 6443 | K3s agent 节点 | K3s server 节点 | Kubernetes API Server |
| UDP | 8472 | K3s server 和 agent 节点 | K3s server 和 agent 节点 | 仅对 Flannel VXLAN 需要 |
| TCP | 10250 | K3s server 和 agent 节点 | K3s server 和 agent 节点 | Kubelet metrics |
成功:
如果以上前期条件均已满足。
即可以通过「离线 - 有代理」方式进行安装。
1.2 VM 信息
️ 信息:
OS 配置 Proxy 过程略
1.2 Proxy 信息
ftp_proxy="http://192.168.0.1:8080"
http_proxy="http://192.168.0.1:8080"
https_proxy="http://192.168.0.1:8080"
proxy 需要 allow 的 doamin 如下:
| 域名 | 用途 |
|---|---|
| http://mirror.cnrancher.com | Rancher 国内组件源 |
| https://registry.cn-hangzhou.aliyuncs.com | Rancher 国内镜像源 |
| https://dockerauth.cn-hangzhou.aliyuncs.com | Rancher 国内镜像源 |
| http://mirrors.aliyun.com | YUM 源 |
| https://mirrors.aliyun.com | YUM 源 |
| https://rpm.rancher.com | Rancher 源 |
评论:
以上的 allowed domain 可能不全,需要进一步补充。
二 「离线 - 有代理」方式安装
评论:
本次环境为:离线,有代理。
通过代理安装部署。
- 假设 K3s 所在主机 IP 地址为:192.168.0.101
- 假设需要安装在
/data目录下
2.1 安装 K3S
(可选)创建私有仓库配置:
# mkdir -p /data/rancher/k3s
# vi /data/rancher/k3s/registries.yaml
mirrors:
docker.io:
endpoint:
- "https://registry.cn-hangzhou.aliyuncs.com"
- "https://docker.mirrors.ustc.edu.cn"
安装 K3S:
# curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_SKIP_DOWNLOAD=false INSTALL_K3S_VERSION=v1.21.7+k3s1 K3S_KUBECONFIG_MODE="644" INSTALL_K3S_MIRROR=cn K3S_CLUSTER_INIT INSTALL_K3S_EXEC="--tls-san 192.168.0.101 --pause-image registry.cn-hangzhou.aliyuncs.com/rancher/pause:3.6 --private-registry '/data/rancher/k3s/registries.yaml' --data-dir /data/rancher/k3s --default-local-storage-path /data/rancher/k3s/storage --disable-cloud-controller" sh -s -
输出如下:
[INFO] Using v1.21.7+k3s1 as release
[INFO] Downloading hash http://rancher-mirror.cnrancher.com/k3s/v1.21.7-k3s1/sha256sum-amd64.txt
[INFO] Downloading binary http://rancher-mirror.cnrancher.com/k3s/v1.21.7-k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/2): epel/x86_64/primary_db | 7.0 MB 00:00:02
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Transaction Summary
=============================================================================================================================================================
Install 1 Package
Total download size: 122 k
Installed size: 337 k
Downloading packages:
yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : yum-utils-1.1.31-54.el7_8.noarch 1/1
Verifying : yum-utils-1.1.31-54.el7_8.noarch 1/1
Installed:
yum-utils.noarch 0:1.1.31-54.el7_8
Complete!
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
rancher-k3s-common-stable | 2.9 kB 00:00:00
rancher-k3s-common-stable/primary_db | 2.8 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package k3s-selinux.noarch 0:0.5-1.el7 will be installed
--> Processing Dependency: container-selinux < 2:2.164.2 for package: k3s-selinux-0.5-1.el7.noarch
--> Processing Dependency: container-selinux >= 2.107-3 for package: k3s-selinux-0.5-1.el7.noarch
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
k3s-selinux noarch 0.5-1.el7 rancher-k3s-common-stable 15 k
Installing for dependencies:
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
Transaction Summary
=============================================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 55 k
Installed size: 124 k
Downloading packages:
(1/2): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
warning: /var/cache/yum/x86_64/$releasever/rancher-k3s-common-stable/packages/k3s-selinux-0.5-1.el7.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID e257814a: NOKEY
Public key for k3s-selinux-0.5-1.el7.noarch.rpm is not installed
(2/2): k3s-selinux-0.5-1.el7.noarch.rpm | 15 kB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 49 kB/s | 55 kB 00:00:01
Retrieving key from https://rpm.rancher.io/public.key
Importing GPG key 0xE257814A:
Userid : "Rancher (CI) <ci@rancher.com>"
Fingerprint: c8cf f216 4551 26e9 b9c9 18be 925e a29a e257 814a
From : https://rpm.rancher.io/public.key
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 1/2
Installing : k3s-selinux-0.5-1.el7.noarch 2/2
Verifying : k3s-selinux-0.5-1.el7.noarch 1/2
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 2/2
Installed:
k3s-selinux.noarch 0:0.5-1.el7
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8
Complete!
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
[INFO] systemd: Starting k3s
运行完成后,使用以下命令查看 K3S 运行状态:
# systemctl status k3s.service
● k3s.service - Lightweight Kubernetes
Loaded: loaded (/etc/systemd/system/k3s.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-01-29 17:05:45 CST; 18s ago
Docs: https://k3s.io
Process: 19436 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Process: 19433 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
Main PID: 19442 (k3s-server)
Tasks: 119
Memory: 586.7M
CGroup: /system.slice/k3s.service
├─19442 /usr/local/bin/k3s server
└─19557 containerd
Jan 29 17:06:03 example01 k3s[19442]: I0129 17:06:03.138349 19442 iptables.go:228] Adding iptables rule: -s 10.42.0.0/16 -d 10.42.0.0/16 -j RETURN
Jan 29 17:06:03 example01 k3s[19442]: I0129 17:06:03.140940 19442 iptables.go:228] Adding iptables rule: -d 10.42.0.0/16 -j ACCEPT
Jan 29 17:06:03 example01 k3s[19442]: I0129 17:06:03.142355 19442 iptables.go:228] Adding iptables rule: -s 10.42.0.0/16 ! -d 224.0.0.0...ASQUERADE
Jan 29 17:06:03 example01 k3s[19442]: I0129 17:06:03.145752 19442 iptables.go:228] Adding iptables rule: ! -s 10.42.0.0/16 -d 10.42.0.0...-j RETURN
Jan 29 17:06:03 example01 k3s[19442]: I0129 17:06:03.148358 19442 iptables.go:228] Adding iptables rule: ! -s 10.42.0.0/16 -d 10.42.0.0...ASQUERADE
Jan 29 17:06:03 example01 k3s[19442]: W0129 17:06:03.297662 19442 handler_proxy.go:101] no RequestInfo found in the context
Jan 29 17:06:03 example01 k3s[19442]: E0129 17:06:03.297804 19442 controller.go:116] loading OpenAPI spec for "v1beta1.metrics.k8s.io" ...available
Jan 29 17:06:03 example01 k3s[19442]: , Header: map[Content-Type:[text/plain; charset=utf-8] X-Content-Type-Options:[nosniff]]
Jan 29 17:06:03 example01 k3s[19442]: I0129 17:06:03.297827 19442 controller.go:129] OpenAPI AggregationController: action for item v1b... Requeue.
Jan 29 17:06:03 example01 k3s[19442]: I0129 17:06:03.551453 19442 request.go:668] Waited for 1.08111535s due to client-side throttling,...unt/token
Hint: Some lines were ellipsized, use -l to show in full.
使用如下命令查看 k3s 节点:
# k3s kubectl get node
NAME STATUS ROLES AGE VERSION
example01 Ready control-plane,master 3m37s v1.21.7+k3s1
️ 信息:
调整 K3S 安装目录后,k3s token 位置在:
/data/rancher/k3s/server/token
总结
至此,K3s 在离线-有代理条件下安装完成。
- Master 和 Server 地址:
192.168.0.101 - K3S API Server 地址:https://192.168.0.101:6443
- K3S kubeconfig 配置:位于
/etc/rancher/k3s/k3s.yaml - K3S 存放数据的目录:
/data/rancher/k3s - K3S 本地存储类的默认存储路径:
/data/rancher/k3s/storage
K3S 系列文章-RHEL7.8 离线有代理条件下安装 K3S的更多相关文章
- Python离线断网情况下安装numpy、pandas和matplotlib等常用第三方包
联网情况下在命令终端CMD中输入“pip install numpy”即可自动安装,pandas和matplotlib同理一样方法进行自动安装. 工作的电脑不能上外网,所以不能通过直接输入pip命令来 ...
- 彻底搞懂 etcd 系列文章(二):etcd 的多种安装姿势
0 专辑概述 etcd 是云原生架构中重要的基础组件,由 CNCF 孵化托管.etcd 在微服务和 Kubernates 集群中不仅可以作为服务注册与发现,还可以作为 key-value 存储的中间件 ...
- NHibernate系列文章十:NHibernate对象二级缓存下
摘要 上一节对NHibernate二级缓存做了简单介绍,NHibernate二级缓存是由SessionFactory管理的,所有Session共享.这一节介绍二级缓存其他两个方面:二级缓存查询和二级缓 ...
- Python学习系列之(二)图解Windows8.1下安装Django
一. 下载 去官网下载https://www.djangoproject.com/download/最新版,最新版本是1.6 二. 安装: 将下载下来的Django-1.6.tar.gz解压到D盘,接 ...
- 彻底搞懂 etcd 系列文章(三):etcd 集群运维部署
0 专辑概述 etcd 是云原生架构中重要的基础组件,由 CNCF 孵化托管.etcd 在微服务和 Kubernates 集群中不仅可以作为服务注册与发现,还可以作为 key-value 存储的中间件 ...
- Jenkins pipeline 入门到精通系列文章
Jenkins2 入门到精通系列文章. Jenkins2 下载与启动jenkins2 插件安装jenkins2 hellopipelinejenkins2 pipeline介绍jenkins2 jav ...
- Maven进价:Maven构建系列文章
Maven:基于Java平台的项目构建.依赖管理和项目信息管理. 1.构建 Maven标准化了构建过程 构建过程:编译.运行单元测试.生成文档.打包和部署 避免重复:设计.编码.文档.构建 2.依赖管 ...
- 安装Windows Server 2022 - 初学者系列 - 学习者系列文章
这天要写一个关于系统部署的系列文章,涉及到Windows Server 2022操作系统的安装,所以就写了此文.Windows系列的操作系统安装,以前的博文中都有介绍,这里再次做一个安装描述吧.需要的 ...
- 不同云服务器下,ubuntu下开k3s集群
首先先感谢老哥的文章:h构建多云环境下的K3S集群,但是我尝试在centos 8.2上面前面一直执行报错 并且安装glibc 2.17时还会报错make版本太低,所以直接放弃centos,投入ubun ...
- 与众不同 windows phone 8.0 & 8.1 系列文章索引
[源码下载] [与众不同 windows phone 7.5 (sdk 7.1) 系列文章索引] 与众不同 windows phone 8.0 & 8.1 系列文章索引 作者:webabcd ...
随机推荐
- 【Java SE】Day09 继承、super、this、抽象类
一.继承 1.概述 多个类具有相同属性和行为,共性抽取到一个类中(父类) 父类更通用,子类更具体 2.继承后的成员变量 本类:this.成员变量名 父类:super.成员变量名 3.继承后的成员方法 ...
- 【每日一题】【排序sort重载】【工具类】2021年12月23日-31. 下一个排列
实现获取 下一个排列 的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列(即,组合出下一个更大的整数). 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列). 必须 ...
- MySQL基础知识(二)-超详细 Linux安装MySQL5.7完整版教程及遇到的坑
1.简介 我们经常会在Linux上安装MySQL数据库,但是安装的时候总是会这里错,那里错,不顺利,今天整理了一下安装流程,连续安装来了两遍,没有遇到什么大错误,基本上十分钟左右可以搞定,教程如下.写 ...
- 第三方模块 request openpyxl
目录 第三方模块的下载 pip工具 简介 pip使用注意 pip位置和环境变量设置 pip安装第三方模块 使用pip下载可能会遇到的问题 pycharm的第三方模块下载功能 request模块 req ...
- 如何使用Abstract类?抽象类的威力
简介: 今天我想谈谈如何使用抽象类,以及抽象类真正的威力.本文将结合具体业务来说明如何使用抽象类. 业务简述: 本人目前只接触过PMS(物业管理系统),公司主要业务的是美国的租房业务.由于美国租房和中 ...
- Spring学习笔记 - 第二章 - 注解开发、配置管理第三方Bean、注解管理第三方Bean、Spring 整合 MyBatis 和 Junit 案例
Spring 学习笔记全系列传送门: Spring学习笔记 - 第一章 - IoC(控制反转).IoC容器.Bean的实例化与生命周期.DI(依赖注入) [本章]Spring学习笔记 - 第二章 - ...
- 【WPF】自定义一个自删除的多功能ListBox
原文地址 https://www.cnblogs.com/younShieh/p/17008534.html 如果本文对你有所帮助,不妨点个关注和推荐呀,这是对笔者最大的支持~ 我需要一个ListBo ...
- Django简介以及基本使用
目录 Django简介以及基本使用 一.django简介 1.web框架的本质是什么 ? 2.python主流web框架有那些 ? 3.web框架的推导过程 二.基本使用 1.运行django注意事项 ...
- [UOJ96] 【集训队互测2015】胡策的小树
先考虑不掺金坷垃的做法. 设猴子处于 \(i\) 节点的概率为 \(f_i\),列出方程如下(\(i\) 的祖先包括自身): \[f_i = \sum_{j为i祖先}\frac{1-p_j}{siz_ ...
- python基础23 之初识面向对象
人狗大战 # 编写代码简单实现人打狗 狗咬人的小游戏 """推导步骤1:代码定义出人和狗""" person1 = { 'name': 'j ...