Skip to content

Instantly share code, notes, and snippets.

@jpbetz
Last active June 9, 2023 16:24
Show Gist options
  • Save jpbetz/c0d4b0c80b846bd7b66b9a03269ada53 to your computer and use it in GitHub Desktop.
Save jpbetz/c0d4b0c80b846bd7b66b9a03269ada53 to your computer and use it in GitHub Desktop.
Examples of fields that allow exact duplicates and are marked as listType=map

env

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    env:
    - name: A
      value: "x"
    - name: B
      value: "x"
    - name: A
      value: "$A $B"
    ports:
    - containerPort: 80
Warning: spec.containers[0].env[2].name: duplicate name "A"
pod/nginx created

ports (containers and ephemeralContainers)

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80
    - containerPort: 80
pod/nginx created

imagePullSecretes

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80
  imagePullSecrets:
    - name: mysecret
    - name: mysecret
Warning: spec.imagePullSecrets[1].name: duplicate name "mysecret"
pod/nginx created

hostAliases

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80
  hostAliases:
    - ip: "127.0.0.1"
    - ip: "127.0.0.1"
Warning: spec.hostAliases[1].ip: duplicate ip "127.0.0.1"
pod/nginx created

serviceAccount secrets

apiVersion: v1
kind: Secret
metadata:
 name: basic-user-pass
type: kubernetes.io/basic-auth
stringData:
 username: fake
 password: fakepass
---
apiVersion: v1
kind: ServiceAccount
metadata:
 name: build-bot
secrets:
 - name: basic-user-pass
 - name: basic-user-pass
serviceaccount/build-bot created

ownerReferences

apiVersion: v1
kind: ConfigMap
metadata:
  name: myconfigmap
data:
  x: "1"
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  ownerReferences:
    - apiVersion: v1
      kind: ConfigMap
      name: myconfigmap
      uid: 421f3acc-5bfd-4007-b28a-4b0749c95888
    - apiVersion: v1
      kind: ConfigMap
      name: myconfigmap
      uid: 421f3acc-5bfd-4007-b28a-4b0749c95888
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80
Warning: .metadata.ownerReferences contains duplicate entries; API server dedups owner references in 1.20+, and may reject such requests as early as 1.24; please fix your requests; duplicate UID(s) observed: 421f3acc-5bfd-4007-b28a-4b0749c95888
pod/nginx created
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment