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.mzph.cn/diannao/53922.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Kubernetes】linux centos安装部署Kubernetes集群

【Kubernetes】centos安装Kubernetes集群 1、环境准备 系统centos7 配置yum源参考文章 Centos系统换yum源 yum -y update 步骤1-3是所有主机都要配置&#xff0c;主机名和hosts配置完后可以使用工具命令同步 1.1 主机 一主二从 主机名ipk8smaster192.168.59.148k8snode11…

git 更新LingDongGui问题解决

今天重新更新灵动gui的代码&#xff0c;以便使用最新的arm-2d&#xff0c;本来以为是比较简单的一件事情&#xff08;因为以前已经更新过一次&#xff09;&#xff0c;却搞了大半天&#xff0c;折腾不易啊&#xff0c;简单记录下来&#xff0c;有同样遇到问题的同学参考&#x…

Maven私服Nexus安装及使用

前言 周末在家闲着无聊&#xff0c;不知道做点啥&#xff0c;就想着自己搭建一个Maven私服来玩玩。刚好使用自己之前在电脑上搭建的虚拟机服务器来操作体验了一把。搭建好私服后&#xff0c;以后自己写的一些小模块啊&#xff0c;工具包啥的就可以发布到自己的私服上了&#xf…

时序预测 | Matlab实现PSO-CNN粒子群优化卷积神经网络时间序列预测

时序预测 | Matlab实现PSO-CNN粒子群优化卷积神经网络时间序列预测 目录 时序预测 | Matlab实现PSO-CNN粒子群优化卷积神经网络时间序列预测预测效果基本介绍程序设计参考资料 预测效果 基本介绍 Matlab实现PSO-CNN粒子群优化卷积神经网络时间序列预测&#xff08;完整源码和数…

yml在线格式转换工具(properties)

网站地址&#xff1a; 在线yaml转properties-在线properties转yaml-ToYaml.com yml&#xff0c;即yaml文本格式文件的后缀名&#xff0c;yaml可以用来替代properties&#xff0c;配置文件短的情况下可读性更好一些。 但是Spring Boot项目配置项多&#xff0c;yml文件看起来不…

一步一步将PlantUML类图导出为自定义格式的XMI文件

一步一步将PlantUML类图导出为自定义格式的XMI文件 说明&#xff1a; 首次发表日期&#xff1a;2024-09-08PlantUML官网&#xff1a; https://plantuml.com/zh/PlantUML命令行文档&#xff1a; https://plantuml.com/zh/command-line#6a26f548831e6a8cPlantUML XMI文档: http…

LabVIEW编程语言出于什么原因开发的?

LabVIEW最初由美国国家仪器公司&#xff08;NI&#xff09;于1986年开发&#xff0c;目的是为工程师和科学家提供一种图形化编程环境&#xff0c;简化数据采集、仪器控制、自动化测试和测量系统开发等工作。开发LabVIEW的主要原因包括以下几点&#xff1a; 简化复杂系统开发&am…

Redis面对数据量庞大处理方法

当Redis面对数据量庞大时&#xff0c;其应对策略需要从多个维度出发&#xff0c;包括数据分片、内存优化、持久化策略、使用集群、硬件升级、数据淘汰策略、合理设计数据结构以及监控系统性能等。以下是对这些策略的详细阐述&#xff0c;以期提供不少于2000字的深入解答。 一、…

别用 npm config set registry 设置淘宝镜像了!!!

常规写法 npm config set registry https://registry.npmmirror.com我相信大部分人都会用这个命令来切换淘宝镜像。我之前也是&#xff0c;我有一个问题那就是我每当想切换镜像的时候都会搜一下淘宝npm镜像。因为我大部分时候都会忘记这个命令是什么样子的。 大宝贝 nrm 自动…

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

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

91、K8s之ingress上集

一、Ingress service模式&#xff1a; loadbalance NodePort&#xff1a;每个节点都会有一个指定的端口 30000-32767 内网 clusterip&#xff1a;默认模式&#xff0c;只能pod内部访问 externalName&#xff1a;需要dns提供域名 1.1、对外提供服务的ingress service&…

SQL Server小技巧之遍历日期

使用背景 一般项目中会遇到&#xff0c;求每日的日报这种&#xff0c;以及计算2个日期内的工作日&#xff0c;或者休息日可能会用到&#xff0c;计算休息日可以用额外的一个字段用来标记当前日期是否是休息日 遍历方式一 DECLARE StartDate DATE 2023-01-01, EndDate DATE …

jmeter之TPS计算公式

需求&#xff1a; 如何确定环境当中的TPS指标 PV:&#xff08;Page View&#xff09;即页面访问量&#xff0c;每打开一次页面PV计数1&#xff0c;刷新页面也是。PV只统计页面访问次 数。 UV(Unique Visitor),唯一访问用户数&#xff0c;用来衡量真实访问网站的用户数量。 一般…

中国电子学会202406青少年软件编程(Python)等级考试试卷(三级)真题与解析

202406Python 三级真题 一、选择题 第 1 题 现有一组初始记录无序的数据“5,8,6,3,9,2”,使用冒泡排序算法,按从小到大的顺序排列,第一轮排序的结果为? A:5,6,3,8,9,2 B:5,6,3,8,2,9 C:5,6,8,3,2,9 D:5,8,3,6,9,2 第 2 题 列表l=[9,…

携手鲲鹏,长亮科技加速银行核心系统升级

新经济周期下&#xff0c;银行净息差持续收窄、盈利压力加大、市场竞争日趋加剧。同时&#xff0c;国家相关政策不断出台&#xff0c;对金融科技的自主创新与安全可控提出了更高要求。 在这样的大背景下&#xff0c;银行业的数字化转型已经步入深水区。其中&#xff0c;核心系统…

ubuntu 执行定时任务crontab -e 无法输入的问题

界面显示 GNU nano 4.8 /tmp/crontab.l0A1HJ/crontab # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined t…

appium server gui详细按照步骤

1.安装appium server desktop Appium安装提供两种方式:桌面版和命令行版。其中桌面版又分为 Appium GuI 和 Appium Desktop 。作为初学者&#xff0c;用桌面版&#xff0c;对初学者比较友好。 官网下载地址&#xff1a;Releases appium/appium-desktop GitHubTags appium/…

OpenCV class2-C#+winfrom显示控件使用窗口大小并内存管理

一.控件效果说明 二.代码声明&#xff08;已经循环读取10000次&#xff09; 全局 OpenCvSharp.Point point new OpenCvSharp.Point(0, 0); OpenCvSharp.Size size2; Mat src new Mat(); 初始化 size2 new OpenCvSharp.Size(pictureBox1.Size.Width, pictureBox1.Size.Hei…

MySQL迁移达梦报错,DMException: 第1 行附近出现错误: 无效的表或视图名[ACT_GE_PROPERTY]

达梦数据库选好模式和登录用户&#xff0c;迁移时的目标模式名要和达梦的当前登录的用户名相同&#xff0c;否则查询的时候需要“form 模式名.表名”&#xff0c;只from表名就会报表不存在的错误。

【YashanDB知识库】DBeaver无法访问数据库

本文转自YashanDB官网&#xff0c;具体内容请见DBeaver无法访问数据库 【标题】DBeaver无法访问数据库 【问题分类】安装部署 【关键字】DBeaver无法访问数据库 【问题描述】数据库部署完成后&#xff0c;无法通过DBeaver进行访问 【问题原因分析】首先通过ping和telnet检…