package main
import (
"context"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
//"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
func main() {
configPath := "C:\\Users\\admin\\Desktop\\api-six\\k8s-config-admin"
config, _ := clientcmd.BuildConfigFromFlags("", configPath)
clientset, _ := kubernetes.NewForConfig(config)
namespace := "devops"
name, serviceName := "nginx", "nginx-svc"
fmt.Println("已删除:", name)
clientset.AppsV1().Deployments(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{})
clientset.CoreV1().Services(namespace).Delete(context.TODO(), serviceName, metav1.DeleteOptions{})
}