commonLabels

为所有资源和 selectors 增加标签。

为所有资源和 selectors 增加标签。如果资源上已经存在注解键,该值将被覆盖。

一旦将资源应用于集群,就不应更改诸如 Deployments 和 Services 之类的资源选择器。

将 commonLabels 更改为可变资源可能会导致部署失败。

  1. apiVersion: kustomize.config.k8s.io/v1beta1
  2. kind: Kustomization
  3. commonLabels:
  4. someName: someValue
  5. owner: alice
  6. app: bingo

Example

文件输入

  1. # kustomization.yaml
  2. apiVersion: kustomize.config.k8s.io/v1beta1
  3. kind: Kustomization
  4. commonLabels:
  5. someName: someValue
  6. owner: alice
  7. app: bingo
  8. resources:
  9. - deploy.yaml
  10. - service.yaml
  1. # deploy.yaml
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. name: example
  1. # service.yaml
  2. apiVersion: v1
  3. kind: Service
  4. metadata:
  5. name: example

构建输出

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. labels:
  5. app: bingo
  6. owner: alice
  7. someName: someValue
  8. name: example
  9. spec:
  10. selector:
  11. app: bingo
  12. owner: alice
  13. someName: someValue
  14. ---
  15. apiVersion: apps/v1
  16. kind: Deployment
  17. metadata:
  18. labels:
  19. app: bingo
  20. owner: alice
  21. someName: someValue
  22. name: example
  23. spec:
  24. selector:
  25. matchLabels:
  26. app: bingo
  27. owner: alice
  28. someName: someValue
  29. template:
  30. metadata:
  31. labels:
  32. app: bingo
  33. owner: alice
  34. someName: someValue