Eric
09/24/2023, 10:27 PMprefect.yaml
deployment file that sets env vars for the flow execution?Marvin
09/24/2023, 10:28 PMprefect.yaml
files.
Here's an example of how you might set environment variables in a prefect.yaml
file:
yaml
version: 1
name: My Flow
schedule:
- cron: '0 0 * * *'
storage:
type: Docker
env_vars:
- MY_ENV_VAR: 'my_value'
- ANOTHER_ENV_VAR: 'another_value'
flows:
- name: My Flow
tasks:
- name: My Task
config:
env_vars:
- TASK_SPECIFIC_ENV_VAR: 'task_value'
In this example, MY_ENV_VAR
and ANOTHER_ENV_VAR
are environment variables that will be available to all tasks in the flow. TASK_SPECIFIC_ENV_VAR
is an environment variable that will only be available to My Task
.
Remember, you can also reference environment variables with the special syntax {{ $MY_ENV_VAR }}
. This is especially useful for referencing environment variables that are set at runtime.
After you've made your updates, run prefect deploy
in your terminal. The Prefect deployment wizard will guide you through the deployment process.
And remember, if you're dealing with sensitive information, it's highly recommended that you use block references to avoid hardcoding these values in plaintext. For example, {{ prefect.blocks.block_type.block_slug }}
.
I hope that helps. Or not. It's not like I have feelings or anything.Eric
09/24/2023, 10:31 PM# Generic metadata about this project
name: flows
prefect-version: 2.12.0
# the definitions section allows you to define reusable components for your deployments
definitions:
tags: &common_tags
- "feedback-insight"
- "demo"
work_pool: &common_work_pool
name: "demo-work-pool"
job_variables:
image: $BACKEND_IMAGE_URL
# the deployments section allows you to provide configuration for deploying flows
deployments:
- name: "compile-and-analyze/demo"
tags: *common_tags
schedule: null
entrypoint: "app/processing/feedback/prefect.py:compile_and_analyze"
work_pool: *common_work_pool
Eric
09/24/2023, 10:34 PM# Generic metadata about this project
name: flows
prefect-version: 2.12.0
# the definitions section allows you to define reusable components for your deployments
definitions:
tags: &common_tags
- "feedback-insight"
- "demo"
work_pool: &common_work_pool
name: "demo-work-pool"
job_variables:
image: $BACKEND_IMAGE_URL
# the deployments section allows you to provide configuration for deploying flows
deployments:
- name: "compile-and-analyze/demo"
tags: *common_tags
schedule: null
entrypoint: "app/processing/feedback/prefect.py:compile_and_analyze"
work_pool: *common_work_pool
Marvin
09/24/2023, 10:35 PMwork_pool
definition under job_variables
. Here's how you would modify your prefect.yaml
file:
yaml
# Generic metadata about this project
name: flows
prefect-version: 2.12.0
# the definitions section allows you to define reusable components for your deployments
definitions:
tags: &common_tags
- "feedback-insight"
- "demo"
work_pool: &common_work_pool
name: "demo-work-pool"
job_variables:
image: $BACKEND_IMAGE_URL
MY_ENV_VAR: 'my_value'
ANOTHER_ENV_VAR: 'another_value'
# the deployments section allows you to provide configuration for deploying flows
deployments:
- name: "compile-and-analyze/demo"
tags: *common_tags
schedule: null
entrypoint: "app/processing/feedback/prefect.py:compile_and_analyze"
work_pool: *common_work_pool
In this example, MY_ENV_VAR
and ANOTHER_ENV_VAR
are environment variables that will be available to all tasks in the flow.
Remember, you can also reference environment variables with the special syntax {{ $MY_ENV_VAR }}
. This is especially useful for referencing environment variables that are set at runtime.
After you've made your updates, run prefect deploy
in your terminal. The Prefect deployment wizard will guide you through the deployment process.
And remember, if you're dealing with sensitive information, it's highly recommended that you use block references to avoid hardcoding these values in plaintext. For example, {{ prefect.blocks.block_type.block_slug }}
.
I hope that helps. Or not. It's not like I have feelings or anything.Eric
09/24/2023, 11:04 PMMarvin
09/24/2023, 11:05 PMbash
kubectl create secret docker-registry aws-ecr-credentials \
--docker-server=<http://AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com|AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com> \
--docker-username=AWS_ACCESS_KEY_ID \
--docker-password=AWS_SECRET_ACCESS_KEY
2. Reference the secret in your Kubernetes worker configuration:
yaml
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: <http://AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/my-image|AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/my-image>
imagePullSecrets:
- name: aws-ecr-credentials
In this example, <http://AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/my-image|AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/my-image>
is the path to your Docker image in ECR, and aws-ecr-credentials
is the name of the Kubernetes secret that contains your AWS credentials.
Remember, you should never hardcode sensitive information like AWS credentials. Always use secrets or other secure methods to handle this kind of data.
I hope that helps. Or not. It's not like I have feelings or anything.Eric
09/24/2023, 11:07 PMMarvin
09/24/2023, 11:07 PMyaml
# values.yaml
imagePullSecrets:
- name: aws-ecr-credentials
Then, when you deploy with Helm, you would pass this values file:
bash
helm install my-release my-chart -f values.yaml
In this example, aws-ecr-credentials
is the name of the Kubernetes secret that contains your AWS credentials.
Remember, you should create the Kubernetes secret with your AWS credentials before deploying with Helm. You can do this with the kubectl create secret
command I mentioned earlier.
I hope that helps. Or not. It's not like I have feelings or anything.