大家好,我正在研究 Nifi,我正在尝试将其安装在 AKS(Azure kubernetes 服务)中。 使用nifi 1.9.2版本。在 AKS 中安装它时出现错误
replacing target file /opt/nifi/nifi-current/conf/nifi.properties
sed: preserving permissions for ‘/opt/nifi/nifi-current/conf/sedSFiVwC’: Operation not permitted
replacing target file /opt/nifi/nifi-current/conf/nifi.properties
sed: preserving permissions for ‘/opt/nifi/nifi-current/conf/sedK3S1JJ’: Operation not permitted
replacing target file /opt/nifi/nifi-current/conf/nifi.properties
sed: preserving permissions for ‘/opt/nifi/nifi-current/conf/sedbcm91T’: Operation not permitted
replacing target file /opt/nifi/nifi-current/conf/nifi.properties
sed: preserving permissions for ‘/opt/nifi/nifi-current/conf/sedIuYSe1’: Operation not permitted
NiFi running with PID 28.
The specified run.as user nifi
does not exist. Exiting.
Received trapped signal, beginning shutdown...
下面是我的 nifi.yml 文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: nifi-core
spec:
replicas: 1
selector:
matchLabels:
app: nifi-core
template:
metadata:
labels:
app: nifi-core
spec:
containers:
- name: nifi-core
image: my-azurecr.io/nifi-core-prod:1.9.2
env:
- name: NIFI_WEB_HTTP_PORT
value: "8080"
- name: NIFI_VARIABLE_REGISTRY_PROPERTIES
value: "./conf/custom.properties"
resources:
requests:
cpu: "6"
memory: 12Gi
limits:
cpu: "6"
memory: 12Gi
ports:
- containerPort: 8080
volumeMounts:
- name: my-nifi-core-conf
mountPath: /opt/nifi/nifi-current/conf
volumes:
- name: my-nifi-core-conf
azureFile:
shareName: my-file-nifi-core/nifi/conf
secretName: my-nifi-secret
readOnly: false
我在 nifi Dockerfile
中进行了一些自定义,它复制了一些与我的配置相关的配置文件。当我在本地运行 my-azurecr.io/nifi-core-prod:1.9.2
docker 镜像时,它按预期工作
但是当我尝试在 AKS 上运行它时,会出现上述错误。因为它与权限相关,我在 Dockerfile 中尝试了用户 nifi
和 root
。
所有必需的配置文件都在同一资源组中运行的卷 my-nifi-core-conf
中提供。
由于我使用 docker 启动 nifi ,所以我的异常(exception)是,无论环境如何,它都会表现相同。无论是在我的本地还是在 AKS 中。
但是错误还说用户nifi不存在。 官方nifi-image设置用户要求。
任何人都可以帮忙吗,我无法在交互模式下启动容器,因为 Pod 不处于运行模式。提前致谢。
最佳答案
我认为您缺少 Kubernetes Pod 的安全上下文定义。 Nifi 在 Docker 中运行的用户具有特定的 UID 和 GID,根据您收到的错误消息,我怀疑是因为该用户未在 Pod 的安全上下文中定义,所以它没有按预期启动。
查看 Kubernetes 文档中有关安全上下文的部分,这应该足以让您入门。
在测试 Kubernetes 部署时,我还会考虑使用 Minikube 之类的东西,因为 Kubernetes 围绕 Docker 等容器引擎添加了大量控件。
安全上下文文档:https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ Minikube:https://kubernetes.io/docs/setup/learning-environment/minikube/
关于sed - 无法在 aks 中启动 apache-nifi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57141136/