无法在Google Cloud Platform中发起Kubernetes Federation

时间:2018-04-11 00:24:34

标签: kubernetes google-cloud-platform kubectl google-kubernetes-engine

我正在尝试设置kubernetes联合会。当我运行以下命令时,出现错误:

# Set the project and domain name
export PROJECT=abc-9102-1sf
export DNS_ZONE=echo.examplefed.com.

# Create the clusters
gcloud container clusters create west-cluster --zone us-west1-c --scopes "cloud-platform,storage-ro,logging-write,monitoring-write,service-control,service-management,https://www.googleapis.com/auth/ndev.clouddns.readwrite" --preemptible &
gcloud container clusters create east-cluster --zone us-east1-b --scopes "cloud-platform,storage-ro,logging-write,monitoring-write,service-control,service-management,https://www.googleapis.com/auth/ndev.clouddns.readwrite" --preemptible &

# Workaround for RBAC error
# https://github.com/kubernetes/kubernetes/issues/42559
gcloud config set container/use_client_certificate True
export CLOUDSDK_CONTAINER_USE_CLIENT_CERTIFICATE=True

# Get credentials
gcloud container clusters get-credentials west-cluster --zone=us-west1-c
gcloud container clusters get-credentials east-cluster --zone=us-east1-b

# Aliases
kubectl config set-context east --cluster=gke_${PROJECT}_us-east1-b_east-cluster --user=gke_${PROJECT}_us-east1-b_east-cluster
kubectl config set-context west --cluster=gke_${PROJECT}_us-west1-c_west-cluster --user=gke_${PROJECT}_us-west1-c_west-cluster

# Initiate Federation. After this step I get the error.
kubefed init kfed  --host-cluster-context=east  --dns-zone-name=${DNS_ZONE}  --dns-provider=google-clouddns

为联合系统组件创建命名空间联合系统...来自服务器的错误(禁止):禁止命名空间:用户“客户端”无法在群集范围创建命名空间:未知用户“client”。

kubefed kubectl 的版本为1.8.8:

gcp@user:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.8", GitCommit:"2f73858c9e6ede659d6828fe5a1862a48034a0fd", GitTreeState:"clean", BuildDate:"2018-02-09T21:30:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"8+", GitVersion:"v1.8.8-gke.0", GitCommit:"6e5b33a290a99c067003632e0fd6be0ead48b233", GitTreeState:"clean", BuildDate:"2018-02-16T18:26:58Z", GoVersion:"go1.8.3b4", Compiler:"gc", Platform:"linux/amd64"}
gcp@user:~$ kubefed version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.8", GitCommit:"2f73858c9e6ede659d6828fe5a1862a48034a0fd", GitTreeState:"clean", BuildDate:"2018-02-09T21:30:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"8+", GitVersion:"v1.8.8-gke.0", GitCommit:"6e5b33a290a99c067003632e0fd6be0ead48b233", GitTreeState:"clean", BuildDate:"2018-02-16T18:26:58Z", GoVersion:"go1.8.3b4", Compiler:"gc", Platform:"linux/amd64"}

1 个答案:

答案 0 :(得分:0)

花了几个小时后,我已经设法使用以下命令修复它。请注意,必须为您拥有的每个上下文执行它:

kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin --user $(gcloud config get-value account) --context east

kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin --user $(gcloud config get-value account) --context west

并且不要运行这个:

# Workaround for RBAC error
# https://github.com/kubernetes/kubernetes/issues/42559
gcloud config set container/use_client_certificate True
export CLOUDSDK_CONTAINER_USE_CLIENT_CERTIFICATE=True