Kubernetes:在命令属性文件中找不到文件

时间:2018-11-23 08:18:35

标签: docker kubernetes

我使用具有32Gb内存的CentOs 7.4虚拟机。

我有docker composer,它具有以下配置:

submenus

使用上述docker级配置,我进行kubernetes配置:

cas-server-depl.yaml:

version: "2"
services:
  shiny-cas-server:
    image: shiny-cas
    command: puma -C config/puma.rb
    volumes:
      - ./cas-server/logs:/app/logs
      - ./cas-server/config:/app/config
      - ./cas-server/public:/app/public

在虚拟机中,我将apiVersion: extensions/v1beta1 kind: Deployment metadata: name: cas-server-depl spec: replicas: 1 template: metadata: labels: app: cas-server-pod spec: containers: - name: cas-server-pod image: shiny-cas imagePullPolicy: Never command: ["puma -C /cas-server/config/puma.rb"] ports: - containerPort: 100 volumeMounts: - mountPath: /app/logs name: cas-server-logs - mountPath: /app/config name: cas-server-config - mountPath: /app/public name: cas-server-public volumes: - name: cas-server-logs hostPath: path: /cas-server/logs - name: cas-server-config hostPath: path: /cas-server/config - name: cas-server-public hostPath: path: /cas-server/public 目录复制到./cas-server,并将chown和chgrp更改为我的登录名/cas-server,当我执行k8s时,它具有以下响应:

sudo kubectl apply -f cas-server-depl.yaml

然后我使用以下命令查看原因:

[k8s@k8s config]$ sudo kubectl get po
NAME                               READY     STATUS              RESTARTS   AGE
cas-server-depl-7f849bf94c-srg77   0/1       RunContainerError   1          5s

它说:

[k8s@k8s config]$ sudo kubectl describe po cas-server-depl-7988d6b447-ffff5
Name:               cas-server-depl-7988d6b447-ffff5
Namespace:          default
Priority:           0

IP:                 100.68.142.72
Controlled By:      ReplicaSet/cas-server-depl-7988d6b447
Containers:
  cas-server-pod:

    Command:
      puma -C /cas-server/config/puma.rb
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       ContainerCannotRun
      Message:      OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"puma -C /cas-server/config/puma.rb\": stat puma -C /cas-server/config/puma.rb: no such file or directory": unknown
      Exit Code:    128
      ...
    Ready:          False
    Restart Count:  2
    Environment:    <none>
    Mounts:
      /app/config from cas-server-config (rw)
      /app/logs from cas-server-logs (rw)
      /app/public from cas-server-public (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-mrkdx (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  cas-server-logs:
    Type:          HostPath (bare host directory volume)
    Path:          /cas-server/logs
    HostPathType:

    HostPathType:
  default-token-mrkdx:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-mrkdx
    Optional:    false


  Normal   Created    15s (x3 over 29s)  kubelet, k8s.xxx.com.cn  Created container
  Warning  Failed     15s (x3 over 28s)  kubelet, k8s.xxx.com.cn  Error: failed to start container "cas-server-pod": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"puma -C /cas-server/config/puma.rb\": stat puma -C /cas-server/config/puma.rb: no such file or directory": unknown
  Warning  BackOff    1s (x3 over 26s)   kubelet, k8s.shinyinfo.com.cn  Back-off restarting failed container

我在命令中尝试了Message: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"puma -C /cas-server/config/puma.rb\": stat puma -C /cas-server/config/puma.rb: no such file or directory": unknown /app/config/puma.rb,它们都有相同的错误消息。我应该写哪个目录?我可以看到puma.rb确实存在。

我的cas-server-svc.yaml被粘贴为参考:

config/puma.rb

3 个答案:

答案 0 :(得分:2)

当你说

int x = 0;
for(int y : binary) {
    x = x * 2 + y;
}
return x;

您要告诉Kubernetes告诉Docker寻找一个名为command: ["puma -C /cas-server/config/puma.rb"] 的可执行文件,您认为命令行选项实际上是文件名的一部分。您需要将参数分成YAML列表语法中的单独元素,例如

puma -C ...

command: ["puma", "-C", "/cas-server/config/puma.rb"]

答案 1 :(得分:1)

路径应为cbar.ax.set_ylim(0, loc_on_cbar) cbar.ax.autoscale_view() 而不是/app/config/puma.rb,因为您在/cas-server/config/puma.rb中装入了cas-server-config。另外,请确保主机路径中存在/app/config/文件。

/cas-server/config/puma.rb

答案 2 :(得分:0)

@David Maze,@ nightfury1204谢谢您的回答。每个人都回答了问题的一部分。

路径应为/app/config,命令行如下:

command: ["/bin/sh"]
args: ["-c","puma -C /app/config/puma.rb"]

此外,还应该注意/ app / config对登录用户的访问权限。