From 400bc8e386ffcd765fb0c92934724b152fcb93b9 Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Tue, 26 Mar 2024 11:46:38 +0800 Subject: [PATCH 1/4] deploying agents in the sandbox Signed-off-by: Future-Outlier --- .../deploying_agents_to_flyte_sandbox.md | 98 +++++++++++++++++++ docs/flyte_agents/index.md | 3 + 2 files changed, 101 insertions(+) create mode 100644 docs/flyte_agents/deploying_agents_to_flyte_sandbox.md diff --git a/docs/flyte_agents/deploying_agents_to_flyte_sandbox.md b/docs/flyte_agents/deploying_agents_to_flyte_sandbox.md new file mode 100644 index 0000000000..662c89e589 --- /dev/null +++ b/docs/flyte_agents/deploying_agents_to_flyte_sandbox.md @@ -0,0 +1,98 @@ +--- +jupytext: + formats: md:myst + text_representation: + extension: .md + format_name: myst +--- + +(deploying_agents_to_the_flyte_sandbox)= +# Deploying agents to the Flyte Sandbox + +After you have finished {ref}`testing an agent locally ` and {ref}`testing agents in the development environment `,you can deploy your agent to the flyte sandbox. + +Here's a step by step guide to deploy your agent image to the flyte sandbox. + +1. Start the flyte sandbox. +```bash +flytectl demo start +``` + +2. Build an agent image. +You can go to [here](https://github.com/flyteorg/flytekit/blob/master/Dockerfile.agent) to see the dockerfile we use in flytekit python. +Take Databricks agent as an example. +```Dockerfile +FROM python:3.9-slim-bookworm + +RUN apt-get update && apt-get install build-essential git -y +RUN pip install prometheus-client grpcio-health-checking +RUN pip install --no-cache-dir -U flytekit \ + git+https://github.com/flyteorg/flytekit.git@#subdirectory=plugins/flytekit-spark \ + && apt-get clean autoclean \ + && apt-get autoremove --yes \ + && rm -rf /var/lib/{apt,dpkg,cache,log}/ \ + && : + +CMD pyflyte serve agent --port 8000 +``` +```bash +docker buildx build -t localhost:30000/flyteagent:example -f Dockerfile.agent . --load +docker push localhost:30000/flyteagent:example +``` + +2. Deploy your agent image to the kubernetes cluster +```bash +kubectl edit deployment flyteagent -n flyte +``` +Search the `image` key, and replace its value to your agent image. +```yaml +image: localhost:30000/flyteagent:example +``` + +3. Set up your secrets +Let's take databricks agent as the example. +```bash +kubectl edit secret flyteagent -n flyte +``` +Get your `BASE64_ENCODED_DATABRICKS_TOKEN`. +```bash +echo -n "" | base64 +``` +Add your token to the `data` field. +```yaml +apiVersion: v1 +data: + flyte_databricks_access_token: +kind: Secret +metadata: + annotations: + meta.helm.sh/release-name: flyteagent + meta.helm.sh/release-namespace: flyte + creationTimestamp: "2023-10-04T04:09:03Z" + labels: + app.kubernetes.io/managed-by: Helm + name: flyteagent + namespace: flyte + resourceVersion: "753" + uid: 5ac1e1b6-2a4c-4e26-9001-d4ba72c39e54 +type: Opaque +``` +:::{note} +Please ensure 2 things. +1. The secret name consists only of lowercase English letters. +2. The secret value is encoded in Base64. +::: + +4. Restart development +```bash +kubectl rollout restart deployment flyte-sandbox -n flyte +``` + +5. Test your agent remotely in flyte sandbox +```bash +pyflyte run --remote agent_workflow.py agent_task +``` + +:::{note} +Please ensure you've built an image and specified it by `--image` flag or use ImageSpec to include the plugin for the task. +::: diff --git a/docs/flyte_agents/index.md b/docs/flyte_agents/index.md index 293f661be9..e381be724a 100644 --- a/docs/flyte_agents/index.md +++ b/docs/flyte_agents/index.md @@ -37,6 +37,8 @@ For a list of agents you can use in your tasks and example usage for each, see t - Whether using an existing agent or developing a new one, you can test the agent locally without needing to configure your Flyte deployment. * - {doc}`Enabling agents in your Flyte deployment ` - Once you have tested an agent locally and want to use it in production, you must configure your Flyte deployment for the agent. +* - {doc}`Deploying agents to the Flyte Sandbox ` + - Once you have tested an agent locally and want to use it in production, you must want to test it in sandbox. ``` ```{toctree} @@ -46,4 +48,5 @@ For a list of agents you can use in your tasks and example usage for each, see t developing_agents testing_agents_locally enabling_agents_in_your_flyte_deployment +deploying_agents_to_the_flyte_sandbox ``` From f5eb22edb41aaf2fbd1fc7060a4eaf23449b76a4 Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Tue, 26 Mar 2024 14:28:28 +0800 Subject: [PATCH 2/4] rename Signed-off-by: Future-Outlier --- ..._flyte_sandbox.md => deploying_agents_to_the_flyte_sandbox.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/flyte_agents/{deploying_agents_to_flyte_sandbox.md => deploying_agents_to_the_flyte_sandbox.md} (100%) diff --git a/docs/flyte_agents/deploying_agents_to_flyte_sandbox.md b/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md similarity index 100% rename from docs/flyte_agents/deploying_agents_to_flyte_sandbox.md rename to docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md From 537465a204493ee9eae3bc5a9df172a09e43df1f Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Tue, 26 Mar 2024 14:46:04 +0800 Subject: [PATCH 3/4] nit Signed-off-by: Future-Outlier --- docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md | 2 +- docs/flyte_agents/enabling_agents_in_your_flyte_deployment.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md b/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md index 662c89e589..ba3316f48a 100644 --- a/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md +++ b/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md @@ -9,7 +9,7 @@ jupytext: (deploying_agents_to_the_flyte_sandbox)= # Deploying agents to the Flyte Sandbox -After you have finished {ref}`testing an agent locally ` and {ref}`testing agents in the development environment `,you can deploy your agent to the flyte sandbox. +After you have finished {ref}`testing an agent locally `, you can deploy your agent to the flyte sandbox. Here's a step by step guide to deploy your agent image to the flyte sandbox. diff --git a/docs/flyte_agents/enabling_agents_in_your_flyte_deployment.md b/docs/flyte_agents/enabling_agents_in_your_flyte_deployment.md index f50b740a21..add7c2598c 100644 --- a/docs/flyte_agents/enabling_agents_in_your_flyte_deployment.md +++ b/docs/flyte_agents/enabling_agents_in_your_flyte_deployment.md @@ -6,7 +6,7 @@ jupytext: format_name: myst --- -(enabling_agents_in_your_flyte_deploymen)= +(enabling_agents_in_your_flyte_deployment)= # Enabling agents in your Flyte deployment After you have finished {ref}`testing an agent locally `, you can enable the agent in your Flyte deployment to use it in production. To enable a particular agent in your Flyte deployment, see the [Agent setup guide](https://docs.flyte.org/en/latest/deployment/agents/index.html) for the agent. From 128985662086ff44833ac904dc4bf63fcdf89bfa Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 28 Mar 2024 03:24:54 -0700 Subject: [PATCH 4/4] nit Signed-off-by: Kevin Su --- .../deploying_agents_to_the_flyte_sandbox.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md b/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md index ba3316f48a..13e4ffa3f6 100644 --- a/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md +++ b/docs/flyte_agents/deploying_agents_to_the_flyte_sandbox.md @@ -11,7 +11,7 @@ jupytext: After you have finished {ref}`testing an agent locally `, you can deploy your agent to the flyte sandbox. -Here's a step by step guide to deploy your agent image to the flyte sandbox. +Here's a step by step guide to deploy your agent to the flyte sandbox. 1. Start the flyte sandbox. ```bash @@ -42,11 +42,7 @@ docker push localhost:30000/flyteagent:example 2. Deploy your agent image to the kubernetes cluster ```bash -kubectl edit deployment flyteagent -n flyte -``` -Search the `image` key, and replace its value to your agent image. -```yaml -image: localhost:30000/flyteagent:example +kubectl set image deployment/flyteagent flyteagent=localhost:30000/flyteagent:example ``` 3. Set up your secrets @@ -79,7 +75,7 @@ type: Opaque ``` :::{note} Please ensure 2 things. -1. The secret name consists only of lowercase English letters. +1. The secret name should not include uppercase English letters. 2. The secret value is encoded in Base64. :::