Microservice Builder 组件

部署

类型

ucf.k8s.app.deployment

描述

用于指定 Kubernetes 工作负载部署类型(例如 Deployment / StatefulSet / DaemonSet 等)。应为 manifest 的 spec 部分中的第一个组件。

参数

字段

类型

描述

apptype

字符串(枚举)(必需

允许的值
statefull (StatefulSet)
stateless (Deployment)
job (Job)
cronjob (CronJob)
daemonset (DaemonSet)
replicaset (ReplicaSet)
static-pod (Pod)

Pod 部署类型

extraSpecs

对象

用于设置未显式支持的部署的额外字段

示例

---
spec:
- name: deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless
    extraSpecs:
      revisionHistoryLimit: 4

要在微服务中组合多种工作负载类型,请在单独的 YAML 文档中创建单独的 spec 部分

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: backend-container
  type: ucf.k8s.container
  ...

---
- name: frontend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: frontend-container
  type: ucf.k8s.container
  ...

容器

类型

ucf.k8s.container

描述

用于向部署工作负载添加容器。

参数

字段

类型

描述

image

对象(必需

容器镜像详情

.repository

字符串

容器镜像仓库地址

.tag

字符串

容器镜像标签

.config_path

字符串

容器构建器配置文件路径

.pullPolicy

字符串(枚举)

允许的值
Always
Never
IfNotPresent

容器镜像拉取策略

workload

字符串

对工作负载组件的名称引用 (ucf.appspec.app.workload)

command

字符串列表

要执行的命令行字符串数组

args

字符串列表

入口点的参数列表

env

列表

要设置的环境变量数组

.[].name

字符串

环境变量的名称

.[].value

字符串

环境变量的值

livenessProbe

对象

容器的存活探测。请参阅 Probe

readinessProbe

对象

容器的就绪探测。请参阅 Probe

startupProbe

对象

容器的启动探测。请参阅 Probe

ports

列表

要暴露的容器端口列表

.[]

对象

要暴露的容器端口的详细信息。请参阅 ContainerPort

resources

对象

容器资源需求。有关更多信息,请参阅 容器资源管理

.limits

对象

允许的最大计算资源量,以键值对形式提及。

.requests

对象

所需的最小计算资源量,以键值对形式提及。

volumeMounts

列表

要在容器中挂载的卷列表。

.[]

对象

要挂载的卷的详细信息。请参阅 VolumeMount

securityContext

对象

容器的安全配置。请参阅 SecurityContext

示例

# ``name`` of the component is set as the container name
- name: server
  type: ucf.k8s.container
  parameters:
    image:
      repository: nvcr.io/nvidia/pytorch
      tag: 22.04-py3
    command: [sh, -c]
    args: ["python -m http.server 8080"]
    ports:
    - containerPort: 8080
      name: http
    volumeMounts:
    - name: localvol
      mountPath: /localvol
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 250m
        memory: 512Mi
        nvidia.com/gpu: 1
    livenessProbe:
      httpGet:
        port: http
    readinessProbe:
      httpGet:
        port: http
    securityContext:
      runAsNonRoot: true

初始化容器

类型

ucf.k8s.initcontainer

描述

用于向部署工作负载添加初始化容器。

参数

字段

类型

描述

image

字符串(必需

容器镜像名称

imagePullPolicy

字符串(枚举)

允许的值
Always
Never
IfNotPresent

容器镜像拉取策略

command

字符串列表

要执行的命令行字符串数组

args

字符串列表

入口点的参数列表

env

列表

要设置的环境变量数组

.[].name

字符串

环境变量的名称

.[].value

字符串

环境变量的值

resources

对象

容器资源需求。有关更多信息,请参阅 容器资源管理

.limits

对象

允许的最大计算资源量,以键值对形式提及。

.requests

对象

所需的最小计算资源量,以键值对形式提及。

volumeMounts

列表

要在容器中挂载的卷列表。

.[]

对象

要挂载的卷的详细信息。请参阅 VolumeMount

securityContext

对象

容器的安全配置。请参阅 SecurityContext

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

# ``name`` of the component is set as the initcontainer name
- name: server
  type: ucf.k8s.initcontainer
  parameters:
    image: nvcr.io/nvidia/pytorch:22.04-py3
    command: [sh, -c]
    args: ["python -m http.server 8080"]
    volumeMounts:
    - name: localvol
      mountPath: /localvol
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 250m
        memory: 512Mi
        nvidia.com/gpu: 1
    securityContext:
      runAsNonRoot: true

类型

ucf.k8s.volume

描述

用于向部署工作负载添加卷。

参数

请参阅 Volume

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

  # ``name`` of the component is set as the volume name
  # ``name`` will be required to mount the volume in a container
- name: configmap-volume
  type: ucf.k8s.volume
  parameters:
    configMap:
      name: my-app-config

- name: data
  type: ucf.k8s.pvc
  parameters:
    annotations:
      helm.sh/resource-policy: "keep"
    spec:
      storageClassName: mdx-local-path # omit this line to use default StorageClass provisioner
      accessModes: [ReadWriteOnce]
      resources:
        requests:
          storage: 50Mi

- name: data-volume
  type: ucf.k8s.volume
  parameters:
    persistentVolumeClaim:
      claimName: ${CHART_NAME}-data # substitue ${CHART_NAME} with manifest.yaml's chartName value

- name: my-container
  type: ucf.k8s.container
  parameters:
    ...
    volumeMounts:
    - name: configmap-volume
      mountPath: /tmp/app-configs
    - name: data-volume
      mountPath: /data

卷声明模板

类型

ucf.k8s.volumeClaimTemplate

描述

用于为 Stateful 工作负载添加卷声明模板。

参数

字段

类型

描述

spec

对象(必需

持久卷声明规范

.storageClassName

字符串

PVC 的存储类

.volumeName

字符串

PVC 的卷名称

.accessModes

字符串列表

允许的值
ReadWriteOnce
ReadOnlyMany
ReadWriteMany
ReadWriteOncePod

请求的存储的访问模式。请参阅 访问模式

.resources

对象

存储资源需求

.requests

对象

存储资源请求

.storage

字符串

最小存储需求

.limits

对象

存储资源限制

.storage

字符串

最小存储需求

annotations

对象

要添加到 PVC 资源的注解,以键值对形式表示

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: statefull
    statefulSetServiceName: myservice

  # ``name`` of the component is set as the volume name
  # ``name`` will be required to mount the volume in a container
- name: data-storage
  type: ucf.k8s.volumeClaimTemplate
  parameters:
    annotations:
      helm.sh/resource-policy: "keep"
    spec:
      accessModes: [ReadWriteOnce]
      storageClassName: mdx-local-path # omit this line to use default StorageClass provisioner
      resources:
        requests:
          storage: 1Gi

- name: my-container
  type: ucf.k8s.container
  parameters:
    ...
    volumeMounts:
    - name: data-storage
      mountPath: /data

- name: myservice
  type: ucf.k8s.service
  parameters:
    ports:
    - port: 1000
      name: http-api

默认卷挂载

类型

ucf.appspec.defaultVolumeMount

描述

用于向部署工作负载中的所有容器/初始化容器添加 volumeMount

参数

请参阅 VolumeMount

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

# Volume ``data-volume`` will be mounted at ``/data`` in all
# containers / init-containers in the deployment
# (my-container & my-init-container in this example)
- name: data-volume-mount
  type: ucf.appspec.defaultVolumeMount
  parameters:
    name: data-volume
    mountPath: /data

- name: data
  type: ucf.k8s.pvc
  parameters:
    annotations:
      helm.sh/resource-policy: "keep"
    spec:
      storageClassName: mdx-local-path
      accessModes: [ReadWriteOnce]
      resources:
        requests:
          storage: 50Mi

- name: data-volume
  type: ucf.k8s.volume
  parameters:
    persistentVolumeClaim:
      claimName: ${CHART_NAME}-data # substitue ${CHART_NAME} with manifest.yaml's chartName value

- name: my-container
  type: ucf.k8s.container
  parameters:
    ...

- name: my-init-container
  type: ucf.k8s.initcontainer
  parameters:
    ...

持久卷声明

类型

ucf.k8s.pvc

描述

用于向微服务添加持久卷声明

参数

字段

类型

描述

spec

对象(必需

持久卷声明规范

.storageClassName

字符串

PVC 的存储类

.volumeName

字符串

PVC 的卷名称

.accessModes

字符串列表

允许的值
ReadWriteOnce
ReadOnlyMany
ReadWriteMany
ReadWriteOncePod

请求的存储的访问模式。请参阅 访问模式

.resources

对象

存储资源需求

.requests

对象

存储资源请求

.storage

字符串

最小存储需求

.limits

对象

存储资源限制

.storage

字符串

最小存储需求

annotations

对象

要添加到 PVC 资源的注解,以键值对形式表示

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

  # ``name`` of the component is set as PVC Name
  # ``name`` will be required to add the PVC as volume to the pod
- name: data
  type: ucf.k8s.pvc
  parameters:
    annotations:
      helm.sh/resource-policy: "keep"
    spec:
      storageClassName: mdx-local-path # omit this line to use default StorageClass provisioner
      accessModes: [ReadWriteOnce]
      resources:
        requests:
          storage: 50Mi

- name: data-volume
  type: ucf.k8s.volume
  parameters:
    persistentVolumeClaim:
      claimName: ${CHART_NAME}-data # substitue ${CHART_NAME} with manifes.yaml's chartName value

- name: my-container
  type: ucf.k8s.container
  parameters:
    ...
    volumeMounts:
    - name: data-volume
      mountPath: /data

服务

类型

ucf.k8s.service

描述

向微服务添加服务资源,并将其与部署工作负载关联。创建 Kubernetes 服务资源。

参数

字段

类型

描述

ports

列表(必需

要在服务中暴露的端口列表

.[].port

整数(必需

要暴露的服务端口

.[].name

字符串(必需

服务端口的名称(这用作端点名称)

.[].targetPort

字符串或整数

目标容器端口的编号或名称

.[].nodePort

整数

节点上暴露此端口的端口号

.[].range

整数

端口范围。 0-<range - 1> 将被添加到 port/targetPort/nodePort

type

字符串(枚举)

允许的值
ClusterIP
NodePort
LoadBalancer
ExternalName

服务类型

externalTrafficPolicy

字符串(枚举)

允许的值
Cluster
Local

将外部流量路由到节点本地或集群范围的端点

clusterIP

字符串

服务的集群 IP 地址

nameOverride

布尔值

启用以将服务名称设置为 <appname>-<service-name>

fullNameOverride

布尔值

启用以将服务名称设置为 <service-name>

annotations

对象

要在服务上设置的注解,以键(字符串)-值(字符串)对形式表示

labels

对象

要在服务上设置的标签,以键(字符串)-值(字符串)对形式表示

extraSpecs

对象

用于设置未显式支持的服务的额外字段

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: "backend-container"
  type: ucf.k8s.container
  parameters:
    image:
      repository: nvcr.io/nvidia/pytorch
      tag: 22.04-py3
    command: [sh, -c]
    args: ["python -m http.server 8080"]
    ports:
    - containerPort: 8080
      name: http

- name: backend-service
  type: ucf.k8s.service
  parameters:
    annotations:
      some-annotation: annotation-value
    labels:
      some-label: label-value
    ports:
    - port: http  # Must match a container port in the workload
      name: http-api
    type: NodePort

镜像拉取密钥

类型

ucf.k8s.imagepullsecret

描述

用于添加 imagepullsecret 以拉取 Pod 中使用的容器镜像。理想情况下,这不应成为微服务的一部分,因为在微服务开发期间可能不知道微服务的部署位置/部署者。相反,它可以从应用程序设置。

参数

字段

类型

描述

name

字符串(必需

镜像拉取密钥名称

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: ngc-image-pull-secret
  type: ucf.k8s.imagepullsecret
  parameters:
    name: ngc-docker-reg-secret

ConfigMap

类型

ucf.k8s.configmap

描述

用于向微服务添加 ConfigMap

参数

字段

类型

描述

name

字符串(必需

configmap 资源的名称

data

对象(必需

要添加到 configmap 的数据,以键(字符串)-值(字符串)对形式表示

annotations

对象(必需

要添加到 configmap 资源的注解,以键(字符串)-值(字符串)对形式表示

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

# ``config.json`` will be mounted at ``/tmp/app-configs/config.json`` in the container
- name: my-app-config
  type: ucf.k8s.configmap
  parameters:
    name: my-app-config
    data:
      config.json: |
        {
          "log-level": "DEBUG"
        }

- name: configmap-volume
  type: ucf.k8s.volume
  parameters:
    configMap:
      name: my-app-config

- name: my-container
  type: ucf.k8s.container
  parameters:
    ...
    volumeMounts:
    - name: configmap-volume
      mountPath: /tmp/app-configs

Pod 注解

类型

ucf.k8s.podAnnotations

描述

用于向属于部署工作负载的 Pod 添加注解

参数

字段

类型

描述

annotations

对象(必需

要添加到 Pod 的注解,以键(字符串)-值(字符串)对形式表示

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: pod-annotations
  type: ucf.k8s.podAnnotations
  parameters:
    kubernetes.io/description: Description of the pod behavior

Pod 标签

类型

ucf.k8s.podLabels

描述

用于向属于部署工作负载的 Pod 添加标签

参数

字段

类型

描述

labels

对象(必需

要添加到 Pod 的标签,以键(字符串)-值(字符串)对形式表示

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: pod-labels
  type: ucf.k8s.podLabels
  parameters:
    pod-type: "backend-pod"

Pod 安全上下文

类型

ucf.k8s.podSecurityContext

描述

用于在 Pod 级别设置安全配置

参数

请参阅 Pod 安全上下文

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: podSecurityContext
  type: ucf.k8s.podSecurityContext
  parameters:
    runAsGroup: 1000
    runAsUser: 1000

容器重启策略

类型

ucf.k8s.restartPolicy

描述

用于为 Pod 中的所有容器设置容器重启策略

参数

字段

类型

描述

policy

字符串(枚举)(必需

允许的值
Always
Never
OnFailure

容器重启策略。仅允许基于工作负载类型的某些值。

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: restartPolicy
  type: ucf.k8s.restartPolicy
  parameters:
    policy: Always

Pod DNS 策略

类型

ucf.k8s.dnsPolicy

描述

用于设置 Pod 的 DNS 策略。请参阅 Pod 的 DNS 策略

参数

字段

类型

描述

policy

字符串(枚举)(必需

允许的值
Default
ClusterFirst
ClusterFirstWithHostNet
None

Pod DNS 策略

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: dnsPolicy
  type: ucf.k8s.dnsPolicy
  parameters:
    policy: ClusterFirst

PVC 保留策略

类型

ucf.k8s.persistentVolumeClaimRetentionPolicy

描述

用于为使用 statefulset 的 volumeClaimTemplates 创建的 PVC 设置保留策略。需要 Kubernetes 1.27+

参数

字段

类型

描述

whenDeleted

字符串(枚举)

允许的值
Retain(保留 PVC)
Delete(删除 PVC)

StatefulSet 资源被删除时的 PVC 保留策略

whenScaled

字符串(枚举)

允许的值
Retain(保留 PVC)
Delete(删除 PVC)

StatefulSet 资源缩减时的 PVC 保留策略

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: statefull

- name: pvc-retention-policy
  type: ucf.k8s.persistentVolumeClaimRetentionPolicy
  parameters:
    whenDeleted: Delete
    whenScaled: Retain

Pod 管理策略

类型

ucf.k8s.persistentVolumeClaimRetentionPolicy

描述

用于为 StatefulSet 设置 Pod 副本排序策略。请参阅 Pod 管理策略

参数

字段

类型

描述

policy

字符串(枚举)

允许的值
OrderedReady(顺序启动 Pod 副本)
Parallel(并行启动 Pod 副本)

Pod 副本管理策略

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: statefull

- name: pvc-management-policy
  type: ucf.k8s.podManagementPolicy
  parameters:
    policy: Parallel

Job 选项

类型

ucf.k8s.app.job.jobOptions

描述

用于为 Job 工作负载设置各种参数。请参阅 Job Spec

参数

字段

类型

描述

backoffLimit

整数

在将 Job 标记为失败之前的重试次数

completionMode

字符串(枚举)

允许的值
NonIndexed
Indexed

跟踪 Pod 完成的方法

completions

整数

此 Job 应运行的成功完成的 Pod 数量

manualSelector

布尔值

启用用户指定的选择器

parallelism

整数

在任何时间运行的 Pod 的最大数量

selector

对象

要查询的标签。应与 Job 计数匹配

suspend

布尔值

Job 控制器是否应创建 Pod

ttlSecondsAfterFinished

整数

Job 完成后多少秒删除 Pod

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: job

- name: job-options
  type: ucf.k8s.app.job.jobOptions
  parameters:
    completionMode: Indexed
    parallelism: 3

Job 截止时间

类型

ucf.k8s.app.job.activeDeadlineSeconds

描述

用于为 Job 工作负载设置 Pod 应执行的最大持续时间。

参数

字段

类型

描述

seconds

整数

Job 的截止时间(秒)

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: job

- name: job-deadline
  type: ucf.k8s.app.job.activeDeadlineSeconds
  parameters:
    seconds: 100

CronJob 计划

类型

ucf.k8s.app.cronjob.schedule

描述

用于为 CronJob 工作负载的 Pod 设置 cron 计划。

参数

字段

类型

描述

schedule

字符串

Cronjob 计划字符串

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: cronjob

# Execute daily at 1:00 am
- name: cronjob-schedule
  type: ucf.k8s.app.cronjob.schedule
  parameters:
    schedule: "1 0 * * *"

配置更改时重启 Pod

类型

ucf.appspec.restartPodOnConfigChanges

描述

用于在与微服务关联的任何 configmap 更新时重启 Pod。仅支持 DeploymentStatefulSetDaemonSet 工作负载类型。请参阅 配置更改时重启 Pod

参数

字段

类型

描述

addAll

布尔值

添加对微服务中找到的所有 configmap 的依赖

addDefault

布尔值

添加对添加到微服务的默认 configmap 的依赖,即 scripts、configs、workload-configs、external-files

configMaps

字符串列表

要添加依赖的 configmap 的名称列表

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: cm-dependencies
  type: ucf.appspec.restartPodOnConfigChanges
  parameters:
    # Add dependency on all configmaps detected in the microservice
    addAll: true

    # Add dependency on default configmaps for scripts, configs and workload configs
    # addDefault: true

    # Add dependency on individual configmaps using the configmap names
    # configMaps:
    # - http-server-configs-cm

Ingress

类型

ucf.appspec.ingress

描述

为微服务添加 Ingress 资源。

参数

字段

类型

描述

enabled

布尔值(必需

Ingress 控制器状态(已启用/已禁用)

className

字符串

Ingress 控制器类名称

annotations

对象(必需

要在 ingress 资源上设置的注解,以键(字符串)-值(字符串)对形式表示

rules

列表(必需

Ingress 规则列表。请参阅 IngressRule

示例

---
spec:
- name: backend
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: backend-container
  type: ucf.k8s.container
  parameters:
    ...
    ports:
      - containerPort: 5000
        name: http

- name: backend-svc
  type: ucf.k8s.service
  parameters:
    ports:
      - port: 5000
        targetPort: http
        protocol: TCP
        name: http
    type: ClusterIP

# Route HTTP calls with /api prefix to the backend service
- name: ingress
  type: ucf.appspec.ingress
  parameters:
    enabled: true
    annotations:
      nginx.ingress.kubernetes.io/proxy-body-size: "0"
    rules:
    - http:
        paths:
          - path: /api(/|$)(.*)
            pathType: Prefix
            backend:
              service:
                name: backend-backend-svc
                port:
                 number: 5000

应用程序工作负载

类型

ucf.appspec.app.workload

描述

用于将应用程序工作负载与容器关联。添加到工作负载组件的字段将在与该工作负载关联的容器上设置。

参数

字段

类型

描述

wl_units

整数

工作负载单元。这转换为 DeploymentsStatefulSets 中的副本计数

wl_resources:工作负载资源需求

.requests

对象

工作负载最小资源需求,以键值对形式提及

.limits

对象

工作负载最大资源限制,以键值对形式提及

wl_data

字符串

工作负载数据。这是一个自由文本部分,将作为 /opt/workload-config/<workload-name> 挂载,在运行时可供容器使用

wl_env

列表

工作负载附加环境变量

.[].name

字符串

环境变量的名称

.[].value

字符串

环境变量的值

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

- name: backend-workload
  type: ucf.appspec.app.workload
  parameters:
    wl_units: 1
    wl_resources:
      limits:
        nvidia.com/gpu: 1
    wl_data: |
      inputFile: /root/video.mp4
    wl_env:
    - name: WORKLOAD_NAME
      env: backend-workload

- name: backend-container
  type: ucf.k8s.container
  parameters:
    ...
    workload: backend-workload

UCX 配置

类型

ucf.k8s.ucx-config

描述

添加用于微服务中的 UCX 组件的配置。UCS Tools 将添加一个容器来替换 $egress 占位符,并使用 UCX 接口的辅助网络接口 IP 地址。请参阅 UCS Tools 中的 UCX 支持

参数

字段

类型

描述

name

字符串

用于创建 configmap 的名称

data

字符串

配置数据,以字符串形式表示

annotations

对象

configmap 的注解,以键(字符串)-值(字符串)对形式表示

updaterImage

字符串

用于使用更新占位符参数更新配置文件的容器镜像

示例

请参阅 UCS Tools 中的 UCX 支持

自定义元数据

类型

ucf.metadata.custom

描述

用于为微服务向其 UCS MS 规范添加用户指定的自定义元数据。

参数

不强制执行架构。用户可以根据需要在 YAML 格式中添加任何元数据。

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless

# Data in this component will be added to MS spec under ``metadata`` field.
- name: custom-data
  type: ucf.metadata.custom
  parameters:
    param1: value1
    param2: value2

Pod 调度规范

类型

ucf.k8s.scheduling

描述

用于指定 Pod 调度控制参数

参数

字段

类型

描述

nodeSelector

对象

k8s 节点选择器定义(请参阅 scheduling)。

tolerations

数组

k8s 容忍度列表(请参阅 scheduling)。

affinity

对象

k8s 亲和性定义(请参阅 scheduling)。

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless
- name: my-service-scheduling
  type: ucf.k8s.scheduling
  parameters:
    nodeSelector:
      kubernetes.io/os: linux
    tolerations:
      - key: key1
        operator: Exists
        effect: NoSchedule
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
           - matchExpressions:
             - key: some-key-1
               operator: In
               values: [some-value-1, some-value-2]
           - matchFields:
             - key: status.phase
               operator: In
               values:
                 - Running

服务帐户规范

类型

ucf.k8s.serviceAccount

描述

用于指定 Pod 的 serviceAccount

参数

字段

类型

描述

name

字符串

服务帐户的名称

clusterRole

字符串

服务帐户绑定的集群角色

create

布尔值

创建服务帐户的选项

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless
- name: my-service-sa
  type: ucf.k8s.serviceAccount
  parameters:
    name: my-sa
    clusterRole: edit
    create: true

Pod 监控器自定义资源定义

类型

ucf.crd.podMonitor

描述

创建 Pod 监控器

参数

字段

类型

描述

portName

字符串

指标端点的容器端口名称

path

字符串

指标可用的 HTTP 路径

示例

---
spec:
- name: backend-deployment
  type: ucf.k8s.app.deployment
  parameters:
    apptype: stateless
- name: "abcd-container"
  type: ucf.k8s.container
  parameters:
    image:
      repository: ubuntu
      tag: "latest"
    ports:
    - containerPort: 1000 # <PORT>
      name: http
    - containerPort: 10002 # <PORT>
      name: ms-metrics
- name: ms-metrics
  type: ucf.crd.podMonitor
  parameters:
    portName: ms-metrics
    path: /metrics