Create a new EKS cluster:
eksctl create cluster --name nx-cloud-cluster --region us-east-1 --nodegroup-name ng-1 --node-type t3.medium --nodes 5 --managed
resource annotations - this will tell you how many resources each Pod needs.kubectl config get-contextskubectl config use-context <your-new-cluster-context>NxCloud needs a Mongo database to store details about your runs and record your hashes. You can either point it to your existing external Mongo instance or let it create its own inside the above cluster. Below, we’ll create one inside the cluster. If you already have an external Mongo instance, you can skip this section.
Create your Amazon EBS CSI plugin IAM role:
eksctl create iamserviceaccount \
--name ebs-csi-controller-sa \
--namespace kube-system \
--cluster nx-cloud-cluster \
--attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \
--approve \
--override-existing-serviceaccounts \
--role-only \
--role-name AmazonEKS_EBS_CSI_DriverRole
111122223333 with your account IDeksctl create addon --name aws-ebs-csi-driver --cluster nx-cloud-cluster --service-account-role-arn arn:aws:iam::111122223333:role/AmazonEKS_EBS_CSI_DriverRole --force
helm repo add mongodb https://mongodb.github.io/helm-charts
helm install community-operator mongodb/community-operator
curl -o mongodb.yml https://raw.githubusercontent.com/nrwl/nx-cloud-helm/main/aws-guide/mongodb.ymlsed -i '' 's/DB_PASSWORD/my_password_123/' mongodb.ymlkubectl apply -f mongodb.ymlkubectl get pods
kubectl describe pod cloud-mongodb-0Note: If you’d like to use something like the “AWS Secrets Manager”, you can skip this step and check out the guide below.
curl -o secrets.yml https://raw.githubusercontent.com/nrwl/nx-cloud-helm/main/aws-guide/secret.ymlDB_PASSWORD with your configured password): mongodb+srv://admin-user:DB_PASSWORD@cloud-mongodb-svc.default.svc.cluster.local/nrwl-api?replicaSet=cloud-mongodb&ssl=falsekubectl apply -f secrets.ymlcurl -o iam_policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.2.0/docs/install/iam_policy.jsonaws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicy --policy-document file://iam_policy.jsoneksctl create iamserviceaccount --cluster=nx-cloud-cluster --namespace=kube-system --name=aws-load-balancer-controller --attach-policy-arn=arn:aws:iam::YOUR_AWS_ACCOUNT_ID:policy/AWSLoadBalancerControllerIAMPolicy --override-existing-serviceaccounts --approvekubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master"eks-charts Helm charts repository: helm repo add eks https://aws.github.io/eks-chartshelm upgrade -i aws-load-balancer-controller eks/aws-load-balancer-controller --set clusterName=nx-cloud-cluster --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller -n kube-systemkubectl get deployment -n kube-system aws-load-balancer-controllerWe recommend setting up HTTPS for your NxCloud cluster, but you can skip this step if you’d just like to see it working for now:
curl -o helm-values.yml https://raw.githubusercontent.com/nrwl/nx-cloud-helm/main/aws-guide/helm-values.ymlDeploy NxCloud to your cluster: helm upgrade --install nx-cloud nx-cloud/nx-cloud --values=./helm-values.yml
kubectl get ingress
helm-values.yml file update the NxCloud URL with either your custom domain or your Load Balancer HTTP address from step 3.:
nxCloudAppURL: 'https://your-new-nx-cloud-url.com'nxCloudAppURL: 'http://k8s-default-nxcloudi-f36cd47328-1606205137.us-east-1.elb.amazonaws.com'helm upgrade --install nx-cloud nx-cloud/nx-cloud --values=./helm-values.ymlkubectl rollout restart deployment nx-cloud-nx-api nx-cloud-apiNX_CLOUD_API=https://your-nx-cloud-url.com nx connectCreate an IAM policy that can read/write/delete from your S3 bucket. Make sure to copy its ARN. Here’s an example:
POLICY_ARN=$(aws iam create-policy --policy-name s3-bucket-access-policy --policy-document '{
"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>/*"
]
}
]
}' | jq -r .Policy.Arn)
Create an nx-cloud-service-account service account and an IAM role attached to it, using the Permission Policy you created above (replace the items in angled brackets):
eksctl create iamserviceaccount \
--name nx-cloud-service-account \
--cluster nx-cloud-cluster \
--attach-policy-arn $POLICY_ARN \
--override-existing-serviceaccounts \
--approve \
--role-name nx-cloud-cluster-s3-access-role
Increase the session duration of the role to 5 hours:
aws iam update-role --role-name nx-cloud-cluster-s3-access-role --max-session-duration=18000
We need to do this because the URLs for writing artefacts to your S3 cache are generated at the beginning of your CI run. And depending on how long your CI run takes, the URLs might expire if we don’t give them a long enough time window.
Add these options to the helm.yaml file:
awsS3:
enabled: true
bucket: '<your-bucket-name>'
serviceAccountName: 'nx-cloud-service-account'
# accelerated: true uncomment when using accelerated bucket
# endpoint: '' uncomment when using a custom endpoint
Push the new config: helm upgrade --install nx-cloud nx-cloud/nx-cloud --values=./helm-values.yml
nx-cloud-k8s-secret, otherwise it will affect the below
kubectl delete secret nx-cloud-k8s-secretAWS Secret Manager secret with key/value pairs called nx-cloud-secrets

POLICY_ARN=$(aws iam create-policy --policy-name secrets-reader --policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetResourcePolicy",
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret",
"secretsmanager:ListSecretVersionIds"
],
"Resource": [
"<SECRET-ARN>"
]
},
{
"Effect": "Allow",
"Action": "secretsmanager:ListSecrets",
"Resource": "*"
}
]
}
' | jq -r .Policy.Arn)
eksctl create iamserviceaccount \
--name read-secrets-service-account \
--cluster nx-cloud-cluster \
--role-name read-secrets-role \
--attach-policy-arn $POLICY_ARN \
--approve \
--override-existing-serviceaccounts
helm repo add external-secrets https://charts.external-secrets.iohelm install external-secrets \
external-secrets/external-secrets \
-n external-secrets \
--create-namespace \
--set installCRDs=true \
--set webhook.port=9443
curl -o secret-store.yml https://raw.githubusercontent.com/nrwl/nx-cloud-helm/main/aws-guide/secret-store.yml
kubectl apply -f secret-store.ymlcurl -o secret-store.yml https://raw.githubusercontent.com/nrwl/nx-cloud-helm/main/aws-guide/external-secret.yml
kubectl apply -f external-secret.ymlkubectl get secrets nx-cloud-k8s-secret -o jsonkubectl describe externalsecrets.external-secrets.io nx-cloud-external-secretkubectl rollout restart deployment nx-cloud-nx-api nx-cloud-apiWhen setting up Ingress “unable to discover at least one subnet”
alb.ingress.kubernetes.io/target-type to ipIf you experience S3 permissions issues when trying to retrieve an artefact with the NxCloud runner:
kms:GenerateDataKey to the S3 access policy