gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 11:52:21 25 4
gpt4 key购买 nike

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

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

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

使用以上 docker 级别的配置,我进行 kubernetes 配置:

cas-server-depl.yaml:
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目录到 /cas-server ,并将 chown 和 chgrp 更改为我的登录名 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.rbconfig/puma.rb在命令中,两者都有相同的错误消息。我要写哪个目录?我可以看到 puma.rb 确实存在。

我的 cas-server-svc.yaml 被粘贴为引用:
apiVersion: v1
kind: Service
metadata:
name: cas-server-svc
labels:
name: cas-server-svc
spec:
selector:
app: cas-server-pod
type: NodePort
ports:
- port: 100
nodePort: 31101
name: tcp

最佳答案

当你说

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

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

或者
command:
- puma
- -C
- /cas-server/config/puma.rb

关于docker - Kubernetes:在命令属性文件中找不到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53442906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com