Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在同一部署的pod中运行的python代码中引用openshift部署中提到的环境变量_Python_Image_Containers_Openshift_Kubernetes Secrets - Fatal编程技术网

如何在同一部署的pod中运行的python代码中引用openshift部署中提到的环境变量

如何在同一部署的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):

我是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名称空间中创建一个secretr
dm
,并将其添加到部署中,如下所示


在我的python代码中,如何使用这个秘密中提到的用户名和密码,我已经尝试过了,但它没有满足我在代码中使用值的要求。

可能是重复的哦,是的,Philip,这很简单。
auth_user = os.environ.get('principle')
auth_password = os.environ.get('credential')