【问题标题】:How to access the k8s services from AppEngine development server如何从 AppEngine 开发服务器访问 k8s 服务
【发布时间】:2018-07-05 19:10:54
【问题描述】:

太多的挣扎,我需要分享。

需要:dev_appserverhttps://ip_cluster_/apis/v1/xxx 上的GET/POST(用于本地测试)

错误:Invalid and/or missing SSL certificate for URL

原因:k8s 集群端点使用自动签名证书

尝试:

  • 使用 Let's Encrypt 证书和入口。失败,因为 Let's encrypt 需要 DNS
  • 要求 AppEngine 进行不安全的连接:全局与 PYTHONHTTPSVERIFY: 0main.app 和本地与 validate_certificate=Noneurl_fetchverify=Falserequests。失败,因为 AppEngine 中不允许使用带有自动签名证书的不安全 SSL 连接。公关:https://github.com/GoogleCloudPlatform/python-compat-runtime/pull/124
  • https://container.googleapis.com/v1beta1/projects/<my-gcp-project>/locations/<location>/clusters/<my-cluster> 获取证书/密钥,解码base64,写入文件,将它们与cert=('cluster_k8s.cert', 'cluster_k8s.key') 中的requests 一起使用。失败,因为在 AppEngine 中禁用了本地证书支持。将它们与 curl 一起使用就可以了。很明显。
  • 像上面一样获取证书/密钥,并将它们作为自定义证书添加到 google cloud sdk:gcloud config set core/custom_ca_certs_file=my_cert.pem。失败是因为生活艰难。
  • 像上面一样获取证书/密钥并将它们附加到谷歌云 sdk 之一: cd /usr/lib/google-cloud-sdk/platform/google_appengine/lib/cacerts/ cat my_cert >> urlfetch_cacerts.txt 失败是因为生活更加艰难。

【问题讨论】:

    标签: google-app-engine kubernetes ssl-certificate google-kubernetes-engine


    【解决方案1】:

    解决方案:使用 kubectl 代理,如 kubectl proxy --port=8001

    知道 k8s 服务可以通过 http 访问 http://localhost:8001

    在您的 AppEngine 中使用如下代码切换端点:

    if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'): # Production else: # Local development server

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-04
      • 1970-01-01
      • 2015-12-15
      • 1970-01-01
      • 2021-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多