k8s/io/kubernetes/pkg/api.ServiceSpec 示例代码

2022-03-03

以下示例是关于golang中包含api.ServiceSpec用法的示例代码,想了解api.ServiceSpec的具体用法?api.ServiceSpec怎么用?api.ServiceSpec使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
validation_test.go开发语言: Go项目名称: kubernetes代码行数: 2544
1098				ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault},
1099				Spec: api.ServiceSpec{
1100					Port:            8675,
1112				ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
1113				Spec: api.ServiceSpec{
1114					Port:            8675,
1125				ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
1126				Spec: api.ServiceSpec{
1127					Port:     8675,
1138				ObjectMeta: api.ObjectMeta{Name: "foo"},
1139				Spec: api.ServiceSpec{
1140					Port:            8675,
1152				ObjectMeta: api.ObjectMeta{Name: "-123abc", Namespace: api.NamespaceDefault},
1153				Spec: api.ServiceSpec{
1154					Port:            8675,
示例2:
service.go开发语言: Go项目名称: docker代码行数: 1126
474
475func validateMode(s *api.ServiceSpec) error {
476	m := s.GetMode()
477	switch mode := m.(type) {
478	case *api.ServiceSpec_Replicated:
479		if int64(mode.Replicated.Replicas) < 0 {
481		}
482	case *api.ServiceSpec_Global:
483	case *api.ServiceSpec_ReplicatedJob:
501		}
502	case *api.ServiceSpec_GlobalJob:
503	default:
509
510func validateJob(spec *api.ServiceSpec) error {
511	if spec.Update != nil {
示例3:
spreading_test.go开发语言: Go项目名称: kubernetes代码行数: 294
65			nodes:        []string{"machine1", "machine2"},
66			services:     []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"key": "value"}}}},
67			expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}},
76			nodes:        []string{"machine1", "machine2"},
77			services:     []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}},
78			expectedList: []HostPriority{{"machine1", 10}, {"machine2", 0}},
88			nodes:        []string{"machine1", "machine2"},
89			services:     []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}},
90			expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
101			nodes:        []string{"machine1", "machine2"},
102			services:     []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}},
103			expectedList: []HostPriority{{"machine1", 5}, {"machine2", 0}},
113			nodes:        []string{"machine1", "machine2"},
114			services:     []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"baz": "blah"}}}},
115			expectedList: []HostPriority{{"machine1", 0}, {"machine2", 5}},
示例4:
config_test.go开发语言: Go项目名称: kubernetes代码行数: 296
138	config.RegisterHandler(handler)
139	serviceUpdate := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Spec: api.ServiceSpec{Port: 10}})
140	channel <- serviceUpdate
149	config.RegisterHandler(handler)
150	serviceUpdate := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Spec: api.ServiceSpec{Port: 10}})
151	handler.Wait(1)
154
155	serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Spec: api.ServiceSpec{Port: 20}})
156	handler.Wait(1)
166
167	serviceUpdate4 := CreateServiceUpdate(SET, api.Service{ObjectMeta: api.ObjectMeta{Name: "foobar"}, Spec: api.ServiceSpec{Port: 99}})
168	handler.Wait(1)
182	config.RegisterHandler(handler)
183	serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Spec: api.ServiceSpec{Port: 10}})
184	serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Spec: api.ServiceSpec{Port: 20}})
示例5:
endpoints_controller_test.go开发语言: Go项目名称: kubernetes代码行数: 492
235				ObjectMeta: api.ObjectMeta{Name: "foo"},
236				Spec:       api.ServiceSpec{},
237			},
264				ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "other"},
265				Spec: api.ServiceSpec{
266					Selector: map[string]string{},
296				ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "other"},
297				Spec: api.ServiceSpec{
298					Selector: map[string]string{},
328				ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "other"},
329				Spec: api.ServiceSpec{
330					Selector: map[string]string{},
367				ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "bar"},
368				Spec: api.ServiceSpec{
369					Selector: map[string]string{
示例6:
integration.go开发语言: Go项目名称: kubernetes代码行数: 746
330			},
331			Spec: api.ServiceSpec{
332				Port: 12345,
395			},
396			Spec: api.ServiceSpec{
397				Port: 12345,
562		ObjectMeta: api.ObjectMeta{Name: "service1"},
563		Spec: api.ServiceSpec{
564			Selector: map[string]string{
579		ObjectMeta: api.ObjectMeta{Name: "service1"},
580		Spec: api.ServiceSpec{
581			Selector: map[string]string{
599		ObjectMeta: api.ObjectMeta{Name: "service2"},
600		Spec: api.ServiceSpec{
601			Selector: map[string]string{
示例7:
predicates_test.go开发语言: Go项目名称: kubernetes代码行数: 577
521			node:     "machine1",
522			services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
523			fits:     true,
530			node:     "machine1",
531			services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
532			fits:     true,
539			node:     "machine1",
540			services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
541			fits:     false,
548			node:     "machine1",
549			services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
550			fits:     false,
557			node:     "machine4",
558			services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
559			fits:     true,
示例8:
request_test.go开发语言: Go项目名称: kubernetes代码行数: 1037
606	reqBody := "request body"
607	expectedObj := &api.Service{Spec: api.ServiceSpec{Port: 12345}}
608	expectedBody, _ := v1beta2.Codec.Encode(expectedObj)
641	reqBodyExpected, _ := v1beta1.Codec.Encode(reqObj)
642	expectedObj := &api.Service{Spec: api.ServiceSpec{Port: 12345}}
643	expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
677	reqBodyExpected, _ := v1beta2.Codec.Encode(reqObj)
678	expectedObj := &api.Service{Spec: api.ServiceSpec{Port: 12345}}
679	expectedBody, _ := v1beta2.Codec.Encode(expectedObj)
727
728	expectedObj := &api.Service{Spec: api.ServiceSpec{Port: 12345}}
729	expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
769
770	expectedObj := &api.Service{Spec: api.ServiceSpec{Port: 12345}}
771	expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
示例9:
service.go开发语言: Go项目名称: docker代码行数: 99
12// values.
13var Service = api.ServiceSpec{
14	Task: api.TaskSpec{
44// has all unspecified values filled in with default values.
45func InterpolateService(origSpec *api.ServiceSpec) *api.ServiceSpec {
46	spec := origSpec.Copy()
示例10:
rest_test.go开发语言: Go项目名称: ddysher代码行数: 1564
91		ObjectMeta: metav1.ObjectMeta{Name: "foo"},
92		Spec: api.ServiceSpec{
93			Selector:        map[string]string{"bar": "baz"},
143				ObjectMeta: metav1.ObjectMeta{Name: "foo1"},
144				Spec: api.ServiceSpec{
145					Selector:        map[string]string{"bar": "baz"},
171				ObjectMeta: metav1.ObjectMeta{Name: "foo2"},
172				Spec: api.ServiceSpec{
173					Selector:        map[string]string{"bar": "baz"},
198				ObjectMeta: metav1.ObjectMeta{Name: "foo3"},
199				Spec: api.ServiceSpec{
200					Selector:        map[string]string{"bar": "baz"},
261			ObjectMeta: metav1.ObjectMeta{Name: ""},
262			Spec: api.ServiceSpec{
263				Selector:        map[string]string{"bar": "baz"},

本文地址:https://www.itbaoku.cn/snippets/415682.html