企业网站优化定制/网络seo营销推广
概述
在我们搭建完k8s的时候,有时需要启动个centos系统的pod,打印日志,不可避免的就需要在command字段里是循环。
操作
示例1
死循环输出“hello”
command:- /bin/sh- -c- while true; do echo hello; sleep 1;done
完整发布文件centos-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:labels:k8s-app: centosqcloud-app: centosname: centosspec:replicas: 1selector:matchLabels:k8s-app: centosqcloud-app: centosstrategy:rollingUpdate:maxSurge: 1maxUnavailable: 0type: RollingUpdatetemplate:metadata:labels:k8s-app: centosqcloud-app: centosspec:containers:- image: centos:7imagePullPolicy: Alwaysname: centoscommand:- /bin/sh- -c- while true; do echo hello; sleep 1;done
示例2
死循环维持pod运行
- command:- sleep- '3600'