k8s:两个图像但一个容器 [英] k8s:Two images but single container

查看:71
本文介绍了k8s:两个图像但一个容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是在线测试中出现的问题的确切字词.

Below are the exact words of a question that came up in an online test.

创建一个在名为"bla-bla"的pod中运行的单一容器应用,和 下面列出的四个图像中的任何三个.图片:nginx + redis + 内存缓存.

Create an single container app running in a pod named "bla-bla" with any 3 of the four images listed below. Images: nginx + redis+ memcached.

我不确定这是文字游戏还是错字,但我想知道的是在单个容器中是否有用于启动多个图像的语法?我知道可以通过在单个吊舱中放置多个容器来完成此操作,但是根据问题中的措辞,我认为这不是他们所期望的.我在Kubernetes官方论坛上看到了同样的问题,但那里也没有答案.因此,将其发布在此处,以便覆盖更广泛的受众.

I'm not sure whether this is a wordplay or a typo but what I would like to know is whether there is any syntax for launching multiple images in a single container? I know this can be done by having multiple containers within a single pod but according to the wordings in the question, I don't think that is what they expect. I saw this same exact question in Kubernetes official forum but no answer there too. Hence posting it here so it can reach a wider audience.

论坛问题:推荐答案

我看不到问题所在.它要求创建一个在容器中运行的容器应用" ,而不是一个单个容器" .

I don't see the problem with the question. It asks to create a single "container app running in a pod", not a "single container".

因此,具有多个容器的单个吊舱就是答案.这是示例.

So single pod with multiple containers is the answer. Here is the example.

apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:

  restartPolicy: Never

  volumes:
  - name: shared-data
    emptyDir: {}

  containers:

  - name: nginx-container
    image: nginx
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html

  - name: debian-container
    image: debian
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]

这篇关于k8s:两个图像但一个容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆