当前位置: 首页 > news >正文

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

相关文章:

2024.9.14(RC和RS)

一、replicationcontroller &#xff08;RC&#xff09; 1、更改镜像站 [rootk8s-master ~]# vim /etc/docker/daemon.json {"registry-mirrors": ["https://do.nark.eu.org","https://dc.j8.work","https://docker.m.daocloud.io",&…...

【算法随想录04】KMP 字符串匹配算法

这是字符串模式匹配经典算法。 给定一个文本 t 和一个字符串 s&#xff0c;我们尝试找到并展示 s 在 t 中的所有出现&#xff08;occurrence&#xff09;。 #include<bits/stdc.h>using namespace std;vector<int> KMP(string s) {int n s.size();vector<int&g…...

TCP和MQTT通信协议

协议分层 网络分层 协议应用层 Co AP MQTT HTTP传输层 UDP TCP网络层 IP链路层 Enternet 网络分层中最…...

Python Pickle 与 JSON 序列化详解:存储、反序列化与对比

Python Pickle 与 JSON 序列化详解&#xff1a;存储、反序列化与对比 文章目录 Python Pickle 与 JSON 序列化详解&#xff1a;存储、反序列化与对比一 功能总览二 Pickle1 应用2 序列化3 反序列化4 系统资源对象1&#xff09;不能被序列化的系统资源对象2&#xff09;强行序列…...

第二百三十二节 JPA教程 - JPA教程 - JPA ID自动生成器示例、JPA ID生成策略示例

JPA教程 - JPA ID自动生成器示例 我们可以将id字段标记为自动生成的主键列。 数据库将在插入时自动为id字段生成一个值数据到表。 例子 下面的代码来自Person.java。 package cn.w3cschool.common;import javax.persistence.Entity; import javax.persistence.GeneratedValu…...

计算机网络 ---- 计算机网络的体系结构【计算机网络的分层结构】

一、以快递网络来引入分层思想 1.1 “分层” 的设计思想【将庞大而复杂的问题&#xff0c;转化为若干较小的局部问题】 从我们最熟悉的快递网络出发&#xff0c;在你家附近会有一个快递终点站A&#xff0c;在其他的城市&#xff0c;也会有这种快递终点站&#xff0c;比如说快递…...

Vite + Electron 时,Electron 渲染空白,静态资源加载错误等问题解决

问题 如果在 electron 里直接引入 vite 打包后的东西&#xff0c;那么有些资源是请求不到的 这是我的引入方式 根据报错&#xff0c;我们来到 vite 打包后的路径看一看 &#xff0c;修改一下 dist 里的文件路径试了一试 修改后的样子&#xff0c;发现是可以的了 原因分析 …...

ZAB协议(算法)

一、ZAB&#xff08;ZooKeeper Atomic Broadcast&#xff09;介绍 ZAB 即 ZooKeeper Atomic Broadcast&#xff0c;是 ZooKeeper 实现分布式数据一致性的核心算法。它是一种原子广播协议&#xff0c;用于确保在分布式环境中&#xff0c;多个 ZooKeeper 服务器之间的数据一致性。…...

多个音频怎么合并?把多个音频合并在一起的方法推荐

多个音频怎么合并&#xff1f;无论是制作连贯的播客节目还是将音乐片段整合成专辑&#xff0c;音频合并已成为许多创作者的常见需求。通过有效合并音频&#xff0c;可以显著提升项目的整体质量&#xff0c;确保内容的连续性和一致性。然而&#xff0c;合并后的文件通常比原始单…...

【Django】Django Class-Based Views (CBV) 与 DRF APIView 的区别解析

Django Class-Based Views (CBV) 与 DRF APIView 的区别解析 在 Django 开发中&#xff0c;基于类的视图&#xff08;Class-Based Views, CBV&#xff09;是实现可重用性和代码结构化的利器。而 Django REST Framework (DRF) 提供的 APIView 是针对 API 开发的扩展。 一、CBV …...

如何增加Google收录量?

想增加Google收录量&#xff0c;首先自然是你的页面数量就要多&#xff0c;但这些页面的内容也绝对不能敷衍&#xff0c;你的网站都没多少页面&#xff0c;谷歌哪怕想收录都没办法&#xff0c;当然&#xff0c;这是一个过程&#xff0c;持续缓慢的增加页面&#xff0c;增加网站…...

leetcode练习 格雷编码

n 位格雷码序列 是一个由 2n 个整数组成的序列&#xff0c;其中&#xff1a; 每个整数都在范围 [0, 2n - 1] 内&#xff08;含 0 和 2n - 1&#xff09;第一个整数是 0一个整数在序列中出现 不超过一次每对 相邻 整数的二进制表示 恰好一位不同 &#xff0c;且第一个 和 最后一…...

【LLM:Gemini】文本摘要、信息提取、验证和纠错、重新排列图表、视频理解、图像理解、模态组合

开始使用Gemini 目录 开始使用Gemini Gemini简介 Gemini实验结果 Gemini的多模态推理能力 文本摘要 信息提取 验证和纠错 重新排列图表 视频理解 图像理解 模态组合 Gemini多面手编程助理 库的使用 引用 本文概述了Gemini模型和如何有效地提示和使用这些模型。本…...

CMS之Wordpress建设

下载 https://cn.wordpress.org/ 宝塔安装Wordpress 创建网站 上传文件、并解压、剪切文件到项目根目录 安装 -> 数据库信息 -> 标题信息 http://wordpress.xxxxx.com 登录 http://wordpress.xxxxxxxxx.com/wp-admin/ 1. 主题(模板) wordpress-基本使用-02-在主题…...

使用Neo4j存储聊天记录的简单教程

引言 在当今的数据驱动世界中&#xff0c;关系型数据库有时难以处理复杂的、相互关联的数据集。Neo4j作为一款开源图数据库&#xff0c;以其高效管理高连接数据的能力而广受欢迎。本篇文章将详细介绍如何使用Neo4j来存储聊天信息历史&#xff0c;引导您在实际项目中利用其强大…...

前端面试常考算法

快速排序 #include<iostream> #include<cstdio> using namespace std; const int N 100005; int a[N];void quick_sort(int a[], int l, int r) {if (l > r) return;int x a[l r >> 1];int i l - 1, j r 1;while (i < j) {while (a[i] < x);…...

【机试准备】常用容器与函数

Vector详解 原文链接&#xff1a;【超详细】C vector 详解 例题&#xff0c;这一篇就够了-CSDN博客 向量&#xff08;Vector&#xff09;是一个封装了动态大小数组的顺序容器&#xff08;Sequence Container&#xff09;。跟任意其它类型容器一样&#xff0c;它能够存放各种…...

Base 社区见面会 | 新加坡站

活动信息 备受期待的 Base 社区见面会将于 Token2049 期间在新加坡举行&#xff0c;为 Base 爱好者和生态系统建设者提供一个独特的交流机会。本次活动由 DAOBase 组织&#xff0c;Base 和 Coinbase 提供支持&#xff0c;并得到了以下合作伙伴的大力支持&#xff1a; The Sand…...

麒麟操作系统搭建Nacos集群

Nacos 集群搭建 2.4.2 环境介绍 操作系统Kylin Linux Advanced Server V10 (Lance)Kylin Linux Advanced Server V10 (Lance)Kylin Linux Advanced Server V10 (Lance)内核版本Linux 4.19.90-52.22.v2207.ky10.aarch64Linux 4.19.90-52.22.v2207.ky10.aarch64Linux 4.19.90-52…...

Imagination推出性能最高且具有高等级功能安全性的汽车GPU IP

Imagination DXS GPU 进一步扩大其在汽车领域的领先地位 产品亮点 &#xff1a; 峰值性能比 Imagination 上一代汽车 GPU 提高了 50%&#xff0c;可扩展至 192GPixel/s、6 TFLOPS 和 24TOPS计算工作负载的性能提升多达十倍引入创新的分布式功能安全机制&#xff0c;以最小的…...

基于大模型的 UI 自动化系统

基于大模型的 UI 自动化系统 下面是一个完整的 Python 系统,利用大模型实现智能 UI 自动化,结合计算机视觉和自然语言处理技术,实现"看屏操作"的能力。 系统架构设计 #mermaid-svg-2gn2GRvh5WCP2ktF {font-family:"trebuchet ms",verdana,arial,sans-…...

vscode(仍待补充)

写于2025 6.9 主包将加入vscode这个更权威的圈子 vscode的基本使用 侧边栏 vscode还能连接ssh&#xff1f; debug时使用的launch文件 1.task.json {"tasks": [{"type": "cppbuild","label": "C/C: gcc.exe 生成活动文件"…...

使用van-uploader 的UI组件,结合vue2如何实现图片上传组件的封装

以下是基于 vant-ui&#xff08;适配 Vue2 版本 &#xff09;实现截图中照片上传预览、删除功能&#xff0c;并封装成可复用组件的完整代码&#xff0c;包含样式和逻辑实现&#xff0c;可直接在 Vue2 项目中使用&#xff1a; 1. 封装的图片上传组件 ImageUploader.vue <te…...

Unsafe Fileupload篇补充-木马的详细教程与木马分享(中国蚁剑方式)

在之前的皮卡丘靶场第九期Unsafe Fileupload篇中我们学习了木马的原理并且学了一个简单的木马文件 本期内容是为了更好的为大家解释木马&#xff08;服务器方面的&#xff09;的原理&#xff0c;连接&#xff0c;以及各种木马及连接工具的分享 文件木马&#xff1a;https://w…...

算法岗面试经验分享-大模型篇

文章目录 A 基础语言模型A.1 TransformerA.2 Bert B 大语言模型结构B.1 GPTB.2 LLamaB.3 ChatGLMB.4 Qwen C 大语言模型微调C.1 Fine-tuningC.2 Adapter-tuningC.3 Prefix-tuningC.4 P-tuningC.5 LoRA A 基础语言模型 A.1 Transformer &#xff08;1&#xff09;资源 论文&a…...

R 语言科研绘图第 55 期 --- 网络图-聚类

在发表科研论文的过程中&#xff0c;科研绘图是必不可少的&#xff0c;一张好看的图形会是文章很大的加分项。 为了便于使用&#xff0c;本系列文章介绍的所有绘图都已收录到了 sciRplot 项目中&#xff0c;获取方式&#xff1a; R 语言科研绘图模板 --- sciRplothttps://mp.…...

LabVIEW双光子成像系统技术

双光子成像技术的核心特性 双光子成像通过双低能量光子协同激发机制&#xff0c;展现出显著的技术优势&#xff1a; 深层组织穿透能力&#xff1a;适用于活体组织深度成像 高分辨率观测性能&#xff1a;满足微观结构的精细研究需求 低光毒性特点&#xff1a;减少对样本的损伤…...

pgsql:还原数据库后出现重复序列导致“more than one owned sequence found“报错问题的解决

问题&#xff1a; pgsql数据库通过备份数据库文件进行还原时&#xff0c;如果表中有自增序列&#xff0c;还原后可能会出现重复的序列&#xff0c;此时若向表中插入新行时会出现“more than one owned sequence found”的报错提示。 点击菜单“其它”-》“序列”&#xff0c;…...

写一个shell脚本,把局域网内,把能ping通的IP和不能ping通的IP分类,并保存到两个文本文件里

写一个shell脚本&#xff0c;把局域网内&#xff0c;把能ping通的IP和不能ping通的IP分类&#xff0c;并保存到两个文本文件里 脚本1 #!/bin/bash #定义变量 ip10.1.1 #循环去ping主机的IP for ((i1;i<10;i)) doping -c1 $ip.$i &>/dev/null[ $? -eq 0 ] &&am…...

stm32进入Infinite_Loop原因(因为有系统中断函数未自定义实现)

这是系统中断服务程序的默认处理汇编函数&#xff0c;如果我们没有定义实现某个中断函数&#xff0c;那么当stm32产生了该中断时&#xff0c;就会默认跑这里来了&#xff0c;所以我们打开了什么中断&#xff0c;一定要记得实现对应的系统中断函数&#xff0c;否则会进来一直循环…...