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

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

请求示例

  • 创建一个名为"deployment-test"的普通Deployment,使用redis镜像创建一个Pod,每个Pod占用500m core CPU、1024Mi内存。

    {
      "apiVersion" : "apps/v1",
      "kind" : "Deployment",
      "metadata" : {
        "name" : "deployment-test"
      },
      "spec" : {
        "replicas" : 1,
        "selector" : {
          "matchLabels" : {
            "app" : "redis"
          }
        },
        "template" : {
          "metadata" : {
            "labels" : {
              "app" : "redis"
            }
          },
          "spec" : {
            "containers" : [ {
              "image" : "redis",
              "name" : "container-0",
              "resources" : {
                "limits" : {
                  "cpu" : "500m",
                  "memory" : "1024Mi"
                },
                "requests" : {
                  "cpu" : "500m",
                  "memory" : "1024Mi"
                }
              }
            } ],
            "imagePullSecrets" : [ {
              "name" : "imagepull-secret"
            } ],
            "priority" : 0
          }
        }
      }
    }
  • 创建使用GPU的Deployment,NVIDIA GPU的驱动版本为418.126。

    {
      "apiVersion" : "apps/v1",
      "kind" : "Deployment",
      "metadata" : {
        "name" : "test-app",
        "namespace" : "test-namespace"
      },
      "spec" : {
        "replicas" : 2,
        "selector" : {
          "matchLabels" : {
            "app" : "test-app"
          }
        },
        "template" : {
          "metadata" : {
            "annotations" : {
              "cri.cci.io/gpu-driver" : "gpu-418.126"
            },
            "labels" : {
              "app" : "test-app"
            }
          },
          "spec" : {
            "containers" : [ {
              "image" : "library/nginx:stable-alpine-perl",
              "lifecycle" : { },
              "name" : "container-0",
              "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"
            } ],
            "restartPolicy" : "Always"
          }
        }
      }
    }
support.huaweicloud.com/api-cci/createAppsV1NamespacedDeployment.html