kubernetes-retired / cluster-registry

[EOL] Cluster Registry API
https://kubernetes.github.io/cluster-registry/
Apache License 2.0
238 stars 94 forks source link

kubefed2 join fails with gke clusters #264

Closed danehans closed 5 years ago

danehans commented 5 years ago

kubefed2 join does not work with gke clusters:

k8s v1.11:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.2-gke.4", GitCommit:"bb037862be432125e098164b4fec8d45c3a43407", GitTreeState:"clean", BuildDate:"2018-08-29T23:15:26Z", GoVersion:"go1.10.3b4", Compiler:"gc", Platform:"linux/amd64"}

fed-v2 master branch:

$ git log --oneline
b8b49c97 Merge pull request #301 from pmorie/doc-readme

I successfully create the registry ns, crd, and cluster role binding:

$ kubectl create ns kube-multicluster-public
namespace/kube-multicluster-public created

$ kubectl apply --validate=false -f vendor/k8s.io/cluster-registry/cluster-registry-crd.yaml 
customresourcedefinition.apiextensions.k8s.io/clusters.clusterregistry.k8s.io created

$ kubectl create clusterrolebinding federation-admin --clusterrole=cluster-admin \
>     --serviceaccount="federation-system:default"
clusterrolebinding.rbac.authorization.k8s.io/federation-admin created

I get the following error when trying to add the 1st cluster:

$ ./bin/kubefed2 join cluster1 --cluster-context cluster1 \
>     --host-cluster-context cluster1 --add-to-registry --v=2
I1004 09:29:46.316699   54078 join.go:141] Args and flags: name cluster1, host: cluster1, host-system-namespace: federation-system, registry-namespace: kube-multicluster-public, kubeconfig: , cluster-context: cluster1, secret-name: , limited-scope: false, dry-run: false
I1004 09:29:46.322189   54078 join.go:195] Performing preflight checks.
I1004 09:29:46.847440   54078 join.go:283] Registering cluster: cluster1 with the cluster registry.
I1004 09:29:47.214533   54078 join.go:287] Could not register cluster: cluster1 with the cluster registry: the server could not find the requested resource (post clusters.clusterregistry.k8s.io)
F1004 09:29:47.214579   54078 join.go:117] error: the server could not find the requested resource (post clusters.clusterregistry.k8s.io)

The crd exists:

$ kubectl get crd | grep reg
clusters.clusterregistry.k8s.io                                   2018-10-04T16:27:24Z

The kube config matches the kubefed2 join flags:

$ kubectl config get-contexts
CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
          cluster1   cluster1   cluster1   
*         cluster2   cluster2   cluster2   

I can add the cluster to the registry manually:

$ cat cluster-reg.yaml
apiVersion: clusterregistry.k8s.io/v1alpha1
kind: Cluster
metadata:
  name: cluster1
  namespace: kube-multicluster-public
spec:
  authInfo: {}
  kubernetesApiEndpoints:
    serverEndpoints:
      - clientCIDR: "0.0.0.0/0"
        serverAddress: "https://<SNIP>"

$ kubectl apply -f cluster-reg.yaml 
cluster.clusterregistry.k8s.io/cluster1 created

$ kubectl get clusters -n kube-multicluster-public -o yaml
apiVersion: v1
items:
- apiVersion: clusterregistry.k8s.io/v1alpha1
  kind: Cluster
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"clusterregistry.k8s.io/v1alpha1","kind":"Cluster","metadata":{"annotations":{},"name":"cluster1","namespace":"kube-multicluster-public"},"spec":{"authInfo":{},"kubernetesApiEndpoints":{"serverEndpoints":[{"clientCIDR":"0.0.0.0/0","serverAddress":"https://35.203.129.80"}]}}}
    creationTimestamp: 2018-10-04T17:08:01Z
    generation: 1
    name: cluster1
    namespace: kube-multicluster-public
    resourceVersion: "170570"
    selfLink: /apis/clusterregistry.k8s.io/v1alpha1/namespaces/kube-multicluster-public/clusters/cluster1
    uid: 0cc43b02-c7f8-11e8-9b5d-42010a8a0277
  spec:
    authInfo: {}
    kubernetesApiEndpoints:
      serverEndpoints:
      - clientCIDR: 0.0.0.0/0
        serverAddress: https://35.203.129.80
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

/sig multicluster

danehans commented 5 years ago

User error and created the issue in the wrong repo.