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 kubectl (https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- Install eksctl (https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html)
- Install k9s (https://github.com/derailed/k9s)
- Install jq (https://stedolan.github.io/jq/download/)
- 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.off
file toconfig.ACC_ID.sh
, replacingACC_ID
with 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_ID
can be anything you like as long as it's different between accounts). If there's a single account, you can leaveENV
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.
- AWS_PROFILE should be the AWS profile used to access the resources of the AWS account of the client. It can be setup with
aws --profile CLIENT_PROFILE configure
- Run
./scripts/account/setup.sh
and follow the instructions. When being asked for the config.sh suffix, provide theACC_ID
string mentioned aboved. - Navigate to the CloudFormation tab in the AWS console to ensure that your stack is being spun up.
NOTE: Should only be run once per environment, when creating the first cluster for the config.
- Under
./scripts/environments
, copy theconfig.sh.off
file toconfig.ENV.sh
, replacingENV
with 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 leaveENV
empty (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.sh
script 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.off
file toconfig.ENV-(blue|green).sh
, replacingENV
with a string representing the environment of this cluster, andblue
if it's going to be the main cluster, orgreen
if it's cluster that it's going to be used for testing and will eventually transition to become theblue
cluster. For example, if this is going to be the Prodblue
cluster, 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.
- 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.
- Run the
./scripts/clusters/setup.sh
script 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 push the cluster back up to the master repository before continuing with this section.
-
In another terminal, start port-forward connection
kubectl port-forward svc/argocd-server -n argocd 18080:443
-
Login to ArgoCD at http://localhost:18080 from your browser
-
Click on the gears icon on the left nav bar (Settings), then Repositories.
-
Connect to the repo at
GITOPS_REPO_URL
, either through SSH or HTTPs.- Name: crafter-aws-{CLIENT_NAME}
- Project: default
- Repository URL: URL of the repository you connected to previously
- SSH Private key data: Private key (Given beforehand)
-
Click on
Create
-
Create
crafter-cloud-app
by clicking theNEW APP
icon on the Applications page. Fill the following configurations and the leave the rest as default.- Name: crafter-cloud-apps
- Project: default
- Repository URL: URL of the repository you connected to previously
- Revision: master
- Path: clusters/
CLUSTER_REGION
/CLUSTER_NAME
/kubernetes/gitops/apps/bootstrap - Cluster URL: https://kubernetes.default.svc
-
Click on
Sync
and thenSynchronize
in thecrafter-cloud-apps
app. All the Kubernetes addons and the
- Commit the change and push it to the repo. Click on the
Refresh
button ofcraftercms
app. - Click on
Sync
and thenSynchronize
on thecraftercms
app. - Get the Authoring LB from
k9s
(by entering:ingress
), or by runningkubectl -n craftercms get ingress
- Finally enter
http://AUTHORING_LB/studio
in your browser, Studio should appear. You should be able to login withadmin/admin
.
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 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