开发者社区> 问答> 正文

如何使用 ECS 规格创建 Pod?

如何使用 ECS 规格创建 Pod?

展开
收起
小天使爱美 2020-03-20 17:32:18 1247 0
1 条回答
写回答
取消 提交回答
  • 根据 ECS 指定实例规格 创建 Pod(ECI实例) 容器服务支持根据 指定 ECS 实例规格 创建 ECI 实例。

    进入容器服务应用菜单,比如无状态,创建应用 k8s

    点击右上角,使用模板创建 k8s

    k8s

    只要在pod模板里加入以下注解即可(这里预留实例券购买的是ecs.c5.large实例) 注意 annotations 是加在 Pod 描述上,并根据实际需求填写 ECS 规格,ECS 规格列表可以参考 ECS 实例规格列表:

    annotations: k8s.aliyun.com/eci-instance-type : "ecs.c5.large" #根据需要替换 ECS 规格 ecs.规格族.规格大小,例如:(ecs.c6.3xlarge) Pod Yaml文件 apiVersion: v1 kind: Pod metadata: labels: name: hello-pod name: hello-pod annotations: k8s.aliyun.com/eci-instance-type : "ecs.c5.large" #根据需要替换 ECS 规格 spec:

    serviceAccountName: user1 # specify specific sevice account for pod creation

    automountServiceAccountToken: true # mount token for api access inside pod/container

    imagePullSecrets: #Comment out to enable specific image pull secret

    - name: myregistrykey # repleace it to specific registry key

    containers: - image: nginx imagePullPolicy: IfNotPresent name: hello-pod ports: - containerPort: 8080 protocol: TCP resources: {} securityContext: capabilities: {} privileged: false terminationMessagePath: /dev/termination-log dnsPolicy: ClusterFirst restartPolicy: Always

    nodeSelector:

    env: test-team

    status: {} Deployment Yaml文件 需要注意 annotations 添加的位置,需要添加到 Pod 的 metadata 中。

    apiVersion: apps/v1beta2 # for versions before 1.8.0 use apps/v1beta1 kind: Deployment metadata: name: nginx-deployment-basic labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx annotations: k8s.aliyun.com/eci-instance-type : "ecs.c5.large" #根据需要替换 ECS 规格 spec: # nodeSelector: # env: test-team containers: - name: nginx image: nginx:1.7.9 # replace it with your exactly <image_name:tags> ports: - containerPort: 80 查看创建的容器组 k8s

    另外,也可以在 ECI 控制台上看到新创建的实例

    2020-03-20 17:33:43
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS快储存加密技术 立即下载