Pilosa k8s pod crashloopbackoff 出现错误 "server : executable file not found in $PATH"

Pilosa k8s pod crashloopbackoff with error "server : executable file not found in $PATH"

我正在为 pilosa 准备舵图。安装图表后(或创建部署时), pilosa pod 进入 CrashLoopBackOff。

这是为 k8s 部署渲染的 YAML 文件。

# Source: pilosa/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: RELEASE-NAME-pilosa
  labels:
    helm.sh/chart: pilosa-0.1.0
    app.kubernetes.io/name: pilosa
    app.kubernetes.io/instance: RELEASE-NAME
    app.kubernetes.io/version: "1.16.0"
    app.kubernetes.io/managed-by: Helm
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: pilosa
      app.kubernetes.io/instance: RELEASE-NAME
  template:
    metadata:
      labels:
        app.kubernetes.io/name: pilosa
        app.kubernetes.io/instance: RELEASE-NAME
    spec:
      imagePullSecrets:
        - name: my-cr-secret
      serviceAccountName: default
      securityContext:
        {}
      initContainers:
        - command:
          - /bin/sh
          - -c
          - |
            sysctl -w net.ipv4.tcp_keepalive_time=600
            sysctl -w net.ipv4.tcp_keepalive_intvl=60
            sysctl -w net.ipv4.tcp_keepalive_probes=3
          image: busybox
          name: init-sysctl
          securityContext:
            privileged: true
      containers:
        - name: pilosa
          securityContext:
            {}
          image: "mycr.azurecr.io/pilosa:v1.4.0"
          imagePullPolicy: IfNotPresent
          command:
            - server
            - --data-dir
            - /data
            - --max-writes-per-request
            - "20000"
            - --bind
            - http://pilosa:10101
            - --cluster.coordinator=true
            - --gossip.seeds=pilosa:14000
            - --handler.allowed-origins="*"
          ports:
            - name: http
              containerPort: 10101
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          volumeMounts:
            - name: "pilosa-pv-storage"
              mountPath: /data
          resources:
            {}
      volumes:
      - name: pilosa-pv-storage
        persistentVolumeClaim:
          claimName: pilosa-pv-claim

检查原因后我发现:

$ kubectl describe pod pilosa-57cb7b8764-knsmw
.

.

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  48s                default-scheduler  Successfully assigned default/pilosa-57cb7b8764-knsmw to 10.0.10.3
  Normal   Pulling    47s                kubelet            Pulling image "busybox"
  Normal   Pulled     45s                kubelet            Successfully pulled image "busybox"
  Normal   Created    45s                kubelet            Created container init-sysctl
  Normal   Started    45s                kubelet            Started container init-sysctl
  Normal   Pulling    45s                kubelet            Pulling image "mycr.azurecr.io/pilosa:v1.2.0"
  Normal   Pulled     15s                kubelet            Successfully pulled image "mycr.azurecr.io/pilosa:v1.2.0"
  Normal   Created    14s (x2 over 15s)  kubelet            Created container pilosa
  Warning  Failed     14s (x2 over 15s)  kubelet            Error: failed to start container "pilosa": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"server\": executable file not found in $PATH": unknown
  Normal   Pulled     14s                kubelet            Container image "mycr.azurecr.io/pilosa:v1.2.0" already present on machine
  Warning  BackOff    10s                kubelet            Back-off restarting failed container

这意味着问题是它不能 运行 命令服务器 :

 Error: failed to start container "pilosa": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"server\": executable file not found in $PATH": unknown

但是该命令在此处指定的 pilosa 中可用:https://www.pilosa.com/docs/latest/installation/

谁能帮我找到解决办法?

这里的问题是 Kubernetes 覆盖了 Pilosa Docker 图像中的 ENTRYPOINTserver 命令实际上是 pilosa 的子命令,它的工作原理是因为 Pilosa Docker 文件定义命令的方式:

ENTRYPOINT ["/pilosa"]
CMD ["server", "--data-dir", "/data", "--bind", "http://0.0.0.0:10101"]

因为您使用的是 command: 声明,它会在调用容器时覆盖 ENTRYPOINTCMD

我认为简单的解决方案是将command:替换为args:,我相信k8s将不再覆盖ENTRYPOINT。或者您可以将 /pilosa 添加到命令的前面。

您也可以看看这个 Pilosa helm chart,它没有维护,但可能对您有用。请注意,它使用 StatefulSet 而不是 Deployment,这应该更适合 Pilosa:https://github.com/pilosa/helm