首页 > 系统相关 >AlmaLinux 系统搭建 K8s 集群

AlmaLinux 系统搭建 K8s 集群

时间:2022-12-18 11:00:16浏览次数:69  
标签:00 x86 kubernetes AlmaLinux 64 yum key 集群 K8s

前言

容器技术:有效的将单个操作系统的资源划分到孤立的组中,技术核心就是通过对资源的限制和隔离把进程运行在一个沙盒中。 并且这个沙盒可以被打包成容器镜像(Image),任意地跨平台移植到另一台机器上可以直接运行,不需要任何的多余配置,其中 Docker 是容器技术的基础标准。

k8s 在 Docker 技术的基础上,为容器化的应用提供部署运行、资源调度、服务发现和动态伸缩等一系列完整功能,提高了大规模容器集群管理的便捷性。

实操动手搭建一套 K8s 集群环境,系统深入的学习容器技术,边搭建安装边记录实操整个过程,更好分享给各位有需要的同学们,希望同学们能少踩点坑,更快更高效的掌握容器相关技术,绝对不会错。


系统平台

操作系统: AlmaLinux 8.7 Linux 4.18.0-425.3.1.el8.x86_64

AlmaLinux 系统搭建 K8s 集群_Docker


​Kubernetes 集群资源规划

AlmaLinux 系统搭建 K8s 集群_git_02

架构图

AlmaLinux 系统搭建 K8s 集群_Docker_03

如下是收集其他网友的架构图,供参考学习。

AlmaLinux 系统搭建 K8s 集群_centos_04

AlmaLinux 系统搭建 K8s 集群_Docker_05


下面开始动手安装,准备基础环境。


系统更新,所有主机上都需要执行。

AlmaLinux 系统搭建 K8s 集群_Docker_06


安装所需的依赖包,所有主机上都需要执行。

AlmaLinux 系统搭建 K8s 集群_Docker_07

所有主机上,都需安装配置 Docker ,添加阿里云 yum 源,并指定版本安装。

如下图所执行指令截图:

AlmaLinux 系统搭建 K8s 集群_centos_08

开始执行安装

​# yum install --allowerasing docker-ce-3:20.10.21-3.el8​

AlmaLinux 系统搭建 K8s 集群_Docker_09

可以看到 Docker 容器已安装完成,也正常启动 Docker 服务。

如不能正常顺利的安装 Docker 容器,就需要到如下镜像站点,下载缺失的依赖包,再继续接着安装即可完成安装。

官方镜像链接: ​​https://download.docker.com/linux/centos/​

AlmaLinux 系统搭建 K8s 集群_Docker_10

设置系统时区并同步时间服务器

[root@k8smaster scm]# rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
Retrieving http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:wlnmp-release-centos-2-1 ################################# [100%]
[root@gitlabcicd scm]# yum install ntpdate -y
gitlab_gitlab-ce 96 B/s | 862 B 00:08
gitlab_gitlab-ce-source 197 B/s | 862 B 00:04
Kubernetes 1.9 kB/s | 844 B 00:00
Kubernetes 37 kB/s | 4.2 kB 00:00
Importing GPG key 0x13EDEF05:
Userid : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Importing GPG key 0x307EA071:
Userid : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2021-03-01-08_01_09.pub)"
Fingerprint: 7F92 E05B 3109 3BEF 5A3C 2D38 FEEA 9169 307E A071
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Importing GPG key 0xDC6315A3:
Userid : "Artifact Registry Repository Signer <[email protected]>"
Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Kubernetes 9.3 kB/s | 975 B 00:00
Importing GPG key 0x3E1BA8D5:
Userid : "Google Cloud Packages RPM Signing Key <[email protected]>"
Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
From : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Kubernetes 372 kB/s | 162 kB 00:00
wlnmp 2.1 MB/s | 2.2 MB 00:01
No match for argument: ntpdate
Error: Unable to find a match: ntpdate
[root@gitlabcicd scm]# dnf install wntp
Last metadata expiration check: 0:03:31 ago on Sun 11 Dec 2022 10:14:10 AM CST.
Dependencies resolved.
======================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================
Installing:
wntp x86_64 4.2.8p15-1.el8 wlnmp 1.9 M

Transaction Summary
======================================================================================================================================================================================
Install 1 Package

Total download size: 1.9 M
Installed size: 4.7 M
Is this ok [y/N]: y
Downloading Packages:
wntp-4.2.8p15-1.el8.x86_64.rpm 2.3 MB/s | 1.9 MB 00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.3 MB/s | 1.9 MB 00:00
wlnmp 10 kB/s | 1.7 kB 00:00
Importing GPG key 0xBCC6A00D:
Userid : "wlnmp (GPG-RPM-KEY) <[email protected]>"
Fingerprint: 5D5B 5609 0305 9039 D96E 717C 9F3B A65F BCC6 A00D
From : https://mirrors.wlnmp.com/centos/RPM-GPG-KEY-wlnmp
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: wntp-4.2.8p15-1.el8.x86_64 1/1
Installing : wntp-4.2.8p15-1.el8.x86_64 1/1
Running scriptlet: wntp-4.2.8p15-1.el8.x86_64 1/1
Verifying : wntp-4.2.8p15-1.el8.x86_64 1/1

Installed:
wntp-4.2.8p15-1.el8.x86_64

Complete!
[root@k8smaster scm]#
[root@k8smaster scm]# ntpdate ntp1.aliyun.com
11 Dec 10:19:53 ntpdate[9498]: adjust time server 120.25.115.20 offset -0.384307 sec
[root@k8smaster scm]#
[root@k8smaster scm]# date
Sun Dec 11 10:19:57 CST 2022
[root@k8smaster scm]#

AlmaLinux 系统搭建 K8s 集群_Docker_11


添加 kubernetes 阿里云 YUM 软件源

阿里云 yum 源
#################################################################################
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

AlmaLinux 系统搭建 K8s 集群_Docker_12

阿里云镜像站

​https://mirrors.aliyun.com/kubernetes/yum/repos/?spm=a2c6h.25603864.0.0.2613274fi1jVZy​

AlmaLinux 系统搭建 K8s 集群_git_13

执行安装

#
[root@k8smaster yum.repos.d]# yum install -y kubeadm kubectl kubelet
Kubernetes 1.5 kB/s | 844 B 00:00
Kubernetes 50 kB/s | 4.2 kB 00:00
Importing GPG key 0x13EDEF05:
Userid : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Importing GPG key 0x307EA071:
Userid : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2021-03-01-08_01_09.pub)"
Fingerprint: 7F92 E05B 3109 3BEF 5A3C 2D38 FEEA 9169 307E A071
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Importing GPG key 0xDC6315A3:
Userid : "Artifact Registry Repository Signer <[email protected]>"
Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Kubernetes 10 kB/s | 975 B 00:00
Importing GPG key 0x3E1BA8D5:
Userid : "Google Cloud Packages RPM Signing Key <[email protected]>"
Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
From : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Kubernetes 284 kB/s | 162 kB 00:00
Dependencies resolved.
======================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================
Installing:
kubeadm x86_64 1.26.0-0 kubernetes 10 M
kubectl x86_64 1.26.0-0 kubernetes 11 M
kubelet x86_64 1.26.0-0 kubernetes 22 M
Installing dependencies:
cri-tools x86_64 1.25.0-0 kubernetes 8.2 M
kubernetes-cni x86_64 1.1.1-0 kubernetes 15 M

Transaction Summary
======================================================================================================================================================================================
Install 5 Packages

Total download size: 66 M
Installed size: 290 M
Downloading Packages:
(1/5): e382ead81273ab8ebcddf14cc15bf977e44e1fd541a2cfda6ebe5741c255e59f-cri-tools-1.25.0-0.x86_64.rpm 997 kB/s | 8.2 MB 00:08
(2/5): da58cbf31a0337a968e5a06cfcc00eee420cc2df8930ea817ed2a4227bd81d48-kubeadm-1.26.0-0.x86_64.rpm 1.0 MB/s | 10 MB 00:10
(3/5): 23e112935127da08ffd1c32c392cbf62346305ee97ba6c5d070cda422945e4ff-kubectl-1.26.0-0.x86_64.rpm 987 kB/s | 11 MB 00:11
(4/5): 14083ac8b11792469524dae98ebb6905b3921923937d6d733b8abb58113082b7-kubernetes-cni-1.1.1-0.x86_64.rpm 845 kB/s | 15 MB 00:18
(5/5): 9be8590c2de60e249f40726e979a3a7a046320079bc41d330834de74f5399383-kubelet-1.26.0-0.x86_64.rpm 807 kB/s | 22 MB 00:27
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.8 MB/s | 66 MB 00:36
Kubernetes 45 kB/s | 4.2 kB 00:00
Importing GPG key 0x13EDEF05:
Userid : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Importing GPG key 0x307EA071:
Userid : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2021-03-01-08_01_09.pub)"
Fingerprint: 7F92 E05B 3109 3BEF 5A3C 2D38 FEEA 9169 307E A071
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Importing GPG key 0xDC6315A3:
Userid : "Artifact Registry Repository Signer <[email protected]>"
Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
From : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Kubernetes 11 kB/s | 975 B 00:00
Importing GPG key 0x3E1BA8D5:
Userid : "Google Cloud Packages RPM Signing Key <[email protected]>"
Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
From : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : kubernetes-cni-1.1.1-0.x86_64 1/5
Installing : kubelet-1.26.0-0.x86_64 2/5
Installing : kubectl-1.26.0-0.x86_64 3/5
Installing : cri-tools-1.25.0-0.x86_64 4/5
Installing : kubeadm-1.26.0-0.x86_64 5/5
Running scriptlet: kubeadm-1.26.0-0.x86_64 5/5
Verifying : cri-tools-1.25.0-0.x86_64 1/5
Verifying : kubeadm-1.26.0-0.x86_64 2/5
Verifying : kubectl-1.26.0-0.x86_64 3/5
Verifying : kubelet-1.26.0-0.x86_64 4/5
Verifying : kubernetes-cni-1.1.1-0.x86_64 5/5

Installed:
cri-tools-1.25.0-0.x86_64 kubeadm-1.26.0-0.x86_64 kubectl-1.26.0-0.x86_64 kubelet-1.26.0-0.x86_64 kubernetes-cni-1.1.1-0.x86_64

Complete!
[root@k8smaster yum.repos.d]# yum install -y kubeadm kubectl kubelet
Last metadata expiration check: 0:01:07 ago on Sun 11 Dec 2022 10:24:14 AM CST.
Package kubeadm-1.26.0-0.x86_64 is already installed.
Package kubectl-1.26.0-0.x86_64 is already installed.
Package kubelet-1.26.0-0.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@k8smaster yum.repos.d]#

AlmaLinux 系统搭建 K8s 集群_centos_14

AlmaLinux 系统搭建 K8s 集群_centos_15

导出集群初始化配置文件

AlmaLinux 系统搭建 K8s 集群_Docker_16

标签:00,x86,kubernetes,AlmaLinux,64,yum,key,集群,K8s
From: https://blog.51cto.com/wst021sh/5950822

相关文章

  • Kubernetes(k8s) kubectl rollout status常用命令
    kubectl在$HOME/.kube目录中查找一个名为config的配置文件。可以通过设置KUBECONFIG环境变量或设置--kubeconfig参数来指定其它kubeconfig文件。本文主要介绍K......
  • K8S的Kafka监控(Prometheus+Grafana)
    欢迎访问我的GitHub这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos对于部署在K8S上的Kafka来说,Prometheus+Grafana是常用的监控......
  • TIDB-DM数据迁移第三部(集群管理)
    1、对现在dm集群进行缩容,将free状态的worker下线。tiupdmdisplaydm-test查看free状态节点tiupdmscale-indm172.16.1.13:8262-N2、扩容DM集群我是......
  • K8S基础-POD
    1.1POD1.1.1创建一个pod定义一个pod(分层使用两个空格,勿用tab键)#vimnginx.yamlapiVersion:v1#必选,API的版本号kind:Pod#必选,类型Podmetadata:#必......
  • K8s-发布方式浅谈
    K8s-发布方式浅谈蓝绿发布环境存在两个版本,蓝版本和绿版本同时存在,部署新版本然后进行测试,将流量切到新版本,最终实际运行的只有一个版本(蓝/绿)。好处是无需停机,并......
  • 解决k8s中service暴露的端口使用公网ip无法访问
    背景在华为云服务器上使用kk工具安装k8s+kubesphere,正常安装后无法通过公网ip+端口号的方式访问kubesphere页面(ps:华为云上的安全组已经放开)解决办法在命令行执行iptable......
  • Etcd高可用集群扩容,故障恢复
    etcd是一个开源的分布式键值对数据库,他的每一个节点都有一份数据的copy,当有节点故障时保证了高可用性。etcd使用Raft算法来保证一致性。特别提醒:若使用v3备份数据时存在v2的......
  • 主备集群增加异步备机
    背景因用户需要增加远程异地灾备功能,用户要求远距离的备机不能影响原有的主备集群,允许有远程备机有一定延迟,现测试在主备集群增加一台异步备机 IP规划:主机名服......
  • k8s 网络抓包
    背景工具介绍nsenter是一款可以进入进程的名称空间中。例如,如果一个容器以非root用户身份运行,而使用 ​​dockerexec​​​ 进入其中后,但该容器没有安装 ​​sudo​......
  • (六) 分库分表与集群
    分库分表一、为什么要分库分表关系型数据库以MySQL为例,单机的存储能力、连接数是有限的,它自身就很容易会成为系统的瓶颈。当单表数据量在百万以里时,我们还可以通过添加从......