-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cloud Security Group and Rule Visibility (#251)
* Cloud Security Group and Rule Visibility Cloud Security Group and Rules will be fetched periodically with vpc/vm poll interval. It will contain both ingress and egress rules. SG will be added for managed VPC/VNET only and it will also include user defined SG too. Signed-off-by: Rahul Jain <[email protected]> * Security Group and rule visibility for Azure & AWS. - Add new fields in SecurityGroup runtime struct. - Enhance snapshot related code for handling cached SGs. - Add parsing logic for parsing SecurityGrup fields obtained from AWS, Azure clouds. - Implement SG Inventory add/delete code. - Implement plugin call from poller for fetching SG details from internal snapshot. - Added new unit tests for the entire feature ie in Azure plugin, AWS plugin, inventory and sg rest handling. Signed-off-by: Archana Holla <[email protected]> * Add support for enabling/disabling sg visibility Handle review comments too and fixed bugs found during UTP Signed-off-by: Rahul Jain <[email protected]> * Set cloudSecurityGroupVisibility in helm Signed-off-by: Rahul Jain <[email protected]> --------- Signed-off-by: Rahul Jain <[email protected]> Signed-off-by: Archana Holla <[email protected]> Co-authored-by: Archana Holla <[email protected]>
- Loading branch information
1 parent
d0b4c3c
commit 71c522a
Showing
40 changed files
with
2,716 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2023 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 v1alpha1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
type Rule struct { | ||
Action string `json:"action,omitempty"` | ||
Description string `json:"description,omitempty"` | ||
Destination []string `json:"destination,omitempty"` | ||
Id string `json:"id,omitempty"` | ||
Ingress bool `json:"ingress"` | ||
Name string `json:"name,omitempty"` | ||
Port string `json:"port"` | ||
Priority int32 `json:"priority,omitempty"` | ||
Protocol string `json:"protocol"` | ||
Source []string `json:"source,omitempty"` | ||
} | ||
|
||
type SecurityGroupStatus struct { | ||
// CloudName is the cloud assigned name of the SG. | ||
CloudName string `json:"cloudName,omitempty"` | ||
// CloudId is the cloud assigned ID of the SG. | ||
CloudId string `json:"cloudId,omitempty"` | ||
// Provider specifies cloud provider of the SG. | ||
Provider CloudProvider `json:"provider,omitempty"` | ||
// Region indicates the cloud region of the SG. | ||
Region string `json:"region"` | ||
// Rules contains ingress and egress rules of the SG. | ||
Rules []Rule `json:"rules,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// SecurityGroup is the Schema for the Security Group API. | ||
// Security Group object is automatically created upon CloudProviderAccount CR add. | ||
type SecurityGroup struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Status SecurityGroupStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// SecurityGroupList is a list of Security Group objects. | ||
type SecurityGroupList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
|
||
Items []SecurityGroup `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&SecurityGroup{}, &SecurityGroupList{}) | ||
SchemeBuilder.SchemeBuilder.Register(addSgConversionFuncs) | ||
} | ||
|
||
func addSgConversionFuncs(scheme *runtime.Scheme) error { | ||
return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("SecurityGroup"), | ||
func(label, value string) (string, string, error) { | ||
switch label { | ||
case "metadata.name", "metadata.namespace", "status.cloudId": | ||
return label, value, nil | ||
default: | ||
return "", "", fmt.Errorf("field label not supported: %s", label) | ||
} | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.