apiVersion: v1
kind: Pod
metadata:
name: test
labels:
app: test-pod
spec:
containers:
- name: testserver
image: test_server:2.5
ports:
- containerPort: 8080
- containerPort: 5100
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
volumeMounts:
- name: testserver
mountPath: /app/test/csv
# command: ["/bin/bash"]
# args: ["-c", "python /app/api/Python_Rest.py"]
- name: testdb
image: lev_test_db:1.4
ports:
- containerPort: 1433
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
volumeMounts:
- name: testdb
mountPath: /var/opt/mssql/data
volumes:
- name: testserver
hostPath:
path: /usr/testhostpath/testserver
- name: levmldb
hostPath:
path: /usr/testhostpath/testdb
如果按照我注释掉的方式去做,tomcat就不能正常工作,因为在tomcat成功之前python服务器就在运行。
在kubernetes环境下使用yaml文件部署tomcat conatiner,如果tomcat正常成功,我想运行python文件。我该怎么办?
答案 0 :(得分:-1)
可以使用sleep命令延迟testserver启动 一个更花哨的解决方案可以
command:
- "sleep"
- "100"
lifecycle:
postStart:
exec:
command:
- "sh"
- "-c"
- |
python /app/api/Python_Rest.py