我在Kubernetes上部署Airflow时遇到错误(正是这个版本的Airflow https://github.com/puckel/docker- airflow/blob/1.8.1/Dockerfile)关于将权限写入文件系统。
窗格的日志中显示的错误是:
sed: couldn't open temporary file /usr/local/airflow/sed18bPUH: Read-only file system sed: -e expression #1, char 131: unterminated `s' command sed: -e expression #1, char 118: unterminated `s' command Initialize database... sed: couldn't open temporary file /usr/local/airflow/sedouxZBL: Read-only file system Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/airflow/configuration.py", line 769, in .... with open(TEST_CONFIG_FILE, 'w') as f: IOError: [Errno 30] Read-only file system: '/usr/local/airflow/unittests.cfg'
看来文件系统是只读的,但我不明白为什么会这样。我不确定这是否是 Kubernetes的错误配置 (我是否需要Pod专用的RBAC?不知道)还是 Dockerfile 出现问题。
部署文件如下所示:
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: airflow namespace: test spec: replicas: 1 revisionHistoryLimit: 3 strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 0 maxSurge: 1 template: metadata: labels: app: airflow spec: restartPolicy: Always containers: - name: webserver image: davideberdin/docker-airflow:0.0.4 imagePullPolicy: Always resources: limits: cpu: 1 memory: 1Gi requests: cpu: 50m memory: 128Mi securityContext: #does not have any effect runAsUser: 0 #does not have any effect ports: - name: airflow-web containerPort: 8080 args: ["webserver"] volumeMounts: - name: airflow-config-volume mountPath: /usr/local/airflow readOnly: false #does not have any effect - name: airflow-logs mountPath: /usr/local/logs readOnly: false #does not have any effect volumes: - name: airflow-config-volume secret: secretName: airflow-config-secret - name: airflow-parameters-volume secret: secretName: airflow-parameters-secret - name: airflow-logs emptyDir: {}
知道如何使文件系统可写吗?容器以 USER气流的 形式运行,但我认为该用户具有root特权。
volumeMounts: - name: airflow-config-volume mountPath: /usr/local/airflow volumes: - name: airflow-config-volume secret: secretName: airflow-config-secret
是您的问题的根源,有两个原因:首先,您已通过将秘密秘密直接卷装到映像上,将其秘密存储到该映像需要目录拥有的位置,从而砸碎了气流用户的主目录。airflow
airflow
另外,尽管我必须启动一个集群以确认100%,但我很确定Secret卷装载-我 认为 他们的ConfigMap朋友- 是对Pod文件系统的只读投影;这种怀疑肯定符合您的经验。当然,不希望这些卷的更改传播回到kubernetes集群中,所以为什么假装不然。
Secret
ConfigMap
如果您想继续尝试这种事情,那么实际上您确实会对投影到defaultMode该 文件 中的 文件 产生影响volumeMount,因此可以将它们设置为0666,但请确保一定要注意。到目前为止,简短的版本不适合$AIRFLOW_HOME使用卷安装。
defaultMode
volumeMount
0666
$AIRFLOW_HOME