@@ -23,7 +23,7 @@ import (
23
23
//+kubebuilder:subresource:status
24
24
25
25
// BaselineAdminNetworkPolicy is a cluster level resource that is part of the
26
- // adminNetworkPolicy api .
26
+ // adminNetworkPolicy API .
27
27
type BaselineAdminNetworkPolicy struct {
28
28
metav1.TypeMeta `json:",inline"`
29
29
metav1.ObjectMeta `json:"metadata"`
@@ -33,7 +33,13 @@ type BaselineAdminNetworkPolicy struct {
33
33
34
34
// Status is the status to be reported by the implementation.
35
35
// +optional
36
- Status AdminNetworkPolicyStatus `json:"status,omitempty"`
36
+ Status BaselineAdminNetworkPolicyStatus `json:"status,omitempty"`
37
+ }
38
+
39
+ // BaselineAdminNetworkPolicyStatus defines the observed state of
40
+ // BaselineAdminNetworkPolicy.
41
+ type BaselineAdminNetworkPolicyStatus struct {
42
+ Conditions []metav1.Condition `json:"conditions"`
37
43
}
38
44
39
45
// BaselineAdminNetworkPolicySpec defines the desired state of
@@ -42,47 +48,51 @@ type BaselineAdminNetworkPolicySpec struct {
42
48
// Subject defines the pods to which this BaselineAdminNetworkPolicy applies.
43
49
Subject AdminNetworkPolicySubject `json:"subject"`
44
50
45
- // List of Ingress rules to be applied to the selected pods AFTER all
46
- // AdminNetworkPolicy and NetworkPolicy rules have been applied .
51
+ // List of Ingress rules to be applied to the selected pods if they are not
52
+ // matched by any AdminNetworkPolicy or NetworkPolicy rules .
47
53
// A total of 100 Ingress rules will be allowed in each BANP instance.
48
54
// BANPs with no ingress rules do not affect ingress traffic.
49
55
// +optional
50
56
// +kubebuilder:validation:MaxItems=100
51
- Ingress []AdminNetworkPolicyIngressRule `json:"ingress,omitempty"`
57
+ Ingress []BaselineAdminNetworkPolicyIngressRule `json:"ingress,omitempty"`
52
58
53
- // List of Egress rules to be applied to the selected pods AFTER all
54
- // AdminNetworkPolicy and NetworkPolicy rules have been applied .
55
- // A total of 100 Egress rules will be allowed in each BANP instance. ANPs
59
+ // List of Egress rules to be applied to the selected pods if they are not
60
+ // matched by any AdminNetworkPolicy or NetworkPolicy rules .
61
+ // A total of 100 Egress rules will be allowed in each BANP instance. BANPs
56
62
// with no egress rules do not affect egress traffic.
57
63
// +optional
58
64
// +kubebuilder:validation:MaxItems=100
59
- Egress []AdminNetworkPolicyEgressRule `json:"egress,omitempty"`
65
+ Egress []BaselineAdminNetworkPolicyEgressRule `json:"egress,omitempty"`
60
66
}
61
67
62
68
// BaselineAdminNetworkPolicyIngressRule describes an action to take on a particular
63
69
// set of traffic destined for pods selected by a BaselineAdminNetworkPolicy's
64
70
// Subject field. The traffic must match both ports and from.
65
71
type BaselineAdminNetworkPolicyIngressRule struct {
66
72
// Name is an identifier for this rule, that may be no more than 100 characters
67
- // in length.
73
+ // in length. This field should be used by the implementation to help
74
+ // improve observability, readability and error-reporting for any applied
75
+ // BaselineAdminNetworkPolicies.
68
76
// +optional
69
77
// +kubebuilder:validation:MaxLength=100
70
78
Name string `json:"name,omitempty"`
71
79
72
- // Action specifies whether this rule must allow or deny traffic.
80
+ // Action specifies the affect this rule will have on matching traffic,
81
+ // currently the following actions are supported:
73
82
// Allow: allows the selected traffic
74
83
// Deny: denies the selected traffic
75
84
// This field is mandatory.
76
85
Action BaselineAdminNetworkPolicyRuleAction `json:"action"`
77
86
78
87
// Ports allows for matching traffic based on port and protocols.
79
- // If Ports is empty or missing then traffic is not filtered via port.
88
+ // If Ports is not set then traffic is not filtered via port.
80
89
// +optional
81
90
Ports []AdminNetworkPolicyPort `json:"ports,omitempty"`
82
91
83
92
// List of sources whose traffic this AdminNetworkPolicyRule applies to.
84
- // Items in this list are combined using a logical OR
85
- // operation. This field must be defined and contain at least one item.
93
+ // If any adminNetworkPolicyPeer matches the source of incoming
94
+ // traffic then the specified action is applied.
95
+ // This field must be defined and contain at least one item.
86
96
// +kubebuilder:validation:MinItems=1
87
97
From []AdminNetworkPolicyPeer `json:"from"`
88
98
}
@@ -92,25 +102,29 @@ type BaselineAdminNetworkPolicyIngressRule struct {
92
102
// Subject field. The traffic must match both ports and to.
93
103
type BaselineAdminNetworkPolicyEgressRule struct {
94
104
// Name is an identifier for this rule, that may be no more than 100 characters
95
- // in length.
105
+ // in length. This field should be used by the implementation to help
106
+ // improve observability, readability and error-reporting for any applied
107
+ // BaselineAdminNetworkPolicies.
96
108
// +optional
97
109
// +kubebuilder:validation:MaxLength=100
98
110
Name string `json:"name,omitempty"`
99
111
100
- // Action specifies whether this rule must pass, allow or deny traffic.
112
+ // Action specifies the affect this rule will have on matching traffic,
113
+ // currently the following actions are supported:
101
114
// Allow: allows the selected traffic
102
115
// Deny: denies the selected traffic
103
116
// This field is mandatory.
104
117
Action BaselineAdminNetworkPolicyRuleAction `json:"action"`
105
118
106
- // Ports allows for matching traffic based on port and protocols.
107
- // If Ports is empty or missing then traffic is not filtered via port.
119
+ // Ports allows for matching traffic based on port and protocols.
120
+ // If Ports is not set then traffic is not filtered via port.
108
121
// +optional
109
122
Ports []AdminNetworkPolicyPort `json:"ports,omitempty"`
110
123
111
- // List of destinations to which traffic will be allowed/denied/passed from the entities
112
- // selected by this AdminNetworkPolicyRule. Items in this list are combined using a logical OR
113
- // operation. This field must be defined and contain at least one item.
124
+ // List of destinations whose traffic this adminNetworkPolicyRule applies to.
125
+ // If any adminNetworkPolicyPeer matches the destination of outgoing
126
+ // traffic then the specified action is applied.
127
+ // This field must be defined and contain at least one item.
114
128
// +kubebuilder:validation:MinItems=1
115
129
To []AdminNetworkPolicyPeer `json:"to"`
116
130
}
@@ -122,10 +136,10 @@ type BaselineAdminNetworkPolicyRuleAction string
122
136
123
137
const (
124
138
125
- // RuleActionDeny enables admins to deny specific traffic.
126
- BaselineAdminNetworkPolicyRuleActionDeny AdminNetworkPolicyRuleAction = "Deny"
127
- // RuleActionAllow enables admins to specifically allow certain traffic.
128
- BaselineAdminNetworkPolicyRuleActionAllow AdminNetworkPolicyRuleAction = "Allow"
139
+ // BaselineAdminNetworkPolicyRuleActionDeny enables admins to deny specific traffic.
140
+ BaselineAdminNetworkPolicyRuleActionDeny BaselineAdminNetworkPolicyRuleAction = "Deny"
141
+ // BaselineAdminNetworkPolicyRuleActionAllow enables admins to specifically allow certain traffic.
142
+ BaselineAdminNetworkPolicyRuleActionAllow BaselineAdminNetworkPolicyRuleAction = "Allow"
129
143
)
130
144
131
145
//+kubebuilder:object:root=true
0 commit comments