package util

import (
	"cicv-data-closedloop/amd64/dispatch_server/package/infra"
	"context"
	"fmt"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
)

func DeletePod(clientSet *kubernetes.Clientset, podName, namespace string) error {
	err := clientSet.CoreV1().Pods(namespace).Delete(context.TODO(), podName, metav1.DeleteOptions{})
	if err != nil {
		return fmt.Errorf("删除pod报错: %s", err)
	}
	infra.GlobalLogger.Infof("Pod %s in namespace %s 删除成功\n", podName, namespace)
	return nil
}
