How to Deploy Services
Deployer gives you a toolset for deploying Kubernetes resources. You can get started by following these three steps:
- Create a deployment target description.
- Optionally, enable debugging with hot code reload.
- Bring up the target.
- Manage your deployment.
Prerequisites
Before using Deployer, you must install the Terminal Client on your machine and set up a Kubernetes cluster you want to deploy to using Skyramp.
1. Create a Deployment Target Description
- Create a folder called
targets
at the root of your microservice repository. This folder will store your target description files. - Inside the
targets
folder, create a target description file (e.g.helm-demo.yaml
) to describe the target you want to deploy. - Customize the target description file to match your deployment needs.
Example:
namespace: helm-namespace
containers:
- type: helm
releaseName: my-release
path: charts/test1
valuesPath: files/values.yaml
values:
server:
enabled: true
service:
port: 10000
service:
port: 5000
type: ClusterIP
includes:
- Deployment/my-release-test1
- Job/* # include all jobs
- server/* # include subchart server with all subresources
Modify the values according to your specific deployment requirements. The target description file includes:
- The
namespace
field, which defines the target Kubernetes namespace. - The
containers
section, where you configure the deployment settings, including the release name (releaseName
), the path to your Helm charts (path
), an optional values file path (valuesPath
), and additional values to override (values
). - The
includes
field (alternatively,excludes
), which specifies the resources to include in the deployment. You can specify specific resources or use the*
wildcard to include matching resources.
Learn more about what you can configure in your target description in Target Description ».
Enable Debugging with Hot Code Reload (Optional)
Deployer supports a powerful debugging feature known as Hot Code Reload. This feature allows you to debug your services in real-time without the need for re-deployments. You can attach your debugger, step through code, and make changes while your service is running.
A visual walkthrough of the Hot Code Reload feature is available in this video:
To enable Hot Code Reload, include a debug
section in your target description file under containers
.
Example:
debug:
- containerName: Deployment/my-service
runtimeType: go
command: myservice
debugPort: 33333
mountPaths:
- /workspaces/myproject/src/myservice
With this debug section, you can enable Hot Code Reload for debugging purposes. Here’s a breakdown of the parameters you can configure in the debug section:
containerName
: The name of the container to use in debug mode.runtimeType
: The runtime type of your service, such asgo
,node
, orpython
.command
: The application entry point that will run in a loop, relative to the first path specified inmountPaths
.debugPort
: The local port of the running service to debug.mountPaths
: Path(s) mounted to the remote container.
With Hot Code Reload, any code changes you make will immediately take effect, streamlining your debugging process.
2. Bring Up the Target
Run the up
command to deploy the target, replacing helm-demo
with your target name:
skyramp deployer up helm-demo
Deployer will read the target description file and launch the deployment process. It will handle the deployment of Helm charts using the configurations from your target description. Deployer will create or update the necessary Kubernetes resources, removing the need for manual management.
Tip
To deploy mocks for excluded service dependencies, take advantage of our custom tool Mocker.3. Manage Your Deployment
View the Status of Deployments
Once you have run deployer up
on a target, you can view the status of the deployment by running the status
command:
skyramp deployer status
This will output the status of the deployment in a digestible table format.
Tear Down the Target
After testing or when you’re done with the deployment, you can bring down the target using the down
command:
skyramp deployer down helm-demo
Deployer will clean up all the resources deployed using the skyramp deployer up
command.
That’s it! With these steps, you can quickly start using Deployer to simplify the deployment of your Kubernetes resources.