-
Notifications
You must be signed in to change notification settings - Fork 66
/
mco_statefulset.go
40 lines (34 loc) · 1.09 KB
/
mco_statefulset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) Red Hat, Inc.
// Copyright Contributors to the Open Cluster Management project
// Licensed under the Apache License 2.0
package utils
import (
"context"
appv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog"
)
func GetStatefulSet(opt TestOptions, isHub bool, name string,
namespace string) (*appv1.StatefulSet, error) {
clientKube := getKubeClient(opt, isHub)
sts, err := clientKube.AppsV1().StatefulSets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
klog.Errorf("Failed to get statefulset %s in namespace %s due to %v", name, namespace, err)
}
return sts, err
}
func GetStatefulSetWithLabel(opt TestOptions, isHub bool, label string,
namespace string) (*appv1.StatefulSetList, error) {
clientKube := getKubeClient(opt, isHub)
sts, err := clientKube.AppsV1().StatefulSets(namespace).List(context.TODO(), metav1.ListOptions{
LabelSelector: label,
})
if err != nil {
klog.Errorf(
"Failed to get statefulset with label selector %s in namespace %s due to %v",
label,
namespace,
err)
}
return sts, err
}