docs/concepts/jcloud/index.md
(jcloud)=
:hidden:
configuration
:width: 0 %
:scale: 0 %
:scale: 0 %
:width: 0 %
After building a Jina-serve project, the next step is to deploy and host it on the cloud. Jina AI Cloud is Jina-serve's reliable, scalable and production-ready cloud-hosting solution that manages your project lifecycle without surprises or hidden development costs.
Are you ready to unlock the power of AI with Jina AI Cloud? Take a look at our [pricing options](https://cloud.jina.ai/pricing) now!
In addition to deploying Flows, jcloud supports the creation of secrets and jobs which are created in the Flow's namespace.
Jina AI Cloud provides a CLI that you can use via jina cloud from the terminal (or jcloud or simply jc for minimalists.)
You can also install just the JCloud CLI without installing the Jina-serve package.
```bash
pip install jcloud
jc -h
```
If you installed the JCloud CLI individually, all of its commands fall under the `jc` or `jcloud` executable.
In case the command `jc` is already occupied by another tool, use `jcloud` instead. If your pip install doesn't register bash commands for you, you can run `python -m jcloud -h`.
For the rest of this section, we use jc or jcloud. But again they are interchangeable with jina cloud.
In Jina's idiom, a project is a Flow, which represents an end-to-end task such as indexing, searching or recommending. In this document, we use "project" and "Flow" interchangeably.
A Flow can have two types of file structure: a single YAML file or a project folder.
A self-contained YAML file, consisting of all configuration at the Flow-level and Executor-level.
All Executors'
usesmust follow the formatjinaai+docker://<username>/MyExecutor(from Executor Hub) to avoid any local file dependencies:
# flow.yml
jtype: Flow
executors:
- name: sentencizer
uses: jinaai+docker://jina-ai/Sentencizer
To deploy:
jc flow deploy flow.yml
When `jcloud` deploys a flow it automatically appends the following global arguments to the `flow.yml`, if not present:
```yaml
jcloud:
version: jina-version
docarray: docarray-version
```
The `jina` and `docarray` corresponds to your development environment's `jina` and `docarray` versions.
We recommend testing locally before deployment:
```bash
jina flow --uses flow.yml
```
The best practice for creating a Jina AI Cloud project is to use:
```bash
jc new
```
This ensures the correct project structure that is accepted by Jina AI Cloud.
Just like a regular Python project, you can have sub-folders of Executor implementations and a flow.yml on the top-level to connect all Executors together.
You can create an example local project using jc new hello. The default structure looks like:
hello/
├── .env
├── executor1
│ ├── config.yml
│ ├── executor.py
│ └── requirements.txt
└── flow.yml
Where:
hello/ is your top-level project folder.executor1 directory has all Executor related code/configuration. You can read the best practices for file structures. Multiple Executor directories can be created.flow.yml Your Flow YAML..env All environment variables used during deployment.To deploy:
jc flow deploy hello
The Flow is successfully deployed when you see:
:width: 70%
You will get a Flow ID, say merry-magpie-82b9c0897f. This ID is required to manage, view logs and remove the Flow.
As this Flow is deployed with the default gRPC gateway (feel free to change it to http or websocket), you can use jina.Client to access it:
from jina import Client, Document
print(
Client(host='grpcs://merry-magpie-82b9c0897f.wolf.jina.ai').post(
on='/', inputs=Document(text='hello')
)
)
(jcloud-flow-status)=
To get the status of a Flow:
jc flow status merry-magpie-82b9c0897f
:width: 70%
Basic monitoring is provided to Flows deployed on Jina AI Cloud.
To access the Grafana-powered dashboard, first get {ref}the status of the Flow<jcloud-flow-status>. The Grafana Dashboard link is displayed at the bottom of the pane. Visit the URL to find basic metrics like 'Number of Request Gateway Received' and 'Time elapsed between receiving a request and sending back the response':
:width: 80%
To list all of your "Starting", "Serving", "Failed", "Updating", and "Paused" Flows:
jc flows list
:width: 90%
You can also filter your Flows by passing a phase:
jc flows list --phase Deleted
:width: 90%
Or see all Flows:
jc flows list --phase all
:width: 90%
You can remove a single Flow, multiple Flows or even all Flows by passing different identifiers.
To remove a single Flow:
jc flow remove merry-magpie-82b9c0897f
To remove multiple Flows:
jc flow remove merry-magpie-82b9c0897f wondrous-kiwi-b02db6a066
To remove all Flows:
jc flow remove all
By default, removing multiple or all Flows is an interactive process where you must give confirmation before each Flow is deleted. To make it non-interactive, set the below environment variable before running the command:
export JCLOUD_NO_INTERACTIVE=1
You can update a Flow by providing an updated YAML.
To update a Flow:
jc flow update super-mustang-c6cf06bc5b flow.yml
:width: 70%
You have the option to pause a Flow that is not currently in use but may be needed later. This will allow the Flow to be resumed later when it is needed again by using resume.
To pause a Flow:
jc flow pause super-mustang-c6cf06bc5b
:width: 70%
To resume a Flow:
jc flow resume super-mustang-c6cf06bc5b
:width: 70%
If you need to restart a Flow, there are two options: restart all Executors and the Gateway associated with the Flow, or selectively restart only a specific Executor or the Gateway.
To restart a Flow:
jc flow restart super-mustang-c6cf06bc5b
:width: 70%
To restart the Gateway:
jc flow restart super-mustang-c6cf06bc5b --gateway
:width: 70%
To restart an Executor:
jc flow restart super-mustang-c6cf06bc5b --executor executor0
:width: 70%
To recreate a deleted Flow:
jc flow recreate profound-rooster-eec4b17c73
:width: 70%
You can also manually scale any Executor.
jc flow scale good-martin-ca6bfdef84 --executor executor0 --replicas 2
:width: 70%
To normalize a Flow:
jc flow normalize flow.yml
Normalizing a Flow is the process of building the Executor image and pushing the image to Hubble.
To get the Gateway logs:
jc flow logs --gateway central-escargot-354a796df5
:width: 70%
To get the Executor logs:
jc flow logs --executor executor0 central-escargot-354a796df5
:width: 70%
To create a Secret for a Flow:
jc secret create mysecret rich-husky-af14064067 --from-literal "{'env-name': 'secret-value'}"
You can optionally pass the `--update` flag to automatically update the Flow spec with the updated secret information. This flag will update the Flow which is hosted on the cloud. Finally, you can also optionally pass a Flow's yaml file path with `--path` to update the yaml file locally. Refer to [this](https://jina.ai/serve/cloud-nativeness/kubernetes/#deploy-flow-with-custom-environment-variables-and-secrets) section for more information.
If the `--update` flag is not passed then you have to manually update the flow with `jc update flow rich-husky-af14064067 updated-flow.yml`
To list all the Secrets created in a Flow's namespace:
jc secret list rich-husky-af14064067
:width: 90%
To retrieve a Secret's details:
jc secret get mysecret rich-husky-af14064067
:width: 90%
jc secret remove rich-husky-af14064067 mysecret
You can update a Secret for a Flow.
jc secret update rich-husky-af14064067 mysecret --from-literal "{'env-name': 'secret-value'}"
You can optionally pass the `--update` flag to automatically update the Flow spec with the updated secret information. This flag will update the Flow which is hosted on the cloud. Finally, you can also optionally pass a Flow's yaml file path with `--path` to update the yaml file locally. Refer to [this](https://jina.ai/serve/cloud-nativeness/kubernetes/#deploy-flow-with-custom-environment-variables-and-secrets) section for more information.
Updating a Secret automatically restarts a Flow.
To create a Job for a Flow:
jc job create job-name rich-husky-af14064067 image 'job entrypoint' --timeout 600 --backofflimit 2
`image` can be any Executor image passed to a Flow's Executor `uses` or any normal docker image prefixed with `docker://`
To listg all Jobs created in a Flow's namespace:
jc jobs list rich-husky-af14064067
:width: 90%
To retrieve a Job's details:
jc job get myjob1 rich-husky-af14064067
:width: 90%
jc job remove rich-husky-af14064067 myjob1
To get the Job logs:
jc job logs myjob1 -f rich-husky-af14064067
:width: 90%
When `jcloud` deploys a deployment it automatically appends the following global arguments to the `deployment.yml`, if not present:
jcloud:
version: jina-version
docarray: docarray-version
A self-contained YAML file, consisting of all configuration information at the Deployment-level and Executor-level.
A Deployment's
usesparameter must follow the formatjinaai+docker://<username>/MyExecutor(from Executor Hub) to avoid any local file dependencies:
# deployment.yml
jtype: Deployment
with:
protocol: grpc
uses: jinaai+docker://jina-ai/Sentencizer
To deploy:
jc deployment deploy ./deployment.yaml
The Deployment is successfully deployed when you see:
:width: 70%
You will get a Deployment ID, for example pretty-monster-130a5ac952. This ID is required to manage, view logs, and remove the Deployment.
Since this Deployment is deployed with the default gRPC protocol (feel free to change it to http), you can use jina.Client to access it:
from jina import Client, Document
print(
Client(host='grpcs://executor-pretty-monster-130a5ac952.wolf.jina.ai').post(
on='/', inputs=Document(text='hello')
)
)
(jcloud-deployoment-status)=
To get the status of a Deployment:
jc deployment status pretty-monster-130a5ac952
:width: 70%
To list all of your "Starting", "Serving", "Failed", "Updating", and "Paused" Deployments:
jc deployment list
:width: 90%
You can also filter your Deployments by passing a phase:
jc deployment list --phase Deleted
:width: 90%
Or see all Deployments:
jc deployment list --phase all
:width: 90%
You can remove a single Deployment, multiple Deployments, or even all Deployments by passing different commands to the jc executable at the command line.
To remove a single Deployment:
jc deployment remove pretty-monster-130a5ac952
To remove multiple Deployments:
jc deployment remove pretty-monster-130a5ac952 artistic-tuna-ab154c4dcc
To remove all Deployments:
jc deployment remove all
By default, removing all or multiple Deployments is an interactive process where you must give confirmation before each Deployment is deleted. To make it non-interactive, set the below environment variable before running the command:
export JCLOUD_NO_INTERACTIVE=1
You can update a Deployment by providing an updated YAML.
To update a Deployment:
jc deployment update pretty-monster-130a5ac952 deployment.yml
:width: 70%
You have the option to pause a Deployment that is not currently in use but may be needed later. This will allow the Deployment to be resumed later when it is needed again by using resume.
To pause a Deployment:
jc deployment pause pretty-monster-130a5ac952
:width: 70%
To resume a Deployment:
jc eployment resume pretty-monster-130a5ac952
:width: 70%
To restart a Deployment:
jc deployment restart pretty-monster-130a5ac952
:width: 70%
To recreate a deleted Deployment:
jc deployment recreate pretty-monster-130a5ac952
:width: 70%
You can also manually scale any Deployment.
jc deployment scale pretty-monster-130a5ac952 --replicas 2
:width: 70%
To get the Deployment logs:
jc deployment logs pretty-monster-130a5ac952
:width: 70%
Please refer to {ref}Configuration <jcloud-configuration> for configuring the Flow on Jina AI Cloud.
Jina AI Cloud scales according to your needs. You can demand different instance types with GPU/memory/CPU predefined based on the needs of your Flows and Executors. If you have specific resource requirements, please contact us on Discord or raise a GitHub issue.
- Deployments are only supported in the `us-east` region.