您好,欢迎来到12图资源库!分享精神,快乐你我!我们只是素材的搬运工!!
  • 首 页
  • 当前位置:首页 > 开发 > WEB开发 >
    Kubernetes资源清单篇:如何创立资源?(4)
    时间:2020-11-23 08:59 来源:网络整理 作者:网络 浏览:收藏 挑错 推荐 打印

         expanded, regardless of whether the variable exists or not. Cannot be 

         updated. More info: 

         https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell 

     

       command  <[]string> 

         Entrypoint array. Not executed within a shell. The docker image's 

         ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) 

         are expanded using the container's environment. If a variable cannot be 

         resolved, the reference in the input string will be unchanged. The 

         $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). 

         Escaped references will never be expanded, regardless of whether the 

         variable exists or not. Cannot be updated. More info: 

         https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell 

    …… 

    2.2 示例

    在命名空间test中,定义一个名为frontend的Pod。

    (1)定义命名空间

    为了便于前期测试,特定义一个新的命名空间test。(假设命名空间test已存在,则无需再建)

    命名空间test的资源清单文件test-namespace.yaml如下:

    apiVersion: v1 

    kind: Namespace 

    metadata:    

      name: test 

    执行kubectl create命令创立该Namespace:

    [xcbeyond@bogon ~]$ kubectl create -f test-namespace.yaml  

    namespace/test created 

    (2)定义Pod

    定义一个名为frontend的Pod,由一个容器组成,资源清单文件frontend-pod.yaml如下:

    apiVersion: v1 

    kind: Pod 

    metadata: 

      name: frontend 

      namespace: test 

      labels: 

        app: frontend 

    spec: 

      containers: 

      - name: frontend 

        image: xcbeyond/vue-frontend:latest 

        ports: 

          - name: port 

            containerPort: 80 

            hostPort: 8080 

    执行kubectl create命令创立该Pod:

    [xcbeyond@bogon ~]$ kubectl create -f frontend-pod.yaml  

    pod/frontend created 

    经过命令kubectl get pods -n 查看,创立Pod的形状:

    [xcbeyond@bogon ~]$ kubectl get pods -n test 

    NAME       READY   STATUS   RESTARTS   AGE 

    frontend   1/1     Runing   0          79s 

    【编辑引荐】

    谷歌概述了2021年的Android运用开发与政策变动规划

    GitHub CEO霸气回应:「千年数字版权法」不适用,把youtube-dl还给开发者!

    【开发板试用报告】HarmonyOS之HelloWorld,WIFI衔接,Socket tcp

    致命错误!Python开发者的7个崩溃瞬间

    与10倍开发者同事两年,我学到了不一样的东西

    (责任编辑:admin)