pip需要持久化,先容器sleep 10000,进容器
export PYTHONPATH=/usr/src/app/requirements
export PIP_CONFIG_FILE=/usr/src/app/pip.config
pip install 巴拉巴拉巴拉巴拉
正式的yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: chinese-clip
namespace: cn-clip
spec:
selector:
matchLabels:
component: chinese-clip
template:
metadata:
labels:
component: chinese-clip
spec:
containers:
- name: chinese-clip
image: <你自己的仓库>/python:3.11.10-slim-bookworm
workingDir: /usr/src/app/Chinese-CLIP
ports:
- containerPort: 5000
name: http
protocol: TCP
volumeMounts:
- name: localtime
mountPath: /etc/localtime
- name: data-persistent-storage-prd
mountPath: /usr/src/app
resources:
requests:
memory: 4096Mi
command:
- sh
args:
- -c
- export PYTHONPATH=/usr/src/app/requirements && export PIP_CONFIG_FILE=/usr/src/app/pip.config && python ./cnClipRestApi.py
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: data-persistent-storage-prd
<你自己的持久化配置>
---
apiVersion: v1
kind: Service
metadata:
name: chinese-clip
namespace: cn-clip
labels:
service: chinese-clip
spec:
type: NodePort
selector:
component: chinese-clip
ports:
- port: 5000
targetPort: 5000
nodePort: <你自己的端口>
参考
https://www.cnblogs.com/13579net/p/13814972.html