mirror of https://github.com/docker/compose.git
Set kube namespace properly
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
15c0b883fe
commit
677bfc9ce5
|
@ -32,7 +32,8 @@ import (
|
||||||
|
|
||||||
// KubeClient API to access kube objects
|
// KubeClient API to access kube objects
|
||||||
type KubeClient struct {
|
type KubeClient struct {
|
||||||
client *kubernetes.Clientset
|
client *kubernetes.Clientset
|
||||||
|
namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKubeClient new kubernetes client
|
// NewKubeClient new kubernetes client
|
||||||
|
@ -46,8 +47,15 @@ func NewKubeClient(config genericclioptions.RESTClientGetter) (*KubeClient, erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace, _, err := config.ToRawKubeConfigLoader().Namespace()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &KubeClient{
|
return &KubeClient{
|
||||||
client: clientset,
|
client: clientset,
|
||||||
|
namespace: namespace,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +66,7 @@ func (kc KubeClient) GetContainers(ctx context.Context, projectName string, all
|
||||||
fieldSelector = "status.phase=Running"
|
fieldSelector = "status.phase=Running"
|
||||||
}
|
}
|
||||||
|
|
||||||
pods, err := kc.client.CoreV1().Pods("").List(ctx, metav1.ListOptions{
|
pods, err := kc.client.CoreV1().Pods(kc.namespace).List(ctx, metav1.ListOptions{
|
||||||
LabelSelector: fmt.Sprintf("%s=%s", compose.ProjectTag, projectName),
|
LabelSelector: fmt.Sprintf("%s=%s", compose.ProjectTag, projectName),
|
||||||
FieldSelector: fieldSelector,
|
FieldSelector: fieldSelector,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue