gpt4 book ai didi

kubernetes - G8 v1.16.13-gke.401中不提供K8S api cloud.google.com

转载 作者:行者123 更新时间:2023-12-02 12:09:29 27 4
gpt4 key购买 nike

我正在尝试在GKE群集v1.16.13-gke.401上创建BackendConfig资源,但它给了我以下错误:

unable to recognize "backendconfig.yaml": no matches for kind "BackendConfig" in version "cloud.google.com/v1"
我已经使用 kubectl api-versions命令检查了可用的api,但是cloud.google.com不可用。如何启用它?
我想创建一个BackendConfig,并进行如下自定义健康检查:
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: my-backendconfig
spec:
healthCheck:
checkIntervalSec: 8
timeoutSec: 1
healthyThreshold: 1
unhealthyThreshold: 3
type: HTTP
requestPath: /health
port: 10257
将此BackendConfig附加到这样的服务上:
apiVersion: v1
kind: Service
metadata:
annotations:
cloud.google.com/backend-config: '{"default": "my-backendconfig"}'

最佳答案

如评论中所述,问题是由于群集中缺少HTTP Load Balancing附加组件引起的。
使用所有默认设置创建GKE集群时,将启用HTTP Load Balancing之类的功能。

The HTTP Load Balancing add-on is required to use the Google Cloud Load Balancer with Kubernetes Ingress. If enabled, a controller will be installed to coordinate applying load balancing configuration changes to your GCP project


可以在 GKE documentation中找到更多详细信息。
为了进行测试,我创建了没有 Cluster-1附加组件的 HTTP Load Balancing。没有 BackendConfig CRD- Custom Resource Definition

The CustomResourceDefinition API resource allows you to define custom resources. Defining a CRD object creates a new custom resource with a name and schema that you specify. The Kubernetes API serves and handles the storage of your custom resource. The name of a CRD object must be a valid DNS subdomain name.


没有 BackendConfig和没有 cloud apiVersion,如下所示
user@cloudshell:~ (k8s-tests-XXX)$ kubectl get crd | grep backend
user@cloudshell:~ (k8s-tests-XXX)$ kubectl api-versions | grep cloud
我无法创建任何 BackendConfig
user@cloudshell:~ (k8s-tests-XXX) $ kubectl apply -f bck.yaml
error: unable to recognize "bck.yaml": no matches for kind "BackendConfig" in version "cloud.google.com/v1"
要使其工作,必须启用HTTP Load Balancing 。可以通过UI或命令来实现。
使用用户界面:

Navigation Menu > Clusters > [Cluster-Name] > Details > Clikc onEdit > Scroll down to Add-ons and expand > Find HTTP load balancing and change from Disabled to Enabled.


或命令:
gcloud beta container clusters update <clustername> --update-addons=HttpLoadBalancing=ENABLED --zone=<your-zone>

$ gcloud beta container clusters update cluster-1 --update-addons=HttpLoadBalancing=ENABLED --zone=us-central1-c
WARNING: Warning: basic authentication is deprecated, and will be removed in GKE control plane versions 1.19 and newer. For a list of recommended authentication methods, see: https://cloud.google.com/kubernetes-engine/docs/how-to/api-server-authentication
一段时间后,启用附加组件时:
$ kubectl get crd | grep backend
backendconfigs.cloud.google.com 2020-10-23T13:09:29Z
$ kubectl api-versions | grep cloud
cloud.google.com/v1
cloud.google.com/v1beta1
$ kubectl apply -f bck.yaml
backendconfig.cloud.google.com/my-backendconfig created

关于kubernetes - G8 v1.16.13-gke.401中不提供K8S api cloud.google.com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64440761/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com