nutritious-rocket-28038
08/30/2025, 1:57 AMancient-wolf-19325
08/30/2025, 1:57 AMancient-wolf-19325
08/30/2025, 1:58 AMContainerTask
that runs a git checkout
before executing your main command, and you can manage secrets for a private git repo by injecting credentials as secrets. You would define a Kubernetes secret containing your git credentials (e.g., SSH key or personal access token), then request this secret in your ContainerTask
and mount it as an environment variable or file, making it accessible to the git command. The secret is referenced in the secret_requests
argument, and Flyte will inject it into the container at runtime. For example, you might use a secret named git-creds
with a key ssh_key
and mount it as a file, then configure your git command to use this key.
Here is a conceptual example (note: the exact syntax for ContainerTask
secret mounting is not fully detailed in the data sources, but the approach is supported for Python tasks and should be similar for ContainerTask
):
from flytekit import Secret, ContainerTask
git_checkout_task = ContainerTask(
name="git_checkout_task",
image="ubuntu:20.04",
command=["/bin/bash", "-c"],
args=[
"""
mkdir -p ~/.ssh && \
echo "$GIT_SSH_KEY" > ~/.ssh/id_rsa && \
chmod 600 ~/.ssh/id_rsa && \
git clone git@github.com:yourorg/yourrepo.git && \
cd yourrepo && \
<your-command-here>
"""
],
secret_requests=[
Secret(group="git-creds", key="ssh_key", mount_requirement=Secret.MountType.ENV_VAR)
],
)
You would create the secret in Kubernetes with:
kubectl create secret generic git-creds --from-literal=ssh_key='<your-private-key>' -n <namespace>
This approach is based on the secret management documentation and examples for Python tasks, which also apply to container-based tasks as of recent Flyte versions. For more details, see the Flyte secrets documentation and related issues.
Would you like more detail or a more specific example for your use case?
Sources:
- Flyte secrets documentation
- Flytesnacks use_secrets.py example
- related issues š 0 button š 0 button š” Hint: Mention @runllm in the thread for followups.