使用特定命令启动kubernetes容器 [英] Start kubernetes container with specific command

查看:357
本文介绍了使用特定命令启动kubernetes容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用车队,我可以指定一个在容器启动时要在容器内运行的命令. Kubernetes似乎也应该很容易做到这一点,但是我似乎找不到任何能说明如何实现的东西.似乎您必须创建专门用于通过特定命令启动的容器.

Using fleet I can specify a command to be run inside the container when it is started. It seems like this should be easily possible with Kubernetes as well, but I can't seem to find anything that says how. It seems like you have to create the container specifically to launch with a certain command.

拥有一个通用容器并用不同的参数启动它要比为特定情况创建许多不同的容器或设置和获取环境变量要简单得多.

Having a general purpose container and launching it with different arguments is far simpler than creating many different containers for specific cases, or setting and getting environment variables.

是否可以在启动时指定kubernetes pod在Docker映像中运行的命令?

Is it possible to specify the command a kubernetes pod runs within the Docker image at startup?

推荐答案

我花了45分钟寻找它.然后我发布了一个问题,并在9分钟后找到了解决方案.

I spend 45 minutes looking for this. Then I post a question about it and find the solution 9 minutes later.

我想在Cassandra 示例中找到什么.图片下方的command行:

There is an hint at what I wanted inside the Cassandra example. The command line below the image:

id: cassandra
kind: Pod
apiVersion: v1beta1
desiredState:
  manifest:
    version: v1beta1
    id: cassandra
    containers:
      - name: cassandra
        image: kubernetes/cassandra
        command:
          - /run.sh
        cpu: 1000
        ports:
          - name: cql
            containerPort: 9042
          - name: thrift
            containerPort: 9160
        env:
          - key: MAX_HEAP_SIZE
            value: 512M
          - key: HEAP_NEWSIZE
            value: 100M
labels:
  name: cassandra

尽管找到了解决方案,但是如果Kubernetes项目中有明显的地方,我可以看到所有各种配置文件(pod,服务,复制控制器)的可能选项,那将是很好的选择

Despite finding the solution, it would be nice if there was somewhere obvious in the Kubernetes project where I could see all of the possible options for the various configuration files (pod, service, replication controller).

这篇关于使用特定命令启动kubernetes容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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