云容器实例 CCI-对容器进行初始化操作:操作步骤

时间:2024-11-05 11:16:28

操作步骤

  1. 编辑initcontainer工作负载yaml文件。

    vi deployment.yaml

    Yaml示例如下:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mysql
    spec:
      replicas: 1
      selector:
        matchLabels:
          name: mysql
      template:
        metadata:
          labels:
            name: mysql
        spec:
          initContainers:
          - name: getresource
            image: busybox
            command: ['sleep','20']
          containers:
          - name: mysql
            image: percona:5.7.22
            imagePullPolicy: Always
            ports:
            - containerPort: 3306
            resources:
              limits:
                memory: "500Mi"
                cpu: "500m"
              requests:
                memory: "500Mi"
                cpu: "250m"
            env:
            - name: MYSQL_ROOT_PASSWORD
              value: "mysql"

  2. 创建initcontainer工作负载。

    kubectl create -f deployment.yaml

    命令行终端显示如下类似信息:

    deployment.apps/mysql created

support.huaweicloud.com/devg-cci/cci_05_0030.html