In addition to Core Services, CX Cloud makes it really easy for you to deploy any Docker-based service. You just need to follow a few simple steps to deploy a service:
Make sure your project has a
Dockerfile (this is just an example):
FROM nginxCOPY html /usr/share/nginx/htmlEXPOSE 80
Create a file named
.cxcloud.yaml in the root of your project:
deployment:name: my-frontendimage:name: my-frontend-imagerepository: YOUR_AWS_ECR_REPOSITORY_URL_HEREversion: 1.1.1containerPort: 80replicas: 2env:- name: NODE_ENVvalue: production
Run CX Cloud deployment tool:
$ cxcloud deploy
Your service will be deployed to your Kubernetes cluster.
.cxcloud.yaml file has different configurable sections:
The name of your service to be saved in Kubernetes
The name of your docker image
Your AWS ECR Repository
A version to tag your docker image with
Your Dockerfile's exposed port
Number of replicas to be made (usually more than 1 just to be safe)
A list of environment variables that will be attached to your deployment
You can use Bash environment variables anywhere in this file. Just prefix a string with
$ to denote it:
There are a few special environment variables that are available to be used:
For example you can set those environment variables on runtime:
$ MY_BASH_ENV=frontend cxcloud deploy
deployment.env option in the deployment manifest can be used to pass environment variables to your docker container when it's deployed to your Kubernetes cluster. This can be useful for passing things like secrets, environment config, etc.
deployment:# ...env:- name: NODE_ENVvalue: production- name: MY_SECRET_KEYvalue: $SECRET_BASH_ENV
You can pass environment variables also when running the
cxcloud deploy command:
$ cxcloud deploy -e MY_SECRET_KEY=something
You can pass multiple environment variables using commas.
Now that you have deployed your service, you can make it available to the world by creating a routing manifest. Read more about that in it's section.