mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(app): allow editing pod services [EE-6480] (#10875)
* fix(app): allow editing pod services [EE-6480] * address review comment --------- Co-authored-by: testa113 <testa113> Co-authored-by: prabhat khera <prabhat.khera@portainer.io>
This commit is contained in:
parent
7cba02226e
commit
4c0049edbe
5 changed files with 60 additions and 11 deletions
|
@ -315,7 +315,12 @@ class KubernetesApplicationHelper {
|
|||
ports.push(svcport);
|
||||
});
|
||||
svc.Ports = ports;
|
||||
svc.Selector = app.Raw.spec.selector.matchLabels;
|
||||
// if the app is a pod (doesn't have a selector), then get the pod labels
|
||||
if (app.Raw.spec.selector) {
|
||||
svc.Selector = app.Raw.spec.selector.matchLabels;
|
||||
} else {
|
||||
svc.Selector = app.Raw.metadata.labels || { app: app.Name };
|
||||
}
|
||||
services.push(svc);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,10 +14,12 @@ class KubernetesServiceHelper {
|
|||
}
|
||||
|
||||
static findApplicationBoundServices(services, rawApp) {
|
||||
if (!rawApp.spec.template) {
|
||||
// if the app is a naked pod (doesn't have a template), then get the pod labels
|
||||
const appLabels = rawApp.spec.template ? rawApp.spec.template.metadata.labels : rawApp.metadata.labels;
|
||||
if (!appLabels) {
|
||||
return undefined;
|
||||
}
|
||||
return _.filter(services, (item) => item.spec.selector && _.isMatch(rawApp.spec.template.metadata.labels, item.spec.selector));
|
||||
return _.filter(services, (item) => item.spec.selector && _.isMatch(appLabels, item.spec.selector));
|
||||
}
|
||||
}
|
||||
export default KubernetesServiceHelper;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue