/
securitygrouppolicy_types.go
69 lines (57 loc) · 2.73 KB
/
securitygrouppolicy_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
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file 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 v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Important: Run "make" to regenerate code after modifying this file
// SecurityGroupPolicySpec defines the desired state of SecurityGroupPolicy
type SecurityGroupPolicySpec struct {
PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"`
ServiceAccountSelector *metav1.LabelSelector `json:"serviceAccountSelector,omitempty"`
SecurityGroups GroupIds `json:"securityGroups,omitempty"`
}
// GroupIds contains the list of security groups that will be applied to the network interface of the pod matching the criteria.
type GroupIds struct {
// Groups is the list of EC2 Security Groups Ids that need to be applied to the ENI of a Pod.
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=5
Groups []string `json:"groupIds,omitempty"`
}
// ServiceAccountSelector contains the selection criteria for matching pod with service account that matches the label selector
// requirement and the exact name of the service account.
type ServiceAccountSelector struct {
*metav1.LabelSelector `json:",omitempty"`
// matchNames is the list of service account names. The requirements are ANDed
// +kubebuilder:validation:MinItems=1
MatchNames []string `json:"matchNames,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:printcolumn:name="Security-Group-Ids",type=string,JSONPath=`.spec.securityGroups.groupIds`,description="The security group IDs to apply to the elastic network interface of pods that match this policy"
// +kubebuilder:resource:shortName=sgp
// Custom Resource Definition for applying security groups to pods
type SecurityGroupPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec SecurityGroupPolicySpec `json:"spec,omitempty"`
}
// +kubebuilder:object:root=true
// SecurityGroupPolicyList contains a list of SecurityGroupPolicy
type SecurityGroupPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []SecurityGroupPolicy `json:"items"`
}
func init() {
SchemeBuilder.Register(&SecurityGroupPolicy{}, &SecurityGroupPolicyList{})
}