首页 > 解决方案 > Kubernetes 上已安装卷的写入访问错误

问题描述

当我们在 azure kubernetes 服务(aks)中部署 active-mq 时,其中 active-mq 数据文件夹作为持久卷声明安装在 azure 托管磁盘上。下面是用于部署的 yaml。 使用的 ActiveMQ 映像:rmohr/activemq Kubernetes 版本:v1.15.7

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: activemqcontainer
spec:
  replicas: 1
  selector:
    matchLabels:
        app: activemqcontainer
  template:
    metadata:
      labels:
        app: activemqcontainer
    spec:
      securityContext:
        runAsUser: 1000
        fsGroup: 2000
        runAsNonRoot: false
      containers:
      - name: web
        image: azureregistry.azurecr.io/rmohractivemq
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 61616
        volumeMounts:
        -  mountPath: /opt/activemq/data
            subPath: data
            name: volume
        - mountPath: /opt/apache-activemq-5.15.6/conf/activemq.xml
          name: config-xml
          subPath: activemq.xml
      imagePullSecrets:
      - name: secret
      volumes:
      - name: config-xml
        configMap:
            name: active-mq-xml
      - name: volume
        persistentVolumeClaim:
            claimName: azure-managed-disk
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azure-managed-disk
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: managed-premium
  resources:
    requests:
      storage: 100Gi

低于错误。

WARN | Failed startup of context o.e.j.w.WebAppContext@517566b{/admin,file:/opt/apache-activemq-5.15.6/webapps/admin/,null}
java.lang.IllegalStateException: Parent for temp dir not configured correctly: writeable=false
        at org.eclipse.jetty.webapp.WebInfConfiguration.makeTempDirectory(WebInfConfiguration.java:336)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.webapp.WebInfConfiguration.resolveTempDirectory(WebInfConfiguration.java:304)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:69)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:468)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:504)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)[jetty-all-9.2.25.v20180606.jar:9.2.25.v20180606]
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)[jetty-all-9.2.25.v20180606.jar:9.2.2

标签: azurekubernetesactivemqazure-aks

解决方案


它来自 activemq Web 管理控制台的警告。托管 Web 控制台的 Jetty 无法创建临时目录。

WARN | Failed startup of context o.e.j.w.WebAppContext@517566b{/admin,file:/opt/apache-activemq-5.15.6/webapps/admin/,null}
java.lang.IllegalStateException: Parent for temp dir not configured correctly: writeable=false

您可以通过在容器规范中设置环境变量 ACTIVEMQ_TMP 来覆盖默认临时目录

 env:
    - name: ACTIVEMQ_TMP
      value : "/tmp"

推荐阅读