diff options
Diffstat (limited to 'internal/pkg/kube')
-rw-r--r-- | internal/pkg/kube/kube.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/internal/pkg/kube/kube.go b/internal/pkg/kube/kube.go index cc7c29b..e51963e 100644 --- a/internal/pkg/kube/kube.go +++ b/internal/pkg/kube/kube.go @@ -41,7 +41,7 @@ type Kube struct { func (k *Kube) SetAnnotationOnPod(pod *kapi.Pod, key, value string) error { logrus.Infof("Setting annotations %s=%s on pod %s", key, value, pod.Name) patchData := fmt.Sprintf(`{"metadata":{"annotations":{"%s":"%s"}}}`, key, value) - _, err := k.KClient.Core().Pods(pod.Namespace).Patch(pod.Name, types.MergePatchType, []byte(patchData)) + _, err := k.KClient.CoreV1().Pods(pod.Namespace).Patch(pod.Name, types.MergePatchType, []byte(patchData)) if err != nil { logrus.Errorf("Error in setting annotation on pod %s/%s: %v", pod.Name, pod.Namespace, err) } @@ -52,7 +52,7 @@ func (k *Kube) SetAnnotationOnPod(pod *kapi.Pod, key, value string) error { func (k *Kube) SetAnnotationOnNode(node *kapi.Node, key, value string) error { logrus.Infof("Setting annotations %s=%s on node %s", key, value, node.Name) patchData := fmt.Sprintf(`{"metadata":{"annotations":{"%s":"%s"}}}`, key, value) - _, err := k.KClient.Core().Nodes().Patch(node.Name, types.MergePatchType, []byte(patchData)) + _, err := k.KClient.CoreV1().Nodes().Patch(node.Name, types.MergePatchType, []byte(patchData)) if err != nil { logrus.Errorf("Error in setting annotation on node %s: %v", node.Name, err) } @@ -67,7 +67,7 @@ func (k *Kube) SetAnnotationOnNamespace(ns *kapi.Namespace, key, ns.Name) patchData := fmt.Sprintf(`{"metadata":{"annotations":{"%s":"%s"}}}`, key, value) - _, err := k.KClient.Core().Namespaces().Patch(ns.Name, + _, err := k.KClient.CoreV1().Namespaces().Patch(ns.Name, types.MergePatchType, []byte(patchData)) if err != nil { logrus.Errorf("Error in setting annotation on namespace %s: %v", @@ -78,7 +78,7 @@ func (k *Kube) SetAnnotationOnNamespace(ns *kapi.Namespace, key, // GetAnnotationsOnPod obtains the pod annotations from kubernetes apiserver, given the name and namespace func (k *Kube) GetAnnotationsOnPod(namespace, name string) (map[string]string, error) { - pod, err := k.KClient.Core().Pods(namespace).Get(name, metav1.GetOptions{}) + pod, err := k.KClient.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{}) if err != nil { return nil, err } @@ -87,12 +87,12 @@ func (k *Kube) GetAnnotationsOnPod(namespace, name string) (map[string]string, e // GetPod obtains the Pod resource from kubernetes apiserver, given the name and namespace func (k *Kube) GetPod(namespace, name string) (*kapi.Pod, error) { - return k.KClient.Core().Pods(namespace).Get(name, metav1.GetOptions{}) + return k.KClient.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{}) } // GetPods obtains the Pod resource from kubernetes apiserver, given the name and namespace func (k *Kube) GetPods(namespace string) (*kapi.PodList, error) { - return k.KClient.Core().Pods(namespace).List(metav1.ListOptions{}) + return k.KClient.CoreV1().Pods(namespace).List(metav1.ListOptions{}) } // GetPodsByLabels obtains the Pod resources from kubernetes apiserver, @@ -100,42 +100,42 @@ func (k *Kube) GetPods(namespace string) (*kapi.PodList, error) { func (k *Kube) GetPodsByLabels(namespace string, selector labels.Selector) (*kapi.PodList, error) { options := metav1.ListOptions{} options.LabelSelector = selector.String() - return k.KClient.Core().Pods(namespace).List(options) + return k.KClient.CoreV1().Pods(namespace).List(options) } // GetNodes returns the list of all Node objects from kubernetes func (k *Kube) GetNodes() (*kapi.NodeList, error) { - return k.KClient.Core().Nodes().List(metav1.ListOptions{}) + return k.KClient.CoreV1().Nodes().List(metav1.ListOptions{}) } // GetNode returns the Node resource from kubernetes apiserver, given its name func (k *Kube) GetNode(name string) (*kapi.Node, error) { - return k.KClient.Core().Nodes().Get(name, metav1.GetOptions{}) + return k.KClient.CoreV1().Nodes().Get(name, metav1.GetOptions{}) } // GetService returns the Service resource from kubernetes apiserver, given its name and namespace func (k *Kube) GetService(namespace, name string) (*kapi.Service, error) { - return k.KClient.Core().Services(namespace).Get(name, metav1.GetOptions{}) + return k.KClient.CoreV1().Services(namespace).Get(name, metav1.GetOptions{}) } // GetEndpoints returns all the Endpoint resources from kubernetes // apiserver, given namespace func (k *Kube) GetEndpoints(namespace string) (*kapi.EndpointsList, error) { - return k.KClient.Core().Endpoints(namespace).List(metav1.ListOptions{}) + return k.KClient.CoreV1().Endpoints(namespace).List(metav1.ListOptions{}) } // GetNamespace returns the Namespace resource from kubernetes apiserver, // given its name func (k *Kube) GetNamespace(name string) (*kapi.Namespace, error) { - return k.KClient.Core().Namespaces().Get(name, metav1.GetOptions{}) + return k.KClient.CoreV1().Namespaces().Get(name, metav1.GetOptions{}) } // GetNamespaces returns all Namespace resource from kubernetes apiserver func (k *Kube) GetNamespaces() (*kapi.NamespaceList, error) { - return k.KClient.Core().Namespaces().List(metav1.ListOptions{}) + return k.KClient.CoreV1().Namespaces().List(metav1.ListOptions{}) } // GetNetworkPolicies returns all network policy objects from kubernetes func (k *Kube) GetNetworkPolicies(namespace string) (*kapisnetworking.NetworkPolicyList, error) { - return k.KClient.Networking().NetworkPolicies(namespace).List(metav1.ListOptions{}) + return k.KClient.NetworkingV1().NetworkPolicies(namespace).List(metav1.ListOptions{}) } |