当前位置:网站首页>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]#边栏推荐
- Build graphql service based on Actix, async graphql, rbatis, pgsql/mysql (4) - change service
- Small program container technology to promote the operation efficiency of the park
- MySQL function to get the full path
- torch stack() meshgrid()
- com.alibaba.fastjson.JSONObject # toJSONString 消除循环引用
- 正则表达式(正则匹配)
- Electronic components bidding and purchasing Mall: optimize traditional purchasing business and speed up enterprise digital upgrading
- Kalman滤波器--从高斯融合推导
- 教你30分钟快速搭建直播间
- 【TiDB】TiCDC canal_ Practical application of JSON
猜你喜欢

Pytorch learning (III)

Cobbler轻松上手

Teach you to quickly set up a live studio in 30 minutes

一套十万级TPS的IM综合消息系统的架构实践与思考

Personally test the size of flutter after packaging APK, quite satisfied

Evolution of screen display technology

PC wechat multi open

Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 1)

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

屏幕显示技术进化史
随机推荐
German agbb VOC hazardous substances test
正则表达式(正则匹配)
Go Redis连接池
Where do the guests come from
【合集- 行业解决方案】如何搭建高性能的数据加速与数据编排平台
[Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
详解单例模式
Troubleshooting MySQL for update deadlock
How to do a good job in software system demand research? Seven weapons make it easy for you to do it
Small program container technology to promote the operation efficiency of the park
France a+ France VOC label highest environmental protection level
Cloud Native Landing Practice Using rainbond for extension dimension information
Is it safe to open an account for goucai? Is it reliable?
PC wechat multi open
mysql下载和安装详细教程
Word——Word在试图打开文件时遇到错误的一种解决办法
Construction and practice of full stack code test coverage and use case discovery system
[community star selection] the 23rd issue of the July revision plan | bit by bit creation, converging into a tower! Huawei freebuses 4E and other cool gifts
Full recharge, im+rtc+x full communication service "feedback season" starts
链表中环的入口结点-链表专题