标签:deploy default print namespace name err amp mars names
clientset := K8sClient() var ( err error data []byte deployment =&v1.Deployment{} ) //读取yaml if data, err = ioutil.ReadFile("C:/Users/72088854/go/src/config"); err != nil { fmt.Print(err) } //yaml转json if data, err = yaml2.ToJSON(data); err != nil { return } //json转struct if err = json.Unmarshal(data, deployment); err != nil { return } cluster := deployment.ObjectMeta.ClusterName namespace := deployment.ObjectMeta.Namespace deploymentName := deployment.ObjectMeta.Name fmt.Println(deploymentName) if deployment, err = clientset.AppsV1().Deployments(apiv1.NamespaceDefault).Create(context.TODO(), deployment, metav1.CreateOptions{}); err != nil { return } fmt.Println("create成功!!!") fmt.Println(cluster, namespace, deploymentName)
标签:deploy default print namespace name err amp mars names
原文地址:https://www.cnblogs.com/wuchangblog/p/14208555.html