|
1 |
| -# Deploying the AWS Gateway API Controller |
2 |
| - |
3 |
| -Follow these instructions to create a cluster and deploy the AWS Gateway API Controller. |
4 |
| -Run through them again for a second cluster to use with the extended example shown later. |
5 |
| - |
6 |
| -**NOTE**: You can get the yaml files used on this page by cloning the [AWS Gateway API Controller for VPC Lattice](https://github.com/aws/aws-application-networking-k8s) site. The files are in the `examples/` directory. |
7 |
| - |
8 |
| -1. Set your region and cluster name as environment variables. See the [Amazon VPC Lattice FAQs](https://aws.amazon.com/vpc/lattice/faqs/) for a list of supported regions. For this example, we use `us-west-2`: |
9 |
| - ```bash |
10 |
| - export AWS_REGION=us-west-2 |
11 |
| - export CLUSTER_NAME=my-cluster |
12 |
| - ``` |
13 |
| -2. You can use an existing EKS cluster or create a new one as shown here: |
14 |
| - ```bash |
15 |
| - eksctl create cluster --name $CLUSTER_NAME --region $AWS_REGION |
16 |
| - ``` |
17 |
| -3. Configure security group to receive traffic from the VPC Lattice network. You must set up security groups so that they allow all Pods communicating with VPC Lattice to allow traffic from the VPC Lattice managed prefix lists. See [Control traffic to resources using security groups](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html) for details. Lattice has both an IPv4 and IPv6 prefix lists available. |
18 |
| - |
19 |
| - ```bash |
20 |
| - CLUSTER_SG=$(aws eks describe-cluster --name $CLUSTER_NAME --output json| jq -r '.cluster.resourcesVpcConfig.clusterSecurityGroupId') |
21 |
| - PREFIX_LIST_ID=$(aws ec2 describe-managed-prefix-lists --query "PrefixLists[?PrefixListName=="\'com.amazonaws.$AWS_REGION.vpc-lattice\'"].PrefixListId" | jq -r '.[]') |
22 |
| - aws ec2 authorize-security-group-ingress --group-id $CLUSTER_SG --ip-permissions "PrefixListIds=[{PrefixListId=${PREFIX_LIST_ID}}],IpProtocol=-1" |
23 |
| - PREFIX_LIST_ID_IPV6=$(aws ec2 describe-managed-prefix-lists --query "PrefixLists[?PrefixListName=="\'com.amazonaws.$AWS_REGION.ipv6.vpc-lattice\'"].PrefixListId" | jq -r '.[]') |
24 |
| - aws ec2 authorize-security-group-ingress --group-id $CLUSTER_SG --ip-permissions "PrefixListIds=[{PrefixListId=${PREFIX_LIST_ID_IPV6}}],IpProtocol=-1" |
25 |
| - ``` |
26 |
| -3. Create an IAM OIDC provider: See [Creating an IAM OIDC provider for your cluster](https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html) for details. |
27 |
| - ```bash |
28 |
| - eksctl utils associate-iam-oidc-provider --cluster $CLUSTER_NAME --approve --region $AWS_REGION |
29 |
| - ``` |
30 |
| -4. Create a policy (`recommended-inline-policy.json`) in IAM with the following content that can invoke the gateway API and copy the policy arn for later use: |
31 |
| - ```bash |
32 |
| - { |
33 |
| - "Version": "2012-10-17", |
34 |
| - "Statement": [ |
35 |
| - { |
36 |
| - "Effect": "Allow", |
37 |
| - "Action": [ |
38 |
| - "vpc-lattice:*", |
39 |
| - "iam:CreateServiceLinkedRole", |
40 |
| - "ec2:DescribeVpcs", |
41 |
| - "ec2:DescribeSubnets", |
42 |
| - "ec2:DescribeTags", |
43 |
| - "ec2:DescribeSecurityGroups", |
44 |
| - "logs:CreateLogDelivery", |
45 |
| - "logs:GetLogDelivery", |
46 |
| - "logs:UpdateLogDelivery", |
47 |
| - "logs:DeleteLogDelivery", |
48 |
| - "logs:ListLogDeliveries" |
49 |
| - ], |
50 |
| - "Resource": "*" |
51 |
| - } |
52 |
| - ] |
53 |
| - } |
54 |
| - ``` |
55 |
| - ```bash |
56 |
| - aws iam create-policy \ |
57 |
| - --policy-name VPCLatticeControllerIAMPolicy \ |
58 |
| - --policy-document file://examples/recommended-inline-policy.json |
59 |
| - ``` |
60 |
| -5. Create the `aws-application-networking-system` namespace: |
61 |
| - ```bash |
62 |
| - kubectl apply -f examples/deploy-namesystem.yaml |
63 |
| - ``` |
64 |
| -6. Retrieve the policy ARN: |
65 |
| - ```bash |
66 |
| - export VPCLatticeControllerIAMPolicyArn=$(aws iam list-policies --query 'Policies[?PolicyName==`VPCLatticeControllerIAMPolicy`].Arn' --output text) |
67 |
| - ``` |
68 |
| -7. Create an iamserviceaccount for pod level permission: |
69 |
| - ```bash |
70 |
| - eksctl create iamserviceaccount \ |
71 |
| - --cluster=$CLUSTER_NAME \ |
72 |
| - --namespace=aws-application-networking-system \ |
73 |
| - --name=gateway-api-controller \ |
74 |
| - --attach-policy-arn=$VPCLatticeControllerIAMPolicyArn \ |
75 |
| - --override-existing-serviceaccounts \ |
76 |
| - --region $AWS_REGION \ |
77 |
| - --approve |
78 |
| - ``` |
79 |
| -8. Run either `kubectl` or `helm` to deploy the controller: |
80 |
| - ```bash |
81 |
| - kubectl apply -f examples/deploy-v0.0.18.yaml |
82 |
| - ``` |
83 |
| - or |
84 |
| - ```bash |
85 |
| - # login to ECR |
86 |
| - aws ecr-public get-login-password --region us-east-1 | helm registry login --username AWS --password-stdin public.ecr.aws |
87 |
| - # Run helm with either install or upgrade |
88 |
| - helm install gateway-api-controller \ |
89 |
| - oci://public.ecr.aws/aws-application-networking-k8s/aws-gateway-controller-chart\ |
90 |
| - --version=v0.0.18 \ |
91 |
| - --set=serviceAccount.create=false --namespace aws-application-networking-system \ |
92 |
| - # awsRegion, clusterVpcId, clusterName, awsAccountId are required for case where IMDS is NOT AVAILABLE, e.g Fargate, self-managed clusters with IMDS access blocked |
93 |
| - --set=awsRegion= \ |
94 |
| - --set=clusterVpcId= \ |
95 |
| - --set=clusterName= \ |
96 |
| - --set=awsAccountId= \ |
97 |
| - --set=defaultServiceNetwork= \ # check environment.md for more its details |
98 |
| - # latticeEndpoint is required for the case where the VPC Lattice endpoint is being overridden |
99 |
| - --set=latticeEndpoint= \ |
100 |
| - |
101 |
| - |
102 |
| - ``` |
103 |
| -9. Create the `amazon-vpc-lattice` GatewayClass: |
104 |
| - ```bash |
105 |
| - kubectl apply -f examples/gatewayclass.yaml |
106 |
| - ``` |
0 commit comments