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

2022-03-03

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

示例1:
validation_test.go开发语言: Go项目名称: kubernetes代码行数: 2544
1068			Spec: api.PodSpec{
1069				RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
1070				DNSPolicy:     api.DNSClusterFirst,
1487			Spec: api.PodSpec{
1488				RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
1489				DNSPolicy:     api.DNSClusterFirst,
1626			Spec: api.PodSpec{
1627				RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
1628				DNSPolicy:     api.DNSClusterFirst,
1638				Volumes:       []api.Volume{{Name: "gcepd", Source: api.VolumeSource{GCEPersistentDisk: &api.GCEPersistentDiskVolumeSource{"my-PD", "ext4", 1, false}}}},
1639				RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
1640				DNSPolicy:     api.DNSClusterFirst,
1647			Spec: api.PodSpec{
1648				RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
1649				DNSPolicy:     api.DNSClusterFirst,
示例2:
validation.go开发语言: Go项目名称: kubernetes代码行数: 938
565
566func validateRestartPolicy(restartPolicy *api.RestartPolicy) errs.ValidationErrorList {
567	numPolicies := 0
732			// TODO: should probably be Unsupported
733			// TODO: api.RestartPolicy should have a String() method for nicer printing
734			allErrs = append(allErrs, errs.NewFieldInvalid("template.restartPolicy", spec.Template.Spec.RestartPolicy, "must be Always"))
示例3:
etcd_tools_test.go开发语言: Go项目名称: kubernetes代码行数: 611
106				Spec: api.PodSpec{
107					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
108					DNSPolicy:     api.DNSClusterFirst,
113				Spec: api.PodSpec{
114					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
115					DNSPolicy:     api.DNSClusterFirst,
120				Spec: api.PodSpec{
121					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
122					DNSPolicy:     api.DNSClusterFirst,
189				Spec: api.PodSpec{
190					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
191					DNSPolicy:     api.DNSClusterFirst,
196				Spec: api.PodSpec{
197					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
198					DNSPolicy:     api.DNSClusterFirst,
示例4:
validation.go开发语言: Go项目名称: kubernetes代码行数: 440
305
306func validateRestartPolicy(restartPolicy *api.RestartPolicy) errs.ErrorList {
307	numPolicies := 0
318	if numPolicies == 0 {
319		restartPolicy.Always = &api.RestartPolicyAlways{}
320	}
示例5:
get_test.go开发语言: Go项目名称: kubernetes代码行数: 489
45				Spec: api.PodSpec{
46					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
47					DNSPolicy:     api.DNSClusterFirst,
52				Spec: api.PodSpec{
53					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
54					DNSPolicy:     api.DNSClusterFirst,
324			Spec: api.PodSpec{
325				RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
326				DNSPolicy:     api.DNSClusterFirst,
339				Spec: api.PodSpec{
340					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
341					DNSPolicy:     api.DNSClusterFirst,
353				Spec: api.PodSpec{
354					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
355					DNSPolicy:     api.DNSClusterFirst,
示例6:
http_test.go开发语言: Go项目名称: kubernetes代码行数: 274
137					Spec: api.PodSpec{
138						RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
139						DNSPolicy:     api.DNSClusterFirst,
159					Spec: api.PodSpec{
160						RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
161						DNSPolicy:     api.DNSClusterFirst,
177					Spec: api.PodSpec{
178						RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
179						DNSPolicy:     api.DNSClusterFirst,
204					Spec: api.PodSpec{
205						RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
206						DNSPolicy:     api.DNSClusterFirst,
220					Spec: api.PodSpec{
221						RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
222						DNSPolicy:     api.DNSClusterFirst,
示例7:
validation_test.go开发语言: Go项目名称: kubernetes代码行数: 826
271func TestValidateRestartPolicy(t *testing.T) {
272	successCases := []api.RestartPolicy{
273		{},
274		{Always: &api.RestartPolicyAlways{}},
275		{OnFailure: &api.RestartPolicyOnFailure{}},
276		{Never: &api.RestartPolicyNever{}},
277	}
285		{Always: &api.RestartPolicyAlways{}, Never: &api.RestartPolicyNever{}},
286		{Never: &api.RestartPolicyNever{}, OnFailure: &api.RestartPolicyOnFailure{}},
287	}
408				ID:      "abc",
409				RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{},
410					Never: &api.RestartPolicyNever{}},
示例8:
helpers_test.go开发语言: Go项目名称: kubernetes代码行数: 186
47				Spec: api.PodSpec{
48					RestartPolicy: api.RestartPolicy{
49						Always: &api.RestartPolicyAlways{},
68					Host: "bar",
69					RestartPolicy: api.RestartPolicy{
70						Always: &api.RestartPolicyAlways{},
98					},
99					RestartPolicy: api.RestartPolicy{
100						Always: &api.RestartPolicyAlways{},
125				Spec: api.PodSpec{
126					RestartPolicy: api.RestartPolicy{
127						Always: &api.RestartPolicyAlways{},
示例9:
run.go开发语言: Go项目名称: ddysher代码行数: 633
174	}
175	if restartPolicy != api.RestartPolicyAlways && replicas != 1 {
176		return cmdutil.UsageErrorf(cmd, "--restart=%s requires that --replicas=1, found %d", restartPolicy, replicas)
215		switch restartPolicy {
216		case api.RestartPolicyAlways:
217			// TODO: we need to deprecate this along with extensions/v1beta1.Deployments
223			}
224		case api.RestartPolicyOnFailure:
225			if contains(resourcesList, batchv1.SchemeGroupVersion.WithResource("jobs")) {
229			}
230		case api.RestartPolicyNever:
231			generatorName = cmdutil.RunPodV1GeneratorName
310		leaveStdinOpen := cmdutil.GetFlagBool(cmd, "leave-stdin-open")
311		waitForExitCode := !leaveStdinOpen && restartPolicy == api.RestartPolicyNever
312		if waitForExitCode {
示例10:
run.go开发语言: Go项目名称: detiber代码行数: 639
174	}
175	if restartPolicy != api.RestartPolicyAlways && replicas != 1 {
176		return cmdutil.UsageError(cmd, fmt.Sprintf("--restart=%s requires that --replicas=1, found %d", restartPolicy, replicas))
215		switch restartPolicy {
216		case api.RestartPolicyAlways:
217			// TODO: we need to deprecate this along with extensions/v1beta1.Deployments
223			}
224		case api.RestartPolicyOnFailure:
225			if contains(resourcesList, batchv1.SchemeGroupVersion.WithResource("jobs")) {
229			}
230		case api.RestartPolicyNever:
231			generatorName = cmdutil.RunPodV1GeneratorName
315		leaveStdinOpen := cmdutil.GetFlagBool(cmd, "leave-stdin-open")
316		waitForExitCode := !leaveStdinOpen && restartPolicy == api.RestartPolicyNever
317		if waitForExitCode {

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