set-label

command module
v0.0.0-...-6bb4c43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

set-label

Overview

Add a list of labels to all resources.

Synopsis

Configured using a ConfigMap with key-value pairs in data field in ConfigMap resource.

For example: To add a label color: orange to all resources:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config
data:
  color: orange

To add 2 labels color: orange and fruit: apple to all resources:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config
data:
  color: orange
  fruit: apple

You can use key fieldSpecs to specify the resource selector you want to use. By default, the function will not only add or update the labels in metadata/labels but also a bunch of different places where have references to the labels. These field specs are defined in https://github.com/kubernetes-sigs/kustomize/blob/master/api/konfig/builtinpluginconsts/commonlabels.go#L6

You need to use a custom resource to specify additional information.

Example:

To add a label color: orange to path data/selector in MyOwnKind resource:

apiVersion: fn.kpt.dev/v1alpha1
kind: SetLabelConfig
metadata:
  name: my-config
labels:
  color: orange
fieldSpecs:
- path: data/selector
  kind: MyOwnKind
  create: true

To support your own CRDs you will need to add more items to fieldSpecs list. Your own specs will be used with the default ones.

Field spec has following fields:

  • group: Select the resources by API version group. Will select all groups if omitted.
  • version: Select the resources by API version. Will select all versions if omitted.
  • kind: Select the resources by resource kind. Will select all kinds if omitted.
  • path: Specify the path to the field that the value will be updated. This field is required.
  • create: If it's set to true, the field specified will be created if it doesn't exist. Otherwise the function will only update the existing field.

For more information about fieldSpecs, please see https://kubectl.docs.kubernetes.io/guides/extending_kustomize/builtins/#arguments-3

Examples

https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/master/examples/set-label/

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Code generated by "mdtogo"; DO NOT EDIT.
Code generated by "mdtogo"; DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL