【问题标题】:Pod with a single container and multiple images具有单个容器和多个图像的 Pod
【发布时间】:2021-07-08 22:38:03
【问题描述】:

如何为在一个容器 Redis + Nginx + busybox 内运行的以下每个图像创建一个名为 pod1 的 pod。

  • 有人可以回答这个问题吗?
  • 这是否可以在 Kubernetes?

【问题讨论】:

    标签: kubernetes


    【解决方案1】:
    • 有人可以回答这个问题吗? => 是的

    • 这可以在 Kubernetes 中创建吗? => 是的


    第一种方式(不推荐)

    apiVersion: v1
    kind: Pod
    metadata:
      name: po-with-multiple-container
    spec:
      containers:
      - image: redis:5.0.4
        name: redis-container
    
      - image: nginx:latest
        name: webserver-container
        ports:
          - containerPort: 80
    
      - image: busybox
        name: busybox-container
        command: [ "/bin/bash", "-c", "--" ]
        args: [ "while true; do sleep 30; done;" ]
    

    第二种方式 - 推荐方式

    apiVersion: v1
    kind: Pod
    metadata:
      name: po-with-multiple-container
    spec:
      containers:
        - image: redis:5.0.4
          name: redis-container
     
    ---
    
    apiVersion: v1
    kind: Pod
    metadata:
      name: po-with-multiple-container
    spec:
      containers:
        - image: nginx:latest
          name: webserver-container
          ports:
            - containerPort: 80
              
    ---
    apiVersion: v1
    kind: Pod
    metadata:
      name: po-with-multiple-container
    spec:
      containers:
        - image: busybox
          name: busybox-container
          command: [ "/bin/bash", "-c", "--" ]
          args: [ "while true; do sleep 30; done;" ]
    

    【讨论】:

      猜你喜欢
      • 2021-08-15
      • 1970-01-01
      • 2019-09-19
      • 2019-12-28
      • 2021-06-22
      • 2022-01-19
      • 1970-01-01
      • 2020-08-18
      • 2021-09-30
      相关资源
      最近更新 更多