/
node_pod_probe_types.go
117 lines (98 loc) · 3.2 KB
/
node_pod_probe_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
Copyright 2022 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless persistent by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// NodePodProbeSpec defines the desired state of NodePodProbe
type NodePodProbeSpec struct {
PodProbes []PodProbe `json:"podProbes,omitempty"`
}
type PodProbe struct {
// pod name
Name string `json:"name"`
// pod namespace
Namespace string `json:"namespace"`
// pod uid
UID string `json:"uid"`
// pod ip
IP string `json:"IP"`
// Custom container probe, supports Exec, Tcp, and returns the result to Pod yaml
Probes []ContainerProbe `json:"probes,omitempty"`
}
type ContainerProbe struct {
// Name is podProbeMarker.Name#probe.Name
Name string `json:"name"`
// container name
ContainerName string `json:"containerName"`
// container probe spec
Probe ContainerProbeSpec `json:"probe"`
}
type NodePodProbeStatus struct {
// pod probe results
PodProbeStatuses []PodProbeStatus `json:"podProbeStatuses,omitempty"`
}
type PodProbeStatus struct {
// pod name
Name string `json:"name"`
// pod namespace
Namespace string `json:"namespace"`
// pod uid
UID string `json:"uid"`
// pod probe result
ProbeStates []ContainerProbeState `json:"probeStates,omitempty"`
}
type ContainerProbeState struct {
// Name is podProbeMarker.Name#probe.Name
Name string `json:"name"`
// container probe exec state, True or False
State ProbeState `json:"state"`
// Last time we probed the condition.
// +optional
LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"`
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// If Status=True, Message records the return result of Probe.
// If Status=False, Message records Probe's error message
Message string `json:"message,omitempty"`
}
type ProbeState string
const (
ProbeSucceeded ProbeState = "Succeeded"
ProbeFailed ProbeState = "Failed"
ProbeUnknown ProbeState = "Unknown"
)
// +genclient
// +genclient:nonNamespaced
// +k8s:openapi-gen=true
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
// NodePodProbe is the Schema for the NodePodProbe API
type NodePodProbe struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec NodePodProbeSpec `json:"spec,omitempty"`
Status NodePodProbeStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// NodePodProbeList contains a list of NodePodProbe
type NodePodProbeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NodePodProbe `json:"items"`
}
func init() {
SchemeBuilder.Register(&NodePodProbe{}, &NodePodProbeList{})
}