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 ...
随机推荐
- 【每日一题】【暴力&双指针&动态规划】42. 接雨水-211130/220214
给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水. 方法1:暴力求解(超时) import java.util.*; public class Solu ...
- Windows10下python3和python2同时安装(二)python2.exe、python3.exe和pip2、pip3设置
Windows10下python3和python2同时安装(二) python2.exe.python3.exe和pip2.pip3设置 说明:安装安装python3和python2请参考本系列教程( ...
- react 高效高质量搭建后台系统 系列 —— 脚手架搭建
其他章节请看: react 高效高质量搭建后台系统 系列 脚手架搭建 本篇主要创建新项目 myspug,以及准备好环境(例如:安装 spug 中用到的包.本地开发和部署.自定义配置 react-app ...
- vlc qt player 播放器开发实例
(一)VLC-Qt下载 官网地址:https://vlc-qt.tano.si/ Github 地址:https://github.com/vlc-qt 示例地址:https://github.com ...
- vulnhub靶场之IA: KEYRING (1.0.1)
准备: 攻击机:虚拟机kali.本机win10. 靶机:IA: KEYRING (1.0.1),下载地址:https://download.vulnhub.com/ia/keyring-v1.01.o ...
- Web初级——数组对象常用api
js数组常用api 连接函数:join("连接符") var array = [1,2,3,4,5] console.log(array.join("+")) ...
- [Leetcode]环形链表 II
题目 代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * Li ...
- [LeetCode]226.翻转二叉树——递归遍历交换孩子
题目 翻转一棵二叉树. 4 / \ 2 7 / \ / \ 1 3 6 9 //转换为: 4 / \ 7 2 / \ / \ 9 6 3 1 代码 TreeNode* invertTree(Tre ...
- 1.【窗口组件】小部件-QWidgt
一.前言 QWidget翻译过来是小部件的意思,QWidgt 类是所有用户界面对象的基类. 窗口部件是用户界面的一个基本单元:它从窗 口系统接收鼠标.键盘和其它事件,并且在屏幕上绘制自己.每一个窗口部 ...
- SICP:复数的直角和极坐标的表示(Python实现)
绪论 我们已经介绍过数据抽象,这是一种构造系统的方法学,它能够使程序中的大部分描述与其所操作的数据对象的具体表示无关,比如一个有理数程序的设计与有理数的实现相分离.这里的关键是构筑数据抽象屏障--在有 ...