Skip to content

Commit c0c6186

Browse files
authored
Refactor existing docs content into multiple pages (#74)
* refactor docs * revise site name * revise indents
1 parent 0f50d32 commit c0c6186

File tree

8 files changed

+398
-410
lines changed

8 files changed

+398
-410
lines changed

docs/configure.md

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
# Using the AWS Gateway API Controller
2+
3+
The first part of this section provides an example of setting up of service-to-service communications on a single cluster.
4+
The second section extends that example by creating another inventory service on a second cluster on a different VPC, and spreading traffic to that service across the two clusters and VPCs.
5+
Both clusters are created using `eksctl`, with both clusters created from the same account by the same cluster admin.
6+
7+
## Set up single-cluster/VPC service-to-service communications
8+
9+
This example creates a single cluster in a single VPC, then configures two routes (rates and inventory) and three services (parking, review, and inventory-1). The following figure illustrates this setup:
10+
11+
![Single cluster/VPC service-to-service communications](images/example1.png)
12+
13+
**Steps**
14+
15+
**Set up Service-to-Service communications**
16+
17+
1. Create the Kubernetes Gateway `my-hotel`:
18+
```bash
19+
kubectl apply -f examples/my-hotel-gateway.yaml
20+
```
21+
1. Verify that `my-hotel` gateway is created (this could take about five minutes):
22+
```bash
23+
kubectl get gateway
24+
```
25+
```
26+
NAME CLASS ADDRESS READY AGE
27+
my-hotel aws-lattice 7d12h
28+
```
29+
1. Once the gateway is created, find the VPC Lattice service network:
30+
```bash
31+
kubectl get gateway my-hotel -o yaml
32+
```
33+
```
34+
apiVersion: gateway.networking.k8s.io/v1alpha2
35+
kind: Gateway
36+
...
37+
status:
38+
conditions:
39+
message: 'aws-gateway-arn: arn:aws:vpc-lattice:us-west-2:694065802095:servicenetwork/sn-0ab6bb70055929edd'
40+
reason: Reconciled
41+
status: "True"
42+
```
43+
1. Create the Kubernetes HTTPRoute rates for the parking service, review service, and HTTPRoute rate:
44+
```bash
45+
kubectl apply -f examples/parking.yaml
46+
kubectl apply -f examples/review.yaml
47+
kubectl apply -f examples/rate-route-path.yaml
48+
```
49+
1. Create the Kubernetes HTTPRoute inventory (this could take about five minutes):
50+
```bash
51+
kubectl apply -f examples/inventory-ver1.yaml
52+
kubectl apply -f examples/inventory-route.yaml
53+
```
54+
1. Find out HTTPRoute's DNS name from HTTPRoute status:
55+
```bash
56+
kubectl get httproute
57+
```
58+
```
59+
NAME HOSTNAMES AGE
60+
inventory 51s
61+
rates 6m11s
62+
```
63+
1. List the route’s yaml file to see the DNS address (highlighted here on the `message` line):
64+
65+
```bash
66+
kubectl get httproute inventory -o yaml
67+
```
68+
69+
```
70+
apiVersion: gateway.networking.k8s.io/v1alpha2
71+
kind: HTTPRoute
72+
metadata:
73+
annotations:
74+
kubectl.kubernetes.io/last-applied-configuration: |
75+
{"apiVersion":"gateway.networking.k8s.io/v1alpha2","kind":"HTTPRoute","metadata":{"annotations":{},"name":"inventory","namespace":"default"}... }}]}]}}
76+
...
77+
status:
78+
parents:
79+
- conditions:
80+
- lastTransitionTime: "2022-11-22T02:29:22Z"
81+
message: 'DNS Name: <b><i>inventory-default-0f326944c3d681c0d.7d67968.vpc-lattice-svcs.us-west-2.on.aws</i></b>'
82+
reason: Reconciled
83+
status: "True"
84+
type: httproute
85+
controllerName: application-networking.k8s.aws/gateway-api-controller
86+
parentRef:
87+
group: gateway.networking.k8s.io
88+
kind: Gateway
89+
name: my-hotel
90+
...
91+
```
92+
93+
```bash
94+
kubectl get httproute rates inventory -o yaml
95+
```
96+
97+
**Check service connectivity**
98+
99+
1. Check Service-Inventory Pod access for Service-Rates/parking or Service-Rates/review by execing into the pod, then curling each service.
100+
```bash
101+
kubectl get pod
102+
```
103+
```
104+
NAME READY STATUS RESTARTS AGE
105+
inventory-ver1-7bb6989d9d-2p2hk 1/1 Running 0 7d13h
106+
inventory-ver1-7bb6989d9d-464rk 1/1 Running 0 7d13h
107+
parking-6cdcd5b4b4-bbzvt 1/1 Running 0 103m
108+
parking-6cdcd5b4b4-g8dkb 1/1 Running 0 103m
109+
review-5888566ff6-2plsj 1/1 Running 0 101m
110+
review-5888566ff6-89fqk 1/1 Running 0 101m
111+
```
112+
1. Exec into an inventory pod to check connectivity to parking and review services:
113+
```bash
114+
kubectl exec -ti inventory-ver1-7bb6989d9d-2p2hk sh
115+
```
116+
1. From inside of the inventory pod, use `curl` to connect to the parking service (using the DNS Name from the previous `kubectl get httproute` command):
117+
```bash
118+
curl rates-00422586e3362607e.7d67968.vpc-service-network-svcs.us-west-2.amazonaws.com/parking
119+
```
120+
```
121+
Requesting to Pod(parking-6cdcd5b4b4-g8dkb): parking handler pod
122+
```
123+
1. From inside of the pod, use `curl` to connect to the review service:
124+
```bash
125+
curl rates-00422586e3362607e.7d67968.vpc-service-network-svcs.us-west-2.amazonaws.com/review
126+
```
127+
```
128+
Requesting to Pod(review-5888566ff6-89fqk): review handler pod
129+
```
130+
1. Exit the pod:
131+
```bash
132+
exit
133+
```
134+
1. Exec into a parking pod to check connectivity to the inventory-ver1 service:
135+
```bash
136+
kubectl exec -ti parking-6cdcd5b4b4-bbzvt sh
137+
```
138+
1. From inside of the parking pod, use `curl` to connect to the inventory-ver1 service:
139+
```bash
140+
curl inventory-00422586e3362607e.7d67968.vpc-service-network-svcs.us-west-2.amazonaws.com
141+
```
142+
```
143+
Requesting to Pod(inventory-ver1-7bb6989d9d-2p2hk): inventory-ver1 handler pod
144+
```
145+
## Set up multi-cluster/multi-VPC service-to-service communications
146+
147+
This sections builds on the previous section by migrating a Kubernetes service (HTTPRoute inventory) from one Kubernetes cluster to a different Kubernetes cluster.
148+
For example, it will:
149+
150+
* Migrate the Kubernetes inventory service from a Kubernetes v1.21 cluster to a Kubernetes v1.23 cluster in a different VPC.
151+
* Scale up the Kubernetes inventory service to run it in another cluster (and another VPC) in addition to the current cluster.
152+
153+
The following figure illustrates this:
154+
155+
![Multiple clusters/VPCs service-to-service communications](images/example2.png)
156+
157+
**Steps**
158+
159+
**Set up inventory on a second cluster**
160+
161+
1. Create a second cluster (using the same instructions used to create the first).
162+
163+
1. Ensure you're using the second cluster profile.
164+
```bash
165+
kubectl config get-contexts
166+
```
167+
If your profile is set to the first cluster, switch your credentials to use the second cluster:
168+
```bash
169+
kubectl config use-context <yourcluster2info>
170+
```
171+
1. Create a Kubernetes inventory-ver2 service in the second cluster:
172+
```bash
173+
kubectl apply -f examples/inventory-ver2.yaml
174+
```
175+
1. Export this Kubernetes inventory-ver2 from the second cluster, so that it can be referenced by HTTPRoute in the other cluster:
176+
```bash
177+
kubectl apply -f examples/inventory-ver2-export.yaml
178+
```
179+
**Switch back to the first cluster**
180+
181+
1. Switch credentials back to the first cluster
182+
```bash
183+
kubectl config use-context <yourcluster1info>
184+
```
185+
1. Import the Kubernetes inventory-ver2 into first cluster:
186+
```bash
187+
kubectl apply -f examples/inventory-ver2-import.yaml
188+
```
189+
1. Update the HTTPRoute inventory to route 10% traffic to the first cluster and 90% traffic to the second cluster:
190+
```bash
191+
kubectl apply -f examples/inventory-route-bluegreen.yaml
192+
```
193+
1. Check the Service-Rates/parking pod access to Service-Inventory by execing into the parking pod:
194+
```bash
195+
kubectl exec -ti parking-6cdcd5b4b4-bbzvt sh
196+
```
197+
1. From inside of the pod, use `curl` to connect to the inventory service:
198+
199+
```bash
200+
for ((i=1;i<=30;i++)); do curl "inventory-default-0f89d8ff5e98400d0.7d67968.vpc-lattice-svcs.us-west-2.on.aws"; done
201+
```
202+
```
203+
Requsting to Pod(inventory-ver2-6dc74b45d8-rlnlt): Inventory-ver2 handler pod <----> in 2nd cluster
204+
Requsting to Pod(inventory-ver2-6dc74b45d8-rlnlt): Inventory-ver2 handler pod
205+
Requsting to Pod(inventory-ver2-6dc74b45d8-rlnlt): Inventory-ver2 handler pod
206+
Requsting to Pod(inventory-ver2-6dc74b45d8-rlnlt): Inventory-ver2 handler pod
207+
Requsting to Pod(inventory-ver2-6dc74b45d8-95rsr): Inventory-ver1 handler pod <----> in 1st cluster
208+
Requsting to Pod(inventory-ver2-6dc74b45d8-rlnlt): Inventory-ver2 handler pod
209+
Requsting to Pod(inventory-ver2-6dc74b45d8-95rsr): Inventory-ver2 handler pod
210+
Requsting to Pod(inventory-ver2-6dc74b45d8-95rsr): Inventory-ver2 handler pod
211+
Requsting to Pod(inventory-ver1-74fc59977-wg8br): Inventory-ver1 handler pod....
212+
```
213+
You can see that the traffic is distributed between *inventory-ver1* and *inventory-ver2* as expected.

docs/deploy.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
1. You can use an existing EKS cluster or create a new one as shown here:
7+
```bash
8+
eksctl create cluster --name <my-cluster> --region us-west-2
9+
```
10+
1. Configure security group: To receive traffic from the VPC Lattice fleet, you must set up security groups so that they allow all Pods communicating with VPC Lattice to allow traffic on all ports from the 169.254.171.0/24 address range. See [Control traffic to resources using security groups](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html) for details. You can use the following managed prefix to provide the values:
11+
```bash
12+
aws ec2 get-managed-prefix-list-entries --region us-west-2 --prefix-list-id pl-0721453c7ac4ec009
13+
```
14+
```
15+
ENTRIES 169.254.171.0/24
16+
```
17+
1. 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.
18+
```bash
19+
eksctl utils associate-iam-oidc-provider --cluster <my-cluster> --approve
20+
```
21+
1. 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:
22+
```bash
23+
{
24+
"Version": "2012-10-17",
25+
"Statement": [
26+
{
27+
"Effect": "Allow",
28+
"Action": [
29+
"vpc-lattice:*",
30+
"iam:CreateServiceLinkedRole",
31+
"ec2:DescribeVpcs",
32+
"ec2:DescribeSubnets"
33+
],
34+
"Resource": "*"
35+
}
36+
]
37+
}
38+
```
39+
```bash
40+
aws iam create-policy \
41+
--policy-name VPCLatticeControllerIAMPolicy \
42+
--policy-document file://examples/recommended-inline-policy.json
43+
```
44+
1. Create the `system` namespace:
45+
```bash
46+
kubectl apply -f examples/deploy-namesystem.yaml
47+
```
48+
1. Retrieve the policy ARN:
49+
```bash
50+
export VPCLatticeControllerIAMPolicyArn=$(aws iam list-policies --query 'Policies[?PolicyName==`VPCLatticeControllerIAMPolicy`].Arn' --output text)
51+
```
52+
1. Create an iamserviceaccount for pod level permission:
53+
```bash
54+
eksctl create iamserviceaccount \
55+
--cluster=<my-cluster> \
56+
--namespace=system \
57+
--name=gateway-api-controller \
58+
--attach-policy-arn=$VPCLatticeControllerIAMPolicyArn \
59+
--override-existing-serviceaccounts \
60+
--region us-west-2 \
61+
--approve
62+
```
63+
64+
1. Run either `kubectl` or `helm` to deploy the controller:
65+
66+
```bash
67+
kubectl apply -f examples/deploy-v0.0.1.yaml
68+
```
69+
70+
or
71+
72+
```bash
73+
# login to ECR
74+
aws ecr-public get-login-password --region us-east-1 | helm registry login --username AWS --password-stdin public.ecr.aws
75+
# Run helm with either install or upgrade
76+
helm install gateway-api-controller \
77+
oci://public.ecr.aws/aws-application-networking-k8s/aws-gateway-controller-chart\
78+
--version=v0.0.2 \
79+
--set=aws.region=us-west-2 --set=serviceAccount.create=false --namespace system
80+
```
81+
82+
1. Create the amazon-vpc-lattice GatewayClass:
83+
```bash
84+
kubectl apply -f examples/gatewayclass.yaml
85+
```

docs/examples/bluegreen.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)