Skip to content

Commit

Permalink
Add egress policy CRD types
Browse files Browse the repository at this point in the history
Add types for egress policy CRDs, including Egress for the egress
policy definition, and a common AppliedTo struct for defining the scope
to which a policy is applied.
  • Loading branch information
jianjuns committed Apr 2, 2021
1 parent 117cd94 commit b03188d
Show file tree
Hide file tree
Showing 12 changed files with 619 additions and 0 deletions.
51 changes: 51 additions & 0 deletions pkg/apis/crd/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,54 @@ type ClusterGroupList struct {

Items []ClusterGroup `json:"items,omitempty"`
}

// AppliedTo selects the entities to which a policy is applied.
type AppliedTo struct {
// Select Pods matched by this selector. If set with NamespaceSelector,
// Pods are matched from Namespaces matched by the NamespaceSelector;
// otherwise, Pods are matched from all Namespaces.
// +optional
PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"`
// Select all Pods from Namespaces matched by this selector. If set with
// PodSelector, Pods are matched from Namespaces matched by the
// NamespaceSelector.
// +optional
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`
// Groups is the set of ClusterGroup names.
// +optional
Groups []string `json:"groups,omitempty"`
}

// +genclient
// +genclient:nonNamespaced
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Egress defines which egress (SNAT) IP the traffic from the selected Pods to
// the external network should use.
type Egress struct {
metav1.TypeMeta `json:",inline"`
// Standard metadata of the object.
metav1.ObjectMeta `json:"metadata,omitempty"`

// Specification of the desired behavior of Egress.
Spec EgressSpec `json:"spec"`
}

// EgressSpec defines the desired state for Egress.
type EgressSpec struct {
// AppliedTo selects Pods to which the Egress will be applied.
AppliedTo AppliedTo `json:"appliedTo"`
// EgressIP specifies the SNAT IP address for the selected workloads.
EgressIP string `json:"egressIP"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type EgressList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`

Items []Egress `json:"items"`
}
108 changes: 108 additions & 0 deletions pkg/apis/crd/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

166 changes: 166 additions & 0 deletions pkg/client/clientset/versioned/typed/crd/v1alpha2/egress.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b03188d

Please sign in to comment.