我是 Openshift 容器平台的新手。我正在尝试部署用 python 编写的 ML 模型,该模型根据 py 代码中已经提到的名称/密码身份验证来提供 Json 请求。
@app.before_request
def validate_request():
try :
if(request.authorization.username != auth_user or request.authorization.password != auth_password):
return "Authentication failed: invalid or missing user/password."
except:
return "Authentication failed: invalid or missing user/password"
现在我正在做的是,我在 Openshift 命名空间中创建一个 secret dm
并将其添加到部署中,如下所示
如何在我的 python 代码中使用此 secret 中提到的用户名和密码,我已尝试使用 the openshift doc但它没有完成我在代码中使用值的要求。
最佳答案
auth_user = os.environ.get('principle')
auth_password = os.environ.get('credential')
关于python - 如何在同一部署的 pod 中运行的 python 代码中引用 openshift 部署中提到的环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57671231/