Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Use batch/v1beta1 instead of batch/v2alpha1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
squaremo committed Jan 2, 2018
1 parent 0972ee9 commit ce3b293
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 83 deletions.
115 changes: 55 additions & 60 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
19 changes: 9 additions & 10 deletions cluster/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -38,7 +37,7 @@ type extendedClient struct {
v1core.CoreV1Interface
v1beta1extensions.ExtensionsV1beta1Interface
v1beta1apps.StatefulSetsGetter
v2alpha1batch.CronJobsGetter
v1beta1batch.CronJobsGetter
}

type apiObject struct {
Expand Down Expand Up @@ -138,7 +137,7 @@ func NewCluster(clientset k8sclient.Interface,
clientset.Core(),
clientset.Extensions(),
clientset.AppsV1beta1(),
clientset.BatchV2alpha1(),
clientset.BatchV1beta1(),
},
applier: applier,
logger: logger,
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions cluster/kubernetes/resourcekinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -222,7 +222,7 @@ func makeStatefulSetPodController(statefulSet *apiapps.StatefulSet) podControlle
}

/////////////////////////////////////////////////////////////////////////////
// batch/v2alpha1 CronJob
// batch/v1beta1 CronJob

type cronJobKind struct{}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ce3b293

Please sign in to comment.