-
Notifications
You must be signed in to change notification settings - Fork 629
✨ ROSANetwork: new CRD & reconciler to provision network infrastructure for ROSA-HCP #5464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hi @mzazrivec. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
webhookClientConfig: | ||
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, | ||
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) | ||
caBundle: Cg== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add the caBundle.
exp/api/v1beta2/rosanetwork_types.go
Outdated
Resource string `json:"resource"` | ||
|
||
// Identified of the created resource. Will be filled in once the resource is created & ready | ||
ID string `json:"ID"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ID string `json:"ID"` | |
Id string `json:"id"` |
Or resourceId
exp/api/v1beta2/rosanetwork_types.go
Outdated
// CFResource groups information pertaining to a resource created as a part of a cloudformation stack | ||
type CFResource struct { | ||
// Name of the created resource: NATGateway1, VPC, SecurityGroup, ... | ||
Resource string `json:"resource"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resource string `json:"resource"` | |
Name string `json:"name"` |
OR resourceName
Status string `json:"status"` | ||
|
||
// Message pertaining to the status of the resource | ||
Reason string `json:"reason"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message is better I guess ?
Reason string `json:"reason"` | |
Message string `json:"message"` |
exp/api/v1beta2/rosanetwork_types.go
Outdated
// Availability zone of the subnet pair | ||
AvailabilityZone string `json:"availabilityZone"` | ||
|
||
// ID of the public subnet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ID of the public subnet | |
// Public subnet Id ex; subnet-xxxxxxxxxx |
main.go
Outdated
} | ||
} | ||
|
||
// TODO: feature gates? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a new feature gate, we can have it under ROSA feature gate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I did not mean a new feature gate here, just the existing rosa FG.
you also need to update the ValidatingWebhookConfiguration and MutatingWebhookConfiguration here |
5907fb1
to
24a5950
Compare
a947563
to
a255790
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
// If no identity is specified, the default identity for this controller will be used. | ||
// | ||
// +optional | ||
IdentityRef *infrav1.AWSIdentityReference `json:"identityRef,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, if we want to provide this option to end user. We don't do that with RosaControlPlane only default aws identity. However, we should provide OCM identityRef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shouldn't we provide this option to the end user? We need to specify the ref to the aws secret somehow. Here I'm just reusing existing structures & code.
What do you mean by OCM identity ref? OCM will not be involved here in any way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, to use openshift/rosa and establish ocm client you need to have ocm authentication. Is this not the case with the RosaNetwork CF stack creation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. No OCM credentials are needed for rosanet, just AWS credentials.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@serngawy Are you satisfied with the answers here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mzazrivec I do remember we discuss that, but after checking the ROSANetwork cloud formation stack template , there are tags added as rosa_hcp_policy and roas service here.
Those tags I think is used to check for privileges ?
I think we have to authenticate the ocm credential. Even if we don't need to create the CF stack but enduser must be a valid OCM user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@serngawy What does creating VPC with certain tags and checking OCM credentials have to do with each other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, as we discussed no need to have ocm authentication.
d2534a7
to
dcc599d
Compare
023f99b
to
1729dff
Compare
8d886df
to
c6b826d
Compare
config/crd/kustomization.yaml
Outdated
- patches/webhook_in_awsmanagedcontrolplanetemplates.yaml | ||
- patches/webhook_in_eksconfigs.yaml | ||
- patches/webhook_in_eksconfigtemplates.yaml | ||
#- patches/webhook_in_rosanetworks.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
subnets := make(map[string]*expinfrav1.ROSANetworkSubnet) | ||
|
||
for _, resource := range rosaNet.Status.Resources { | ||
if resource.ResourceType != "AWS::EC2::Subnet" { // Skip all non subnets | ||
continue | ||
} | ||
|
||
az, err := r.awsClient.GetSubnetAvailabilityZone(resource.PhysicalID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if subnets[az] == nil { | ||
subnets[az] = &expinfrav1.ROSANetworkSubnet{ | ||
AvailabilityZone: az, | ||
PublicSubnet: "", | ||
PrivateSubnet: "", | ||
} | ||
} | ||
|
||
if strings.HasPrefix(resource.LogicalID, "SubnetPrivate") { | ||
subnets[az].PrivateSubnet = resource.PhysicalID | ||
} else { | ||
subnets[az].PublicSubnet = resource.PhysicalID | ||
} | ||
} | ||
|
||
rosaNet.Status.Subnets = make([]expinfrav1.ROSANetworkSubnet, len(subnets)) | ||
for i, v := range slices.Collect(maps.Values(subnets)) { | ||
rosaNet.Status.Subnets[i] = *v | ||
} | ||
|
||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better golang style and avoiding extra loop
subnets := make(map[string]*expinfrav1.ROSANetworkSubnet) | |
for _, resource := range rosaNet.Status.Resources { | |
if resource.ResourceType != "AWS::EC2::Subnet" { // Skip all non subnets | |
continue | |
} | |
az, err := r.awsClient.GetSubnetAvailabilityZone(resource.PhysicalID) | |
if err != nil { | |
return err | |
} | |
if subnets[az] == nil { | |
subnets[az] = &expinfrav1.ROSANetworkSubnet{ | |
AvailabilityZone: az, | |
PublicSubnet: "", | |
PrivateSubnet: "", | |
} | |
} | |
if strings.HasPrefix(resource.LogicalID, "SubnetPrivate") { | |
subnets[az].PrivateSubnet = resource.PhysicalID | |
} else { | |
subnets[az].PublicSubnet = resource.PhysicalID | |
} | |
} | |
rosaNet.Status.Subnets = make([]expinfrav1.ROSANetworkSubnet, len(subnets)) | |
for i, v := range slices.Collect(maps.Values(subnets)) { | |
rosaNet.Status.Subnets[i] = *v | |
} | |
return nil | |
subnets := make(map[string]expinfrav1.ROSANetworkSubnet) | |
for _, resource := range rosaNet.Status.Resources { | |
if resource.ResourceType != "AWS::EC2::Subnet" { | |
continue | |
} | |
az, err := r.awsClient.GetSubnetAvailabilityZone(resource.PhysicalID) | |
if err != nil { | |
return fmt.Errorf("failed to get AZ for subnet %s: %w", resource.PhysicalID, err) | |
} | |
subnet := subnets[az] | |
subnet.AvailabilityZone = az | |
if strings.HasPrefix(resource.LogicalID, "SubnetPrivate") { | |
subnet.PrivateSubnet = resource.PhysicalID | |
} else { | |
subnet.PublicSubnet = resource.PhysicalID | |
} | |
subnets[az] = subnet | |
} | |
rosaNet.Status.Subnets = slices.Collect(maps.Values(subnets)) | |
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
c6b826d
to
dffef26
Compare
main.go
Outdated
|
||
setupLog.Debug("enabling ROSA network controller") | ||
if err = (&expcontrollers.ROSANetworkReconciler{ | ||
Client: mgr.GetClient(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add watchFilterValue string
Client: mgr.GetClient(), | |
Client: mgr.GetClient(), | |
WatchFilterValue: watchFilterValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
// ROSANetworkReconciler reconciles a ROSANetwork object. | ||
type ROSANetworkReconciler struct { | ||
client.Client | ||
Log logr.Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the WatchFilterValue to the struct
Log logr.Logger | |
Log logr.Logger | |
WatchFilterValue string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the webhook patch file as it is not included in kustomization.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
95b12df
to
bd3b722
Compare
/assign @nrb @damdo @richardcase |
/label tide/merge-method-squash |
func getSessionName(region string, clusterScoper cloud.SessionMetadata) string { | ||
return fmt.Sprintf("%s-%s-%s", region, clusterScoper.InfraClusterName(), clusterScoper.Namespace()) | ||
return fmt.Sprintf("%s-%s-%s-%s", region, clusterScoper.ControllerName(), clusterScoper.InfraClusterName(), clusterScoper.Namespace()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the session name in all the places already using this (not only ROSA ones). Is this a backward compatible change? (cc. @richardcase @punkwalker)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it should be okay as when the capa-manager update happen all cache sessions will be re-created with the new session name.
Does the cache stored some how even when the pod re-created, we need to fail safe when loading session fail ?
// Is the referenced ROSANetwork ready yet? | ||
if !conditions.IsTrue(rosaNet, expinfrav1.ROSANetworkReadyCondition) { | ||
rosaScope.Info(fmt.Sprintf("referenced ROSANetwork %s is not ready", rosaNet.Name)) | ||
return ctrl.Result{RequeueAfter: time.Minute}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minute seems quite a lot here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes about 5 minutes to create the cloudformation stack, i.e. approximately 5 cycles through the reconciliation loop. I'm fine with making it smaller (suggestions welcome), but not quite sure how it would help or improve the situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok and do we need to requeue after or are we watching and we should get a reconciliation event anyway?
bd3b722
to
974568c
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM label has been added. Git tree hash: 5f64d3fa3341e2ef3426645208e69a234b4147e3
|
What type of PR is this?
/kind feature
What this PR does / why we need it:
This pull request implements CRD and a controller for provisioning complete networking infrastructure required to install a ROSA-HCP cluster in AWS. The proposal for this implementation has been described in #5381.
Under the hood, the implementation uses cloudformation stack and a static (i.e. no possibility of customization) cloudformation template from rosa-cli
This pull request depends on openshift/rosa#2904 (now merged).
Quick howto:
To use the
ROSANetwork
from ROSA control plane:and skip / remove subnets and availability zones from the CP spec.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Checklist:
Release note: