【问题标题】:How to update loggingService of container.v1.cluster with deployment-manager如何使用部署管理器更新 container.v1.cluster 的 loggingService
【发布时间】:2020-02-18 16:02:22
【问题描述】:

我想通过部署管理器设置现有 container.v1.cluster 的 loggingService 字段。 我有以下配置

resources:                                                                      
- name: px-cluster-1                                                            
  type: container.v1.cluster                                                    
  properties:                                                                   
    zone: europe-west1-b                                                        
    cluster:                                                                    
      description: "dev cluster"                                                
      initialClusterVersion: "1.13"                                             
      nodePools:                                                                
        - name: cluster-pool                                                    
          config:                                                               
            machineType: "n1-standard-1"                                        
            oauthScopes:                                                        
            - https://www.googleapis.com/auth/compute                           
            - https://www.googleapis.com/auth/devstorage.read_only              
            - https://www.googleapis.com/auth/logging.write                     
            - https://www.googleapis.com/auth/monitoring                        
          management:                                                           
            autoUpgrade: true                                                   
            autoRepair: true                                                    
          initialNodeCount: 1                                                   
          autoscaling:                                                          
            enabled: true                                                       
            minNodeCount: 3                                                     
            maxNodeCount: 10                                                    
      ipAllocationPolicy:                                                       
        useIpAliases: true                                                      
      loggingService: "logging.googleapis.com/kubernetes"                       
      masterAuthorizedNetworksConfig:                                           
        enabled: false                                
      locations:                                                                
        - "europe-west1-b"                                                      
        - "europe-west1-c"

当我尝试运行 gcloud deployment-manager deployments update ... 时,出现以下错误

ERROR: (gcloud.deployment-manager.deployments.update) Error in Operation [operation-1582040492957-59edb819a5f3c-7155f798-5ba37285]: errors:
- code: NO_METHOD_TO_UPDATE_FIELD
  message: No method found to update field 'cluster' on resource 'px-cluster-1' of
    type 'container.v1.cluster'. The resource may need to be recreated with the new
    field.

如果我删除 loggingService,同样会成功。

有没有办法在不删除集群的情况下使用部署管理器更新 loggingService?

【问题讨论】:

    标签: google-deployment-manager


    【解决方案1】:

    错误 NO_METHOD_TO_UPDATE_FIELD 是由于您在向 GKE 发出更新调用时更新了“initialClusterVersion”。该字段仅在创建集群时使用,类型定义目前不允许稍后更新。因此,它应该保持原始值不变,并且不会影响向前的部署或尝试删除/评论该行。

    即使前面的条目为真,也没有更新日志服务的方法,实际上部署管理器没有很多更新方法,所以,尝试使用 gcloud 命令直接更新集群,记住你必须同时使用监控服务和日志服务,所以,突击队看起来像:

    gcloud 容器集群更新 px-cluster-1 --logging-service=logging.googleapis.com/kubernetes --monitoring-service=monitoring.googleapis.com/kubernetes --zone=europe-west1-b

    【讨论】:

    • 我已经从我的问题的配置中删除了 initialClusterVersion。我仍然遇到同样的错误。
    • 您的架构文件中是否将其作为默认设置?因为它可能也在那里
    • 我没有为这个模板使用架构文件,所以我不这么认为。
    • 但是您使用的是 .py 文件,不是吗?可以分享一下吗?
    • 龙太郎,经过多次测试和研究,我更新了答案,希望对你有用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-19
    • 1970-01-01
    相关资源
    最近更新 更多