Skip to content

Commit

Permalink
controlplane/rosa: support Private Link
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov committed Jan 24, 2024
1 parent e278d2e commit 3fbec96
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ DOCKER_BUILDKIT=1
export ACK_GINKGO_DEPRECATIONS := 1.16.4

# Set --output-base for conversion-gen if we are not within GOPATH
ifneq ($(abspath $(REPO_ROOT)),$(shell go env GOPATH)/src/sigs.k8s.io/cluster-api-provider-aws)
ifneq ($(abspath $(REPO_ROOT)),$(abspath $(shell go env GOPATH)/src/sigs.k8s.io/cluster-api-provider-aws))
GEN_OUTPUT_BASE := --output-base=$(REPO_ROOT)
else
export GOPATH := $(shell go env GOPATH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,28 @@ spec:
items:
type: string
type: array
aws:
description: AWS configures aspects of the ROSA HCP workload cluster
that are specific to AWS.
properties:
privateLink:
description: PrivateLink configures whether Private Link is enabled
for the cluster
type: boolean
privateLinkConfiguration:
description: PrivateLinkConfiguration configures the Private Link
for the cluster
properties:
principals:
description: Principals are the ARNs for principals that are
allowed for the Private Link.
items:
type: string
type: array
type: object
required:
- privateLink
type: object
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint used to
communicate with the control plane.
Expand Down Expand Up @@ -277,6 +299,7 @@ spec:
required:
- accountID
- availabilityZones
- aws
- creatorARN
- installerRoleARN
- machineCIDR
Expand Down
16 changes: 16 additions & 0 deletions controlplane/rosa/api/v1beta2/rosacontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ type RosaControlPlaneSpec struct { //nolint: maligned
// - ocmApiUrl: Optional, defaults to 'https://api.openshift.com'
// +optional
CredentialsSecretRef *corev1.LocalObjectReference `json:"credentialsSecretRef,omitempty"`

// AWS configures aspects of the ROSA HCP workload cluster that are specific to AWS.
AWS AWSConfiguration `json:"aws"`
}

type AWSConfiguration struct {
// PrivateLink configures whether Private Link is enabled for the cluster
PrivateLink bool `json:"privateLink"`

// PrivateLinkConfiguration configures the Private Link for the cluster
PrivateLinkConfiguration *PrivateLinkConfiguration `json:"privateLinkConfiguration,omitempty"`
}

type PrivateLinkConfiguration struct {
// Principals are the ARNs for principals that are allowed for the Private Link.
Principals []string `json:"principals,omitempty"`
}

// AWSRolesRef contains references to various AWS IAM roles required for operators to make calls against the AWS API.
Expand Down
41 changes: 41 additions & 0 deletions controlplane/rosa/api/v1beta2/zz_generated.deepcopy.go

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

15 changes: 15 additions & 0 deletions controlplane/rosa/controllers/rosacontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,21 @@ func ocmCluster(controlPlane *rosacontrolplanev1.ROSAControlPlane, now func() ti
AccountID(*controlPlane.Spec.AccountID).
BillingAccountID(*controlPlane.Spec.AccountID).
SubnetIDs(controlPlane.Spec.Subnets...).
PrivateLink(controlPlane.Spec.AWS.PrivateLink).
PrivateLinkConfiguration(
clustersmgmtv1.NewPrivateLinkClusterConfiguration().
Principals(
func(aws rosacontrolplanev1.AWSConfiguration) []*clustersmgmtv1.PrivateLinkPrincipalBuilder {
var out []*clustersmgmtv1.PrivateLinkPrincipalBuilder
if aws.PrivateLinkConfiguration != nil {
for _, principal := range aws.PrivateLinkConfiguration.Principals {
out = append(out, clustersmgmtv1.NewPrivateLinkPrincipal().Principal(principal))
}
}
return out
}(controlPlane.Spec.AWS)...,
),
).
STS(
clustersmgmtv1.NewSTS().
RoleARN(*controlPlane.Spec.InstallerRoleARN).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ func TestOCMCluster(t *testing.T) {
CredentialsSecretRef: &corev1.LocalObjectReference{
Name: "credentials-secret-name",
},
AWS: rosacontrolplanev1beta2.AWSConfiguration{
PrivateLink: true,
PrivateLinkConfiguration: &rosacontrolplanev1beta2.PrivateLinkConfiguration{
Principals: []string{"principal-arn-1", "principal-arn-2"},
},
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@
},
"account_id": "account-id",
"billing_account_id": "account-id",
"private_link": true,
"private_link_configuration": {
"principals": [
{
"kind": "PrivateLinkPrincipal",
"principal": "principal-arn-1"
},
{
"kind": "PrivateLinkPrincipal",
"principal": "principal-arn-2"
}
]
},
"subnet_ids": [
"subnet-1",
"subnet-2"
Expand Down

0 comments on commit 3fbec96

Please sign in to comment.