Skip to main content

deployment_create

A deployment it's the action to upload a release of code to a scope If the deployment it's initial it will be finalized automatically but it can be cancelled If the deployment it's blue green It can be cancelled or finalized, also by default you can manage the ammount of traffic that goes to the new deployment

It's important to notice that deployments works over releases and not builds. A release is created using a build as reference

Important Requirements for Kubernetes (k8s) Scopes

If you're deploying to a Kubernetes scope, make sure your application meets these requirements:

  • Dockerfile Required: Your application must include a Dockerfile in the repository for building the Docker image
  • Listen Port: Your application should typically listen on port 8080
  • Health Endpoint: Your application must expose a /health endpoint that returns a successful status (200 OK) for health checks

If you want to create a deployment, you can use: Api:

Method: POST
Endpoint: /deployment
Body:'{
"scope_id": "<scope_id>",
"release_id": "<release_id>",
"asset_name": "<asset_name>" //Optional if the scope has not be deployed before you can see the available assets from build
}'

Np Cli:

np deployment create  --body '{
"scope_id": "<scope_id>",
"release_id": "<release_id>",
"asset_name": "<asset_name>" //Optional if the scope has not be deployed before you can see the available assets from build
}'

if you need to create a release, you can use:

Api Call:

Method: POST
Endpoint: /release
Body: '{
"status":"active",
"build_id": "<build_id>",
"application_id": <application_id>,
"semver": <semver to use>, //Usually you can check the last release
}'

Np Cli:

np release create  --body '{
"status":"active",
"build_id": "<build_id>",
application_id: <application_id>,
semver: <semver to use>, //Usually you can check the last release and use the next semver
}'

You can list the builds which have a commit id reference using (check all the available options with np build list --help): example:

Api Call:

Method: GET
Endpoint: /build?application_id=<application_id>

Np Cli:

np build list --application_id <application_id> 

If you want to cancel a deployment, you can use: Api Call:

Method: PATCH
Endpoint: /deployment/:id
Body: '{
"status": "cancelling"
}'

Np Cli:

np deployment patch --id <deployment_id> --body '{
"status": "cancelling"
}'

if you want to finalize a deployment you can use: Api Call:

Method: PATCH
Endpoint: /deployment/:id
Body: '{
"status": "finalizing"
}'

Np Cli:

np deployment patch --id <deployment_id> --body '{
"status": "finalizing"
}'