Skip to content

Conversation

@zijun726911
Copy link
Contributor

Which issue does this PR fix: Add VpcAssociationPolicy CRD to support SNVA security Group API

What does this PR do / Why do we need it: Add VpcAssociationPolicy CRD to support SNVA security Group API

If an issue # is not available please add repro steps and logs from aws-gateway-controller showing the issue:

Testing done on this change:

Installed this CRD in my own cluster succeeded by kubectl apply -f config/crds/bases/application-networking.k8s.aws_vpcassociationpolicies.yaml

Automation added to e2e:

Will this PR introduce any new dependencies?:

Will this break upgrades or downgrades. Has updating a running cluster been tested?:

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@liwenwu-amazon
Copy link
Contributor

Shall we use a different name, e.g. GatewayAWSPolicy? And we can add other parameters to them, e.g.

  • enable/disable access log

@zijun726911
Copy link
Contributor Author

Shall we use a different name, e.g. GatewayAWSPolicy? And we can add other parameters to them, e.g.

* enable/disable access log

I think we decide to do them in 2 CRDs,

  • one CRD for access log and authpolicy that can apply to both Gateway and Route
  • Another one VpcAssociationPolicy CRD that can only apply to Gateway

For the name of VpcAssociationPolicy we could discuss, GatewayAWSPolicy can be a option

// +kubebuilder:validation:MinItems=1
SecurityGroupIds []SecurityGroupId `json:"securityGroupIds,omitempty"`

// AssociateWithVpc indicates whether the VpcServiceNetworkAssociation should be created for current the VPC of EKS cluster.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: current the -> the current

I would avoid saying "EKS", I think this product is supposed to work for non-eks k8s clusters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.. but k8s cluster in other cloud provider don't have vpc lattice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be plain, un-managed k8s cluster installed on ec2 instance


type Policy interface {
GetNamespacedName() types.NamespacedName
GetTargetRef() *v1alpha2.PolicyTargetReference
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with having this interface but not sure how we could benefit from it

Copy link
Contributor Author

@zijun726911 zijun726911 Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually my later code change will use that:

func (r *resourceMapper) TargetGroupPolicyToService(ctx context.Context, tgp *v1alpha1.TargetGroupPolicy) *corev1.Service {
	if obj := r.policyToTargetRefObj(ctx, tgp, &corev1.Service{}); obj != nil {
		return obj.(*corev1.Service)
	} else {
		return nil
	}
}

func (r *resourceMapper) VpcAssociationPolicyToGateway(ctx context.Context, vap *v1alpha1.VpcAssociationPolicy) *gateway_api.Gateway {
	if obj := r.policyToTargetRefObj(ctx, vap, &gateway_api.Gateway{}); obj != nil {
		return obj.(*gateway_api.Gateway)
	} else {
		return nil
	}
}

func (r *resourceMapper) policyToTargetRefObj(ctx context.Context, policy core.Policy, retObj client.Object) client.Object { }
	

// Either one of them set to true or both of them undefined will result in the VpcServiceNetworkAssociation created.
// +optional
// +kubebuilder:default=true
AssociateWithVpc *bool `json:"associateWithVpc,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at this I'm thinking it is quite not straightforward to have optional value true by default. Could we have an inverse of this option?

Copy link
Contributor Author

@zijun726911 zijun726911 Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove the // +kubebuilder:default=true here

I will do that in the controller code logic: Either one of them set to true or both of them undefined will result in the VpcServiceNetworkAssociation created.

type VpcAssociationPolicySpec struct {

// SecurityGroupIds defines the security groups enforced on the VpcServiceNetworkAssociation.
// For more details, please check the VPC Lattice documentation https://docs.aws.amazon.com/vpc-lattice/latest/ug/security-groups.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth mentioning that it does not take any effect when it is not associated with vpc

@coveralls
Copy link

coveralls commented Sep 14, 2023

Pull Request Test Coverage Report for Build 6191268261

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 39.061%

Totals Coverage Status
Change from base Build 6163918423: 0.0%
Covered Lines: 4008
Relevant Lines: 10261

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants