/
types.go
128 lines (107 loc) · 4.55 KB
/
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
118
119
120
121
122
123
124
125
126
127
128
// Copyright 2021 Antrea 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 required 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 v1alpha3
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"antrea.io/antrea/pkg/apis/crd/v1alpha1"
)
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ClusterGroup struct {
metav1.TypeMeta `json:",inline"`
// Standard metadata of the object.
metav1.ObjectMeta `json:"metadata,omitempty"`
// Desired state of the group.
Spec GroupSpec `json:"spec"`
// Most recently observed status of the group.
Status GroupStatus `json:"status"`
}
type GroupSpec struct {
// Select Pods matching the labels set in the PodSelector in
// AppliedTo/To/From fields. If set with NamespaceSelector, Pods are
// matched from Namespaces matched by the NamespaceSelector.
// Cannot be set with any other selector except NamespaceSelector.
// +optional
PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"`
// Select all Pods from Namespaces matched by this selector, as
// workloads in AppliedTo/To/From fields. If set with PodSelector,
// Pods are matched from Namespaces matched by the NamespaceSelector.
// Cannot be set with any other selector except PodSelector.
// +optional
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`
// IPBlocks describe the IPAddresses/IPBlocks that are matched in to/from.
// IPBlocks cannot be set as part of the AppliedTo field.
// Cannot be set with any other selector or ServiceReference.
// +optional
IPBlocks []v1alpha1.IPBlock `json:"ipBlocks,omitempty"`
// Select backend Pods of the referred Service.
// Cannot be set with any other selector or ipBlock.
// +optional
ServiceReference *v1alpha1.NamespacedName `json:"serviceReference,omitempty"`
// Select ExternalEntities from all Namespaces as workloads
// in AppliedTo/To/From fields. If set with NamespaceSelector,
// ExternalEntities are matched from Namespaces matched by the
// NamespaceSelector.
// Cannot be set with any other selector except NamespaceSelector.
// +optional
ExternalEntitySelector *metav1.LabelSelector `json:"externalEntitySelector,omitempty"`
// Select other ClusterGroups by name. The ClusterGroups must already
// exist and must not contain ChildGroups themselves.
// Cannot be set with any selector/IPBlock/ServiceReference.
// +optional
ChildGroups []ClusterGroupReference `json:"childGroups,omitempty"`
}
type GroupConditionType string
const GroupMembersComputed GroupConditionType = "GroupMembersComputed"
type GroupCondition struct {
Type GroupConditionType `json:"type"`
Status v1.ConditionStatus `json:"status"`
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
}
// GroupStatus represents information about the status of a Group.
type GroupStatus struct {
Conditions []GroupCondition `json:"conditions,omitempty"`
}
// ClusterGroupReference represent reference to a ClusterGroup.
type ClusterGroupReference string
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ClusterGroupList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterGroup `json:"items,omitempty"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Group can be used in AntreaNetworkPolicies. When used with AppliedTo, it cannot include NamespaceSelector,
// otherwise, Antrea will not realize the NetworkPolicy or rule, but will just update the NetworkPolicy
// Status as "Unrealizable".
type Group struct {
metav1.TypeMeta `json:",inline"`
// Standard metadata of the object.
metav1.ObjectMeta `json:"metadata,omitempty"`
// Desired state of the group.
Spec GroupSpec `json:"spec"`
// Most recently observed status of the group.
Status GroupStatus `json:"status"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type GroupList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []Group `json:"items,omitempty"`
}