当前位置:网站首页>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]#边栏推荐
- Electron 入门
- How to improve the three passive situations in data analysis
- The folder is transferred between servers. The folder content is empty
- Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 1)
- 「干货」数据分析常用的10种统计学方法,附上重点应用场景
- Huaxing Securities: kitex practice under the original hybrid Cloud Architecture
- Delete duplicate elements in the sorting linked list ii[unified operation of linked list nodes --dummyhead]
- 服务器之间传文件夹,文件夹内容为空
- PC端微信多开
- PyTorch学习(三)
猜你喜欢

屏幕显示技术进化史

AI chief architect 10-aica-lanxiang, propeller frame design and core technology

Regular expressions (regular matching)

Dlib library for face key point detection (openCV Implementation)

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

Coding officially entered Tencent conference application market!

Swin-transformer --relative positional Bias

Lenovo Yoga 27 2022, full upgrade of super configuration

TCP粘包问题

Evolution of screen display technology
随机推荐
Adhering to the concept of 'home in China', 2022 BMW children's traffic safety training camp was launched
拓維信息使用 Rainbond 的雲原生落地實踐
亲测flutter打包apk后大小,比较满意
Electronic components bidding and purchasing Mall: optimize traditional purchasing business and speed up enterprise digital upgrading
Hospital online consultation applet source code Internet hospital source code smart hospital source code
Iris, the web framework of go
Pytorch learning (III)
传统微服务框架如何无缝过渡到服务网格 ASM
The folder is transferred between servers. The folder content is empty
《Go题库·15》go struct 能不能比较?
法国A+ 法国VOC标签最高环保级别
The online procurement system of the electronic components industry accurately matches the procurement demand and leverages the digital development of the electronic industry
PO模式简介「建议收藏」
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户
Coding officially entered Tencent conference application market!
[Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
PC端微信多开
Compare the audio librosa library with the Mel spectrogram in the torchaudio library
Troubleshooting MySQL for update deadlock
开发那些事儿:Linux系统中如何安装离线版本MySQL?