<p>I followed this tutorial <a href="https://kubernetes.io/docs/tutorials/configuration/configure-redis-using-configmap/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/configuration/configure-redis-using-configmap/</a></p>

<p>I got the error as bellow when I try to create the pods</p>

<pre><code>kubectl apply -k .
error: json: unknown field "metadata"
</code></pre>

<p>My kubectl version is as bellow:</p>

<pre><code>kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:40:16Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.3", GitCommit:"5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0", GitTreeState:"clean", BuildDate:"2019-06-06T01:36:19Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<p>Bellow are some files that I created following the toturial.</p>

<p>kustomization.yaml</p>

<pre><code>configMapGenerator:
- name: example-redis-config
  files:
  - redis-config
apiVersion: v1
kind: Pod
metadata:
  name: redis
spec:
  containers:
  - name: redis
    image: redis:5.0.4
    command:
      - redis-server
      - "/redis-master/redis.conf"
    env:
    - name: MASTER
      value: "true"
    ports:
    - containerPort: 6379
    resources:
      limits:
        cpu: "0.1"
    volumeMounts:
    - mountPath: /redis-master-data
      name: data
    - mountPath: /redis-master
      name: config
  volumes:
    - name: data
      emptyDir: {}
    - name: config
      configMap:
        name: example-redis-config
        items:
        - key: redis-config
          path: redis.conf
resources:
- redis-pod.yaml
</code></pre>

<p>redis-config </p>

<pre><code>maxmemory 2mb
maxmemory-policy allkeys-lru
</code></pre>

<p>redis-pod.yaml</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: redis
spec:
  containers:
  - name: redis
    image: redis:5.0.4
    command:
      - redis-server
      - "/redis-master/redis.conf"
    env:
    - name: MASTER
      value: "true"
    ports:
    - containerPort: 6379
    resources:
      limits:
        cpu: "0.1"
    volumeMounts:
    - mountPath: /redis-master-data
      name: data
    - mountPath: /redis-master
      name: config
  volumes:
    - name: data
      emptyDir: {}
    - name: config
      configMap:
        name: example-redis-config
        items:
        - key: redis-config
          path: redis.conf
</code></pre>

<p>Any help?</p>

wanghaoming
<p>I think you misinterpreted the <code>kustomization.yaml</code> instructions (which are confusing). You don't add the contents of <code>pods/config/redis-pod.yaml</code> to <code>kustomization.yaml</code>. You just download that file and add the <code>resources</code> snippet.</p>

<p>The resulting <code>kustomization.yaml</code> should look like:</p>

<pre><code>configMapGenerator:
- name: example-redis-config
  files:
  - redis-config
resources:
- redis-pod.yaml
</code></pre>
