我该如何定义伊瓜齐奥的秘密?它们是集群范围的,还是仅仅是项目级的?一旦这个秘密被定义,我如何在我的工作中使用它?如果分布的作业有很多播客/工作人员,比如星火和达斯克,我能用这些框架的秘密吗?
谢谢。
发布于 2022-06-25 00:00:00
你可以在伊瓜齐奥定义一个秘密。您可以在项目级别或群集级别定义秘密。为了在项目级别定义一个秘密,下面是一个示例代码片段:
# Create project secrets for the myproj project
project = mlrun.get_or_create_project("myproj", "./")
secrets = {'AWS_KEY': '111222333'}
project.set_secrets(secrets=secrets, provider="kubernetes")
# Create and run the MLRun job
function = mlrun.code_to_function(
name="secret_func",
filename="my_code.py",
handler="test_function",
kind="job",
image="mlrun/mlrun"
)
function.run()MLRun提供了将外部创建的k8s秘密映射到正在执行的作业的工具。
function = mlrun.code_to_function(
name="secret_func",
handler="test_function",
...
)
function.set_env_from_secret(
"SECRET_ENV_VAR_1", secret="my-secret", secret_key="secret1"
)然后,您将在这样的函数中使用这个秘密:
# Function handler
def test_function(context):
# Getting the value in the secret2 key.
my_secret_value = os.environ.get("SECRET_ENV_VAR_2")
...https://stackoverflow.com/questions/72746425
复制相似问题