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

2022-03-03

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

示例1:
kubecfg_test.go开发语言: Go项目名称: 289代码行数: 310
44	pods    api.PodList
45	ctrl    api.ReplicationController
46}
72
73func (client *FakeKubeClient) GetReplicationController(name string) (api.ReplicationController, error) {
74	client.actions = append(client.actions, Action{action: "get-controller", value: name})
77
78func (client *FakeKubeClient) CreateReplicationController(controller api.ReplicationController) (api.ReplicationController, error) {
79	client.actions = append(client.actions, Action{action: "create-controller", value: controller})
80	return api.ReplicationController{}, nil
81}
82
83func (client *FakeKubeClient) UpdateReplicationController(controller api.ReplicationController) (api.ReplicationController, error) {
84	client.actions = append(client.actions, Action{action: "update-controller", value: controller})
示例2:
controller_registry_test.go开发语言: Go项目名称: 289代码行数: 237
32	err         error
33	controllers []api.ReplicationController
34}
35
36func (registry *MockControllerRegistry) ListControllers() ([]api.ReplicationController, error) {
37	return registry.controllers, registry.err
39
40func (registry *MockControllerRegistry) GetController(ID string) (*api.ReplicationController, error) {
41	return &api.ReplicationController{}, registry.err
43
44func (registry *MockControllerRegistry) CreateController(controller api.ReplicationController) error {
45	return registry.err
47
48func (registry *MockControllerRegistry) UpdateController(controller api.ReplicationController) error {
49	return registry.err
示例3:
replication_controller.go开发语言: Go项目名称: 289代码行数: 219
43	// To allow injection of syncReplicationController for testing.
44	syncHandler func(controllerSpec api.ReplicationController) error
45}
50	// createReplica creates new replicated pods according to the spec.
51	createReplica(controllerSpec api.ReplicationController)
52	// deletePod deletes the pod identified by podID.
60
61func (r RealPodControl) createReplica(controllerSpec api.ReplicationController) {
62	labels := controllerSpec.DesiredState.PodTemplate.Labels
91	}
92	rm.syncHandler = func(controllerSpec api.ReplicationController) error {
93		return rm.syncReplicationController(controllerSpec)
142
143func (rm *ReplicationManager) handleWatchResponse(response *etcd.Response) (*api.ReplicationController, error) {
144	if response.Action == "set" {
示例4:
replication_controller_test.go开发语言: Go项目名称: 289代码行数: 484
48type FakePodControl struct {
49	controllerSpec []api.ReplicationController
50	deletePodID    []string
52
53func (f *FakePodControl) createReplica(spec api.ReplicationController) {
54	f.controllerSpec = append(f.controllerSpec, spec)
61
62func makeReplicationController(replicas int) api.ReplicationController {
63	return api.ReplicationController{
64		DesiredState: api.ReplicationControllerState{
65			Replicas: replicas,
180
181	controllerSpec := api.ReplicationController{
182		DesiredState: api.ReplicationControllerState{
示例5:
etcd_registry_test.go开发语言: Go项目名称: 289代码行数: 657
409					{
410						Value: util.MakeJSONString(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}),
411					},
412					{
413						Value: util.MakeJSONString(api.ReplicationController{JSONBase: api.JSONBase{ID: "bar"}}),
414					},
429	fakeClient := tools.MakeFakeEtcdClient(t)
430	fakeClient.Set("/registry/controllers/foo", util.MakeJSONString(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
431	registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
475	registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
476	err := registry.CreateController(api.ReplicationController{
477		JSONBase: api.JSONBase{
483	expectNoError(t, err)
484	var ctrl api.ReplicationController
485	err = json.Unmarshal([]byte(resp.Node.Value), &ctrl)
示例6:
memory_registry.go开发语言: Go项目名称: 289代码行数: 139
27	podData        map[string]api.Pod
28	controllerData map[string]api.ReplicationController
29	serviceData    map[string]api.Service
34		podData:        map[string]api.Pod{},
35		controllerData: map[string]api.ReplicationController{},
36		serviceData:    map[string]api.Service{},
73
74func (registry *MemoryRegistry) ListControllers() ([]api.ReplicationController, error) {
75	result := []api.ReplicationController{}
81
82func (registry *MemoryRegistry) GetController(controllerID string) (*api.ReplicationController, error) {
83	controller, found := registry.controllerData[controllerID]
90
91func (registry *MemoryRegistry) CreateController(controller api.ReplicationController) error {
92	registry.controllerData[controller.ID] = controller
示例7:
etcd_registry.go开发语言: Go项目名称: 289代码行数: 269
192
193func (registry *EtcdRegistry) ListControllers() ([]api.ReplicationController, error) {
194	var controllers []api.ReplicationController
202
203func (registry *EtcdRegistry) GetController(controllerID string) (*api.ReplicationController, error) {
204	var controller api.ReplicationController
212
213func (registry *EtcdRegistry) CreateController(controller api.ReplicationController) error {
214	// TODO : check for existence here and error.
217
218func (registry *EtcdRegistry) UpdateController(controller api.ReplicationController) error {
219	return registry.helper().SetObj(makeControllerKey(controller.ID), controller)
示例8:
client_test.go开发语言: Go项目名称: 289代码行数: 468
176			StatusCode: 200,
177			Body: api.ReplicationController{
178				JSONBase: api.JSONBase{
180				},
181				DesiredState: api.ReplicationControllerState{
182					Replicas: 2,
195func TestUpdateController(t *testing.T) {
196	requestController := api.ReplicationController{
197		JSONBase: api.JSONBase{
204			StatusCode: 200,
205			Body: api.ReplicationController{
206				JSONBase: api.JSONBase{
208				},
209				DesiredState: api.ReplicationControllerState{
210					Replicas: 2,
示例9:
memory_registry_test.go开发语言: Go项目名称: 289代码行数: 148
98	registry := MakeMemoryRegistry()
99	registry.CreateController(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}})
100	pods, err := registry.ListControllers()
108	registry := MakeMemoryRegistry()
109	expectedController := api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}
110	registry.CreateController(expectedController)
119	registry := MakeMemoryRegistry()
120	oldController := api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}
121	expectedController := api.ReplicationController{
124		},
125		DesiredState: api.ReplicationControllerState{
126			Replicas: 2,
139	registry := MakeMemoryRegistry()
140	expectedController := api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}
141	registry.CreateController(expectedController)
示例10:
interfaces.go开发语言: Go项目名称: 289代码行数: 55
39type ControllerRegistry interface {
40	ListControllers() ([]api.ReplicationController, error)
41	GetController(controllerId string) (*api.ReplicationController, error)
42	CreateController(controller api.ReplicationController) error
43	UpdateController(controller api.ReplicationController) error

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