2020-10-30 16:30:03 +01:00
|
|
|
package k8s
|
|
|
|
|
|
|
|
import (
|
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
"k8s.io/client-go/kubernetes"
|
|
|
|
)
|
|
|
|
|
2020-11-11 20:46:19 +01:00
|
|
|
// GetKubernetesServices return List of Services from given namespace
|
|
|
|
func GetKubernetesServices(client *kubernetes.Clientset, ns string) ([]corev1.Service, error) {
|
|
|
|
services, err := client.CoreV1().Services(ns).List(metav1.ListOptions{})
|
2020-10-30 16:30:03 +01:00
|
|
|
if err != nil {
|
2020-11-11 20:46:19 +01:00
|
|
|
return nil, err
|
2020-10-30 16:30:03 +01:00
|
|
|
}
|
2020-11-11 20:46:19 +01:00
|
|
|
return services.Items, nil
|
2020-10-30 16:30:03 +01:00
|
|
|
}
|