Skip to content

Commit

Permalink
CLOUDP-280222: Private Endpoint controller (#1916)
Browse files Browse the repository at this point in the history
  • Loading branch information
helderjs authored Dec 3, 2024
1 parent 678a565 commit beaa709
Show file tree
Hide file tree
Showing 26 changed files with 3,642 additions and 30 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ jobs:
"multinamespaced",
"networkpeering",
"privatelink",
"private-endpoint",
"project-settings",
"serverless-pe",
"x509auth",
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/atlas.mongodb.com_atlasprivateendpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ spec:
- id
type: object
type: array
x-kubernetes-list-map-keys:
- id
x-kubernetes-list-type: map
azureConfiguration:
description: AzureConfiguration is the specific Azure settings for
the private endpoint
Expand All @@ -93,6 +96,9 @@ spec:
- ipAddress
type: object
type: array
x-kubernetes-list-map-keys:
- id
x-kubernetes-list-type: map
connectionSecret:
description: Name of the secret containing Atlas API private and public
keys
Expand Down Expand Up @@ -156,6 +162,9 @@ spec:
- projectId
type: object
type: array
x-kubernetes-list-map-keys:
- groupName
x-kubernetes-list-type: map
projectRef:
description: Project is a reference to AtlasProject resource the user
belongs to
Expand Down
2 changes: 2 additions & 0 deletions config/rbac/clusterwide/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ rules:
- atlasdatafederations
- atlasdeployments
- atlasfederatedauths
- atlasprivateendpoints
- atlasprojects
- atlassearchindexconfigs
- atlasstreamconnections
Expand All @@ -58,6 +59,7 @@ rules:
- atlasdatafederations/status
- atlasdeployments/status
- atlasfederatedauths/status
- atlasprivateendpoints/status
- atlasprojects/status
- atlassearchindexconfigs/status
- atlasstreamconnections/status
Expand Down
2 changes: 2 additions & 0 deletions config/rbac/namespaced/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ rules:
- atlasdatafederations
- atlasdeployments
- atlasfederatedauths
- atlasprivateendpoints
- atlasprojects
- atlassearchindexconfigs
- atlasstreamconnections
Expand All @@ -58,6 +59,7 @@ rules:
- atlasdatafederations/status
- atlasdeployments/status
- atlasfederatedauths/status
- atlasprivateendpoints/status
- atlasprojects/status
- atlassearchindexconfigs/status
- atlasstreamconnections/status
Expand Down
27 changes: 27 additions & 0 deletions internal/translation/privateendpoint/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,3 +473,30 @@ func interfaceCreateToAtlas(peInterface EndpointInterface, gcpProjectID string)

return nil
}

type CompositeEndpointInterface struct {
AKO EndpointInterface
Atlas EndpointInterface
}

func MapPrivateEndpoints(akoInterfaces, atlasInterfaces []EndpointInterface) map[string]CompositeEndpointInterface {
m := map[string]CompositeEndpointInterface{}

for _, akoInterface := range akoInterfaces {
m[akoInterface.InterfaceID()] = CompositeEndpointInterface{
AKO: akoInterface,
}
}

for _, atlasInterface := range atlasInterfaces {
i := CompositeEndpointInterface{}
if existing, ok := m[atlasInterface.InterfaceID()]; ok {
i = existing
}

i.Atlas = atlasInterface
m[atlasInterface.InterfaceID()] = i
}

return m
}
6 changes: 6 additions & 0 deletions pkg/api/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ const (
TeamUnmanaged ConditionType = "TeamUnmanaged"
)

// Atlas Private Endpoint condition types
const (
PrivateEndpointServiceReady ConditionType = "PrivateEndpointServiceReady"
PrivateEndpointReady ConditionType = "PrivateEndpointReady"
)

// Generic condition type
const (
ResourceVersionStatus ConditionType = "ResourceVersionIsValid"
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/v1/atlasprivateendpoint_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ type AtlasPrivateEndpointSpec struct {
// +kubebuilder:validation:Required
Region string `json:"region"`
// AWSConfiguration is the specific AWS settings for the private endpoint
// +listType=map
// +listMapKey=id
// +kubebuilder:validation:Optional
AWSConfiguration []AWSPrivateEndpointConfiguration `json:"awsConfiguration,omitempty"`
// AzureConfiguration is the specific Azure settings for the private endpoint
// +listType=map
// +listMapKey=id
// +kubebuilder:validation:Optional
AzureConfiguration []AzurePrivateEndpointConfiguration `json:"azureConfiguration,omitempty"`
// GCPConfiguration is the specific Google Cloud settings for the private endpoint
// +listType=map
// +listMapKey=groupName
// +kubebuilder:validation:Optional
GCPConfiguration []GCPPrivateEndpointConfiguration `json:"gcpConfiguration,omitempty"`
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/atlas/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ func (p *ProductionProvider) IsResourceSupported(resource api.AtlasCustomResourc
*akov2.AtlasDatabaseUser,
*akov2.AtlasSearchIndexConfig,
*akov2.AtlasBackupCompliancePolicy,
*akov2.AtlasFederatedAuth:
*akov2.AtlasFederatedAuth,
*akov2.AtlasPrivateEndpoint:
return true
case *akov2.AtlasDataFederation,
*akov2.AtlasStreamInstance,
Expand Down
Loading

0 comments on commit beaa709

Please sign in to comment.