Skip to content

Commit 2e05700

Browse files
authored
CLOUDP-116867: Add Private Link for GCP (#516)
1 parent 3776e10 commit 2e05700

File tree

15 files changed

+380
-249
lines changed

15 files changed

+380
-249
lines changed

config/crd/bases/atlas.mongodb.com_atlasprojects.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,30 @@ spec:
193193
for the current Project.
194194
items:
195195
properties:
196+
endpointGroupName:
197+
description: Unique identifier of the endpoint group. The endpoint
198+
group encompasses all of the endpoints that you created in
199+
Google Cloud.
200+
type: string
201+
endpoints:
202+
description: Collection of individual private endpoints that
203+
comprise your endpoint group.
204+
items:
205+
properties:
206+
endpointName:
207+
description: Forwarding rule that corresponds to the endpoint
208+
you created in Google Cloud.
209+
type: string
210+
ipAddress:
211+
description: Private IP address of the endpoint you created
212+
in Google Cloud.
213+
type: string
214+
type: object
215+
type: array
216+
gcpProjectId:
217+
description: Unique identifier of the Google Cloud project in
218+
which you created your endpoints.
219+
type: string
196220
id:
197221
description: Unique identifier of the private endpoint you created
198222
in your AWS VPC or Azure Vnet.
@@ -476,6 +500,23 @@ spec:
476500
project
477501
items:
478502
properties:
503+
endpoints:
504+
description: Collection of individual GCP private endpoints
505+
that comprise your network endpoint group.
506+
items:
507+
properties:
508+
endpointName:
509+
type: string
510+
ipAddress:
511+
type: string
512+
status:
513+
type: string
514+
required:
515+
- endpointName
516+
- ipAddress
517+
- status
518+
type: object
519+
type: array
479520
id:
480521
description: Unique identifier for AWS or AZURE Private Link
481522
Connection.

config/rbac/role.yaml

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

docs/gcpPrivateEndpoint.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Create a PrivateLink for GCP
2+
3+
## I. Create a Private Endpoint Service
4+
```yaml
5+
cat <<EOF | kubectl apply -f -
6+
apiVersion: atlas.mongodb.com/v1
7+
kind: AtlasProject
8+
metadata:
9+
name: my-project
10+
spec:
11+
name: Test Atlas Operator Project
12+
privateEndpoints:
13+
- provider: "GCP"
14+
region: "us-east1"
15+
EOF
16+
```
17+
18+
## II. Setup GCP Side of connection
19+
20+
- Use `EDIT` Atlas UI Button and follow a few steps to get a similar script:
21+
22+
```
23+
#!/bin/bash
24+
gcloud config set project atlasoperator
25+
26+
for i in {0..5}
27+
do
28+
gcloud compute addresses create user-private-endpoint-ip-$i --region=us-east1 --subnet=user-test-subnet
29+
done
30+
31+
for i in {0..5}
32+
do
33+
if [ $(gcloud compute addresses describe user-private-endpoint-ip-$i --region=us-east1 --format="value(status)") != "RESERVED" ]; then
34+
echo "user-private-endpoint-ip-$i is not RESERVED";
35+
exit 1;
36+
fi
37+
done
38+
39+
for i in {0..5}
40+
do
41+
gcloud compute forwarding-rules create user-private-endpoint-$i --region=us-east1 --network=user-test-vpc --address=user-private-endpoint-ip-$i --target-service-attachment=projects/p-long-id/regions/us-east1/serviceAttachments/long-id-$i
42+
done
43+
44+
if [ $(gcloud compute forwarding-rules list --regions=us-east1 --format="csv[no-heading](name)" --filter="name:user-private-endpoint" | wc -l) -gt 6 ]; then
45+
echo "Project has too many forwarding rules that match prefix user-private-endpoint. Either delete the competing resources or choose another endpoint prefix."
46+
exit 2;
47+
fi
48+
49+
gcloud compute forwarding-rules list --regions=us-east1 --format="json(IPAddress,name)" --filter="name:user-private-endpoint" > atlasEndpoints-user-private-endpoint.json
50+
```
51+
52+
- Run the scipt `sh setup_psk.sh`
53+
- Run a couple command to format the output for the operator:
54+
```bash
55+
yq e -P atlasEndpoints-user-private-endpoint.json > atlasEndpoints-user-private-endpoint.yaml
56+
awk 'sub("name","endpointName")sub("IPAddress","ipAddress")' atlasEndpoints-user-private-endpoint.yaml
57+
```
58+
Expected output:
59+
```
60+
- ipAddress: 10.0.0.00
61+
endpointName: user-private-endpoint-0
62+
- ipAddress: 10.0.0.01
63+
endpointName: user-private-endpoint-1
64+
- ipAddress: 10.0.0.02
65+
endpointName: user-private-endpoint-2
66+
- ipAddress: 10.0.0.03
67+
endpointName: user-private-endpoint-3
68+
- ipAddress: 10.0.0.04
69+
endpointName: user-private-endpoint-4
70+
- ipAddress: 10.0.0.05
71+
endpointName: user-private-endpoint-5
72+
```
73+
74+
## III. Create the Private Endpoint Inteface
75+
```yaml
76+
cat <<EOF | kubectl apply -f -
77+
apiVersion: atlas.mongodb.com/v1
78+
kind: AtlasProject
79+
metadata:
80+
name: my-project
81+
spec:
82+
name: Test Atlas Operator Project
83+
privateEndpoints:
84+
- provider: "GCP"
85+
region: "us-east1"
86+
gcpProjectId: "atlasoperator"
87+
endpointGroupName: "user-test-vpc"
88+
endpoints:
89+
- ipAddress: 10.0.0.00
90+
endpointName: user-private-endpoint-0
91+
- ipAddress: 10.0.0.01
92+
endpointName: user-private-endpoint-1
93+
- ipAddress: 10.0.0.02
94+
endpointName: user-private-endpoint-2
95+
- ipAddress: 10.0.0.03
96+
endpointName: user-private-endpoint-3
97+
- ipAddress: 10.0.0.04
98+
endpointName: user-private-endpoint-4
99+
- ipAddress: 10.0.0.05
100+
endpointName: user-private-endpoint-5
101+
EOF
102+
```

docs/release-notes/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
## AtlasProject Resource
88
* [3rd Party Integration](https://docs.atlas.mongodb.com/reference/api/third-party-integration-settings/) are supported `spec.integrations`
9+
* [GCP Private Endpoints](https://www.mongodb.com/docs/atlas/reference/api/private-endpoints/) are now supported
910

1011
## AtlasCluster Resource
1112
* Changes

go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ require (
6666
github.com/mitchellh/go-homedir v1.1.0 // indirect
6767
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6868
github.com/modern-go/reflect2 v1.0.2 // indirect
69-
github.com/nxadm/tail v1.4.8 // indirect
70-
github.com/onsi/ginkgo v1.16.5 // indirect
7169
github.com/openlyinc/pointy v1.1.2 // indirect
7270
github.com/pkg/errors v0.9.1 // indirect
7371
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -96,7 +94,6 @@ require (
9694
google.golang.org/protobuf v1.27.1 // indirect
9795
gopkg.in/inf.v0 v0.9.1 // indirect
9896
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
99-
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
10097
gopkg.in/yaml.v2 v2.4.0 // indirect
10198
k8s.io/apiextensions-apiserver v0.23.4 // indirect
10299
k8s.io/component-base v0.23.4 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC
9797
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
9898
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
9999
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
100-
github.com/aws/aws-sdk-go v1.43.7 h1:Gbs53KxXJWbO3txoVkevf56bhdDFqRisl7MQQ6581vc=
101-
github.com/aws/aws-sdk-go v1.43.7/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
102100
github.com/aws/aws-sdk-go v1.43.23 h1:/YmZzPMK6Xzi0B/W9O/Pq7nyIXpBv6mTiJdDDFC7u94=
103101
github.com/aws/aws-sdk-go v1.43.23/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
104102
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
@@ -635,8 +633,6 @@ golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWP
635633
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
636634
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
637635
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
638-
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE=
639-
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
640636
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
641637
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
642638
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=

pkg/api/v1/atlasproject_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type AtlasProjectSpec struct {
5656
ProjectIPAccessList []project.IPAccessList `json:"projectIpAccessList,omitempty"`
5757

5858
// PrivateEndpoints is a list of Private Endpoints configured for the current Project.
59-
PrivateEndpoints []project.PrivateEndpoint `json:"privateEndpoints,omitempty"`
59+
PrivateEndpoints []PrivateEndpoint `json:"privateEndpoints,omitempty"`
6060

6161
// Flag that indicates whether to create the new project with the default alert settings enabled. This parameter defaults to true
6262
// +kubebuilder:default:=true

0 commit comments

Comments
 (0)