当前位置: 首页>>代码示例>>Golang>>正文


Golang Clientset.Services方法代码示例

本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/clientset_generated/internalclientset.Clientset.Services方法的典型用法代码示例。如果您正苦于以下问题:Golang Clientset.Services方法的具体用法?Golang Clientset.Services怎么用?Golang Clientset.Services使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在k8s/io/kubernetes/pkg/client/clientset_generated/internalclientset.Clientset的用法示例。


在下文中一共展示了Clientset.Services方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: CreateEssentialAddons

func CreateEssentialAddons(s *kubeadmapi.MasterConfiguration, client *clientset.Clientset) error {
	arches := [3]string{"amd64", "arm", "arm64"}

	for _, arch := range arches {
		kubeProxyDaemonSet := NewDaemonSet(kubeProxy+"-"+arch, createKubeProxyPodSpec(s, arch))
		SetMasterTaintTolerations(&kubeProxyDaemonSet.Spec.Template.ObjectMeta)

		if _, err := client.Extensions().DaemonSets(api.NamespaceSystem).Create(kubeProxyDaemonSet); err != nil {
			return fmt.Errorf("<master/addons> failed creating essential kube-proxy addon [%v]", err)
		}
	}

	fmt.Println("<master/addons> created essential addon: kube-proxy")

	kubeDNSDeployment := NewDeployment("kube-dns", 1, createKubeDNSPodSpec(s))
	SetMasterTaintTolerations(&kubeDNSDeployment.Spec.Template.ObjectMeta)

	if _, err := client.Extensions().Deployments(api.NamespaceSystem).Create(kubeDNSDeployment); err != nil {
		return fmt.Errorf("<master/addons> failed creating essential kube-dns addon [%v]", err)
	}

	kubeDNSServiceSpec, err := createKubeDNSServiceSpec(s)
	if err != nil {
		return fmt.Errorf("<master/addons> failed creating essential kube-dns addon - %v", err)
	}

	kubeDNSService := NewService("kube-dns", *kubeDNSServiceSpec)
	if _, err := client.Services(api.NamespaceSystem).Create(kubeDNSService); err != nil {
		return fmt.Errorf("<master/addons> failed creating essential kube-dns addon [%v]", err)
	}

	fmt.Println("<master/addons> created essential addon: kube-dns")

	return nil
}
开发者ID:ncdc,项目名称:kubernetes,代码行数:35,代码来源:addons.go

示例2: CreateEssentialAddons

func CreateEssentialAddons(cfg *kubeadmapi.MasterConfiguration, client *clientset.Clientset) error {
	kubeProxyDaemonSet := NewDaemonSet(kubeProxy, createKubeProxyPodSpec(cfg))
	SetMasterTaintTolerations(&kubeProxyDaemonSet.Spec.Template.ObjectMeta)
	SetNodeAffinity(&kubeProxyDaemonSet.Spec.Template.ObjectMeta, NativeArchitectureNodeAffinity())

	if _, err := client.Extensions().DaemonSets(api.NamespaceSystem).Create(kubeProxyDaemonSet); err != nil {
		return fmt.Errorf("<master/addons> failed creating essential kube-proxy addon [%v]", err)
	}

	fmt.Println("<master/addons> created essential addon: kube-proxy")

	kubeDNSDeployment := NewDeployment("kube-dns", 1, createKubeDNSPodSpec(cfg))
	SetMasterTaintTolerations(&kubeDNSDeployment.Spec.Template.ObjectMeta)
	SetNodeAffinity(&kubeDNSDeployment.Spec.Template.ObjectMeta, NativeArchitectureNodeAffinity())

	if _, err := client.Extensions().Deployments(api.NamespaceSystem).Create(kubeDNSDeployment); err != nil {
		return fmt.Errorf("<master/addons> failed creating essential kube-dns addon [%v]", err)
	}

	kubeDNSServiceSpec, err := createKubeDNSServiceSpec(cfg)
	if err != nil {
		return fmt.Errorf("<master/addons> failed creating essential kube-dns addon - %v", err)
	}

	kubeDNSService := NewService("kube-dns", *kubeDNSServiceSpec)
	if _, err := client.Services(api.NamespaceSystem).Create(kubeDNSService); err != nil {
		return fmt.Errorf("<master/addons> failed creating essential kube-dns addon [%v]", err)
	}

	fmt.Println("<master/addons> created essential addon: kube-dns")

	return nil
}
开发者ID:eljefedelrodeodeljefe,项目名称:kubernetes,代码行数:33,代码来源:addons.go


注:本文中的k8s/io/kubernetes/pkg/client/clientset_generated/internalclientset.Clientset.Services方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。