2024.9.14(RC和RS)

一、replicationcontroller (RC)

1、更改镜像站

[root@k8s-master ~]# vim /etc/docker/daemon.json

{"registry-mirrors": ["https://do.nark.eu.org","https://dc.j8.work","https://docker.m.daocloud.io","https://dockerproxy.com","https://docker.mirrors.ustc.edu.cn","https://docker.nju.edu.cn"]
}
2、加载启动docker服务

[root@k8s-master ~]# systemctl daemon-reload
[root@k8s-master ~]# systemctl start docker

3、拉取常用镜像

[root@k8s-master ~]# docker pull centos
[root@k8s-master ~]# docker pull nginx
[root@k8s-master ~]# docker pull mysql:5.7.44

[root@k8s-master ~]# docker pull haproxy

[root@k8s-master ~]# docker images

REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
haproxy      latest    a782c02b8259   10 days ago    103MB
nginx        latest    39286ab8a5e1   4 weeks ago    188MB
mysql        5.7.44    5107333e08a8   9 months ago   501MB
centos       latest    5d0da3dc9764   2 years ago    231MB
4、使用docker save指令打包镜像

[root@k8s-master ~]# docker save -o centos.tar centos:latest
[root@k8s-master ~]# docker save -o nginx.tar nginx:latest
[root@k8s-master ~]# docker save -o haproxy.tar haproxy:latest
[root@k8s-master ~]# docker save -o mysql.tar mysql:5.7.44

5、使用ctr指令将tar包导入到containerd的镜像中

[root@k8s-master ~]# ctr -n k8s.io images import centos.tar --platform=linux/amd64

[root@k8s-master ~]# ctr -n k8s.io images import nginx.tar --platform=linux/amd64

[root@k8s-master ~]# ctr -n k8s.io images import haproxy.tar --platform=linux/amd64

[root@k8s-master ~]# ctr -n k8s.io images import mysql.tar --platform=linux/amd64

6、查看containerd镜像列表

[root@k8s-master ~]# crictl images

IMAGE                                                                         TAG                 IMAGE ID            SIZE
docker.io/library/centos                                                      latest              5d0da3dc97646       239MB
docker.io/library/haproxy                                                     latest              a782c02b82595       106MB
docker.io/library/mysql                                                       5.7.44              5107333e08a87       520MB
docker.io/library/nginx                                                       latest              39286ab8a5e14       192MB
7、在node1和node2节点上引入tar包

[root@k8s-master ~]# scp /etc/docker/daemon.json root@192.168.8.178:/etc/docker/ 

[root@k8s-master ~]# scp ~/*.tar root@192.168.8.178:~/
[root@k8s-master ~]# scp mysql.tar root@192.168.8.178:~/
[root@k8s-master ~]# scp nginx.tar root@192.168.8.178:~/  
[root@k8s-master ~]# scp haproxy.tar root@192.168.8.178:~/  
[root@k8s-master ~]# scp centos.tar root@192.168.8.178:~/
[root@k8s-master ~]# scp /etc/docker/daemon.json root@192.168.8.168:/etc/docker/

[root@k8s-master ~]# scp ~/*.tar root@192.168.8.168:~/

[root@k8s-master ~]# scp centos.tar root@192.168.8.168:~/ 
[root@k8s-master ~]# scp haproxy.tar root@192.168.8.168:~/   
[root@k8s-master ~]# scp nginx.tar root@192.168.8.168:~/
[root@k8s-master ~]# scp mysql.tar root@192.168.8.168:~/

[root@k8s-node2 ~]# systemctl daemon-reload
[root@k8s-node2 ~]# systemctl start docker

[root@k8s-node1 ~]# systemctl daemon-reload
[root@k8s-node1 ~]# systemctl start docker

[root@k8s-node2 ~]# ctr -n k8s.io images import mysql.tar --platform=linux/amd64  //指定平台
[root@k8s-node2 ~]# ctr -n k8s.io images import nginx.tar --platform=linux/amd64
[root@k8s-node2 ~]# ctr -n k8s.io images import haproxy.tar --platform=linux/amd64
[root@k8s-node2 ~]# ctr -n k8s.io images import centos.tar --platform=linux/amd64
[root@k8s-node1 ~]# ctr -n k8s.io images import haproxy.tar --platform=linux/amd64
[root@k8s-node1 ~]# ctr -n k8s.io images import centos.tar --platform=linux/amd64
[root@k8s-node1 ~]# ctr -n k8s.io images import nginx.tar --platform=linux/amd64
[root@k8s-node1 ~]# ctr -n k8s.io images import mysql.tar --platform=linux/amd64

8、是由kubectl run 创建pod

[root@k8s-master ~]# kubectl run test001 --image docker.io/library/nginx:latest --image-pull-policy=IfNotPresent

[root@k8s-master ~]# kubectl get po

NAME                             READY   STATUS    RESTARTS   AGE
test001                          1/1     Running   0          84s

[root@k8s-master ~]# kubectl describe pod test001
[root@k8s-master ~]# kubectl describe pod test001

Events:Type    Reason     Age    From               Message----    ------     ----   ----               -------Normal  Scheduled  2m26s  default-scheduler  Successfully assigned default/test001 to k8s-node1Normal  Pulled     2m25s  kubelet            Container image "docker.io/library/nginx:latest" already present on machineNormal  Created    2m25s  kubelet            Created container test001Normal  Started    2m25s  kubelet            Started container test001
9、使用配置文件创建pod

[root@k8s-master ~]# vim test0007.yaml

apiVersion: v1
kind: Pod
metadata:name: test0007labels:name: test0007
spec:containers:-       name: test0007nginximage: docker.io/library/nginx:latestimagePullPolicy: IfNotPresentports:-       name: nginxportcontainerPort: 80

[root@k8s-master ~]# mv test0007.yaml pods/
[root@k8s-master ~]# cd pods/

[root@k8s-master pods]# kubectl create -f test0007.yaml 

[root@k8s-master pods]# kubectl get po

NAME                             READY   STATUS    RESTARTS   AGE
test0007                         1/1     Running   0          4s
10、添加两个容器

[root@k8s-master pods]# kubectl delete -f test0007.yaml 
[root@k8s-master pods]# vim test0007.yaml

apiVersion: v1
kind: Pod
metadata:name: test0007labels:name: test0007
spec:containers:-       name: test0007nginximage: docker.io/library/nginx:latestimagePullPolicy: IfNotPresentports:-       name: nginxportcontainerPort: 80-       name: test0007centosimage: docker.io/library/centos:latestimagePullPolicy: Nevercommand:- sleep- infinity

[root@k8s-master pods]# kubectl create -f test0007.yaml 

[root@k8s-master pods]# kubectl get po
NAME                             READY   STATUS    RESTARTS   AGE
test0007                         2/2     Running   0          9s
11、监控容器运行的5个切入点

postStart startup lived ready perStop

12、replicationcontroller (RC)

[root@k8s-master pods]# kubectl delete -f test0007.yaml 

[root@k8s-master pods]# vim test0007.yaml

# 版本
apiVersion: v1
# 类型
kind: Pod
# 数据
metadata:name: test0007labels:name: test0007
#信息
spec:# 重启策略restartPolicy: OnFailurecontainers:-       name: test0007nginximage: docker.io/library/nginx:latestimagePullPolicy: IfNotPresentports:-       name: nginxportcontainerPort: 80startupProbe:tcpSocket:port: 80initialDelaySeconds: 10timeoutSeconds: 2  #超时periodSeconds: 20successThreshold: 1failureThreshold: 2readinessProbe:httpGet:port: 80path: /index.htmlinitialDelaySeconds: 10timeoutSeconds: 2periodSeconds: 20successThreshold: 1failureThreshold: 2livenessProbe:tcpSocket:port: 80initialDelaySeconds: 10timeoutSeconds: 2periodSeconds: 20successThreshold: 1failureThreshold: 2-       name: test0007centosimage: docker.io/library/centos:latestimagePullPolicy: Nevercommand:- sleep- infinity                        

[root@k8s-master pods]# kubectl create -f test0007.yaml 

[root@k8s-master pods]# vim test0007.yaml

 41                 lifecycle:42                         postStart:43                                 exec:44                                         command:45                                         - sh46                                         - c47                                         - mkdir /data48                         preStop:49                                 exec:50                                         command:51                                         - sh52                                         - c53                                         - pkill nginx;sleep     30; 

[root@k8s-master pods]# kubectl delete -f test0007.yaml 

[root@k8s-master pods]# kubectl create -f test0007.yaml 

[root@k8s-master pods]# vim test0008.yaml
 

apiVersion: v1
kind: ReplicationController
metadata:name: nginx0
spec:replicas: 3selector:app: nginx0# 模板template:# pod 源数据metadata:# pod名称name: ngixn0# pod标签labels:app: nginx# pod详细信息spec:containers:-       name: nginx0image: docker.io/library/nginx:l
atestimagePullPolicy: Neverports:-       name: containerportcontainerPort: 80

[root@k8s-master pods]# kubectl create -f test0008.yaml 
replicationcontroller/nginx0 created
[root@k8s-master pods]# kubectl get po

NAME                             READY   STATUS     RESTARTS      AGE
cluster-test1-54575cf56c-46mb4   1/1     Running    3 (51m ago)   3h59m
nginx0-25xpx                     1/1     Running    0             14s
nginx0-49n2k                     1/1     Running    0             14s
nginx0-6lzvw                     1/1     Running    0             14s

[root@k8s-master pods]# kubectl delete pod nginx0-49n2k   //删除后会自动创建
pod "nginx0-49n2k" deleted
[root@k8s-master pods]# kubectl get po

NAME                             READY   STATUS     RESTARTS      AGE
cluster-test1-54575cf56c-46mb4   1/1     Running    3 (52m ago)   4h
nginx0-25xpx                     1/1     Running    0             103s
nginx0-6lzvw                     1/1     Running    0             103s
nginx0-gf22s                     1/1     Running    0             3s
[root@k8s-master pods]# kubectl get po -owide
NAME                             READY   STATUS    RESTARTS      AGE     IP               NODE        NOMINATED NODE   READINESS GATES
cluster-test1-54575cf56c-46mb4   1/1     Running   3 (54m ago)   4h2m    172.16.36.77     k8s-node1   <none>           <none>
nginx0-25xpx                     1/1     Running   0             3m23s   172.16.36.81     k8s-node1   <none>           <none>
nginx0-6lzvw                     1/1     Running   0             3m23s   172.16.169.141   k8s-node2   <none>           <none>
nginx0-gf22s                     1/1     Running   0             103s    172.16.169.143   k8s-node2   <none>           <none>

[root@k8s-master pods]# curl http://172.16.36.81:80

[root@k8s-master pods]# kubectl top node

NAME         CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
k8s-master   159m         7%     1147Mi          66%       
k8s-node1    50m          2%     843Mi           49%       
k8s-node2    58m          2%     897Mi           52%     

[root@k8s-master pods]# kubectl delete -f test0008.yaml    //根据文件完全删除

[root@k8s-master pods]# kubectl delete replicationcontrollers nginx0  //删除

二、replicaSet

[root@k8s-master pods]# vim test0009.yaml

apiVersion: apps/v1
kind: ReplicaSet
metadata:name: nginx1
apiVersion: apps/v1
kind: ReplicaSet
metadata:name: nginx1
spec:replicas: 3selector:matchLabels:tier: nginx1matchExpressions:-     key: tieroperator: Invalues: [nginx1]template:metadata:name: nginx1labels:app: guestbooktier: nginx1spec:#restartPolicy: OnFailurecontainers:-     name: nginx1image: docker.io/library/nginx:latestimagePullPolicy: Neverports:-     name: nginxportcontainerPort: 80

[root@k8s-master pods]# kubectl create -f test0009.yaml 

[root@k8s-master pods]# kubectl get po

NAME                             READY   STATUS    RESTARTS      AGE
cluster-test1-54575cf56c-46mb4   1/1     Running   5 (52s ago)   5h9m
nginx1-jg6lp                     1/1     Running   0             35s
nginx1-r5hlp                     1/1     Running   0             35s
nginx1-s26lm                     1/1     Running   0             35s

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1534681.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

探索UWB技术的独特优势:实现高精度定位

UWB定位技术是一种利用无线信号进行精确位置定位的技术&#xff0c;它利用超宽带无线电信号通过测量信号的到达时间、相位差和信号能量等参数来确定物体的精确位置。 UWB定位技术具有多种优势&#xff0c;首先&#xff0c;它具有较高的定位精度&#xff0c;可实现毫米级的精确…

哈工大“计算机设计与实践”(cpu)处理器实验设计报告

哈工大“计算机设计与实践”&#xff08;cpu&#xff09;处理器实验设计报告 【哈工大“计算机设计与实践”&#xff08;cpu&#xff09;处理器实验设计报告】 在计算机科学领域&#xff0c;CPU&#xff08;中央处理器&#xff09;是计算机系统的核心部件&#xff0c;负责执行指…

性能诊断的方法(四):自下而上的资源诊断方法和发散的异常信息诊断方法

关于性能诊断的方法&#xff0c;我们可以按照“问题现象—直接原因—问题根源”这样一个思路去归纳。我们先从问题的现象去入手&#xff0c;包括时间的分析、资源的分析和异常信息的分析。接下来再去分析产生问题现象的直接原因是什么&#xff0c;这里我们归纳了自上而下的资源…

C语言 13 指针

指针可以说是整个 C 语言中最难以理解的部分了。 什么是指针 还记得在前面谈到的通过函数交换两个变量的值吗&#xff1f; #include <stdio.h>void swap(int, int);int main() {int a 10, b 20;swap(a, b);printf("a %d, b %d", a, b); }void swap(int …

Python编码系列—Python建造者模式:构建复杂对象的优雅之道

&#x1f31f;&#x1f31f; 欢迎来到我的技术小筑&#xff0c;一个专为技术探索者打造的交流空间。在这里&#xff0c;我们不仅分享代码的智慧&#xff0c;还探讨技术的深度与广度。无论您是资深开发者还是技术新手&#xff0c;这里都有一片属于您的天空。让我们在知识的海洋中…

传知代码-融合经典与创新的图像分类新途径

代码以及视频讲解 本文所涉及所有资源均在传知代码平台可获取 概述 在当前的深度学习领域&#xff0c;构建兼具高性能与灵活性的卷积神经网络&#xff08;CNN&#xff09;已成为计算机视觉研究的核心课题。本文介绍了一种全新的卷积神经网络架构&#xff0c;该网络巧妙地结合…

OZON电子产品大幅增长,OZON跨境PS5销量激增

Top1 存储卡 Карта памяти Canvas Select Plus 128 ГБ 商品id&#xff1a;1548303593 月销量&#xff1a;2131 欢迎各位卖家朋友点击这里&#xff1a; &#x1f449; D。DDqbt。COm/74rD 免费体验 随着智能手机和平板电脑的普及&#xff0c;用户对于存储空…

vite + vue3 + ts 移动端开箱即用现代开发模板

中文 | English SouthernWind https://blog.csdn.net/nanchen_J?typeblog sw-template vite vue3 ts 移动端开箱即用现代开发模板 特点 &#x1f436; Vite 的Vue3 的文件路由布局系统Mock 后续支持Api 自动引入组件自动引入VueUse 支持TypeScript 的Tailwind css 的暗…

Gitlab实现多项目触发式自动CICD

工作中可能会遇到这种场景&#xff0c;存在上游项目A和下游项目B&#xff0c;项目B的功能依赖项目A&#xff08;比如B负责日志解析&#xff0c;A是日志描述语言代码&#xff09;&#xff0c;这种相互依赖的项目更新流程一般如下&#xff1a; A项目更新&#xff0c;通知B项目开发…

好用的电脑监控软件推荐!分享六个企业必备的电脑监控软件,赶紧Get吧!

数字化办公日益普及&#xff0c;由于工作的需要&#xff0c;几乎每个员工都有自己的电脑&#xff0c;并且大多数电脑都接入了互联网。 这使得电脑监控软件&#xff0c;变为企业管理中必不可少的一部分&#xff01;它们不仅能够帮助管理者实时了解员工的工作状态&#xff0c;提…

充电宝什么品牌比较好用?2024年最值得推荐充电宝品牌!

近年来&#xff0c;随着电子设备使用需求的增加&#xff0c;充电宝市场呈现出蓬勃发展的态势。优秀的充电宝产品不仅能够提供稳定的充电速度&#xff0c;还具备方便携带的体验&#xff0c;深受用户喜爱。然而&#xff0c;面对市场上众多品牌和型号的选择&#xff0c;如何找到最…

Linux云计算 |【第二阶段】SHELL-DAY5

主要内容&#xff1a; awk命令、内置变量&#xff08;FS、$0、$1、$2、NF、NR&#xff09;、过滤时机&#xff08;BEGIN{}、{}、END{}&#xff09;、处理条件&#xff08;正则、&&、||、~\!~、等&#xff09;、awk数组、监控脚本、安全检测脚本 一、awk介绍 awk 是一…

基于微信平台的旅游出行必备商城小程序+ssm(lw+演示+源码+运行)

摘 要 随着社会的发展&#xff0c;社会的方方面面都在利用信息化时代的优势。互联网的优势和普及使得各种系统的开发成为必需。 本文以实际运用为开发背景&#xff0c;运用软件工程原理和开发方法&#xff0c;它主要是采用java语言技术和mysql数据库来完成对系统的设计。整个…

影视直冲?对接卡券特权充值接口对于用户来说有什么优势?

对用户来说有哪些优势&#xff1a; 便利性&#xff1a;用户可以直接在应用程序或网站上充值和使用卡券&#xff0c;无需通过多个平台或渠道&#xff0c;提高了用户体验。实时性&#xff1a;卡券充值和使用状态可以实时更新&#xff0c;用户可以立即看到余额变化和卡券状态。安…

移动硬盘无法读取?别慌!这些方法助你恢复数据!

在我们的日常工作和生活中&#xff0c;移动硬盘作为重要的数据存储工具&#xff0c;承载着珍贵资料。然而&#xff0c;移动硬盘无法被电脑读取的情况时有发生&#xff0c;令人焦急。别慌&#xff0c;下面为大家详细介绍恢复移动硬盘数据的有效方法。 一、检查硬件连接和驱动问题…

麒麟桌面操作系统:查看最近安装与卸载的软件包

麒麟桌面操作系统&#xff1a;查看最近安装与卸载的软件包 1、查看最近安装的deb包2、查看最近卸载的deb包 &#x1f496;The Begin&#x1f496;点点关注&#xff0c;收藏不迷路&#x1f496; 在麒麟桌面操作系统中&#xff0c;快速查看最近安装与卸载的软件包非常简单。这里有…

【多因子分组箱线图】:附Origin详细画图教程

目录 No.1 理解箱线图 1 什么是箱线图 2 箱线图的组成 No.2 画图流程 1 导入数据并绘图 2 设置绘图细节 3 设置坐标轴 4 效果图 No.1 理解箱线图 1 什么是箱线图 箱线图&#xff0c;又称箱形图、盒须图或盒式图&#xff0c;用于体现数据分散情况的统计图。在视觉上辅助…

大数据新视界 --大数据大厂之数据挖掘入门:用 R 语言开启数据宝藏的探索之旅

&#x1f496;&#x1f496;&#x1f496;亲爱的朋友们&#xff0c;热烈欢迎你们来到 青云交的博客&#xff01;能与你们在此邂逅&#xff0c;我满心欢喜&#xff0c;深感无比荣幸。在这个瞬息万变的时代&#xff0c;我们每个人都在苦苦追寻一处能让心灵安然栖息的港湾。而 我的…

猜数-while-python

题目要求&#xff1a; 设置一个范围1-100的随机整数变量&#xff0c;通过while循环&#xff0c;诶和input语句&#xff0c;判断输入的数字是否等于随机数 无限次机会&#xff0c;直到猜中为止每一次不猜中都&#xff0c;会提示大了小了猜完数字后&#xff0c;提示裁了几次 imp…

干耳朵要掏吗?高性价比的可视挖耳勺推荐

干耳朵的耳朵属于比较干爽的内部环境&#xff0c;如果耳道中耳屎过多建议使用专业的工具来掏耳朵。在掏耳的过程建议用可视挖耳勺&#xff0c;可以通过内窥镜来实时查看耳道内的情况&#xff0c;更加安全和精准。但市面上的可视挖耳勺枪品质良莠不齐&#xff0c;一些黑心商家只…