unknown field "resources" in io.k8s.api.apps.v1.DeploymentSpec

9/25/2020

_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 }}

But I encountered, following error message

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

Please let me know why I got that one. Thanks.

-- PPShein
helmfile
kubernetes
kubernetes-helm

1 Answer

9/25/2020

Your Deployment file should look something like below:

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) 
-- Kamol Hasan
Source: StackOverflow