代码之家  ›  专栏  ›  技术社区  ›  mkingston

确定Kubernetes创建的冗余GCP资源

  •  0
  • mkingston  · 技术社区  · 6 年前

    在GKE中创建各种Kubernetes对象时,将自动创建关联的GCP资源。我指的是:

    • forwarding-rules
    • target-http-proxies
    • url-maps
    • backend-services
    • health-checks

    它们的名字如 k8s-fw-service-name-tls-ingress--8473ea5ff858586b .

    删除集群后,这些资源将保留。我如何确定其中哪些(被其他kubernetes对象或其他集群使用)以及哪些不在使用中?

    2 回复  |  直到 6 年前
        1
  •  1
  •   Jason    6 年前
        2
  •  0
  •   Dhruva Sagar    6 年前

    https://github.com/kelseyhightower/kubernetes-the-hard-way/blob/master/docs/14-cleanup.md

    gcloud -q compute firewall-rules delete \
    kubernetes-the-hard-way-allow-nginx-service \
    kubernetes-the-hard-way-allow-internal \
    kubernetes-the-hard-way-allow-external \
    kubernetes-the-hard-way-allow-health-check
    
    {
      gcloud -q compute routes delete \
      kubernetes-route-10-200-0-0-24 \
      kubernetes-route-10-200-1-0-24 \
      kubernetes-route-10-200-2-0-24
    
      gcloud -q compute networks subnets delete kubernetes
    
      gcloud -q compute networks delete kubernetes-the-hard-way
    
      gcloud -q compute forwarding-rules delete kubernetes-forwarding-rule \
      --region $(gcloud config get-value compute/region)
    
      gcloud -q compute target-pools delete kubernetes-target-pool
    
      gcloud -q compute http-health-checks delete kubernetes
    
      gcloud -q compute addresses delete kubernetes-the-hard-way
    }