云容器实例 CCI-创建Pod:请求示例

时间:2023-12-01 17:06:47

请求示例

  • 创建普通Pod,使用redis镜像,Pod资源占用CPU为0.5,内存为1024Mi。

    {
      "apiVersion" : "v1",
      "kind" : "Pod",
      "metadata" : {
        "labels" : {
          "name" : "pod-test"
        },
        "name" : "pod-test"
      },
      "spec" : {
        "containers" : [ {
          "image" : "redis",
          "imagePullPolicy" : "Always",
          "name" : "test",
          "resources" : {
            "limits" : {
              "cpu" : "0.5",
              "memory" : "1024Mi"
            },
            "requests" : {
              "cpu" : "0.5",
              "memory" : "1024Mi"
            }
          }
        } ],
        "imagePullSecrets" : [ {
          "name" : "imagepull-secret"
        } ],
        "priority" : 0,
        "restartPolicy" : "Always"
      }
    }
  • 创建GPU型Pod,使用gpu-418.126版本显示驱动,使用redis镜像,Pod资源占用CPU为4,内存为32Gi。

    说明: “华北-北京四”区域,仅支持NVIDIA TeslaV100 32G显卡。“华东-上海一”可支持NVIDIA TeslaV100 32G、NVIDIA TeslaV100 16G显卡。

    {
      "apiVersion" : "v1",
      "kind" : "Pod",
      "metadata" : {
        "annotations" : {
          "cri.cci.io/gpu-driver" : "gpu-418.126"
        },
        "labels" : {
          "name" : "pod-test"
        },
        "name" : "pod-test"
      },
      "spec" : {
        "containers" : [ {
          "image" : "redis",
          "imagePullPolicy" : "Always",
          "name" : "test",
          "resources" : {
            "limits" : {
              "cpu" : "4",
              "memory" : "32Gi",
              "nvidia.com/gpu-tesla-v100-16GB" : "1"
            },
            "requests" : {
              "cpu" : "4",
              "memory" : "32Gi",
              "nvidia.com/gpu-tesla-v100-16GB" : "1"
            }
          }
        } ],
        "imagePullSecrets" : [ {
          "name" : "imagepull-secret"
        } ],
        "priority" : 0,
        "restartPolicy" : "Always"
      }
    }
  • 通过LVM方式创建本地卷的Pod,容器内卷的挂载路径为“/tmp/log”。

    {
      "apiVersion" : "v1",
      "kind" : "Pod",
      "metadata" : {
        "labels" : {
          "app" : "localvolume"
        },
        "name" : "localvolume",
        "namespace" : "cci-namespace-12192721"
      },
      "spec" : {
        "containers" : [ {
          "command" : [ "/bin/sh", "-c", "sleep 10000" ],
          "image" : "100.79.1.215:20202/paas_cci_test/redis:v1",
          "imagePullPolicy" : "Always",
          "lifecycle" : { },
          "name" : "container-0",
          "resources" : {
            "limits" : {
              "cpu" : "500m",
              "memory" : "1024Mi"
            },
            "requests" : {
              "cpu" : "500m",
              "memory" : "1024Mi"
            }
          },
          "terminationMessagePath" : "/dev/termination-log",
          "terminationMessagePolicy" : "File",
          "volumeMounts" : [ {
            "mountPath" : "/tmp/log",
            "name" : "innerevs123"
          } ]
        } ],
        "dnsPolicy" : "Default",
        "imagePullSecrets" : [ {
          "name" : "imagepull-secret"
        } ],
        "nodeSelector" : {
          "node.cci.io/allowed-on-poc-dedicated-node" : "sina"
        },
        "restartPolicy" : "Always",
        "schedulerName" : "default-scheduler",
        "tolerations" : [ {
          "effect" : "NoSchedule",
          "key" : "node.cci.io/allowed-on-poc-dedicated-node",
          "operator" : "Equal",
          "value" : "sina"
        } ],
        "volumes" : [ {
          "emptyDir" : {
            "sizeLimit" : "100Gi"
          },
          "name" : "innerevs123"
        } ]
      }
    }
support.huaweicloud.com/api-cci/createCoreV1NamespacedPod.html