VPC peering
If you are using an internal operator load balancer (i.e. you set operator_load_balancer_scheme: internal
in your cluster configuration file before creating your cluster), you can use VPC Peering to enable your Cortex CLI to connect to your cluster operator from another VPC so that you may run cortex
commands.
If you are using an internal API load balancer (i.e. you set api_load_balancer_scheme: internal
in your cluster configuration file before creating your cluster), you can use VPC Peering to make prediction requests from another VPC.
This guide illustrates how to create a VPC Peering connection between a VPC of your choice and the Cortex load balancers.
Gather Cortex's VPC information
Navigate to AWS's EC2 Load Balancer dashboard and locate the Cortex operator's load balancer. You can determine which is the operator load balancer by inspecting the kubernetes.io/service-name
tag:
![](https://docs.cortexlabs.com/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F808475%2F80126132-804e2a80-8547-11ea-8ce4-57d3fd96e2c4.png&width=768&dpr=4&quality=100&sign=ab345363&sv=1)
Click back to the "Description" tab and note the VPC ID of the load balancer and the ID of each of the subnets associated with the load balancer:
![](https://docs.cortexlabs.com/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F808475%2F80127144-c2c43700-8548-11ea-95b4-ce9d1df024cc.png&width=768&dpr=4&quality=100&sign=ff759086&sv=1)
Navigate to AWS's VPC dashboard and identify the ID and CIDR block of Cortex's VPC:
![](https://docs.cortexlabs.com/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F808475%2F80125554-af17d100-8546-11ea-96ec-00e2aaee7100.png&width=768&dpr=4&quality=100&sign=b51ee60b&sv=1)
The VPC ID here should match that of the load balancer.
Create peering connection
Identify the ID and CIDR block of the VPC from which you'd like to connect to the Cortex VPC.
In my case, I have a VPC in the same AWS account and region, and I can locate its ID and CIDR block from AWS's VPC dashboard:
![](https://docs.cortexlabs.com/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F808475%2F80125729-eb4b3180-8546-11ea-8d20-6bc2478747ae.png&width=768&dpr=4&quality=100&sign=915a426c&sv=1)
From AWS's VPC dashboard, navigate to the "Peering Connections" page, and click "Create Peering Connection":
![](https://docs.cortexlabs.com/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F808475%2F80127600-67df0f80-8549-11ea-9e10-765a6e273b54.png&width=768&dpr=4&quality=100&sign=bd386d3&sv=1)
Name your new VPC Peering Connection (I used "cortex-operator", but "cortex" or "cortex-api" may make more sense depending on your use case). Then configure the connection such that the "Requester" is the VPC from which you'll connect to the Cortex VPC, and the "Accepter" is Cortex's VPC.
![](https://docs.cortexlabs.com/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F808475%2F80131545-3f5a1400-854f-11ea-9ca0-c51433d3fa3d.png&width=768&dpr=4&quality=100&sign=c46a112f&sv=1)
Click "Create Peering Connection", navigate back to the Peering Connections dashboard, select the newly created peering connection, and click "Actions" > "Accept Request":
![](https://docs.cortexlabs.com/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F808475%2F80132179-26059780-8550-11ea-80fc-6670fcab7026.png&width=768&dpr=4&quality=100&sign=54541211&sv=1)
Update route tables
Navigate to the VPC Route Tables page. Select the route table for the VPC from which you'd like to connect to the Cortex cluster (in my case, I just have one route table for this VPC). Select the "Routes" tab, and click "Edit routes":
![](https://docs.cortexlabs.com/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F808475%2F80135180-b940cc00-8554-11ea-8162-c7409090897b.png&width=768&dpr=4&quality=100&sign=e05c85be&sv=1)
Add a route where the "Destination" is the CIDR block for Cortex's VPC, and the "Target" is the newly-created Peering Connection:
Do not create new route tables or change subnet associations.
Navigate back to the VPC Route Tables page. There will be a route table for each of the subnets associated with the Cortex operator load balancer:
For each of these route tables, click "Edit routes" and add a new route where the "Destination" is the CIDR block for the VPC from which you will be connecting to the Cortex cluster, and the "Target" is the newly-created Peering Connection:
Repeat adding this route for each route table associated with the Cortex operator's subnets; in my case there were three. Do not create new route tables or change subnet associations.
You should now be able to use the Cortex CLI and make prediction requests from your VPC.
Cleanup
Delete the VPC Peering connection before spinning down your Cortex cluster:
Last updated