-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into messagequeue-image-tag
- Loading branch information
Showing
12 changed files
with
299 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Getting started with Nx Agents | ||
|
||
We recommend deploying Nx Agents onto a new cluster, but you can also deploy onto your existing NxCloud cluster under a different namespace. | ||
|
||
### Install Valkey | ||
|
||
Valkey is an in-memory key-value store (like Redis) that is used by the workflow controller to hold temporary state. | ||
|
||
1. Create a secret similar to `agents-guide/agents-secrets.yml` and set your valkey password in there. | ||
- Important: the key `valkey-password` itself shouldn't be changed, only its value | ||
- You do not need to set the secret values for the S3 bucket yet. They are there as an example. Please refer to `charts/nx-agents/values.yaml` for info on what Agent storage options we support. | ||
2. Apply the secret: `kubectl apply -f agents-secrets.yml` | ||
3. Now let's deploy Valkey: | ||
```bash | ||
helm repo add bitnami https://charts.bitnami.com/bitnami | ||
helm install valkey bitnami/valkey --set auth.usePassword=true --set auth.existingSecret=nx-cloud-agents-secret | ||
``` | ||
|
||
### Deploy the Agents chart onto your cluster | ||
|
||
##### Configuring nx-agents.yaml | ||
Here is an example `nx-agents.yml` config for deployment on AWS you can use as a starting point: [`basic-agents-config.yaml`](./basic-agents-config.yaml) | ||
(you can also refer to the full [`values.yaml`](../charts/nx-agents/values.yaml) for full docs on all the values we support) | ||
|
||
Modify your `nx-agents.yml` values file, and make sure the secrets we created above are linked up: | ||
1. Ensure `secret.name: nx-cloud-agents-secret` (see [here](https://github.com/nrwl/nx-cloud-helm/blob/main/charts/nx-agents/values.yaml#L132)) | ||
2. Ensure `secret.valkeyPassword: 'valkey-password'`. The name needs to match the exact key you declared in the secret above (example [here](https://github.com/nrwl/nx-cloud-helm/blob/main/charts/nx-agents/values.yaml#L132)). | ||
|
||
##### Deploying the Nx Agents cluster | ||
|
||
Now you can push your chart changes so your controller can connect to valkey: | ||
|
||
```bash | ||
helm repo add nx-cloud https://nrwl.github.io/nx-cloud-helm | ||
helm repo update nx-cloud | ||
helm upgrade --install nx-agents nx-cloud/nx-agents --values=nx-agents.yml | ||
``` | ||
|
||
###### Custom valkey URL | ||
|
||
If you have deployed valkey in a custom location you can overwrite the default url: | ||
|
||
```yaml | ||
controller: | ||
useDefaultValkeyAddress: false # set this to false | ||
deployment: | ||
port: 9000 | ||
env: | ||
- name: VALKEY_CONNECTION_STRING # declare the custom connection string | ||
valueFrom: # you can insert the value from a secret or hardcode it in the nx-agents.yml | ||
secretKeyRef: | ||
name: nx-cloud-k8s-secret | ||
key: valkey-connection-string | ||
``` | ||
--- | ||
Note on storage: | ||
1. The Agents need a storage bucket for storing logs and cached items (such as `node_modules`) | ||
2. You do not need to use S3, we also support Azure Blob Storage and GCloud buckets | ||
3. To choose a storage service you can configure the below values: | ||
- `NX_CLOUD_GCS_BUCKET=...` | ||
- `NX_CLOUD_AWS_BUCKET=...` | ||
- `AZURE_CONNECTION_STRING=...` | ||
4. You'll then need to make sure your pods either have the correct service account attached for interacting with the above buckets (see [the AWS example](./AWS-AGENTS-GUIDE.md#connecting-an-s3-bucket)) | ||
### Connect NxCloud to your Nx Agents deployment | ||
These are the options you can use to configure how NxCloud connects to your Nx Agents cluster. | ||
Depending on how you deployed your Nx Agents cluster (which namespace you used, whether it was in the same or a different cluster etc.) you might need | ||
to use different combinations of the below values. | ||
Set these in your NxCloud `values.yaml` file: | ||
```yaml | ||
nxCloudWorkflows: | ||
enabled: true | ||
port: 9000 | ||
# if you have deployed Nx Agents in the same cluster use these options | ||
name: 'nx-cloud-workflow-controller-service' | ||
workflowsNamespace: 'nx-cloud-workflows' | ||
# use these options if Nx Agents was deployed in a separate cluster | ||
externalName: 'external-address-or-ip.com' | ||
# If you find that an externalName service is not working as expected, you can set this to true to create a headless service | ||
# which will create an endpoint group as an alternative. Please continue to set `externalName` to the IP address | ||
# you wish to direct traffic to as we will use it to populate the endpoint slice. | ||
headless: false | ||
``` | ||
Please see `charts/nx-cloud/values.yaml` for up to date documentation on the above options. | ||
Finally, push the updates to your NxCloud cluster: | ||
```bash | ||
helm upgrade --install nx-cloud nx-cloud/nx-cloud --values=nx-cloud-values.yml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Deploy an Nx Agents cluster on AWS | ||
|
||
## Create the cluster | ||
|
||
```bash | ||
# init the cluster | ||
eksctl create cluster --name nx-cloud-cluster --region us-east-1 \ | ||
--nodegroup-name ng-1 --node-type t3.medium --nodes 5 --managed | ||
|
||
# associate the oidc provider | ||
eksctl utils associate-iam-oidc-provider \ | ||
--cluster=nx-cloud-cluster --approve | ||
``` | ||
|
||
## Installing the EBS CSI add-on | ||
|
||
```bash | ||
# create a service account for the controller to use | ||
eksctl create iamserviceaccount \ | ||
--name ebs-csi-controller-sa \ | ||
--namespace kube-system \ | ||
--cluster ami-test-agents-cluster \ | ||
--attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \ | ||
--approve \ | ||
--override-existing-serviceaccounts | ||
|
||
# install the add-on via helm | ||
helm repo add aws-ebs-csi-driver https://kubernetes-sigs.github.io/aws-ebs-csi-driver | ||
helm repo update | ||
helm install aws-ebs-csi-driver aws-ebs-csi-driver/aws-ebs-csi-driver \ | ||
--namespace kube-system \ | ||
--set controller.serviceAccount.create=false \ | ||
--set controller.serviceAccount.name=ebs-csi-controller-sa | ||
``` | ||
|
||
## Install valkey | ||
|
||
1. Add a valkey password in [agents-secrets.yml](./agents-secrets.yml) | ||
2. Deploy valkey: | ||
|
||
```bash | ||
kubectl apply -f agents-secrets.yaml | ||
helm repo add bitnami https://charts.bitnami.com/bitnami | ||
helm install valkey bitnami/valkey --set auth.usePassword=true --set auth.existingSecret=nx-cloud-agents-secret | ||
``` | ||
|
||
## Connecting an S3 bucket | ||
|
||
1. Create an S3 for the agents to store their cache and their logs | ||
2. Create a policy that allows access to the bucket: | ||
```json | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "VisualEditor0", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"s3:PutObject", | ||
"s3:GetObjectAcl", | ||
"s3:GetObject", | ||
"s3:ListBucket", | ||
"s3:DeleteObject", | ||
"s3:PutObjectAcl" | ||
], | ||
"Resource": [ | ||
"arn:aws:s3:::your-bucket-name", | ||
"arn:aws:s3:::your-bucket-name/*" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
3. Attach the above policy to the NodeGroup IAM Role for your EKS Cluster | ||
|
||
## Deploy Nx Agents | ||
|
||
```bash | ||
helm upgrade --install nx-agents nx-cloud/nx-agents \ | ||
--values=./nx-agents.yml \ | ||
--set controller.image.tag="2405.02.15" | ||
``` | ||
|
||
## Copy the public URL | ||
|
||
```bash | ||
# copy the EXTERNAL-IP value | ||
kubectl get service nx-cloud-workflow-controller-service | ||
``` | ||
|
||
## Connect your NxCloud cluster to your Nx Agents cluster | ||
|
||
Continue following the instructions [here](./AGENTS-GUIDE.md#connect-nxcloud-to-your-nx-agents-deployment) for instructions on how to connect your NxCloud cluster to the above address. | ||
|
||
## Other resources | ||
|
||
Please also check the generic [Agents Guide](./AGENTS-GUIDE.md) for background on how why we need some of the pieces above, such as valkey. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: nx-cloud-agents-secret | ||
type: Opaque | ||
stringData: | ||
AWS_S3_ACCESS_KEY_ID: '' | ||
AWS_S3_SECRET_ACCESS_KEY: '' | ||
valkey-password: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
global: | ||
namespace: default | ||
createNamespace: false | ||
|
||
controller: | ||
deployment: | ||
port: 9000 | ||
env: | ||
- name: AWS_REGION | ||
value: 'us-east-1' | ||
- name: NX_CLOUD_EXECUTOR_BINARY_BUCKET | ||
value: 'https://s3.amazonaws.com/your-custom-location-for-storing-the-executor' | ||
- name: NX_CLOUD_AWS_BUCKET | ||
value: "nx-cloud-agents-s3-bucket" | ||
service: | ||
port: 9000 | ||
type: LoadBalancer | ||
image: | ||
registry: 'us-east1-docker.pkg.dev/your-custom-registry' | ||
imageName: nx-cloud-workflow-controller | ||
repository: 'your-custom-nx-cloud-image-repo' | ||
|
||
executor: | ||
env: | ||
AWS_REGION: 'us-east-1' | ||
NX_CLOUD_AWS_BUCKET: 'nx-cloud-agents-s3-bucket' | ||
|
||
daemonset: | ||
tolerations: [] | ||
image: | ||
registry: '' | ||
imageName: ubuntu | ||
repository: '' | ||
tag: 22.04 | ||
enabled: true | ||
script: | | ||
#!/bin/bash | ||
set -e | ||
# change the file-watcher max-count on each node to 1048576 | ||
# insert the new value into the system config | ||
sysctl -w fs.inotify.max_user_watches=1048576 | ||
# check that the new value was applied | ||
cat /proc/sys/fs/inotify/max_user_watches | ||
secret: | ||
name: 'nx-cloud-agents-secret' | ||
valkeyPassword: 'valkey-password' | ||
awsS3AccessKeyId: '' | ||
awsS3SecretAccessKey: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.