SuperAPI AI 工具集

kubernetes-manifests

部署与运维

查看项目

更新于 10-16 02:21

技能介绍

Kubernetes Manifests 是一个围绕容器编排、聚焦 Kubernetes 清单文件编写与部署的技能,资料标题为“Kubernetes Manifests”,副标题为“Understanding and writing Kubernetes manifest files.”(理解并编写 Kubernetes 清单文件)。

用途:适用于编写和部署 Kubernetes 清单(manifest)以实现容器编排的场景。

主要能力与内容:

一、基本结构。资料给出清单的基础骨架,包含 apiVersion、kind、metadata(name、namespace、labels)以及 spec。示例中 spec 下包含 containers,容器带有 name、image 与 ports(containerPort: 80)。

二、常见资源类型。资料列举并示例了以下资源:

  1. Deployment:apiVersion 为 apps/v1,示例包含 replicas: 3、selector.matchLabels、template 中的标签与容器定义,并在容器中设置 resources.requests(memory "64Mi"、cpu "250m")与 resources.limits(memory "128Mi"、cpu "500m")。
  2. Service:apiVersion 为 v1,示例包含 selector、ports(protocol: TCP、port: 80、targetPort: 8080)以及 type: LoadBalancer。
  3. ConfigMap:apiVersion 为 v1,data 示例包含 database.url 与 log.level。
  4. Secret:apiVersion 为 v1,type: Opaque,data 示例中 password 为 base64 编码值(示例注释标注为 base64 encoded)。

三、最佳实践。资料列出三项:

  1. 资源请求与限制:始终定义 resource requests 和 limits,并给出与 Deployment 示例一致的取值。
  2. 存活与就绪探针:给出 livenessProbe(httpGet path: /healthz、port: 8080、initialDelaySeconds: 30、periodSeconds: 10)与 readinessProbe(httpGet path: /ready、port: 8080、initialDelaySeconds: 5、periodSeconds: 5)。
  3. 标签与选择器:使用一致的标签,示例包含 app、version、environment。

四、校验方式。资料给出三种命令:使用 kubectl apply --dry-run=client -f manifest.yaml 校验清单语法;使用 kubeconform manifest.yaml 校验;使用 kubectl apply --dry-run=server -f manifest.yaml 针对在线集群校验。

适用场景:需要编写、部署与验证 Kubernetes 配置文件的容器编排工作,例如定义工作负载、服务暴露、配置与密钥管理时参考示例与最佳实践。

限制:资料未提供该技能的安装方式、运行环境要求、收费或价格信息、平台支持范围以及具体使用步骤,这些内容暂未提供。