Skip to content

Commit 7909659

Browse files
zijun726911Zijun Wang
andauthored
Add yaml examples for AWS Resource Access Manager sharing ServiceNetwork (gateway) between accounts (#208)
* Add yaml examples for AWS Resource Access Manager sharing ServiceNetwork (gateway) between accounts * Add ram-sharing.md --------- Co-authored-by: Zijun Wang <zijunw@amazon.com>
1 parent 1ebae0c commit 7909659

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

docs/ram-sharing.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Share Kubernetes Gateway (VPC lattice service network) between different AWS accounts
2+
3+
AWS Resource Access Manager(RAM) helps you share your resources across AWS accounts, within your organization or
4+
organizational units (OUs). Now VPC lattice support 2 types of resource sharing: share VPC lattice service or sharing
5+
VPC lattice services, in the AWS Gateway API Controller now it only support sharing VPC lattice service network.
6+
7+
Here in a example that account B (sharer account) could share it's service network with account A (sharee account), and
8+
account A could access all k8s services (vpc lattice target groups) and k8s httproutes(vpc lattice services) within this
9+
sharer account's service network.
10+
11+
**Steps**
12+
13+
1. Create a full connectivity setup example (include a gateway, a service and a httproute ) in the account B (sharer
14+
account): `kubectl apply -f examples/second-account-gw1-full-setup.yaml`
15+
16+
17+
2. Go to accountB's aws "Resource Access Manager" console, create a `VPC Lattice Service Networks` type resource
18+
sharing, share the service network that created from previous step's gateway(second-account-gw1) (You could check
19+
the VPC Lattice console to get the resource arn, service network name should also be second-account-gw1)
20+
21+
3. Open the account A (sharee account)'s "aws Resource Access Manager" console, in the "Shared with me" section accept
22+
the accountB's Service Network sharing invitation.
23+
24+
4. Load the account A's aws credential in you command line, do `kubectl config use-context <accountA cluster>` to switch
25+
to accountA's context
26+
27+
5. Apply the same "second-account-gw1" account A (sharee account)'s cluster
28+
by `kubectl apply -f examples/second-account-gw1-in-primary-account.yaml`
29+
30+
6. All done, you could verify service network(gateway) sharing by: Attach to any pod in account A's cluster,
31+
do `curl <vpc lattice service dns for 'second-account-gw1-httproute'>`, it should be able to get correct response "
32+
second-account-gw1-svc handler pod"
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apiVersion: gateway.networking.k8s.io/v1beta1
2+
kind: Gateway
3+
metadata:
4+
name: second-account-gw1
5+
annotations:
6+
application-networking.k8s.aws/lattice-vpc-association: "true"
7+
spec:
8+
gatewayClassName: amazon-vpc-lattice
9+
listeners:
10+
- name: http
11+
protocol: HTTP
12+
port: 80
13+
14+
---
15+
16+
apiVersion: apps/v1
17+
kind: Deployment
18+
metadata:
19+
name: second-account-gw1-svc
20+
labels:
21+
app: second-account-gw1-svc
22+
spec:
23+
replicas: 1
24+
selector:
25+
matchLabels:
26+
app: second-account-gw1-svc
27+
template:
28+
metadata:
29+
labels:
30+
app: second-account-gw1-svc
31+
spec:
32+
containers:
33+
- name: second-account-gw1-svc-app
34+
image: public.ecr.aws/x2j8p8w7/http-server:latest
35+
env:
36+
- name: PodName
37+
value: "second-account-gw1-svc handler pod"
38+
39+
40+
---
41+
42+
apiVersion: v1
43+
kind: Service
44+
metadata:
45+
name: second-account-gw1-svc
46+
spec:
47+
selector:
48+
app: second-account-gw1-svc
49+
ports:
50+
- protocol: TCP
51+
port: 80
52+
targetPort: 8090
53+
54+
---
55+
56+
apiVersion: gateway.networking.k8s.io/v1beta1
57+
kind: HTTPRoute
58+
metadata:
59+
name: second-account-gw1-httproute
60+
spec:
61+
parentRefs:
62+
- name: second-account-gw1
63+
sectionName: http
64+
rules:
65+
- backendRefs:
66+
- name: second-account-gw1-svc
67+
kind: Service
68+
matches:
69+
- path:
70+
type: PathPrefix
71+
value: /
72+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: gateway.networking.k8s.io/v1beta1
2+
kind: Gateway
3+
metadata:
4+
name: second-account-gw1
5+
annotations:
6+
application-networking.k8s.aws/lattice-vpc-association: "true"
7+
spec:
8+
gatewayClassName: amazon-vpc-lattice
9+
listeners:
10+
- name: http
11+
protocol: HTTP
12+
port: 80

0 commit comments

Comments
 (0)