Skip to content
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

Add support for VPC Endpoint Services #2636

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7db8509
Add models, managers, and synthesizers for VPC Endpoint Services
rifelpet Apr 22, 2021
9ea9cf7
Add the Endpoint Service sythensizer and manager to the stack deployer
rifelpet Apr 22, 2021
a401b06
Add Endpoint Service annotations for parsing by the model
rifelpet Apr 22, 2021
f92ff42
Add support for VPC Endpoint Services
hintofbasil Apr 21, 2022
d76b990
Remove unneeded defaultEndpointServiceManager.ReconcileTags method
hintofbasil May 5, 2022
1ea9b21
Add explanation to algorithm.DiffStringSlice
hintofbasil May 5, 2022
fd56852
Revert formatting only changes
hintofbasil May 6, 2022
ee9746b
Spelling: Principles -> Principals
hintofbasil May 23, 2022
952618b
Fix typos
hintofbasil May 23, 2022
3b637e7
Add PrivateLink permissions to IAM policy
hintofbasil May 30, 2022
2eb51e8
Fix SG -> ES typos
hintofbasil May 30, 2022
6ffe4f8
Add new mocks to gen_mocks.sh
hintofbasil Jul 14, 2022
8977a63
Merge branch 'main' of github.com:kubernetes-sigs/aws-load-balancer-c…
hintofbasil Mar 9, 2023
a4ec005
Use gomock for MockProvider
hintofbasil Mar 9, 2023
82c4cf8
Update VPCES annotations to be alpha
hintofbasil May 1, 2023
afa4b7e
Merge branch 'main' of github.com:kubernetes-sigs/aws-load-balancer-c…
hintofbasil May 1, 2023
a78b671
Merge branch 'main' of github.com:kubernetes-sigs/aws-load-balancer-c…
hintofbasil May 16, 2023
80a68a8
Handle delete VPCEndpoint failures
hintofbasil May 26, 2023
c307458
Move VPCES creation and update to post synthesize
hintofbasil May 26, 2023
20d2f18
Merge branch 'main' of github.com:kubernetes-sigs/aws-load-balancer-c…
hintofbasil Aug 13, 2023
817935c
Merge branch 'main' of https://github.com/kubernetes-sigs/aws-load-ba…
hintofbasil Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions controllers/ingress/group_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
// NewGroupReconciler constructs new GroupReconciler
func NewGroupReconciler(cloud aws.Cloud, k8sClient client.Client, eventRecorder record.EventRecorder,
finalizerManager k8s.FinalizerManager, networkingSGManager networkingpkg.SecurityGroupManager,
vpcEndpointServiceManager networkingpkg.VPCEndpointServiceManager,
networkingSGReconciler networkingpkg.SecurityGroupReconciler, subnetsResolver networkingpkg.SubnetsResolver,
elbv2TaggingManager elbv2deploy.TaggingManager, controllerConfig config.ControllerConfig, backendSGProvider networkingpkg.BackendSGProvider,
sgResolver networkingpkg.SecurityGroupResolver, logger logr.Logger) *groupReconciler {
Expand All @@ -62,8 +63,8 @@ func NewGroupReconciler(cloud aws.Cloud, k8sClient client.Client, eventRecorder
controllerConfig.DefaultSSLPolicy, controllerConfig.DefaultTargetType, backendSGProvider, sgResolver,
controllerConfig.EnableBackendSecurityGroup, controllerConfig.DisableRestrictedSGRules, controllerConfig.IngressConfig.AllowedCertificateAuthorityARNs, controllerConfig.FeatureGates.Enabled(config.EnableIPTargetType), logger)
stackMarshaller := deploy.NewDefaultStackMarshaller()
stackDeployer := deploy.NewDefaultStackDeployer(cloud, k8sClient, networkingSGManager, networkingSGReconciler, elbv2TaggingManager,
controllerConfig, ingressTagPrefix, logger)
stackDeployer := deploy.NewDefaultStackDeployer(cloud, k8sClient, networkingSGManager, networkingSGReconciler, vpcEndpointServiceManager,
elbv2TaggingManager, controllerConfig, ingressTagPrefix, logger)
classLoader := ingress.NewDefaultClassLoader(k8sClient, true)
classAnnotationMatcher := ingress.NewDefaultClassAnnotationMatcher(controllerConfig.IngressConfig.IngressClass)
manageIngressesWithoutIngressClass := controllerConfig.IngressConfig.IngressClass == ""
Expand Down
3 changes: 2 additions & 1 deletion controllers/service/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const (

func NewServiceReconciler(cloud aws.Cloud, k8sClient client.Client, eventRecorder record.EventRecorder,
finalizerManager k8s.FinalizerManager, networkingSGManager networking.SecurityGroupManager,
vpcEndpointServiceManager networking.VPCEndpointServiceManager,
networkingSGReconciler networking.SecurityGroupReconciler, subnetsResolver networking.SubnetsResolver,
vpcInfoProvider networking.VPCInfoProvider, elbv2TaggingManager elbv2deploy.TaggingManager, controllerConfig config.ControllerConfig,
backendSGProvider networking.BackendSGProvider, sgResolver networking.SecurityGroupResolver, logger logr.Logger) *serviceReconciler {
Expand All @@ -48,7 +49,7 @@ func NewServiceReconciler(cloud aws.Cloud, k8sClient client.Client, eventRecorde
controllerConfig.DefaultSSLPolicy, controllerConfig.DefaultTargetType, controllerConfig.FeatureGates.Enabled(config.EnableIPTargetType), serviceUtils,
backendSGProvider, sgResolver, controllerConfig.EnableBackendSecurityGroup, controllerConfig.DisableRestrictedSGRules, logger)
stackMarshaller := deploy.NewDefaultStackMarshaller()
stackDeployer := deploy.NewDefaultStackDeployer(cloud, k8sClient, networkingSGManager, networkingSGReconciler, elbv2TaggingManager, controllerConfig, serviceTagPrefix, logger)
stackDeployer := deploy.NewDefaultStackDeployer(cloud, k8sClient, networkingSGManager, networkingSGReconciler, vpcEndpointServiceManager, elbv2TaggingManager, controllerConfig, serviceTagPrefix, logger)
return &serviceReconciler{
k8sClient: k8sClient,
eventRecorder: eventRecorder,
Expand Down
119 changes: 89 additions & 30 deletions docs/guide/ingress/annotations.md

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions docs/guide/service/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
| [service.beta.kubernetes.io/aws-load-balancer-security-groups](#security-groups) | stringList | | |
| [service.beta.kubernetes.io/aws-load-balancer-manage-backend-security-group-rules](#manage-backend-sg-rules) | boolean | true | If `service.beta.kubernetes.io/aws-load-balancer-security-groups` is specified, this must also be explicitly specified otherwise it defaults to `false`. |
| [service.beta.kubernetes.io/aws-load-balancer-inbound-sg-rules-on-private-link-traffic](#update-security-settings) | string | |
| [service.alpha.kubernetes.io/aws-load-balancer-endpoint-service-enabled](#endpoint-service-enable)| boolean | false | |
| [service.alpha.kubernetes.io/aws-load-balancer-endpoint-service-acceptance-required](#endpoint-service-acceptance)| boolean| | |
| [service.alpha.kubernetes.io/aws-load-balancer-endpoint-service-allowed-principals](#endpoint-allowed-principals)|stringList| | |
| [service.alpha.kubernetes.io/aws-load-balancer-endpoint-service-private-dns-name](#endpoint-private-dns)| string | | |

## Traffic Routing
Traffic Routing can be controlled with following annotations:
Expand Down Expand Up @@ -513,6 +517,16 @@ Load balancer access can be controlled via following annotations:
service.beta.kubernetes.io/aws-load-balancer-inbound-sg-rules-on-private-link-traffic: "off"
```

## VPC Endpoint Service
A VPC Endpoint Service can be attached to a controlled loadbalancer via the following annotations:

- <a name="endpoint-service-enable">`service.alpha.kubernetes.io/aws-load-balancer-endpoint-service-enabled`</a> specifies whether to create a VPC Endpoint Service or not. The `--enable-endpoint-service` flag must also be set.

- <a name="endpoint-service-acceptance">`service.alpha.kubernetes.io/aws-load-balancer-endpoint-service-acceptance-required`</a> specifies whether requests to attach an Endpoint to the Endpoint Service require manual acceptance.

- <a name="endpoint-allowed-principals">`service.alpha.kubernetes.io/aws-load-balancer-endpoint-service-allowed-principals`</a> is a list of principals from which an Endpoint can be attached to this Endpoint Service.

- <a name="endpoint-private-dns">`service.alpha.kubernetes.io/aws-load-balancer-endpoint-service-private-dns-name`</a> is the private DNS name given to the Endpoint Service. This will need to be verified through a valid DNS record.

## Legacy Cloud Provider
The AWS Load Balancer Controller manages Kubernetes Services in a compatible way with the AWS cloud provider's legacy service controller.
Expand Down
60 changes: 60 additions & 0 deletions docs/install/iam_policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,66 @@
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateVpcEndpointServiceConfiguration"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags"
],
"Resource": "arn:aws:ec2:*:*:vpc-endpoint-service/*",
"Condition": {
"Null": {
"aws:RequestTag/elbv2.k8s.aws/cluster": "false"
},
"StringEquals": {
"ec2:CreateAction": "CreateVpcEndpointServiceConfiguration"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags",
"ec2:DeleteTags"
],
"Resource": "arn:aws:ec2:*:*:vpc-endpoint-service/*",
"Condition": {
"Null": {
"aws:RequestTag/elbv2.k8s.aws/cluster": "true",
"aws:ResourceTag/elbv2.k8s.aws/cluster": "false"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteVpcEndpointServiceConfigurations",
"ec2:ModifyVpcEndpointServiceConfiguration",
"ec2:ModifyVpcEndpointServicePermissions",
"ec2:StartVpcEndpointServicePrivateDnsVerification"
],
"Resource": "*",
"Condition": {
"Null": {
"aws:ResourceTag/elbv2.k8s.aws/cluster": "false"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcEndpointServiceConfigurations",
"ec2:DescribeVpcEndpointServicePermissions",
"ec2:DescribeVpcEndpointServices"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
Expand Down
60 changes: 60 additions & 0 deletions docs/install/iam_policy_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,66 @@
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateVpcEndpointServiceConfiguration"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags"
],
"Resource": "arn:aws-cn:ec2:*:*:vpc-endpoint-service/*",
"Condition": {
"Null": {
"aws:RequestTag/elbv2.k8s.aws/cluster": "false"
},
"StringEquals": {
"ec2:CreateAction": "CreateVpcEndpointServiceConfiguration"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags",
"ec2:DeleteTags"
],
"Resource": "arn:aws-cn:ec2:*:*:vpc-endpoint-service/*",
"Condition": {
"Null": {
"aws:RequestTag/elbv2.k8s.aws/cluster": "true",
"aws:ResourceTag/elbv2.k8s.aws/cluster": "false"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteVpcEndpointServiceConfigurations",
"ec2:ModifyVpcEndpointServiceConfiguration",
"ec2:ModifyVpcEndpointServicePermissions",
"ec2:StartVpcEndpointServicePrivateDnsVerification"
],
"Resource": "*",
"Condition": {
"Null": {
"aws:ResourceTag/elbv2.k8s.aws/cluster": "false"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcEndpointServiceConfigurations",
"ec2:DescribeVpcEndpointServicePermissions",
"ec2:DescribeVpcEndpointServices"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
Expand Down
60 changes: 60 additions & 0 deletions docs/install/iam_policy_us-gov.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,66 @@
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateVpcEndpointServiceConfiguration"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags"
],
"Resource": "arn:aws-us-gov:ec2:*:*:vpc-endpoint-service/*",
"Condition": {
"Null": {
"aws:RequestTag/elbv2.k8s.aws/cluster": "false"
},
"StringEquals": {
"ec2:CreateAction": "CreateVpcEndpointServiceConfiguration"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags",
"ec2:DeleteTags"
],
"Resource": "arn:aws-us-gov:ec2:*:*:vpc-endpoint-service/*",
"Condition": {
"Null": {
"aws:RequestTag/elbv2.k8s.aws/cluster": "true",
"aws:ResourceTag/elbv2.k8s.aws/cluster": "false"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteVpcEndpointServiceConfigurations",
"ec2:ModifyVpcEndpointServiceConfiguration",
"ec2:ModifyVpcEndpointServicePermissions",
"ec2:StartVpcEndpointServicePrivateDnsVerification"
],
"Resource": "*",
"Condition": {
"Null": {
"aws:ResourceTag/elbv2.k8s.aws/cluster": "false"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcEndpointServiceConfigurations",
"ec2:DescribeVpcEndpointServicePermissions",
"ec2:DescribeVpcEndpointServices"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func main() {
podInfoRepo := k8s.NewDefaultPodInfoRepo(clientSet.CoreV1().RESTClient(), controllerCFG.RuntimeConfig.WatchNamespace, ctrl.Log)
finalizerManager := k8s.NewDefaultFinalizerManager(mgr.GetClient(), ctrl.Log)
sgManager := networking.NewDefaultSecurityGroupManager(cloud.EC2(), ctrl.Log)
esManager := networking.NewDefaultVPCEndpointServiceManager(cloud.EC2(), ctrl.Log)
sgReconciler := networking.NewDefaultSecurityGroupReconciler(sgManager, ctrl.Log)
azInfoProvider := networking.NewDefaultAZInfoProvider(cloud.EC2(), ctrl.Log.WithName("az-info-provider"))
vpcInfoProvider := networking.NewDefaultVPCInfoProvider(cloud.EC2(), ctrl.Log.WithName("vpc-info-provider"))
Expand All @@ -116,10 +117,10 @@ func main() {
sgResolver := networking.NewDefaultSecurityGroupResolver(cloud.EC2(), cloud.VpcID())
elbv2TaggingManager := elbv2deploy.NewDefaultTaggingManager(cloud.ELBV2(), cloud.VpcID(), controllerCFG.FeatureGates, cloud.RGT(), ctrl.Log)
ingGroupReconciler := ingress.NewGroupReconciler(cloud, mgr.GetClient(), mgr.GetEventRecorderFor("ingress"),
finalizerManager, sgManager, sgReconciler, subnetResolver, elbv2TaggingManager,
finalizerManager, sgManager, esManager, sgReconciler, subnetResolver, elbv2TaggingManager,
controllerCFG, backendSGProvider, sgResolver, ctrl.Log.WithName("controllers").WithName("ingress"))
svcReconciler := service.NewServiceReconciler(cloud, mgr.GetClient(), mgr.GetEventRecorderFor("service"),
finalizerManager, sgManager, sgReconciler, subnetResolver, vpcInfoProvider, elbv2TaggingManager,
finalizerManager, sgManager, esManager, sgReconciler, subnetResolver, vpcInfoProvider, elbv2TaggingManager,
controllerCFG, backendSGProvider, sgResolver, ctrl.Log.WithName("controllers").WithName("service"))
tgbReconciler := elbv2controller.NewTargetGroupBindingReconciler(mgr.GetClient(), mgr.GetEventRecorderFor("targetGroupBinding"),
finalizerManager, tgbResManager,
Expand Down
28 changes: 28 additions & 0 deletions pkg/algorithm/strings.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package algorithm

import "k8s.io/apimachinery/pkg/util/sets"

// ChunkStrings will split slice of String into chunks
func ChunkStrings(targets []string, chunkSize int) [][]string {
var chunks [][]string
Expand All @@ -12,3 +14,29 @@ func ChunkStrings(targets []string, chunkSize int) [][]string {
}
return chunks
}

// DiffStringSlice returns three lists these consist of :-
// - all the elements in the first argument but not the second
// - all the elements in both arguments
// - all the elements in the second argument but not in the first
func DiffStringSlice(first, second []string) ([]*string, []*string, []*string) {
Copy link

Choose a reason for hiding this comment

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

Can we add a comment here to explain what this function does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added one.

firstSet := sets.NewString(first...)
secondSet := sets.NewString(second...)

matchFirst := make([]*string, 0)
matchBoth := make([]*string, 0)
matchSecond := make([]*string, 0)
for _, elem := range firstSet.Difference(secondSet).List() {
elem := elem
matchFirst = append(matchFirst, &elem)
}
for _, elem := range secondSet.Difference(firstSet).List() {
elem := elem
matchSecond = append(matchSecond, &elem)
}
for _, elem := range firstSet.Intersection(secondSet).List() {
elem := elem
matchBoth = append(matchBoth, &elem)
}
return matchFirst, matchBoth, matchSecond
}
Loading