зеркало из https://github.com/docker/compose-cli.git
Set kube namespace properly
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
Родитель
15c0b883fe
Коммит
677bfc9ce5
|
@ -32,7 +32,8 @@ import (
|
|||
|
||||
// KubeClient API to access kube objects
|
||||
type KubeClient struct {
|
||||
client *kubernetes.Clientset
|
||||
client *kubernetes.Clientset
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewKubeClient new kubernetes client
|
||||
|
@ -46,8 +47,15 @@ func NewKubeClient(config genericclioptions.RESTClientGetter) (*KubeClient, erro
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
namespace, _, err := config.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &KubeClient{
|
||||
client: clientset,
|
||||
client: clientset,
|
||||
namespace: namespace,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -58,7 +66,7 @@ func (kc KubeClient) GetContainers(ctx context.Context, projectName string, all
|
|||
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),
|
||||
FieldSelector: fieldSelector,
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче