a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 學院 > 操作系統 > 正文

Kubernetes 1.5 實踐 給Pod中的容器定義命令和參數

2024-06-28 16:02:29
字體:
來源:轉載
供稿:網友

Kubernetes 1.5 實踐 給Pod中的容器定義命令和參數

defining a Command and Arguments for a Container 給容器定義一個命令和參數。

This page shows how to define commands and arguments when you run a container in a Kubernetes Pod. 這篇文章展示當運行kubernetes pod的時候,如何給容器定義命令和參數。

When you create a Pod, you can define a command and arguments for the containers that run in the Pod. To define a command, include the command field in the configuration file. To define arguments for the command, include the args field in the configuration file. The command and arguments that you define cannot be changed after the Pod is created. 當創建Pod的時候,我們可以給這個Pod中的容器定義命令和參數。 定義命令,需要在配置文件中加入command標簽。為這個命令定義參數,需要加入args標簽。當Pod創建好了以后,定義好的命令和參數不可以被變更和修改。

The command and arguments that you define in the configuration file override the default command and arguments PRovided by the container image. If you define args, but do not define a command, the default command is used with your new arguments. For more information, see Commands and Capabilities. 如果在容器的鏡像中定義了命令和參數,那么如果在配置文件中再次定義,則鏡像中定義的命令和參數會被覆蓋。如果只定義了參數,沒有定義命令,那么默認的命令會使用新定義的參數。更多的信息,查看Commands和Capabilities.

In this exercise, you create a Pod that runs one container. The configuration file for the Pod defines a command and two arguments: 在這個練習中,會創建一個運行了一個容器的Pod。在配置文件中配置的Pod定義了一個命令和兩個參數: commands.yaml

apiVersion: v1kind: Podmetadata: name: command-demo labels: purpose: demonstrate-commandspec: containers: - name: command-demo-container image: debian command: ["printenv"] args: ["HOSTNAME", "KUBERNETES_PORT"]Create a Pod based on the YAML configuration file:通過yaml配置文件創建Pod: kubectl create -f http://k8s.io/docs/tasks/configure-pod-container/commands.yamlList the running Pods:查看運行的Pods: kubectl get podsThe output shows that the container that ran in the command-demo Pod has completed.輸出可以查看到容器已經在command-demo pod中已經完成。To see the output of the command that ran in the container, view the logs from the Pod:查看容器的輸出結果,輸出Pod的日志: kubectl logs command-demoThe output shows the values of the HOSTNAME and KUBERNETES_PORT environment variables:輸出顯示出HOSTNAME和KUBERNETES_PORT兩個環境變量的值 command-demo tcp://10.3.240.1:443

Using environment variables to define arguments 使用環境變量來定義參數 In the preceding example, you defined the arguments directly by providing strings. As an alternative to providing strings directly, you can define arguments by using environment variables:

env: - name: MESSAGE value: “hello world” command: [“/bin/echo”] args: [“$(MESSAGE)”]

This means you can define an argument for a Pod using any of the techniques available for defining environment variables, including ConfigMaps and Secrets.

NOTE: The environment variable appears in parentheses, “$(VAR)”. This is required for the variable to be expanded in the command or args field. Running a command in a shell

In some cases, you need your command to run in a shell. For example, your command might consist of several commands piped together, or it might be a shell script. To run your command in a shell, wrap it like this:

command: [“/bin/sh”] args: [“-c”, “while true; do echo hello; sleep 10;done”]


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 免费在线观看av的网站 | 色玖玖综合 | 超碰超碰在线观看 | 日韩成人综合 | 亚洲视频在线看 | 综合色婷婷一区二区亚洲欧美国产 | 国产一区二区在线播放 | 国产在线一区二 | 国产欧美日 | 欧美日韩精品一区二区 | 福利二区视频 | 欧美日韩亚洲国产综合 | 一区二区中文 | 97人人看 | 色激情五月 | 久久成人免费 | 久久久网址 | 精品久久久中文字幕 | 成年人看的羞羞网站 | www国产成人免费观看视频 | 国产拍拍视频 | 日本中文字幕一区 | 日本不卡一区 | 日韩视频在线免费观看 | 亚洲欧美日韩另类一区二区 | 久草在线在线精品观看 | av免费网站在线观看 | 天天澡天天狠天天天做 | 国产91精品在线 | 国产精品自产av一区二区三区 | aa级毛片毛片免费观看久 | 国产精品禁久久精品 | 国产中文在线 | 国产精品视屏 | 成人午夜精品一区二区三区 | 国产女人免费看a级丨片 | 国产精品免费av | 午夜影院18 | 男人天堂视频在线观看 | 国产乱码精品一区二区三区忘忧草 | 一区二区三区视频在线播放 |