diff --git a/deployment/helm/balloons/README.md b/deployment/helm/balloons/README.md index bf1ac7f76..77da2e46a 100644 --- a/deployment/helm/balloons/README.md +++ b/deployment/helm/balloons/README.md @@ -97,6 +97,7 @@ customize with their own values, along with the default values. | `resources.memory` | 512Mi | memory qouta for the Pod | | `hostPort` | 8891 | metrics port to expose on the host | | `config` | see [helm chart values](tree:/deployment/helm/balloons/values.yaml) for the default configuration | plugin configuration data | +| `configGroupLabel` | config.nri/group | node label for grouping configuration | | `nri.patchRuntimeConfig` | false | enable NRI in containerd or CRI-O | | `nri.pluginIndex` | 90 | NRI plugin index to register with | | `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | diff --git a/deployment/helm/balloons/templates/daemonset.yaml b/deployment/helm/balloons/templates/daemonset.yaml index b23ef8ecc..675c05463 100644 --- a/deployment/helm/balloons/templates/daemonset.yaml +++ b/deployment/helm/balloons/templates/daemonset.yaml @@ -56,6 +56,10 @@ spec: - 5s - --nri-plugin-index - "{{ printf "%02d" .Values.nri.pluginIndex }}" + {{- if .Values.configGroupLabel }} + - --config-group-label + - {{ .Values.configGroupLabel }} + {{- end }} ports: - containerPort: 8891 protocol: TCP diff --git a/deployment/helm/balloons/values.schema.json b/deployment/helm/balloons/values.schema.json index 25b8bf4ff..6ca62bb25 100644 --- a/deployment/helm/balloons/values.schema.json +++ b/deployment/helm/balloons/values.schema.json @@ -44,6 +44,9 @@ } } }, + "configGroupLabel": { + "type": "string" + }, "resources": { "type": "object", "required": [ diff --git a/deployment/helm/balloons/values.yaml b/deployment/helm/balloons/values.yaml index b75bf8ffa..7fb9de1d4 100644 --- a/deployment/helm/balloons/values.yaml +++ b/deployment/helm/balloons/values.yaml @@ -31,6 +31,8 @@ config: reportPeriod: 60s samplingRatePerMillion: 0 +# configGroupLabel: config.nri/group + plugin-test: enableAPIs: false diff --git a/deployment/helm/template/README.md b/deployment/helm/template/README.md index 9d0463b0e..fd5770ca4 100644 --- a/deployment/helm/template/README.md +++ b/deployment/helm/template/README.md @@ -97,6 +97,7 @@ customize with their own values, along with the default values. | `resources.memory` | 512Mi | memory qouta for the Pod | | `hostPort` | 8891 | metrics port to expose on the host | | `config` | see [helm chart values](tree:/deployment/helm/template/values.yaml) for the default configuration | plugin configuration data | +| `configGroupLabel` | config.nri/group | node label for grouping configuration | | `nri.patchRuntimeConfig` | false | enable NRI in containerd or CRI-O | | `nri.pluginIndex` | 90 | NRI plugin index to register with | | `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | diff --git a/deployment/helm/template/templates/daemonset.yaml b/deployment/helm/template/templates/daemonset.yaml index 229a19330..b722de6b9 100644 --- a/deployment/helm/template/templates/daemonset.yaml +++ b/deployment/helm/template/templates/daemonset.yaml @@ -49,6 +49,10 @@ spec: - 5s - --nri-plugin-index - "{{ printf "%02d" .Values.nri.pluginIndex }}" + {{- if .Values.configGroupLabel }} + - --config-group-label + - {{ .Values.configGroupLabel }} + {{- end }} ports: - containerPort: 8891 protocol: TCP diff --git a/deployment/helm/template/values.schema.json b/deployment/helm/template/values.schema.json index 25b8bf4ff..6ca62bb25 100644 --- a/deployment/helm/template/values.schema.json +++ b/deployment/helm/template/values.schema.json @@ -44,6 +44,9 @@ } } }, + "configGroupLabel": { + "type": "string" + }, "resources": { "type": "object", "required": [ diff --git a/deployment/helm/template/values.yaml b/deployment/helm/template/values.yaml index 63f11eaaa..673a55c5a 100644 --- a/deployment/helm/template/values.yaml +++ b/deployment/helm/template/values.yaml @@ -19,6 +19,8 @@ config: reportPeriod: 60s samplingRatePerMillion: 0 +# configGroupLabel: config.nri/group + plugin-test: enableAPIs: false diff --git a/deployment/helm/topology-aware/README.md b/deployment/helm/topology-aware/README.md index 6808208a1..b3ef368ad 100644 --- a/deployment/helm/topology-aware/README.md +++ b/deployment/helm/topology-aware/README.md @@ -98,6 +98,7 @@ customize with their own values, along with the default values. | `resources.memory` | 512Mi | memory qouta for the Pod | | `hostPort` | 8891 | metrics port to expose on the host | | `config` | see [helm chart values](tree:/deployment/helm/topology-aware/values.yaml) for the default configuration | plugin configuration data | +| `configGroupLabel` | config.nri/group | node label for grouping configuration | | `nri.patchRuntimeConfig` | false | enable NRI in containerd or CRI-O | | `nri.pluginIndex` | 90 | NRI plugin index to register with | | `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | diff --git a/deployment/helm/topology-aware/templates/daemonset.yaml b/deployment/helm/topology-aware/templates/daemonset.yaml index 1b2f7e8f3..7d11bbe68 100644 --- a/deployment/helm/topology-aware/templates/daemonset.yaml +++ b/deployment/helm/topology-aware/templates/daemonset.yaml @@ -56,6 +56,10 @@ spec: - 5s - --nri-plugin-index - "{{ printf "%02d" .Values.nri.pluginIndex }}" + {{- if .Values.configGroupLabel }} + - --config-group-label + - {{ .Values.configGroupLabel }} + {{- end }} ports: - containerPort: 8891 protocol: TCP diff --git a/deployment/helm/topology-aware/values.schema.json b/deployment/helm/topology-aware/values.schema.json index 25b8bf4ff..6ca62bb25 100644 --- a/deployment/helm/topology-aware/values.schema.json +++ b/deployment/helm/topology-aware/values.schema.json @@ -44,6 +44,9 @@ } } }, + "configGroupLabel": { + "type": "string" + }, "resources": { "type": "object", "required": [ diff --git a/deployment/helm/topology-aware/values.yaml b/deployment/helm/topology-aware/values.yaml index c6b4872b8..b07616aa5 100644 --- a/deployment/helm/topology-aware/values.yaml +++ b/deployment/helm/topology-aware/values.yaml @@ -19,6 +19,8 @@ config: reportPeriod: 60s samplingRatePerMillion: 0 +# configGroupLabel: config.nri/group + plugin-test: enableAPIs: false diff --git a/docs/resource-policy/configuration.md b/docs/resource-policy/configuration.md index a59511a76..c19c37726 100644 --- a/docs/resource-policy/configuration.md +++ b/docs/resource-policy/configuration.md @@ -15,7 +15,7 @@ The names of these custom resources are 3. `default`: secondary: secondary default node configuration You can assign a node to a configuration group by setting the -`group.config.nri` label on the node to the name of the configuration +`config.nri/group` label on the node to the name of the configuration group. You can remove a node from its group by deleting the node group label. diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index 640d78a5b..31c1a396c 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -118,7 +118,7 @@ var ( // always used for the node. Otherwise either a group-specific or the default // configuration is used depending on whether the node belongs to a group. A // node can be assigned to a group by setting the group label on the node. By -// default this group label is 'group.config.nri'. +// default this group label is 'config.nri/group'. type Agent struct { nodeName string // kubernetes node name, defaults to $NODE_NAME namespace string // config resource namespace @@ -211,6 +211,16 @@ func (a *Agent) Start(notifyFn NotifyFn) error { } if e.Type == watch.Added || e.Type == watch.Modified { group, _ := e.Object.(*corev1.Node).Labels[a.groupLabel] + if group == "" { + for _, l := range deprecatedGroupLabels { + group, _ = e.Object.(*corev1.Node).Labels[l] + if group != "" { + log.Warnf("Using DEPRECATED config group label %q", l) + log.Warnf("Please switch to using label %q instead", a.groupLabel) + break + } + } + } if err = a.setupGroupConfigWatch(group); err != nil { log.Errorf("%v", err) } @@ -607,10 +617,15 @@ var ( defaultGroupLabel string defaultKubeConfig string defaultConfigFile string + + deprecatedGroupLabels = []string{ + "group.config.nri", + "resource-policy.nri.io/group", + } ) func init() { - groupLabel := "group." + cfgapi.SchemeGroupVersion.Group + groupLabel := cfgapi.SchemeGroupVersion.Group + "/group" flag.StringVar(&defaultNamespace, "config-namespace", "kube-system", "namespace for configuration CustomResources") diff --git a/sample-configs/balloons-config.yaml b/sample-configs/balloons-config.yaml index d2bc44f3f..a2df3282c 100644 --- a/sample-configs/balloons-config.yaml +++ b/sample-configs/balloons-config.yaml @@ -20,7 +20,7 @@ metadata: # name: group.group-0 # Then label the nodes and remove any node-specific configuration: # for node in node-{A,B,C}; do - # kubectl label node $node group.config.nri=group-0 + # kubectl label node $node config.nri/group=group-0 # kubectl delete -n $NAMESPACE balloonspolicies.config.nri/$node || : # done # diff --git a/sample-configs/template-config.yaml b/sample-configs/template-config.yaml index 4be1cf705..cbc12a109 100644 --- a/sample-configs/template-config.yaml +++ b/sample-configs/template-config.yaml @@ -20,7 +20,7 @@ metadata: # name: group.group-0 # Then label the nodes and remove any node-specific configuration: # for node in node-{A,B,C}; do - # kubectl label node $node group.config.nri=group-0 + # kubectl label node $node config.nri/group=group-0 # kubectl delete -n $NAMESPACE balloonspolicies.config.nri/$node || : # done # diff --git a/sample-configs/topologyaware-config.yaml b/sample-configs/topologyaware-config.yaml index 012f4b36c..8eded4128 100644 --- a/sample-configs/topologyaware-config.yaml +++ b/sample-configs/topologyaware-config.yaml @@ -20,7 +20,7 @@ metadata: # name: group.group-0 # Then label the nodes and remove any node-specific configuration: # for node in node-{A,B,C}; do - # kubectl label node $node group.config.nri=group-0 + # kubectl label node $node config.nri/group=group-0 # kubectl delete -n $NAMESPACE balloonspolicies.config.nri/$node || : # done #