From ce3b293877e8c53957a407b58d5ca49e04d91afa Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Mon, 18 Dec 2017 15:27:59 +0000 Subject: [PATCH] Use batch/v1beta1 instead of batch/v2alpha1 Not all clusters support the API batch/v2lpha1 (to wit: our own clusters don't). Instead use v1beta1, which is counter-intuitively only available in newer revisions of k8s.io/client-go. They are apparently backwards-compatible: fluxctl will happily deal with resources marked with either v1beta1 or v2alpha1, despite it using the API only for the former. Updating the client-go revision required a lot of `dep`ing around. --- Gopkg.lock | 115 +++++++++++++--------------- Gopkg.toml | 7 -- cluster/kubernetes/kubernetes.go | 19 +++-- cluster/kubernetes/resourcekinds.go | 12 +-- 4 files changed, 70 insertions(+), 83 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 4274006be..46e415db6 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -13,12 +13,6 @@ packages = ["."] revision = "de5bf2ad457846296e2031421a34e2568e304e35" -[[projects]] - name = "github.com/asaskevich/govalidator" - packages = ["."] - revision = "73945b6115bfbbcc57d89b7316e28109364124e1" - version = "v7" - [[projects]] branch = "master" name = "github.com/beorn7/perks" @@ -55,12 +49,6 @@ revision = "5741799b275a3c4a5a9623a993576d7545cf7b5c" version = "v2.4.0" -[[projects]] - name = "github.com/emicklei/go-restful-swagger12" - packages = ["."] - revision = "dcef7f55730566d41eae5db10e7d6981829720f6" - version = "1.0.1" - [[projects]] name = "github.com/ghodss/yaml" packages = ["."] @@ -79,18 +67,6 @@ revision = "390ab7935ee28ec6b286364bba9b4dd6410cb3d5" version = "v0.3.0" -[[projects]] - branch = "master" - name = "github.com/go-openapi/analysis" - packages = ["."] - revision = "8ed83f2ea9f00f945516462951a288eaa68bf0d6" - -[[projects]] - branch = "master" - name = "github.com/go-openapi/errors" - packages = ["."] - revision = "03cfca65330da08a5a440053faf994a3c682b5bf" - [[projects]] branch = "master" name = "github.com/go-openapi/jsonpointer" @@ -103,24 +79,12 @@ packages = ["."] revision = "36d33bfe519efae5632669801b180bf1a245da3b" -[[projects]] - branch = "master" - name = "github.com/go-openapi/loads" - packages = ["."] - revision = "a80dea3052f00e5f032e860dd7355cd0cc67e24d" - [[projects]] branch = "master" name = "github.com/go-openapi/spec" packages = ["."] revision = "7abd5745472fff5eb3685386d5fb8bf38683154d" -[[projects]] - branch = "master" - name = "github.com/go-openapi/strfmt" - packages = ["."] - revision = "610b6cacdcde6852f4de68998bd20ce1dac85b22" - [[projects]] branch = "master" name = "github.com/go-openapi/swag" @@ -157,12 +121,24 @@ packages = ["proto","ptypes","ptypes/any","ptypes/duration","ptypes/timestamp"] revision = "130e6b02ab059e7b717a096f397c5b60111cae74" +[[projects]] + branch = "master" + name = "github.com/google/btree" + packages = ["."] + revision = "316fb6d3f031ae8f4d457c6c5186b9e3ded70435" + [[projects]] branch = "master" name = "github.com/google/gofuzz" packages = ["."] revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1" +[[projects]] + name = "github.com/googleapis/gnostic" + packages = ["OpenAPIv2","compiler","extensions"] + revision = "ee43cbb60db7bd22502942cccbc39059117352ab" + version = "v0.1.0" + [[projects]] name = "github.com/gorilla/context" packages = ["."] @@ -181,6 +157,12 @@ revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" version = "v1.2.0" +[[projects]] + branch = "master" + name = "github.com/gregjones/httpcache" + packages = [".","diskcache"] + revision = "2bcd89a1743fd4b373f7370ce8ddc14dfbd18229" + [[projects]] branch = "master" name = "github.com/hashicorp/go-cleanhttp" @@ -193,6 +175,12 @@ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" +[[projects]] + name = "github.com/json-iterator/go" + packages = ["."] + revision = "f7279a603edee96fe7764d3de9c6ff8cf9970994" + version = "1.0.4" + [[projects]] branch = "master" name = "github.com/juju/ratelimit" @@ -217,18 +205,24 @@ revision = "3247c84500bff8d9fb6d579d800f20b3e091582c" version = "v1.0.0" -[[projects]] - branch = "master" - name = "github.com/mitchellh/mapstructure" - packages = ["."] - revision = "d0303fe809921458f417bcf828397a65db30a7e4" - [[projects]] name = "github.com/opencontainers/go-digest" packages = ["."] revision = "279bed98673dd5bef374d3b6e4b09e2af76183bf" version = "v1.0.0-rc1" +[[projects]] + branch = "master" + name = "github.com/petar/GoLLRB" + packages = ["llrb"] + revision = "53be0d36a84c2a886ca057d34b6aa4468df9ccb4" + +[[projects]] + name = "github.com/peterbourgon/diskv" + packages = ["."] + revision = "5f041e8faa004a95c88a202771f4cc3e991971e6" + version = "v2.0.1" + [[projects]] name = "github.com/pkg/errors" packages = ["."] @@ -283,11 +277,6 @@ revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" version = "v1.0.0" -[[projects]] - name = "github.com/ugorji/go" - packages = ["codec"] - revision = "8c0409fcbb70099c748d71f714529204975f6c3f" - [[projects]] branch = "master" name = "github.com/weaveworks/common" @@ -354,12 +343,6 @@ revision = "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" version = "v0.9.0" -[[projects]] - branch = "v2" - name = "gopkg.in/mgo.v2" - packages = ["bson","internal/json"] - revision = "3f83fa5005286a7fe593b055f0d7771a7dce4655" - [[projects]] branch = "v2" name = "gopkg.in/yaml.v2" @@ -367,20 +350,32 @@ revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" [[projects]] - branch = "release-1.7" + branch = "master" + name = "k8s.io/api" + packages = ["admissionregistration/v1alpha1","admissionregistration/v1beta1","apps/v1","apps/v1beta1","apps/v1beta2","authentication/v1","authentication/v1beta1","authorization/v1","authorization/v1beta1","autoscaling/v1","autoscaling/v2beta1","batch/v1","batch/v1beta1","batch/v2alpha1","certificates/v1beta1","core/v1","events/v1beta1","extensions/v1beta1","networking/v1","policy/v1beta1","rbac/v1","rbac/v1alpha1","rbac/v1beta1","scheduling/v1alpha1","settings/v1alpha1","storage/v1","storage/v1alpha1","storage/v1beta1"] + revision = "3b9b65abe0aa9d995259dad1469ff3e1f18802c5" + +[[projects]] + branch = "release-1.8" name = "k8s.io/apimachinery" - packages = ["pkg/api/equality","pkg/api/errors","pkg/api/meta","pkg/api/resource","pkg/apimachinery","pkg/apimachinery/announced","pkg/apimachinery/registered","pkg/apis/meta/v1","pkg/apis/meta/v1/unstructured","pkg/apis/meta/v1alpha1","pkg/conversion","pkg/conversion/queryparams","pkg/conversion/unstructured","pkg/fields","pkg/labels","pkg/openapi","pkg/runtime","pkg/runtime/schema","pkg/runtime/serializer","pkg/runtime/serializer/json","pkg/runtime/serializer/protobuf","pkg/runtime/serializer/recognizer","pkg/runtime/serializer/streaming","pkg/runtime/serializer/versioning","pkg/selection","pkg/types","pkg/util/clock","pkg/util/diff","pkg/util/errors","pkg/util/framer","pkg/util/intstr","pkg/util/json","pkg/util/net","pkg/util/rand","pkg/util/runtime","pkg/util/sets","pkg/util/validation","pkg/util/validation/field","pkg/util/wait","pkg/util/yaml","pkg/version","pkg/watch","third_party/forked/golang/reflect"] - revision = "8ab5f3d8a330c2e9baaf84e39042db8d49034ae2" + packages = ["pkg/api/equality","pkg/api/errors","pkg/api/meta","pkg/api/resource","pkg/apis/meta/v1","pkg/apis/meta/v1/unstructured","pkg/apis/meta/v1alpha1","pkg/conversion","pkg/conversion/queryparams","pkg/conversion/unstructured","pkg/fields","pkg/labels","pkg/runtime","pkg/runtime/schema","pkg/runtime/serializer","pkg/runtime/serializer/json","pkg/runtime/serializer/protobuf","pkg/runtime/serializer/recognizer","pkg/runtime/serializer/streaming","pkg/runtime/serializer/versioning","pkg/selection","pkg/types","pkg/util/clock","pkg/util/diff","pkg/util/errors","pkg/util/framer","pkg/util/intstr","pkg/util/json","pkg/util/net","pkg/util/runtime","pkg/util/sets","pkg/util/validation","pkg/util/validation/field","pkg/util/wait","pkg/util/yaml","pkg/version","pkg/watch","third_party/forked/golang/reflect"] + revision = "5134afd2c0c91158afac0d8a28bd2177185a3bcc" [[projects]] name = "k8s.io/client-go" - packages = ["discovery","kubernetes","kubernetes/scheme","kubernetes/typed/admissionregistration/v1alpha1","kubernetes/typed/apps/v1beta1","kubernetes/typed/authentication/v1","kubernetes/typed/authentication/v1beta1","kubernetes/typed/authorization/v1","kubernetes/typed/authorization/v1beta1","kubernetes/typed/autoscaling/v1","kubernetes/typed/autoscaling/v2alpha1","kubernetes/typed/batch/v1","kubernetes/typed/batch/v2alpha1","kubernetes/typed/certificates/v1beta1","kubernetes/typed/core/v1","kubernetes/typed/extensions/v1beta1","kubernetes/typed/networking/v1","kubernetes/typed/policy/v1beta1","kubernetes/typed/rbac/v1alpha1","kubernetes/typed/rbac/v1beta1","kubernetes/typed/settings/v1alpha1","kubernetes/typed/storage/v1","kubernetes/typed/storage/v1beta1","pkg/api","pkg/api/v1","pkg/api/v1/ref","pkg/apis/admissionregistration","pkg/apis/admissionregistration/v1alpha1","pkg/apis/apps","pkg/apis/apps/v1beta1","pkg/apis/authentication","pkg/apis/authentication/v1","pkg/apis/authentication/v1beta1","pkg/apis/authorization","pkg/apis/authorization/v1","pkg/apis/authorization/v1beta1","pkg/apis/autoscaling","pkg/apis/autoscaling/v1","pkg/apis/autoscaling/v2alpha1","pkg/apis/batch","pkg/apis/batch/v1","pkg/apis/batch/v2alpha1","pkg/apis/certificates","pkg/apis/certificates/v1beta1","pkg/apis/extensions","pkg/apis/extensions/v1beta1","pkg/apis/networking","pkg/apis/networking/v1","pkg/apis/policy","pkg/apis/policy/v1beta1","pkg/apis/rbac","pkg/apis/rbac/v1alpha1","pkg/apis/rbac/v1beta1","pkg/apis/settings","pkg/apis/settings/v1alpha1","pkg/apis/storage","pkg/apis/storage/v1","pkg/apis/storage/v1beta1","pkg/util","pkg/util/parsers","pkg/version","rest","rest/watch","tools/clientcmd/api","tools/metrics","transport","util/cert","util/flowcontrol","util/integer"] - revision = "d92e8497f71b7b4e0494e5bd204b48d34bd6f254" - version = "v4.0.0" + packages = ["discovery","kubernetes","kubernetes/scheme","kubernetes/typed/admissionregistration/v1alpha1","kubernetes/typed/admissionregistration/v1beta1","kubernetes/typed/apps/v1","kubernetes/typed/apps/v1beta1","kubernetes/typed/apps/v1beta2","kubernetes/typed/authentication/v1","kubernetes/typed/authentication/v1beta1","kubernetes/typed/authorization/v1","kubernetes/typed/authorization/v1beta1","kubernetes/typed/autoscaling/v1","kubernetes/typed/autoscaling/v2beta1","kubernetes/typed/batch/v1","kubernetes/typed/batch/v1beta1","kubernetes/typed/batch/v2alpha1","kubernetes/typed/certificates/v1beta1","kubernetes/typed/core/v1","kubernetes/typed/events/v1beta1","kubernetes/typed/extensions/v1beta1","kubernetes/typed/networking/v1","kubernetes/typed/policy/v1beta1","kubernetes/typed/rbac/v1","kubernetes/typed/rbac/v1alpha1","kubernetes/typed/rbac/v1beta1","kubernetes/typed/scheduling/v1alpha1","kubernetes/typed/settings/v1alpha1","kubernetes/typed/storage/v1","kubernetes/typed/storage/v1alpha1","kubernetes/typed/storage/v1beta1","pkg/version","rest","rest/watch","tools/clientcmd/api","tools/metrics","tools/reference","transport","util/cert","util/flowcontrol","util/integer"] + revision = "78700dec6369ba22221b72770783300f143df150" + version = "v6.0.0" + +[[projects]] + branch = "master" + name = "k8s.io/kube-openapi" + packages = ["pkg/common"] + revision = "b16ebc07f5cad97831f961e4b5a9cc1caed33b7e" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "9a246cacb3ba700c40f1d9dddaddb45729b77be85a810753503c096b2a9c70d4" + inputs-digest = "34df08675550de897967373573c4c8d6d515afb8184badc4e3e44dcec32a2561" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index ef44e8c48..a59a8a51b 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,10 +1,3 @@ -[[constraint]] - name = "k8s.io/apimachinery" - branch = "release-1.7" - -[[constraint]] - name = "k8s.io/client-go" - version = "4.0.0" [[override]] name = "github.com/ugorji/go" diff --git a/cluster/kubernetes/kubernetes.go b/cluster/kubernetes/kubernetes.go index 353c88b5e..5612381c3 100644 --- a/cluster/kubernetes/kubernetes.go +++ b/cluster/kubernetes/kubernetes.go @@ -9,16 +9,15 @@ import ( "github.com/go-kit/kit/log" "github.com/pkg/errors" "gopkg.in/yaml.v2" + apiv1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/discovery" k8sclient "k8s.io/client-go/kubernetes" v1beta1apps "k8s.io/client-go/kubernetes/typed/apps/v1beta1" - v2alpha1batch "k8s.io/client-go/kubernetes/typed/batch/v2alpha1" + v1beta1batch "k8s.io/client-go/kubernetes/typed/batch/v1beta1" v1core "k8s.io/client-go/kubernetes/typed/core/v1" v1beta1extensions "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" - "k8s.io/client-go/pkg/api" - apiv1 "k8s.io/client-go/pkg/api/v1" "github.com/weaveworks/flux" "github.com/weaveworks/flux/cluster" @@ -38,7 +37,7 @@ type extendedClient struct { v1core.CoreV1Interface v1beta1extensions.ExtensionsV1beta1Interface v1beta1apps.StatefulSetsGetter - v2alpha1batch.CronJobsGetter + v1beta1batch.CronJobsGetter } type apiObject struct { @@ -138,7 +137,7 @@ func NewCluster(clientset k8sclient.Interface, clientset.Core(), clientset.Extensions(), clientset.AppsV1beta1(), - clientset.BatchV2alpha1(), + clientset.BatchV1beta1(), }, applier: applier, logger: logger, @@ -331,11 +330,11 @@ func mergeCredentials(c *Cluster, namespace string, podTemplate apiv1.PodTemplat var ok bool // These differ in format; but, ParseCredentials will // handle either. - switch api.SecretType(secret.Type) { - case api.SecretTypeDockercfg: - decoded, ok = secret.Data[api.DockerConfigKey] - case api.SecretTypeDockerConfigJson: - decoded, ok = secret.Data[api.DockerConfigJsonKey] + switch apiv1.SecretType(secret.Type) { + case apiv1.SecretTypeDockercfg: + decoded, ok = secret.Data[apiv1.DockerConfigKey] + case apiv1.SecretTypeDockerConfigJson: + decoded, ok = secret.Data[apiv1.DockerConfigJsonKey] default: c.logger.Log("skip", "unknown type", "secret", namespace+"/"+secret.Name, "type", secret.Type) continue diff --git a/cluster/kubernetes/resourcekinds.go b/cluster/kubernetes/resourcekinds.go index 217a2cb74..e2ee3a60e 100644 --- a/cluster/kubernetes/resourcekinds.go +++ b/cluster/kubernetes/resourcekinds.go @@ -3,11 +3,11 @@ package kubernetes import ( "fmt" + apiapps "k8s.io/api/apps/v1beta1" + apibatch "k8s.io/api/batch/v1beta1" + apiv1 "k8s.io/api/core/v1" + apiext "k8s.io/api/extensions/v1beta1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - apiv1 "k8s.io/client-go/pkg/api/v1" - apiapps "k8s.io/client-go/pkg/apis/apps/v1beta1" - apibatch "k8s.io/client-go/pkg/apis/batch/v2alpha1" - apiext "k8s.io/client-go/pkg/apis/extensions/v1beta1" "github.com/weaveworks/flux" "github.com/weaveworks/flux/cluster" @@ -222,7 +222,7 @@ func makeStatefulSetPodController(statefulSet *apiapps.StatefulSet) podControlle } ///////////////////////////////////////////////////////////////////////////// -// batch/v2alpha1 CronJob +// batch/v1beta1 CronJob type cronJobKind struct{} @@ -251,7 +251,7 @@ func (dk *cronJobKind) getPodControllers(c *Cluster, namespace string) ([]podCon func makeCronJobPodController(cronJob *apibatch.CronJob) podController { return podController{ - apiVersion: "batch/v2alpha1", + apiVersion: "batch/v1beta1", kind: "CronJob", name: cronJob.ObjectMeta.Name, status: StatusReady,