本文整理汇总了Golang中k8s/io/kubernetes/pkg/api.Service.GenerateName方法的典型用法代码示例。如果您正苦于以下问题:Golang Service.GenerateName方法的具体用法?Golang Service.GenerateName怎么用?Golang Service.GenerateName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/api.Service
的用法示例。
在下文中一共展示了Service.GenerateName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreatePodService
// create headless service for pod, so tat we can use service ip instead of pods volatile IP
// @param selector - selector that will find corresponding pod, this should have label "replica" set
// @return *api.Service - created service
// @return error
func (cluster *CouchdbCluster) CreatePodService(selector map[string]string) (*api.Service, error) {
// service special label
serviceLabels := make(map[string]string)
for k, v := range selector {
serviceLabels[k] = v
}
// add special label
serviceLabels[LABEL_POD_SERVICE] = "true"
// svc port
svcPorts := api.ServicePort{Port: COUCHDB_PORT}
// service specs
serviceSpec := api.ServiceSpec{Selector: selector, Ports: []api.ServicePort{svcPorts} /* ClusterIP: "None"*/}
// init service struct
service := api.Service{Spec: serviceSpec}
service.GenerateName = cluster.Tag + "-pod-"
service.Labels = serviceLabels
// get a new kube client
c, err := KubeClient(KUBE_API)
// check for errors
if err != nil {
ErrorLog("spawner_rc: CreatePodService: Cannot connect to Kubernetes api ")
ErrorLog(err)
return nil, err
} else {
// create service in namespace
return c.Services(cluster.Namespace).Create(&service)
}
}