如何在同一部署的pod中运行的python代码中引用openshift部署中提到的环境变量
我是Openshift容器平台的新手。我正在尝试部署用python编写的ML模型,该模型基于py代码中已经提到的名称/密码身份验证服务Json请求如何在同一部署的pod中运行的python代码中引用openshift部署中提到的环境变量,python,image,containers,openshift,kubernetes-secrets,Python,Image,Containers,Openshift,Kubernetes Secrets,我是Openshift容器平台的新手。我正在尝试部署用python编写的ML模型,该模型基于py代码中已经提到的名称/密码身份验证服务Json请求 @app.before_request def validate_request(): try : if(request.authorization.username != auth_user or request.authorization.password != auth_password):
@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名称空间中创建一个secretrdm
,并将其添加到部署中,如下所示
在我的python代码中,如何使用这个秘密中提到的用户名和密码,我已经尝试过了,但它没有满足我在代码中使用值的要求。可能是重复的哦,是的,Philip,这很简单。
auth_user = os.environ.get('principle')
auth_password = os.environ.get('credential')