首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >runc创建失败:无法启动容器进程: exec:没有这样的文件或目录

runc创建失败:无法启动容器进程: exec:没有这样的文件或目录
EN

Stack Overflow用户
提问于 2022-11-11 16:24:35
回答 1查看 250关注 0票数 -1

我正试图通过舵图在Openshift上部署一个容器化的helm应用程序。当我部署应用程序时,我会在吊舱日志中得到以下错误-

代码语言:javascript
复制
Events:
  Type     Reason          Age                   From               Message

  Normal   Pulled          14m                   kubelet            Successfully pulled image "<private-gitlab-registry-docker-image>:latest" in 3.787555091s
  Warning  Failed          14m                   kubelet            Error: container create failed: time="2022-11-11T13:51:47Z" level=error msg="runc create failed: unable to start container process: exec: \"python3 src/myapp.py\": stat python3 src/myapp.py: no such file or directory"

这是码头文件-

代码语言:javascript
复制
FROM <private-gitlab-registry-centos-image>

ADD files/etc/yum.repos.d/* /etc/yum.repos.d/

RUN yum update -y

WORKDIR /app

RUN yum install -y python-keystoneclient python3-flask python3-keystoneauth1 python3-redis python3-werkzeug python3-pip python3-keystoneclient
RUN pip install flask-caching

COPY . /app

ENTRYPOINT [ "python3" ]

CMD [ "src/myapp.py" ]

当我手动运行这个码头映像时,它工作得很好。但是当我在Kubernetes上部署它时,kubelet抛出了上面的错误。

这是我的deployment.yaml -

代码语言:javascript
复制
---
apiVersion: apps/v1
kind: Deployment                 # Type of Kubernetes resource
metadata:
  name: myapp             # Unique name of the Kubernetes resource
spec:
  replicas: 1                    # Number of pods to run at any given time
  selector:
    matchLabels:
      app: myapp          # This deployment applies to any Pods matching the specified label
  template:                      # This deployment will create a set of pods using the configurations in this template
    metadata:
      labels:                    # The labels that will be applied to all of the pods in this deployment
        app: myapp 
    spec:
      containers:
      - name: myapp
        image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
        imagePullPolicy: {{ .Values.image.imagePullPolicy }}
          {{- include "myapp.command" . | nindent 8 }}
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        ports:
          - containerPort: 8080  # Should match the port number that the Go application listens on    
        env:                     # Environment variables passed to the container
          - name: REDIS_HOST
            value: redis-master
          - name: REDIS_PORT
            value: "6379"  

而values.yaml -

代码语言:javascript
复制
image:
  repository: gitlab-registry.cern.ch/batch-team/hepspec-query/hepspec-query
  tag: latest
  imagePullSecret: {}
  imagePullPolicy: Always
  command: [ "python3" , "src/hepspecapp.py" ]
  args: {}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-12 01:59:01

这里要做的最简单的事情是删除这里提供command:的Helm图表中的部分,并重写图像的ENTRYPOINT。映像已经知道它应该运行什么命令(如果在两个Docker指令中被奇怪地拆分),并且在运行映像时不需要指定它。类似地,在部署时将其重新配置为运行其他命令而不对容器设置进行实质性重新架构也是很奇怪的。

代码语言:javascript
复制
containers:
  - name: myapp
    image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
    imagePullPolicy: {{ .Values.image.imagePullPolicy }}
    # but you don't need to specify command: or make it configurable

如果对您来说使此可配置很重要,那么您可能会遇到一个语法问题,在模板之外的列表的默认Go序列化中。如果您在图表上运行helm template,它可能会打印以下内容

代码语言:javascript
复制
containers:
  - name: myapp
    image: gitlab-registry.cern.ch/batch-team/hepspec-query/hepspec-query:latest
    imagePullPolicy: Always
    command: [python3 src/hepspecapp.py]

也就是说,.Values.command是一个列表,它作为一个列表在内部被解析和存储,您将得到一个默认的序列化,而这不是values.yaml文件中的内容。碰巧,这是有效的YAML,但现在它是一个包含一个包含嵌入式空间的字符串的列表。

Helm包含一个文档很少的toYaml函数,它可以将任意结构转换回有效的YAML。这是缩进的,从第一列开始,因此您需要确保适当地indent结果。

代码语言:javascript
复制
containers:
  - name: myapp
{{- if .Values.command }}
    command:
{{ .Values.command | toYaml | indent 6 }}
{{- end }}
{{- if .Values.args }}
    args:
{{ .Values.args | toYaml | indent 6 }}
{{- end }}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74405428

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档