本文整理汇总了Golang中k8s/io/kubernetes/pkg/api.Probe类的典型用法代码示例。如果您正苦于以下问题:Golang Probe类的具体用法?Golang Probe怎么用?Golang Probe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Probe类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: deepCopy_api_Probe
func deepCopy_api_Probe(in api.Probe, out *api.Probe, c *conversion.Cloner) error {
if err := deepCopy_api_Handler(in.Handler, &out.Handler, c); err != nil {
return err
}
out.InitialDelaySeconds = in.InitialDelaySeconds
out.TimeoutSeconds = in.TimeoutSeconds
return nil
}
示例2: deepCopy_api_Probe
func deepCopy_api_Probe(in api.Probe, out *api.Probe, c *conversion.Cloner) error {
if err := deepCopy_api_Handler(in.Handler, &out.Handler, c); err != nil {
return err
}
out.InitialDelaySeconds = in.InitialDelaySeconds
out.TimeoutSeconds = in.TimeoutSeconds
out.PeriodSeconds = in.PeriodSeconds
out.SuccessThreshold = in.SuccessThreshold
out.FailureThreshold = in.FailureThreshold
return nil
}
示例3: 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)
}
}
示例4: 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
}
}
示例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{},
}
pod := getTestPod(probeType, probeSpec)
return newWorker(m, probeType, &pod, pod.Spec.Containers[0])
}
示例6: 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
}
示例7: 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])
}
示例8: writeProbe
func writeProbe(m map[string]interface{}, item *api.Probe) {
if x, ok := m["initial_delay"].(int); ok {
item.InitialDelaySeconds = x
}
if x, ok := m["timeout"].(int); ok {
item.TimeoutSeconds = x
}
if x, ok := m["period"].(int); ok {
item.PeriodSeconds = x
}
if x, ok := m["success_threshold"].(int); ok {
item.SuccessThreshold = x
}
if x, ok := m["failure_threshold"].(int); ok {
item.FailureThreshold = x
}
if n, ok := extractSingleMap(m["exec"]); ok {
item.Exec = &api.ExecAction{}
if l, ok := n["command"].([]interface{}); ok {
for _, x := range l {
item.Exec.Command = append(item.Exec.Command, x.(string))
}
}
}
if n, ok := extractSingleMap(m["http_get"]); ok {
item.HTTPGet = &api.HTTPGetAction{}
if x, ok := n["path"].(string); ok {
item.HTTPGet.Path = x
}
if x, ok := n["port"].(int); ok {
item.HTTPGet.Port = intstr.FromInt(x)
}
if x, ok := n["host"].(string); ok {
item.HTTPGet.Host = x
}
if x, ok := n["scheme"].(string); ok {
item.HTTPGet.Scheme = api.URIScheme(x)
}
if l, ok := n["http_header"].([]interface{}); ok {
for _, x := range l {
if y, ok := extractSingleMap(x); ok {
h := api.HTTPHeader{}
if x, ok := y["name"].(string); ok {
h.Name = x
}
if x, ok := y["value"].(string); ok {
h.Value = x
}
item.HTTPGet.HTTPHeaders = append(item.HTTPGet.HTTPHeaders, h)
}
}
}
}
if n, ok := extractSingleMap(m["tcp_socket"]); ok {
item.TCPSocket = &api.TCPSocketAction{}
if x, ok := n["port"].(int); ok {
item.TCPSocket.Port = intstr.FromInt(x)
}
}
}