This project provides scripts to setup an EKS Kubernetes cluster with Crafter CMS. In specific, these scripts:
- Create an EKS Kubernetes cluster in a AWS region, with it's own VPC.
- Provision necessary AWS resources external to the cluster (ES domain, AWS Secrets, IAM users, etc.).
- Install ArgoCD for later deployment of the Crafter CMS Kubernetes resources.
- Install AWS CLI (https://aws.amazon.com/cli/)
- Install the Crafter Cloud Management Tools: https://github.com/craftersoftware/cloud-management-tools.git
- Create a fork of this repository for the client (e.g.
crafter-aws-tpci)
NOTE: This should only be run once, after the AWS account has been created. Make sure you also have setup an AWS profile in your machine for an IAM user with administrator privileges.
- Under
./scripts/account, copy theconfig.sh.offfile toconfig.ACC_ID.sh, replacingACC_IDwith a string representing an identifier for the account. For example, if the client has a separate account for QA resources, then you can name the fileconfig.qa.sh(ACC_IDcan be anything you like as long as it's different between accounts). If there's a single account, you can leaveENVempty (config.sh). - Open the config file and fill the properties appropiately. You can leave the ones that are auto-generated empty and they will be filled by the scripts automatically.
- AWS_PROFILE should be the AWS profile used to access the resources of the AWS account of the client.
- Run
./scripts/account/setup.shand follow the instructions. When being asked for the config.sh suffix, provide theACC_IDstring mentioned aboved. - Navigate to the CloudFormation tab in the AWS console to ensure that your stack is being spun up.
NOTE: This should only be run once per region.
- Under
./scripts/regions, copy theconfig.sh.offfile toconfig.REGION.sh, replacingREGIONwith a string representing an identifier for the REGION. For example, if the client plans to create clusters in us-west-2, then you can name the fileconfig.us-west-2.sh. If there's a singleREGION, you can leave it empty (config.sh). - Open the config file and fill the properties appropiately. You can leave the ones that are auto-generated empty
and they will be filled by the scripts automatically.
ALARMS_SLACK_CHANNEL_HOOK_URLandPAGER_DUTY_INTEGRATION_URLare optional. When Slack is not configured, GuardDuty notifications are sent toALARMS_EMAIL_ADDRESSinstead. - AWS_PROFILE should be the AWS profile used to access the resources of the AWS account of the client.
- Run
./scripts/regions/setup.shand follow the instructions. When being asked for the config.sh suffix, provide theREGIONstring mentioned aboved. - Navigate to the CloudFormation tab and make sure
REGIONis selected on the AWS console. Ensure that your stack creates successfully.
NOTE: Should only be run once per environment, when creating the first cluster for the config.
- Under
./scripts/environments, copy theconfig.sh.offfile toconfig.ENV.sh, replacingENVwith a string representing the environment specific resources. For example, if we're provisioning the resources for the Dev environment, then name the fileconfig.dev.sh. If there's always going to be a single environment, you can leaveENVempty (config.sh). - Open the config.sh file and fill in the properties approriately.
- For the CLIENT_ID section, the first 4/5 letters of the client will be used (For example: Crafter would be either Craf or Craft)
- Run the
./scripts/environments/setup.shscript and enter the environment's name when prompted. - Navigate to the CloudFormation tab in the AWS console to ensure that your stack is being spun up.
- Navigate to Route-53 in the AWS console and create new domain names for the client. The naming convention is $CLIENT_ID-<blue/green>.net
- Under
./scripts/clusters, copy theconfig.sh.offfile toconfig.ENV-(blue|green).sh, replacingENVwith a string representing the environment of this cluster, andblueif it's going to be the main cluster, orgreenif it's cluster that it's going to be used for testing and will eventually transition to become thebluecluster. For example, if this is going to be the Prodbluecluster, then name the fileconfig.prod-blue.sh. If there's always going to be a single environment, you can leaveENV-(blue|green)empty (config.sh). - Open the config.sh file and fill in the properties approriately. You can leave the ones that are auto-generated empty and they will be filled by the scripts automatically.
- For the AWS_AZ sections, the value is $DEFAULT_REGION<a/b/c>
- For the AWS_BACKUP_REGION, the value is the default region's closest region (us-east-1's DR would be us-east-2) OR the region the client has decided as the backup region in case of disaster recovery.
- If you don't already have them, request the mail properties from the Cloud Ops lead.
AUTHORING_DOMAIN_NAMEandDELIVERY_DOMAIN_NAMEare the Route-53 records that point to the future Authoring and Delivery ALBs (you'll create them in a future step). Normally they areENV-authoring.CLIENT_ID-(blue|green).netandENV-delivery.CLIENT_ID-(blue|green).net.ALARMS_SLACK_CHANNEL_HOOK_URLandPAGER_DUTY_INTEGRATION_URLare optional. When Slack is not configured, alarm notifications are sent toALARMS_EMAIL_ADDRESSinstead. LeavePAGER_DUTY_INTEGRATION_URLempty to skip PagerDuty notifications.- Run the
./scripts/clusters/setup.shscript and enter the environment's name when prompted.
- Add the Crafter license under
./clusters/{AWS_REGION}/{CLUSTER_NAME}/kubernetes/gitops/apps/main/craftercms/resources/common/secrets/crafter.lic.
- Make sure you commit and push the cluster config back up to the master repository before continuing with this section.
The install-argocd.sh script (run during cluster setup) already installs Argo CD via kustomize and prints the initial admin password.
After the script completes:
- Register your GitOps repository:
- SSH:
argocd repo add GITOPS_REPO_URL --ssh-private-key-path /path/to/key --name crafter-aws-CLIENT_NAME - HTTPS:
argocd repo add GITOPS_REPO_URL --username GITOPS_USER --password GITOPS_PASS --name crafter-aws-CLIENT_NAME
- SSH:
- Create and sync the bootstrap app (this creates the child Argo CD apps):
argocd app create crafter-cloud-apps \ --project default \ --repo GITOPS_REPO_URL \ --revision master \ --path clusters/CLUSTER_REGION/CLUSTER_NAME/kubernetes/gitops/apps/bootstrap \ --dest-server https://kubernetes.default.svc argocd app sync crafter-cloud-apps --prune - Sync the
aws-load-balancer-controllerapp explicitly (it is not auto-synced by bootstrap app creation):argocd app sync aws-load-balancer-controller --prune
- Wait for the
aws-load-balancer-controllerapp to be healthy:argocd app wait aws-load-balancer-controller --health
Once the AWS Load Balancer Controller is healthy, patch argocd-server from ClusterIP to a proper NLB-backed LoadBalancer service:
./scripts/clusters/kubernetes/enable-argocd-nlb.sh
You can then get the ArgoCD domain name by running:
kubectl -n argocd get svc argocd-server -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'
And finally, access the ArgoCD UI by going to https://ARGOCD_DOMAIN in your browser (ignore the certificate error the browser gives you and proceed, since ArgoCD uses a private certificate)
After login to the ArgoCD UI, you can now install the rest of the apps.
- Go through each app that's in
OutOfSyncstate andSyncit, starting with thestorage-addonsapp. Leave thecraftercmsapp last - Some apps might fail syncing. For those you might need to select
Server-side Applyunder theSync Options. - After the other apps have veen synced, sync the
craftercmsapp. - Wait for the
authoringanddeliverypods to become ready (kubectl -n craftercms get pods) - Get the Authoring LB from
k9s(by entering:ingress), or by runningkubectl -n craftercms get ingress - Finally enter
http://AUTHORING_LB/studioin your browser, Studio should appear. You should be able to login withadmin/admin(after creating the Authoring Route-53 record and setting the SSL certificate you should be able to access Authoring throughhttps://AUTHORING_DOMAIN_NAME/studio).
That's it! Crafter CMS is up and running in a Kubernetes cluster. Remember to configure the Authoring ingress at
./clusters/{CLUSTER_NAME}/kubernetes/gitops/apps/craftercms/authoring-deployment.yaml with and SSL certificate
in order to allow HTTPS access.
- Navigate to the AWS console's Certificate Manager
- Request new Certificate
- Enter the domain name (
*.craftercloud.io) (*.$CLIENT_ID-blue.net) (*.$CLIENT_ID-green.net) - If the client provides their own DNS name for Authoring and Delivery, use that instead of*.craftercloud.io - Click request
- Copy the CNAME and CNAME VALUES and place them in the managed services spreadsheet.
- Navigate to
/clusters/${cluster name}/kubernetes/gitops/apps/main/craftercms/authoring-deployment.yaml - Uncomment the lines that say to uncomment after generating the SSL cert and validating it (15-17)
- In the ARN section, paste the ARN cert in.
- Add/Commit/Push/Merge the changes back into the main repository
- Navigate back to the ArgoCD Application and click the "Refresh" button nuder the craftercms Application once the changes have been merged.
- After the refresh, Synchronize. This will spin up the authoring and delivery pods
- Search for the ingress pods in k9s and copy the Addresses for both the authoring and delivery ingresses. Paste them into the Managed Services Spreadsheet.
- Navigate to the Route-53 console in the AWS console and create a new record under the Public hosted zone. Modify the Record type to CNAME.
- In the sub domain section, add ENV-authoring, where ENV is the environment of the cluster. If it's
.craftercloud.io, it should beENV-authoring-CLIENT_ID.craftercloud.io - Repeat the same for Delivery.
- Navigate to studio
- Create a new empty site
- Publish the home page