-
Notifications
You must be signed in to change notification settings - Fork 527
Expand file tree
/
Copy pathvip.go
More file actions
70 lines (60 loc) · 1.94 KB
/
vip.go
File metadata and controls
70 lines (60 loc) · 1.94 KB
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
package v1
import (
"encoding/json"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type VipList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Vip `json:"items"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient:nonNamespaced
type Vip struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec VipSpec `json:"spec"`
Status VipStatus `json:"status"`
}
type VipSpec struct {
Namespace string `json:"namespace"`
Subnet string `json:"subnet"`
Type string `json:"type"`
// usage type: switch lb vip, allowed address pair vip by default
V4ip string `json:"v4ip"`
V6ip string `json:"v6ip"`
MacAddress string `json:"macAddress"`
ParentV4ip string `json:"parentV4ip"`
ParentV6ip string `json:"parentV6ip"`
ParentMac string `json:"parentMac"`
Selector []string `json:"selector"`
AttachSubnets []string `json:"attachSubnets"`
}
type VipStatus struct {
// Conditions represents the latest state of the object
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
Ready bool `json:"ready" patchStrategy:"merge"`
Type string `json:"type"`
V4ip string `json:"v4ip" patchStrategy:"merge"`
V6ip string `json:"v6ip" patchStrategy:"merge"`
Mac string `json:"mac" patchStrategy:"merge"`
Pv4ip string `json:"pv4ip" patchStrategy:"merge"`
Pv6ip string `json:"pv6ip" patchStrategy:"merge"`
Pmac string `json:"pmac" patchStrategy:"merge"`
}
func (s *VipStatus) Bytes() ([]byte, error) {
bytes, err := json.Marshal(s)
if err != nil {
return nil, err
}
newStr := fmt.Sprintf(`{"status": %s}`, string(bytes))
klog.V(5).Info("status body", newStr)
return []byte(newStr), nil
}