【问题标题】:unknown field "resources" in io.k8s.api.apps.v1.DeploymentSpecio.k8s.api.apps.v1.DeploymentSpec 中的未知字段“资源”
【发布时间】:2020-09-25 03:35:42
【问题描述】:

_helper.tpl

{{- define "fluentd-config" -}}
image: {{ .Values.fluentd.kinesis_image }}
resources:
  limits:
    memory: 200Mi
  requests:
    cpu: 100m
    memory: 200Mi
{{- end -}}

deployment.yaml

- name: log-agent
  {{ include "fluentd-configuration" . | indent 2 }}

但是我遇到了,下面的错误信息

Error: UPGRADE FAILED: error validating "": error validating data: ValidationError(Deployment.spec): unknown field "resources" in io.k8s.api.apps.v1.DeploymentSpec

请告诉我为什么我得到那个。谢谢。

【问题讨论】:

  • 你有所有字段的值吗?以及来自include 和helper.tpl 中'value` 的内容的缩进?
  • @Bimal yap,我们有价值。
  • @PPShein 可以添加$ helm template <name> <chart> 命令的结果吗?
  • @KamolHasan 这是缩进问题,我不知道如何解决。
  • 我希望看到您显示的 YAML 语法错误,但不会看到验证错误。 ({{ 之前有两个空格,然后indent 将包括第一行在内的每一行缩进两个空格;所以你有第一行,然后一行有四个空格,然后一行有两个空格。)

标签: kubernetes kubernetes-helm helmfile


【解决方案1】:

您的部署文件应如下所示:

deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-name
  namespace: {{ .Release.Namespace }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      apps: my-demo-app # <-- here
  template:
    metadata:
      labels:
        apps: my-demo-app # <-- make sure it match the `matchLabels`
    spec:
      containers:
      - name: log-agent
{{include "fluentd-config" .| indent 8}} # (8 spaces added) 

【讨论】:

  • 太甜蜜了。最后一行节省了我的时间,感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-16
  • 1970-01-01
相关资源
最近更新 更多