📦 Create Your First Custom Resource
1
| kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/customresourcedefinition/shirt-resource-definition.yaml
|
By default, the Kubernetes Controller Manager caches every resource to support background operations such as garbage collection and internal indexing.
To reduce memory usage and improve performance in high-volume environments, you can label specific resources with skip-controller-manager-metadata-caching: true
to exclude them from being cached. That means Kubernetes can’t clean-up resources by ownerReference
, you have to do garbage collection on your own.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| cat | kubectl apply -f - <<EOF
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
name: example1
labels:
skip-controller-manager-metadata-caching: true
spec:
color: blue
size: S
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
name: example2
labels:
skip-controller-manager-metadata-caching: true
spec:
color: blue
size: M
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
name: example3
labels:
skip-controller-manager-metadata-caching: true
spec:
color: green
size: M
EOF
|