簡體   English   中英

GCP Google Cloud - 無法創建負載均衡器

[英]GCP Google Cloud - Cannot create Load Balancer

因此,我開始嘗試解決我公司網站上的一個簡單問題。 HTTP 未重定向到 HTTPS。

為了解決這個問題,我嘗試刪除 HTTPS 負載均衡器,以便我可以使用重定向重新創建它。

但是,現在,3 天后,另一個開發人員和我自己無法重新創建它,也無法弄清楚原因。

當我嘗試創建負載均衡器時,出現錯誤:

Invalid value for field 'resource.IPAddress': 'projects/bes-com/global/addresses/bes-load-balancer-ip'. Specified IP address is in-use and would result in a conflict.

如果我從 go 到 IP 地址,指定的 IP 地址顯示“ In use by : None

我還嘗試使用新的 IP 地址而不是當前地址重新創建負載均衡器,但這個也不起作用。

有了這個,我得到:

Operation type [patch] failed with message "Validation failed for instance 'projects/bes-com/zones/us-central1-c/instances/gke-bes-com-bes-com-n-37339480-9xpj': instance may belong to at most one load-balanced instance group."

如果我 go 到 Ingress,它在頂部有這個錯誤:

Error syncing to GCP: error running backend syncing routine: received errors when updating backend service: googleapi: Error 400: INSTANCE_IN_MULTIPLE_LOAD_BALANCED_IGS - Validation failed for instance 'projects/bes-com/zones/us-central1-c/instances/gke-bes-com-bes-com-n-37339480-9xpj': instance may belong to at most one load-balanced instance group. googleapi: Error 400: INSTANCE_IN_MULTIPLE_LOAD_BALANCED_IGS

請注意,我沒有創建此網站。 我繼承了它,並且是 GCP 的新手,所以我正在學習 go。 但是,我必須讓這個網站備份,不知道下一步 go 在哪里。 感謝您的幫助,請讓我知道我可以展示什么。

注意:確保您的域可通過 https 訪問,並且 Google 托管證書已處於活動狀態並已完全傳播。 此外,這些步驟是故障排除步驟的一部分。 它被發布為答案,因為它不適合評論部分 如果您有任何問題或澄清,您可以在評論部分回復。

我要求您列出后端服務,以便您確認多個后端服務中沒有使用 MIG。

如果您使用 YAML 進行部署,我建議使用此過程作為參考。 Since your primary concern is the redirection from HTTP to HTTPs, let me share some basic configuration in deploying GKE redirection using an existing static frontend static IP address and managed SSL certificate.

1. In Cloud shell. Execute below commands to point which region and cluster you’re working on.
gcloud config set compute/zone us-central1-a
gcloud container clusters get-credentials test-gke

test-gke > your existing cluster 
us-central1-a  > “test-gke” cluster region

2. In Cloud shell, create redirection YAML file

sudo nano web-redirect.yaml

web-redirect.yaml  > preferred YAML filename

3. Copy paste below lines

apiVersion: networking.gke.io/v1beta1
kind: FrontendConfig
metadata:
 name: my-frontend-config
spec:
 redirectToHttps:
   enabled: true
   responseCodeName: PERMANENT_REDIRECT

my-frontend-config > preferred name for frontend config
PERMANENT_REDIRECT > for http - https redirection. To return a 308 redirect response code.

4. Save the web-redirect.yaml file. Press ctrl + o to write the lines, then Enter to verify the filename lastly ctrl + x to exit.

5. Apply the resource to the cluster 
kubectl apply -f web-redirect.yaml

6. Modify your existing ingress yaml (sample: web-ingress.yaml)
sudo nano web-ingress.yaml

7. Add the annotation to use the manifested FrontendConfig:
Sample modified ingress YAML:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: basic-ingress
  annotations:
    networking.gke.io/v1beta1.FrontendConfig: "my-frontend-config"
    kubernetes.io/ingress.global-static-ip-name: "bes-load-balancer-ip"
    networking.gke.io/managed-certificates: "managed-cert"
    kubernetes.io/ingress.class: "gce"
spec:
  defaultBackend:
    service:
      name: web
      port:
        number: 8080

my-frontend-config  > FrontendConfig metadata name in web-redirect.yaml
web > name of service deployed in your cluster
bes-load-balancer-ip> name of reserve external IP
managed-cert > name of managed certificate

8. Save the existing ingress.yaml file. Press ctrl + o to write the lines, then Enter to verify the filename lastly ctrl + x to exit.

9. Apply the resource to the cluster:
kubectl apply -f <ingress.yaml>

有關更多信息,您可以查看這些文檔HTTP 到 HTTPS 重定向,並告別即興的 HTTPS 重定向解決方法

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM