Hi,
I’ve been investigating the types of YAML documents kubectl -f accepts for deployment.
I’ve found out that the following are accepted:
A single element in one file
apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-single-element
It deploys. Now we try one file, with two YAML documents:
apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-two-elements-1
---
apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-two-elements-2
It deploys. Now one file with a List object:
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-list-1
- apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-list-2
It deploys. So I continue playing, combining a two document YAML file. One part with an object, and the other with a List:
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-list-and-single-1
- apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-list-and-single-2
---
apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-list-and-single-3
It deploys. Up till here all of these examples are accepted by kubectl apply -f, so I started getting creative: What if we put a List object in a List. Will it deploy?
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-list-within-list-1
- apiVersion: v1
kind: ConfigMap
data:
key: value
metadata:
name: config-list-within-list-2
It doesn’t deploy with the following error:
error: no Items field in &unstructured.Unstructured{Object:map[string]interface {}{“apiVersion”:“v1”, “items”:interface {}{map[string]interface {}{“apiVersion”:“v1”, “data”:map[string]interface {}{“key”:“value”}, “kind”:“ConfigMap”, “metadata”:map[string]interface {}{“name”:“config-list-within-list-1”}}, map[string]interface {}{“apiVersion”:“v1”, “data”:map[string]interface {}{“key”:“value”}, “kind”:“ConfigMap”, “metadata”:map[string]interface {}{“name”:“config-list-within-list-2”}}}, “kind”:“List”}}
The error is a bit strange: I can’t find the missing “items” field. Should this be accepted by kubectl? Or is it explicitly prohibited?