- AWS CLI configured with appropriate credentials (
aws sso login) - kubectl installed
- helm installed
- Terraform installed
-
Fork this repository
- Fork the repository on GitHub to your own account
- Clone your fork locally:
git clone git@github.com:<your-username>/support-cci-server-setup.git cd support-cci-server-setup
-
Get secrets zip and unzip to root folder
- Download secrets from 1Password and unzip to root folder. Should be support-cci-server-setup/secrets/
-
Create S3 bucket for Terraform state
- Create an S3 bucket in your AWS account (e.g.,
ka-cci-terraform-state) - Update the
backend "s3"block interraform/main.tfwith your bucket name
- Create an S3 bucket in your AWS account (e.g.,
-
Modify Terraform configuration
- Update
terraform/main.tf:- Set
cluster_namein locals - Set
regionif different - Update
emailwith your email - Update
hosted_zoneswith your Route53 hosted zone ARN - Update
public_subnets, they must be unique across VPCs (If they conflict during terraform apply, just bump them) - Set
subdomainto your desired subdomain:- For a subdomain:
"circleci"forcircleci.yourdomain.com, or"mycci"formycci.yourdomain.com - For root domain: Set to
""(empty string) to deploy toyourdomain.com
- For a subdomain:
- Set
base_domainto match your Route53 hosted zone domain (e.g.,"ka-cci.com")
- Set
- Update
terraform/nomad-client.tf:- Either remove
ssh_key = file("~/.ssh/id_ed25519.pub")or set it to your own public key (For ssh access onto nomad clients) - Note:
nomad_server_hostnameis now automatically set fromsubdomainandbase_domaininmain.tf
- Either remove
- Update
-
Initialize Terraform
cd terraform terraform init -
Deploy Infrastructure
terraform apply --auto-approve
After running this you might get an error that your public subnets overlap. If this is the case, bump the 3rd octet in the ip string so they don't conflict with existing an VPC setup.
-
Modify Helm values.yaml file
- Edit
k8s/applications/values.yaml:- From the terraform apply command in the previous step, take the securityGroupId and subnets, and replace the values in
machine_provisioner.providers.ec2.subnetsandmachine_provisioner.providers.ec2.securityGroupId. - Update domain configuration (must match the
subdomainyou set interraform/main.tf):- For subdomain:
global.aws.domainNameshould be"<your-subdomain>.<your-base-domain>"(e.g.,"mycci.ka-cci.com") - For root domain:
global.aws.domainNameshould be"<your-base-domain>"(e.g.,"ka-cci.com") nginx.annotations."external-dns.alpha.kubernetes.io/hostname":- For subdomain:
"<your-subdomain>.<your-base-domain>, app.<your-subdomain>.<your-base-domain>"(e.g.,"mycci.ka-cci.com, app.mycci.ka-cci.com") - For root domain:
"<your-base-domain>, app.<your-base-domain>"(e.g.,"ka-cci.com, app.ka-cci.com")
- For subdomain:
- For subdomain:
- Update the following:
argocd.repositoryglobal.clusterNameglobal.aws.regionglobal.aws.domainFilter(should matchbase_domainfrom terraform)machine_provisioner.providers.ec2.regionmachine_provisioner.providers.ec2.tags.ownerkong.acme.emailobject_storage.bucketNameobject_storage.region
- Update
object_storage.bucketNameto match your S3 bucket name. By default it will be<cluster-name>-cci
- From the terraform apply command in the previous step, take the securityGroupId and subnets, and replace the values in
- Edit
-
Push updated values to your fork
cd ../ git commit -am "Updated values.yaml" && git push
-
Connect to EKS Cluster
aws eks update-kubeconfig --name <cluster-name> --region <region>
Replace
<cluster-name>and<region>with values from your Terraform configuration. -
Set Environment Variables Get github client id/secret from: https://circleci.com/docs/server-admin/latest/installation/phase-1-aws-prerequisites/#create-a-new-github-oauth-app
And then run
export REPO_URL=https://github.com/<your-username>/support-cci-server-setup.git export GH_CLIENT_ID=<client-id> export GH_CLIENT_SECRET=<client-secret>
-
Run Bootstrap Script
cd k8s/bootstrap ./bootstrap.sh -
Wait for
kubectl get pods -n circleci-server | grep kongto be ready, then navigate to:- For subdomain: https://[your-subdomain].[yourdomain] (e.g., https://mycci.ka-cci.com if you set subdomain to "mycci")
- For root domain: https://[yourdomain] (e.g., https://ka-cci.com if you set subdomain to "")
-
(Optional) If pods are failing you will probably need to run
hacks/run-hacks.shbecause nomad server start up sometimes fails due to them not all starting at the same time.
After making any changes, push to the repository. ArgoCD will automatically apply them to the cluster (refresh interval: 3 minutes).
To force an immediate refresh:
kubectl annotate app app-of-apps -n argocd argocd.argoproj.io/refresh=normal --overwriteMonitoring will be set up after bootstrap. Run ./portforward.sh to port-forward these services:
You can then navigate to:
- argocd: https://localhost:8080
- User/Pass is admin/$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)
- jaeger: http://localhost:7070
- prometheus: https://localhost:9090
- nomad-server-ui: http://localhost:4646/ui/jobs
Known issues and workarounds:
-
nomad servers need to start up together, if they don't then you need to delete all pods See
hacks/nomad-fix.sh -
policyService doesn't currently override db with new secret See
hacks/policy-service-fix.sh