Skip to content

Commit

Permalink
feat: Update k8s 1.10 (#29)
Browse files Browse the repository at this point in the history
* chore: Update vendor

* feat: Update k8s 1.10
  • Loading branch information
yejiayu authored and Jun Zhang committed Apr 20, 2018
1 parent 88d1d51 commit 57eb5a1
Show file tree
Hide file tree
Showing 6,146 changed files with 1,753,173 additions and 502,235 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
384 changes: 172 additions & 212 deletions Gopkg.lock

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


[[constraint]]
branch = "master"
branch = "release-1.10"
name = "github.com/caicloud/clientset"

[[constraint]]
Expand All @@ -37,14 +37,6 @@
branch = "master"
name = "github.com/golang/glog"

[[constraint]]
branch = "release-1.7"
name = "k8s.io/apimachinery"

[[constraint]]
name = "k8s.io/client-go"
version = "4.0.0"

[[constraint]]
name = "k8s.io/helm"
branch = "release-2.5"
Expand Down
27 changes: 13 additions & 14 deletions cmd/controller/app/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import (
"github.com/caicloud/rudder/pkg/kube"
"github.com/caicloud/rudder/pkg/store"
"github.com/golang/glog"

apps "k8s.io/api/apps/v1"
batch "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
apiv1 "k8s.io/client-go/pkg/api/v1"
corev1 "k8s.io/client-go/pkg/api/v1"
appsv1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
batchv1 "k8s.io/client-go/pkg/apis/batch/v1"
batchv2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
extensionsv1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/tools/clientcmd"
)

Expand Down Expand Up @@ -102,19 +101,19 @@ func AvailableKinds() []schema.GroupVersionKind {
return []schema.GroupVersionKind{
releaseapi.SchemeGroupVersion.WithKind("Release"),
releaseapi.SchemeGroupVersion.WithKind("ReleaseHistory"),
batchv2alpha1.SchemeGroupVersion.WithKind("CronJob"),
extensionsv1beta1.SchemeGroupVersion.WithKind("DaemonSet"),
appsv1beta1.SchemeGroupVersion.WithKind("Deployment"),
batchv1.SchemeGroupVersion.WithKind("Job"),
appsv1beta1.SchemeGroupVersion.WithKind("StatefulSet"),
apiv1.SchemeGroupVersion.WithKind("Service"),
corev1.SchemeGroupVersion.WithKind("PersistentVolumeClaim"),
batchv1beta1.SchemeGroupVersion.WithKind("CronJob"),
apps.SchemeGroupVersion.WithKind("DaemonSet"),
apps.SchemeGroupVersion.WithKind("Deployment"),
batch.SchemeGroupVersion.WithKind("Job"),
apps.SchemeGroupVersion.WithKind("StatefulSet"),
core.SchemeGroupVersion.WithKind("Service"),
core.SchemeGroupVersion.WithKind("PersistentVolumeClaim"),
}
}

// IgnoredKinds provides kinds which need be ignored when deleted.
func IgnoredKinds() []schema.GroupVersionKind {
return []schema.GroupVersionKind{
corev1.SchemeGroupVersion.WithKind("PersistentVolumeClaim"),
core.SchemeGroupVersion.WithKind("PersistentVolumeClaim"),
}
}
8 changes: 4 additions & 4 deletions pkg/kube/apply/pvc.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package apply

import (
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
apiv1 "k8s.io/client-go/pkg/api/v1"
)

func init() {
RegisterApplier(apiv1.SchemeGroupVersion.WithKind("PersistentVolumeClaim"), applyPVC)
RegisterApplier(core.SchemeGroupVersion.WithKind("PersistentVolumeClaim"), applyPVC)
}

func applyPVC(current, desired runtime.Object) error {
if current == nil || desired == nil {
return nil
}
// PVC's spec is immutable.
co := current.(*apiv1.PersistentVolumeClaim)
do := desired.(*apiv1.PersistentVolumeClaim)
co := current.(*core.PersistentVolumeClaim)
do := desired.(*core.PersistentVolumeClaim)
do.Spec = co.Spec
return nil
}
12 changes: 6 additions & 6 deletions pkg/kube/apply/service.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package apply

import (
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
apiv1 "k8s.io/client-go/pkg/api/v1"
)

func init() {
RegisterApplier(apiv1.SchemeGroupVersion.WithKind("Service"), applyService)
RegisterApplier(core.SchemeGroupVersion.WithKind("Service"), applyService)
}

func applyService(current, desired runtime.Object) error {
if current == nil || desired == nil {
return nil
}
co := current.(*apiv1.Service)
do := desired.(*apiv1.Service)
co := current.(*core.Service)
do := desired.(*core.Service)
do.ResourceVersion = co.ResourceVersion
do.Spec.ClusterIP = co.Spec.ClusterIP
if do.Spec.Type == apiv1.ServiceTypeNodePort &&
co.Spec.Type == apiv1.ServiceTypeNodePort {
if do.Spec.Type == core.ServiceTypeNodePort &&
co.Spec.Type == core.ServiceTypeNodePort {
portsMap := map[int32]int32{}
for _, port := range co.Spec.Ports {
portsMap[port.Port] = port.NodePort
Expand Down
8 changes: 4 additions & 4 deletions pkg/kube/apply/ss.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package apply

import (
apps "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/runtime"
appsv1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
)

func init() {
RegisterApplier(appsv1.SchemeGroupVersion.WithKind("StatefulSet"), applyStatefulSet)
RegisterApplier(apps.SchemeGroupVersion.WithKind("StatefulSet"), applyStatefulSet)
}

func applyStatefulSet(current, desired runtime.Object) error {
if current == nil || desired == nil {
return nil
}
co := current.(*appsv1.StatefulSet)
do := desired.(*appsv1.StatefulSet)
co := current.(*apps.StatefulSet)
do := desired.(*apps.StatefulSet)
replicas := do.Spec.Replicas
template := do.Spec.Template
updateStrategy := do.Spec.UpdateStrategy
Expand Down
4 changes: 2 additions & 2 deletions pkg/kube/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"fmt"
"sync"

core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
corev1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/rest"
)

Expand Down Expand Up @@ -65,7 +65,7 @@ func (cp *clientPool) ClientFor(gvk schema.GroupVersionKind, namespace string) (
client, ok := cp.clients[gvk]
if !ok {
conf := *cp.config
if gvk.Group == corev1.SchemeGroupVersion.Group {
if gvk.Group == core.SchemeGroupVersion.Group {
conf.APIPath = "/api"
} else {
conf.APIPath = "/apis"
Expand Down
10 changes: 2 additions & 8 deletions pkg/release/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@ import (
"github.com/caicloud/rudder/pkg/storage"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes/scheme"
)

// applyRelease wouldn't delete anything. It leaves all antiquated resources to GC. So GC should take
// latest releases and delete useless resource.
func (rc *releaseContext) applyRelease(backend storage.ReleaseStorage, release *releaseapi.Release) error {
// Deep copy release. Avoid modifying original release.
ins, err := scheme.Scheme.Copy(release)
if err != nil {
glog.V(4).Infof("Failed to deep copy release %s/%s", release.Namespace, release.Name)
return err
}
release = ins.(*releaseapi.Release)
release = release.DeepCopy()

var manifests []string
if release.Spec.RollbackTo != nil {
Expand Down Expand Up @@ -99,7 +93,7 @@ func (rc *releaseContext) applyRelease(backend storage.ReleaseStorage, release *
glog.Infof("Failed to apply resources for release %s/%s: %v", release.Namespace, release.Name, err)
return recordError(backend, err)
}
_, err = backend.FlushConditions(storage.ConditionAvailable())
_, err := backend.FlushConditions(storage.ConditionAvailable())
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/release/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/caicloud/rudder/pkg/render"
"github.com/caicloud/rudder/pkg/storage"
"github.com/golang/glog"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
apiv1 "k8s.io/client-go/pkg/api/v1"
)

func (rc *releaseContext) updateRelease(backend storage.ReleaseStorage, release *releaseapi.Release) error {
Expand Down Expand Up @@ -77,21 +77,21 @@ func (rc *releaseContext) updateRelease(backend storage.ReleaseStorage, release
// fix modifies new object.
func (rc *releaseContext) fix(origin, new, current runtime.Object) error {
switch origin.GetObjectKind().GroupVersionKind() {
case apiv1.SchemeGroupVersion.WithKind("Service"):
case core.SchemeGroupVersion.WithKind("Service"):
// Fix service when convert NodePort to ClusterIP.
o, ok := origin.(*apiv1.Service)
o, ok := origin.(*core.Service)
if !ok {
return fmt.Errorf("can't convert origin object %v to service", origin.GetObjectKind())
}
n, ok := new.(*apiv1.Service)
n, ok := new.(*core.Service)
if !ok {
return fmt.Errorf("can't convert new object %v to service", new.GetObjectKind())
}
c, ok := current.(*apiv1.Service)
c, ok := current.(*core.Service)
if !ok {
return fmt.Errorf("can't convert current object %v to service", current.GetObjectKind())
}
if o.Spec.Type == apiv1.ServiceTypeNodePort && n.Spec.Type == apiv1.ServiceTypeClusterIP {
if o.Spec.Type == core.ServiceTypeNodePort && n.Spec.Type == core.ServiceTypeClusterIP {
// Set NodePort for origin object
for i := 0; i < len(o.Spec.Ports) && i < len(c.Spec.Ports); i++ {
o.Spec.Ports[i].NodePort = c.Spec.Ports[i].NodePort
Expand Down
4 changes: 2 additions & 2 deletions pkg/status/assistants/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package assistants
import (
"github.com/caicloud/rudder/pkg/status"
"github.com/caicloud/rudder/pkg/store"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
apiv1 "k8s.io/client-go/pkg/api/v1"
)

var gvkConfigMap = apiv1.SchemeGroupVersion.WithKind("ConfigMap")
var gvkConfigMap = core.SchemeGroupVersion.WithKind("ConfigMap")

func ConfigMapAssistant(store store.IntegrationStore, obj runtime.Object) (status.Sentence, error) {
return status.Available, nil
Expand Down
10 changes: 5 additions & 5 deletions pkg/status/assistants/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (

"github.com/caicloud/rudder/pkg/status"
"github.com/caicloud/rudder/pkg/store"
batch "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
batchv1 "k8s.io/client-go/pkg/apis/batch/v1"
batchv2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
)

var gvkCronJob = batchv2alpha1.SchemeGroupVersion.WithKind("CronJob")
var gvkCronJob = batchv1beta1.SchemeGroupVersion.WithKind("CronJob")

func CronJobAssistant(store store.IntegrationStore, obj runtime.Object) (status.Sentence, error) {
cj, ok := obj.(*batchv2alpha1.CronJob)
cj, ok := obj.(*batchv1beta1.CronJob)
if !ok {
return status.None, fmt.Errorf("unknown type for cron job: %s", obj.GetObjectKind().GroupVersionKind().String())
}
Expand All @@ -27,7 +27,7 @@ func CronJobAssistant(store store.IntegrationStore, obj runtime.Object) (status.
if err != nil {
return status.None, err
}
job, ok := obj.(*batchv1.Job)
job, ok := obj.(*batch.Job)
if !ok {
return status.None, fmt.Errorf("unknown type for job: %s", obj.GetObjectKind().GroupVersionKind().String())
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/status/assistants/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (

"github.com/caicloud/rudder/pkg/status"
"github.com/caicloud/rudder/pkg/store"
apps "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/runtime"
extensionsv1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
)

var gvkDaemonSet = extensionsv1beta1.SchemeGroupVersion.WithKind("DaemonSet")
var gvkDaemonSet = apps.SchemeGroupVersion.WithKind("DaemonSet")

func DaemonSetAssistant(store store.IntegrationStore, obj runtime.Object) (status.Sentence, error) {
ds, ok := obj.(*extensionsv1beta1.DaemonSet)
ds, ok := obj.(*apps.DaemonSet)
if !ok {
return status.None, fmt.Errorf("unknown type for daemon set: %s", obj.GetObjectKind().GroupVersionKind().String())
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/status/assistants/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (

"github.com/caicloud/rudder/pkg/status"
"github.com/caicloud/rudder/pkg/store"
apps "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/runtime"
appsv1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
)

var gvkDeployment = appsv1beta1.SchemeGroupVersion.WithKind("Deployment")
var gvkDeployment = apps.SchemeGroupVersion.WithKind("Deployment")

func DeploymentAssistant(store store.IntegrationStore, obj runtime.Object) (status.Sentence, error) {
dp, ok := obj.(*appsv1beta1.Deployment)
dp, ok := obj.(*apps.Deployment)
if !ok {
return status.None, fmt.Errorf("unknown type for deployment: %s", obj.GetObjectKind().GroupVersionKind().String())
}
if len(dp.Status.Conditions) > 0 &&
dp.Status.Conditions[len(dp.Status.Conditions)-1].Type == appsv1beta1.DeploymentReplicaFailure {
dp.Status.Conditions[len(dp.Status.Conditions)-1].Type == apps.DeploymentReplicaFailure {
return status.Failure, nil
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/status/assistants/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (

"github.com/caicloud/rudder/pkg/status"
"github.com/caicloud/rudder/pkg/store"
batch "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/runtime"
batchv1 "k8s.io/client-go/pkg/apis/batch/v1"
)

var gvkJob = batchv1.SchemeGroupVersion.WithKind("Job")
var gvkJob = batch.SchemeGroupVersion.WithKind("Job")

func JobAssistant(store store.IntegrationStore, obj runtime.Object) (status.Sentence, error) {
job, ok := obj.(*batchv1.Job)
job, ok := obj.(*batch.Job)
if !ok {
return status.None, fmt.Errorf("unknown type for job: %s", obj.GetObjectKind().GroupVersionKind().String())
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/status/assistants/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import (

"github.com/caicloud/rudder/pkg/status"
"github.com/caicloud/rudder/pkg/store"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
corev1 "k8s.io/client-go/pkg/api/v1"
)

var gvkPVC = corev1.SchemeGroupVersion.WithKind("PersistentVolumeClaim")
var gvkPVC = core.SchemeGroupVersion.WithKind("PersistentVolumeClaim")

func PVCAssistant(store store.IntegrationStore, obj runtime.Object) (status.Sentence, error) {
pvc, ok := obj.(*corev1.PersistentVolumeClaim)
pvc, ok := obj.(*core.PersistentVolumeClaim)
if !ok {
return status.None, fmt.Errorf("unknown type for persistent volume claim: %s", obj.GetObjectKind().GroupVersionKind().String())
}
switch pvc.Status.Phase {
case corev1.ClaimBound:
case core.ClaimBound:
return status.Available, nil
case corev1.ClaimLost:
case core.ClaimLost:
return status.Failure, nil
default:
return status.Progressing, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/status/assistants/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package assistants
import (
"github.com/caicloud/rudder/pkg/status"
"github.com/caicloud/rudder/pkg/store"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
apiv1 "k8s.io/client-go/pkg/api/v1"
)

var gvkSecret = apiv1.SchemeGroupVersion.WithKind("Secret")
var gvkSecret = core.SchemeGroupVersion.WithKind("Secret")

func SecretAssistant(store store.IntegrationStore, obj runtime.Object) (status.Sentence, error) {
return status.Available, nil
Expand Down
Loading

0 comments on commit 57eb5a1

Please sign in to comment.