Python 引用模板的输出
我有一个部署管理器脚本,如下所示: cluster.py创建一个kubernetes集群,当脚本仅为k8集群创建运行时,它是成功的——因此这意味着cluster.py在创建k8集群时没有问题Python 引用模板的输出,python,google-cloud-platform,yaml,google-kubernetes-engine,google-deployment-manager,Python,Google Cloud Platform,Yaml,Google Kubernetes Engine,Google Deployment Manager,我有一个部署管理器脚本,如下所示: cluster.py创建一个kubernetes集群,当脚本仅为k8集群创建运行时,它是成功的——因此这意味着cluster.py在创建k8集群时没有问题 cluster.py还公开输出: cluster.py的一个小片段如下所示: outputs.append({ 'name': 'v1endpoint' , 'value': type_name + type_suffix }) return {'resou
cluster.py
还公开输出:
cluster.py的一个小片段如下所示:
outputs.append({
'name': 'v1endpoint' ,
'value': type_name + type_suffix })
return {'resources': resources, 'outputs': outputs}
如果我试图以$(ref.dmcluster.v1endpoint)
的形式访问下面dmnginxservice
资源中公开的输出,我会收到一个错误,因为找不到资源
imports:
- path: cluster.py
- path: nodeport.py
resources:
- name: dmcluster
type: cluster.py
properties:
zone: us-central1-a
- name: dmnginxservice
type: nodeport.py
properties:
cluster: $(ref.dmcluster.v1endpoint)
image: gcr.io/pr1/nginx:latest
port: 342
nodeport: 32123
ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1519960432614-566655da89a70-a2f917ad-69eab05a]: errors:
- code: CONDITION_NOT_MET
message: Referenced resource yaml%dmcluster could not be found. At resource
gke-cluster-dmnginxservice.
我试图复制一个类似的实现,并且我能够毫无问题地部署它,将您的sintax用于输出 我部署了2个虚拟机和一个新网络。我会把我的代码发布给你,也许你会发现一些关于输出的有趣提示
- 第一个VM作为输出传递第二个VM的名称,并使用来自网络的引用
- 第二个VM从第一个VM的输出中填充的属性中获取名称
- 由于参考文献,网络是第一个被创建的网络
dmnginxservice
取决于dmcluster
使用。通过这种方式,您可以再次检查它是否正在等待第一个资源
更新
我已经能够用一个更简单的配置来重现这个bug,这基本上取决于我引用变量的方式,行为是不同的,出于某种原因,属性被扩展到$(ref.yaml%vm-1.paolo)
,似乎项目和集群引用的组合会带来麻烦
#'name': context.properties["debug"],WORKING
#'name': context.env["project"],WORKING
'name': context.properties["debug"]+context.env["project"],#NOT WORKING
如果需要,可以检查配置 您好,如果不包含任何合理的数据,您能否同时提供cluster.py和nodeport.py?我想用你的代码或类似的版本重现这个问题。如果stackoverflow太长,您可以在这里跳过它。要点可以在这里找到:基本上,k8.yaml正在尝试引用输出属性v1endpoint,当google部署管理器尝试创建dmnginxservice时,我看到一个错误,即在gist中未找到dmcluster。k8.yaml--dmnginxservice中的属性是cluster而不是ClusterTypeGIST的链接现在可以了。谢谢您的更新。我在Deployment Manager问题列表上提交了一篇类似的帖子。这个bug在它们的末尾也是可以复制的。你能不能发布一下你的配置要点@gallocedrone?