本文整理匯總了Golang中k8s/io/kubernetes/pkg/api.Probe.Handler方法的典型用法代碼示例。如果您正苦於以下問題:Golang Probe.Handler方法的具體用法?Golang Probe.Handler怎麽用?Golang Probe.Handler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/api.Probe
的用法示例。
在下文中一共展示了Probe.Handler方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateProbe
// updateProbe updates only those fields with flags set by the user
func (o *ProbeOptions) updateProbe(probe *kapi.Probe) {
switch {
case o.Command != nil:
probe.Handler = kapi.Handler{Exec: &kapi.ExecAction{Command: o.Command}}
case o.HTTPGetAction != nil:
probe.Handler = kapi.Handler{HTTPGet: o.HTTPGetAction}
case len(o.OpenTCPSocket) > 0:
probe.Handler = kapi.Handler{TCPSocket: &kapi.TCPSocketAction{Port: intOrString(o.OpenTCPSocket)}}
}
if o.InitialDelaySeconds != nil {
probe.InitialDelaySeconds = int32(*o.InitialDelaySeconds)
}
if o.SuccessThreshold != nil {
probe.SuccessThreshold = int32(*o.SuccessThreshold)
}
if o.FailureThreshold != nil {
probe.FailureThreshold = int32(*o.FailureThreshold)
}
if o.TimeoutSeconds != nil {
probe.TimeoutSeconds = int32(*o.TimeoutSeconds)
}
if o.PeriodSeconds != nil {
probe.PeriodSeconds = int32(*o.PeriodSeconds)
}
}
示例2: setTestProbe
func setTestProbe(pod *api.Pod, probeType probeType, probeSpec api.Probe) {
// All tests rely on the fake exec prober.
probeSpec.Handler = api.Handler{
Exec: &api.ExecAction{},
}
// Apply test defaults, overwridden for test speed.
defaults := map[string]int64{
"TimeoutSeconds": 1,
"PeriodSeconds": 1,
"SuccessThreshold": 1,
"FailureThreshold": 1,
}
for field, value := range defaults {
f := reflect.ValueOf(&probeSpec).Elem().FieldByName(field)
if f.Int() == 0 {
f.SetInt(value)
}
}
switch probeType {
case readiness:
pod.Spec.Containers[0].ReadinessProbe = &probeSpec
case liveness:
pod.Spec.Containers[0].LivenessProbe = &probeSpec
}
}
示例3: newTestWorker
func newTestWorker(m *manager, probeType probeType, probeSpec api.Probe) *worker {
// All tests rely on the fake exec prober.
probeSpec.Handler = api.Handler{
Exec: &api.ExecAction{},
}
pod := getTestPod(probeType, probeSpec)
return newWorker(m, probeType, &pod, pod.Spec.Containers[0])
}
示例4: getTestPod
func getTestPod(probeType probeType, probeSpec api.Probe) api.Pod {
container := api.Container{
Name: testContainerName,
}
// All tests rely on the fake exec prober.
probeSpec.Handler = api.Handler{
Exec: &api.ExecAction{},
}
// Apply test defaults, overwridden for test speed.
defaults := map[string]int64{
"TimeoutSeconds": 1,
"PeriodSeconds": 1,
"SuccessThreshold": 1,
"FailureThreshold": 1,
}
for field, value := range defaults {
f := reflect.ValueOf(&probeSpec).Elem().FieldByName(field)
if f.Int() == 0 {
f.SetInt(value)
}
}
switch probeType {
case readiness:
container.ReadinessProbe = &probeSpec
case liveness:
container.LivenessProbe = &probeSpec
}
pod := api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{container},
RestartPolicy: api.RestartPolicyNever,
},
}
pod.Name = "testPod"
pod.UID = testPodUID
return pod
}
示例5: newTestWorker
func newTestWorker(m *manager, probeType probeType, probeSpec api.Probe) *worker {
// All tests rely on the fake exec prober.
probeSpec.Handler = api.Handler{
Exec: &api.ExecAction{},
}
// Apply default values.
defaults := map[string]int64{
"TimeoutSeconds": 1,
"PeriodSeconds": 10,
"SuccessThreshold": 1,
"FailureThreshold": 3,
}
for field, value := range defaults {
f := reflect.ValueOf(&probeSpec).Elem().FieldByName(field)
if f.Int() == 0 {
f.SetInt(value)
}
}
pod := getTestPod(probeType, probeSpec)
return newWorker(m, probeType, &pod, pod.Spec.Containers[0])
}