Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-0.3/#231] fixes: rename default config group label, support/fall back to deprecated labels. #232

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deployment/helm/balloons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 4 additions & 0 deletions deployment/helm/balloons/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions deployment/helm/balloons/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
}
}
},
"configGroupLabel": {
"type": "string"
},
"resources": {
"type": "object",
"required": [
Expand Down
2 changes: 2 additions & 0 deletions deployment/helm/balloons/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ config:
reportPeriod: 60s
samplingRatePerMillion: 0

# configGroupLabel: config.nri/group

plugin-test:
enableAPIs: false

Expand Down
1 change: 1 addition & 0 deletions deployment/helm/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 4 additions & 0 deletions deployment/helm/template/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions deployment/helm/template/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
}
}
},
"configGroupLabel": {
"type": "string"
},
"resources": {
"type": "object",
"required": [
Expand Down
2 changes: 2 additions & 0 deletions deployment/helm/template/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ config:
reportPeriod: 60s
samplingRatePerMillion: 0

# configGroupLabel: config.nri/group

plugin-test:
enableAPIs: false

Expand Down
1 change: 1 addition & 0 deletions deployment/helm/topology-aware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 4 additions & 0 deletions deployment/helm/topology-aware/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions deployment/helm/topology-aware/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
}
}
},
"configGroupLabel": {
"type": "string"
},
"resources": {
"type": "object",
"required": [
Expand Down
2 changes: 2 additions & 0 deletions deployment/helm/topology-aware/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ config:
reportPeriod: 60s
samplingRatePerMillion: 0

# configGroupLabel: config.nri/group

plugin-test:
enableAPIs: false

Expand Down
2 changes: 1 addition & 1 deletion docs/resource-policy/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
19 changes: 17 additions & 2 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion sample-configs/balloons-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
2 changes: 1 addition & 1 deletion sample-configs/template-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
2 changes: 1 addition & 1 deletion sample-configs/topologyaware-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down