[英]Can't assign kubernetes persistent volume to uwsgi application
Trying to assign persistent volume to an uWSGI application, but I'm getting following error: bind(): Operation not permitted [core/socket.c line 230]
. 尝试将持久卷分配给uWSGI应用程序,但出现以下错误: bind(): Operation not permitted [core/socket.c line 230]
。 Works when I assign none-persistent "empty dir" volume. 当我分配非持久的“空目录”卷时,该工程有效。
Here are the yaml files of the persistent volume I'm trying to assign: 以下是我要分配的永久卷的yaml文件:
#volume claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: api-storage
spec:
accessModes:
- ReadWriteMany
storageClassName: api-storage
resources:
requests:
storage: 100Gi
#storage class
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: api-storage
provisioner: kubernetes.io/azure-file
mountOptions:
- dir_mode=0777
- file_mode=0777
- uid=root
- gid=root
parameters:
skuName: Standard_LRS
The manifest of the application looks like this : 该应用程序的清单如下所示:
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-app
spec:
replicas: 2
selector:
matchLabels:
app: api-app
template:
metadata:
labels:
app: api-app
spec:
containers:
- name: nginx
image: nginx
lifecycle:
preStop:
exec:
command: ["/usr/sbin/nginx","-s","quit"]
ports:
- containerPort: 80
protocol: TCP
resources:
limits:
cpu: 50m
memory: 100Mi
requests:
cpu: 10m
memory: 50Mi
volumeMounts:
- name: storage
mountPath: /var/run/api
- name: nginx-conf
mountPath: /etc/nginx/conf.d
- name: api-app
image: azurecr.io/api_api_se:opencv
workingDir: /app
command: ["/usr/local/bin/uwsgi"]
args:
- "--die-on-term"
- "--manage-script-name"
- "--mount=/=api:app_dispatch"
- "--socket=/var/run/api/uwsgi.sock"
- "--chmod-socket=777"
- "--pyargv=se"
# - "--metrics-dir=/storage"
# - "--metrics-dir-restore"
resources:
requests:
cpu: 150m
memory: 1Gi
volumeMounts:
- name: storage
mountPath: /var/run/api
# - name: storage
# mountPath: /storage
volumes:
- name: storage
# work's if following two lines are substituted with "emptyDir: {}"
persistentVolumeClaim:
claimName: api-storage
- name: nginx-conf
configMap:
name: api
tolerations:
- key: "sku"
operator: "Equal"
value: "test"
effect: "NoSchedule"
---
apiVersion: v1
kind: Service
metadata:
labels:
app: api-app
name: api-app
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: api-app
The final goal is to collect metrics from the uWSGI, at this moment, the metrics get delete if the pod gets deleted by scale down 最终目标是从uWSGI收集指标,此时,如果按比例缩小了pod,则指标将被删除。
为了解决此问题,我必须在构建应用程序映像时首先在Dockerfile中创建实际文件夹(在我的情况下为/storage
,因此我向Dockerfile添加了RUN mkdir /storage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.