重启策略
Always: 只要容器一次退出,kubelet 就会自动重启该容器
OnFailure: 当容器终止运行且退出码不为0,由kubelet自动重启容器
Never: 无论容器处于何种状态,kubelet都不会重启该容器
进入Pod指定容器指令
[root@k8smaster4 taints]# kubectl exec -it demo-pod -c tomcat-pod-java -- /bin/bash
重启策略Yaml
[root@k8smaster4 taints]# vi pod-restart.yaml 

apiVersion: v1
kind: Pod
metadata:
name: demo-pod
namespace: default
labels:
environment: test
program: tomcat
spec:
restartPolicy: Always
containers:
- name: tomcat-pod-java
ports:
- containerPort: 8080
image: docker.io/xianchao/tomcat-8.5-jre8:v1
imagePullPolicy: IfNotPresent
重启策略Yaml
[root@k8smaster4 taints]# vi pod-restart.yaml 

apiVersion: v1
kind: Pod
metadata:
name: demo-pod
namespace: default
labels:
environment: test
program: tomcat
spec:
restartPolicy: OnFailure
containers:
- name: tomcat-pod-java
ports:
- containerPort: 8080
image: docker.io/xianchao/tomcat-8.5-jre8:v1
imagePullPolicy: IfNotPresent