当前位置:网站首页>Kubernetes----Pod配置容器启动命令
Kubernetes----Pod配置容器启动命令
2022-06-30 17:53:00 【Jerry00713】
一、启动命令
1.1 编写配置文件
创建pod_command.yaml文件,并编写如下内容,即在容器启动之后,向 、opt/text.txt文件写入时间戳,执行命令主要通过command字段传入,类型为列表格式
apiVersion: v1
kind: Namespace
metadata:
name: dev
---
apiVersion: v1
kind: Pod
metadata:
name: pod-command
namespace: dev
labels:
user: redrose2100
spec:
containers:
- name: busybox
image: busybox:1.30
command: ["/bin/sh","-c","touch /tmp/hello.txt;while true;do /bin/echo $(date +%T) >> /tmp/hello.txt;sleep 3;done;"]1.2 创建资源
使用如下命令创建namespace和pod资源
[[email protected] pod]# kubectl apply -f pod_command.yaml
namespace/dev created
pod/pod-command created
[[email protected] pod]#1.3 进入容器检查数据
如下,进入容器中,并查看 /tmp/hello.txt文件内容,如下,表示已经成功执行命令
[[email protected] pod]# kubectl get pod -n dev
NAME READY STATUS RESTARTS AGE
pod-command 1/1 Running 0 6s
[[email protected] pod]# kubectl exec pod-command -n dev -it -c busybox /bin/sh
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
/ # tail -n 5 /tmp/hello.txt
15:13:58
15:14:01
15:14:04
15:14:07
15:14:10
/ #1.4 关于kubernetes中command和args的参数说明:
- 如果command和args都没写,则使用dockerfile中的配置
- 如果command写了,但是args没写,那么dockerfile默认配置会被忽略,执行输入的command
- 如果command没写,但是args写了,那么dockerfile中配置的ENTRYPOINT的命令会被执行,使用当前args的参数
- 如果command和args都写了,那么dockerfile的配置被忽略,执行command追加上args参数
1.5 删除资源
使用如下命令删除资源
[[email protected] pod]# kubectl delete -f pod_command.yaml
namespace "dev" deleted
pod "pod-command" deleted
[[email protected] pod]#边栏推荐
- CODING 正式入驻腾讯会议应用市场!
- PyTorch学习(三)
- 华兴证券:混合云原生架构下的 Kitex 实践
- Practical application of "experience" crawler in work
- torch.roll
- js 字符串截取方法汇总
- torch stack() meshgrid()
- Ambient light and micro distance detection system based on stm32f1
- 一文详解|Go 分布式链路追踪实现原理
- Practical application of "experience" crawler in work "theory"
猜你喜欢

领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!

ANSI/UL 94 5-V级垂直燃烧试验

sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户

Swin-Transformer(2021-08)

Infineon - GTM architecture -generic timer module

Video content production and consumption innovation

DTD modeling

一点比较有意思的模块

Leader: who can use redis expired monitoring to close orders and get out of here!

SaaS project management system solution for the financial service industry helps enterprises tap a broader growth service space
随机推荐
20220528【聊聊假芯片】贪便宜往往吃大亏,盘点下那些假的内存卡和固态硬盘
MySQL function to get the full path
Entry node of link in linked list - linked list topic
When selecting smart speakers, do you prefer "smart" or "sound quality"? This article gives you the answer
Compare the audio librosa library with the Mel spectrogram in the torchaudio library
At present, the big guys are joining the two streams of flinksql, cdcmysql and Kafka, and the results are put into MySQL or KA
开发那些事儿:如何在视频中添加文字水印?
服务器之间传文件夹,文件夹内容为空
Personally test the size of flutter after packaging APK, quite satisfied
详解单例模式
Small program container technology to promote the operation efficiency of the park
Cobbler轻松上手
js 字符串截取方法汇总
Video content production and consumption innovation
Some interesting modules
torch stack() meshgrid()
PO模式简介「建议收藏」
Electron 入门
「干货」数据分析常用的10种统计学方法,附上重点应用场景
Large file transfer software based on UDP protocol