8000 feat: optionally propagate node labels to application pod view (#15274) by msoderberg · Pull Request #23260 · argoproj/argo-cd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: optionally propagate node labels to application pod view (#15274) #23260

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

Merged
merged 9 commits into from
Jun 13, 2025
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
7 changes: 7 additions & 0 deletions assets/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,16 @@ func (ctrl *ApplicationController) getAppHosts(destCluster *appv1.Cluster, a *ap
sort.Slice(resourcesInfo, func(i, j int) bool {
return resourcesInfo[i].ResourceName < resourcesInfo[j].ResourceName
})
hosts = append(hosts, appv1.HostInfo{Name: nodeName, SystemInfo: node.SystemInfo, ResourcesInfo: resourcesInfo})

allowedNodeLabels := ctrl.settingsMgr.GetAllowedNodeLabels()
nodeLabels := make(map[string]string)
for _, label := range allowedNodeLabels {
if val, ok := node.Labels[label]; ok {
nodeLabels[label] = val
}
}

hosts = append(hosts, appv1.HostInfo{Name: nodeName, SystemInfo: node.SystemInfo, ResourcesInfo: resourcesInfo, Labels: nodeLabels})
}
ts.AddCheckpoint("process_app_pods_by_node_ms")
return hosts, nil
Expand Down
5 changes: 5 additions & 0 deletions controller/appcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,9 @@ func TestGetAppHosts(t *testing.T) {
Server: test.FakeClusterURL,
Revision: "abc123",
},
configMapData: map[string]string{
"application.allowedNodeLabels": "label1,label2",
},
}
ctrl := newFakeController(data, nil)
mockStateCache := &mockstatecache.LiveStateCache{}
Expand All @@ -2214,6 +2217,7 @@ func TestGetAppHosts(t *testing.T) {
Name: "minikube",
SystemInfo: corev1.NodeSystemInfo{OSImage: "debian"},
Capacity: map[corev1.ResourceName]resource.Quantity{corev1.ResourceCPU: resource.MustParse("5")},
Labels: map[string]string{"label1": "value1", "label2": "value2"},
}})

// app pod
Expand Down Expand Up @@ -2251,6 +2255,7 @@ func TestGetAppHosts(t *testing.T) {
ResourceName: corev1.ResourceCPU, Capacity: 5000, RequestedByApp: 1000, RequestedByNeighbors: 2000,
},
},
Labels: map[string]string{"label1": "value1", "label2": "value2"},
}}, hosts)
}

Expand Down
1 change: 1 addition & 0 deletions controller/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ type NodeInfo struct {
Name string
Capacity corev1.ResourceList
SystemInfo corev1.NodeSystemInfo
Labels map[string]string
}

type ResourceInfo struct {
Expand Down
1 change: 1 addition & 0 deletions controller/cache/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ func populateHostNodeInfo(un *unstructured.Unstructured, res *ResourceInfo) {
Name: node.Name,
Capacity: node.Status.Capacity,
SystemInfo: node.Status.NodeInfo,
Labels: node.Labels,
}
}

Expand Down
3 changes: 3 additions & 0 deletions controller/cache/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@ apiVersion: v1
kind: Node
metadata:
name: minikube
labels:
foo: bar
spec: {}
status:
capacity:
Expand All @@ -907,6 +909,7 @@ status:
Name: "minikube",
Capacity: corev1.ResourceList{corev1.ResourceMemory: resource.MustParse("6091320Ki"), corev1.ResourceCPU: resource.MustParse("6")},
SystemInfo: corev1.NodeSystemInfo{Architecture: "amd64", OperatingSystem: "linux", OSImage: "Ubuntu 20.04 LTS"},
Labels: map[string]string{"foo": "bar"},
}, info.NodeInfo)
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/operator-manual/argocd-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ data:
# If omitted, Argo CD injects the app name into the label: 'app.kubernetes.io/instance'
application.instanceLabelKey: mycompany.com/appname

# An optional comma-separated list of node labels to propagate to the application pod view.
application.allowedNodeLabels: topology.kubernetes.io/zone,node.kubernetes.io/instance-type

# You can change the resource tracking method Argo CD uses by changing the
# setting application.resourceTrackingMethod to the desired method.
# The following methods are available:
Expand Down
13 changes: 12 additions & 1 deletion docs/operator-manual/ui-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ By default, the Application Details will show the `Tree` view.

This can be configured on an Application basis, by setting the `pref.argocd.argoproj.io/default-view` annotation, accepting one of: `tree`, `pods`, `network`, `list` as values.

For the Pods view, the default grouping mechanism can be configured using the `pref.argocd.argoproj.io/default-pod-sort` annotation, accepting one of: `node`, `parentResource`, `topLevelResource` as values.
For the Pods view, the default grouping mechanism can be configured using the `pref.argocd.argoproj.io/default-pod-sort` annotation, accepting one of: `node`, `parentResource`, `topLevelResource` as values.

## Node Labels in Pod View

It's possible to propagate node labels to node information in the pod view by configuring `applications.allowedNodeLabels` in the [argocd-cm](argocd-cm-yaml.md) ConfigMap.

The following configuration:
```yaml
application.allowedNodeLabels: topology.kubernetes.io/zone,karpenter.sh/capacity-type
```
Would result in:
![Node Labels in Pod View](../assets/application-pod-view-node-labels.png)
Loading
Loading
0