mirror of https://github.com/k3s-io/k3s
kubectl: Use apps/v1 Deployment/ReplicaSet.
This is necessary since kubectl shares code with the controllers, and the controllers have been updated to use apps/v1.pull/8/head
parent
e32a15558b
commit
1c531fc970
|
@ -177,8 +177,6 @@ go_library(
|
||||||
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/kubernetes/typed/apps/v1:go_default_library",
|
"//vendor/k8s.io/client-go/kubernetes/typed/apps/v1:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/kubernetes/typed/apps/v1beta1:go_default_library",
|
|
||||||
"//vendor/k8s.io/client-go/kubernetes/typed/extensions/v1beta1:go_default_library",
|
|
||||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/scale:go_default_library",
|
"//vendor/k8s.io/client-go/scale:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/util/integer:go_default_library",
|
"//vendor/k8s.io/client-go/util/integer:go_default_library",
|
||||||
|
|
|
@ -102,12 +102,12 @@ type DeploymentHistoryViewer struct {
|
||||||
// ViewHistory returns a revision-to-replicaset map as the revision history of a deployment
|
// ViewHistory returns a revision-to-replicaset map as the revision history of a deployment
|
||||||
// TODO: this should be a describer
|
// TODO: this should be a describer
|
||||||
func (h *DeploymentHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error) {
|
func (h *DeploymentHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error) {
|
||||||
versionedExtensionsClient := h.c.ExtensionsV1beta1()
|
versionedAppsClient := h.c.AppsV1()
|
||||||
deployment, err := versionedExtensionsClient.Deployments(namespace).Get(name, metav1.GetOptions{})
|
deployment, err := versionedAppsClient.Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to retrieve deployment %s: %v", name, err)
|
return "", fmt.Errorf("failed to retrieve deployment %s: %v", name, err)
|
||||||
}
|
}
|
||||||
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(deployment, versionedExtensionsClient)
|
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(deployment, versionedAppsClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to retrieve replica sets from deployment %s: %v", name, err)
|
return "", fmt.Errorf("failed to retrieve replica sets from deployment %s: %v", name, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import (
|
||||||
|
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
extv1beta1 "k8s.io/api/extensions/v1beta1"
|
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
@ -115,10 +115,10 @@ func (r *DeploymentRollbacker) Rollback(obj runtime.Object, updatedAnnotations m
|
||||||
if d.Spec.Paused {
|
if d.Spec.Paused {
|
||||||
return "", fmt.Errorf("you cannot rollback a paused deployment; resume it first with 'kubectl rollout resume deployment/%s' and try again", d.Name)
|
return "", fmt.Errorf("you cannot rollback a paused deployment; resume it first with 'kubectl rollout resume deployment/%s' and try again", d.Name)
|
||||||
}
|
}
|
||||||
deploymentRollback := &extv1beta1.DeploymentRollback{
|
deploymentRollback := &extensionsv1beta1.DeploymentRollback{
|
||||||
Name: d.Name,
|
Name: d.Name,
|
||||||
UpdatedAnnotations: updatedAnnotations,
|
UpdatedAnnotations: updatedAnnotations,
|
||||||
RollbackTo: extv1beta1.RollbackConfig{
|
RollbackTo: extensionsv1beta1.RollbackConfig{
|
||||||
Revision: toRevision,
|
Revision: toRevision,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -184,12 +184,12 @@ func isRollbackEvent(e *api.Event) (bool, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func simpleDryRun(deployment *extensions.Deployment, c kubernetes.Interface, toRevision int64) (string, error) {
|
func simpleDryRun(deployment *extensions.Deployment, c kubernetes.Interface, toRevision int64) (string, error) {
|
||||||
externalDeployment := &extv1beta1.Deployment{}
|
externalDeployment := &appsv1.Deployment{}
|
||||||
if err := legacyscheme.Scheme.Convert(deployment, externalDeployment, nil); err != nil {
|
if err := legacyscheme.Scheme.Convert(deployment, externalDeployment, nil); err != nil {
|
||||||
return "", fmt.Errorf("failed to convert deployment, %v", err)
|
return "", fmt.Errorf("failed to convert deployment, %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(externalDeployment, c.ExtensionsV1beta1())
|
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(externalDeployment, c.AppsV1())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to retrieve replica sets from deployment %s: %v", deployment.Name, err)
|
return "", fmt.Errorf("failed to retrieve replica sets from deployment %s: %v", deployment.Name, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ package kubectl
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
clientappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
|
clientappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1"
|
||||||
clientextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/apps"
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/controller/deployment/util"
|
"k8s.io/kubernetes/pkg/controller/deployment/util"
|
||||||
)
|
)
|
||||||
|
@ -38,28 +38,28 @@ type StatusViewer interface {
|
||||||
func StatusViewerFor(kind schema.GroupKind, c kubernetes.Interface) (StatusViewer, error) {
|
func StatusViewerFor(kind schema.GroupKind, c kubernetes.Interface) (StatusViewer, error) {
|
||||||
switch kind {
|
switch kind {
|
||||||
case extensionsv1beta1.SchemeGroupVersion.WithKind("Deployment").GroupKind(), apps.Kind("Deployment"):
|
case extensionsv1beta1.SchemeGroupVersion.WithKind("Deployment").GroupKind(), apps.Kind("Deployment"):
|
||||||
return &DeploymentStatusViewer{c.ExtensionsV1beta1()}, nil
|
return &DeploymentStatusViewer{c.AppsV1()}, nil
|
||||||
case extensionsv1beta1.SchemeGroupVersion.WithKind("DaemonSet").GroupKind(), apps.Kind("DaemonSet"):
|
case extensionsv1beta1.SchemeGroupVersion.WithKind("DaemonSet").GroupKind(), apps.Kind("DaemonSet"):
|
||||||
return &DaemonSetStatusViewer{c.ExtensionsV1beta1()}, nil
|
return &DaemonSetStatusViewer{c.AppsV1()}, nil
|
||||||
case apps.Kind("StatefulSet"):
|
case apps.Kind("StatefulSet"):
|
||||||
return &StatefulSetStatusViewer{c.AppsV1beta1()}, nil
|
return &StatefulSetStatusViewer{c.AppsV1()}, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no status viewer has been implemented for %v", kind)
|
return nil, fmt.Errorf("no status viewer has been implemented for %v", kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeploymentStatusViewer implements the StatusViewer interface.
|
// DeploymentStatusViewer implements the StatusViewer interface.
|
||||||
type DeploymentStatusViewer struct {
|
type DeploymentStatusViewer struct {
|
||||||
c clientextensionsv1beta1.DeploymentsGetter
|
c clientappsv1.DeploymentsGetter
|
||||||
}
|
}
|
||||||
|
|
||||||
// DaemonSetStatusViewer implements the StatusViewer interface.
|
// DaemonSetStatusViewer implements the StatusViewer interface.
|
||||||
type DaemonSetStatusViewer struct {
|
type DaemonSetStatusViewer struct {
|
||||||
c clientextensionsv1beta1.DaemonSetsGetter
|
c clientappsv1.DaemonSetsGetter
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatefulSetStatusViewer implements the StatusViewer interface.
|
// StatefulSetStatusViewer implements the StatusViewer interface.
|
||||||
type StatefulSetStatusViewer struct {
|
type StatefulSetStatusViewer struct {
|
||||||
c clientappsv1beta1.StatefulSetsGetter
|
c clientappsv1.StatefulSetsGetter
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status returns a message describing deployment status, and a bool value indicating if the status is considered done.
|
// Status returns a message describing deployment status, and a bool value indicating if the status is considered done.
|
||||||
|
@ -78,7 +78,7 @@ func (s *DeploymentStatusViewer) Status(namespace, name string, revision int64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if deployment.Generation <= deployment.Status.ObservedGeneration {
|
if deployment.Generation <= deployment.Status.ObservedGeneration {
|
||||||
cond := util.GetDeploymentCondition(deployment.Status, extensionsv1beta1.DeploymentProgressing)
|
cond := util.GetDeploymentCondition(deployment.Status, appsv1.DeploymentProgressing)
|
||||||
if cond != nil && cond.Reason == util.TimedOutReason {
|
if cond != nil && cond.Reason == util.TimedOutReason {
|
||||||
return "", false, fmt.Errorf("deployment %q exceeded its progress deadline", name)
|
return "", false, fmt.Errorf("deployment %q exceeded its progress deadline", name)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (s *DaemonSetStatusViewer) Status(namespace, name string, revision int64) (
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", false, err
|
return "", false, err
|
||||||
}
|
}
|
||||||
if daemon.Spec.UpdateStrategy.Type != extensionsv1beta1.RollingUpdateDaemonSetStrategyType {
|
if daemon.Spec.UpdateStrategy.Type != appsv1.RollingUpdateDaemonSetStrategyType {
|
||||||
return "", true, fmt.Errorf("Status is available only for RollingUpdate strategy type")
|
return "", true, fmt.Errorf("Status is available only for RollingUpdate strategy type")
|
||||||
}
|
}
|
||||||
if daemon.Generation <= daemon.Status.ObservedGeneration {
|
if daemon.Generation <= daemon.Status.ObservedGeneration {
|
||||||
|
@ -128,7 +128,7 @@ func (s *StatefulSetStatusViewer) Status(namespace, name string, revision int64)
|
||||||
if sts.Spec.UpdateStrategy.Type == apps.OnDeleteStatefulSetStrategyType {
|
if sts.Spec.UpdateStrategy.Type == apps.OnDeleteStatefulSetStrategyType {
|
||||||
return "", true, fmt.Errorf("%s updateStrategy does not have a Status`", apps.OnDeleteStatefulSetStrategyType)
|
return "", true, fmt.Errorf("%s updateStrategy does not have a Status`", apps.OnDeleteStatefulSetStrategyType)
|
||||||
}
|
}
|
||||||
if sts.Status.ObservedGeneration == nil || sts.Generation > *sts.Status.ObservedGeneration {
|
if sts.Status.ObservedGeneration == 0 || sts.Generation > sts.Status.ObservedGeneration {
|
||||||
return "Waiting for statefulset spec update to be observed...\n", false, nil
|
return "Waiting for statefulset spec update to be observed...\n", false, nil
|
||||||
}
|
}
|
||||||
if sts.Spec.Replicas != nil && sts.Status.ReadyReplicas < *sts.Spec.Replicas {
|
if sts.Spec.Replicas != nil && sts.Status.ReadyReplicas < *sts.Spec.Replicas {
|
||||||
|
|
|
@ -20,9 +20,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
apps "k8s.io/api/apps/v1beta1"
|
apps "k8s.io/api/apps/v1"
|
||||||
api "k8s.io/api/core/v1"
|
api "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
)
|
)
|
||||||
|
@ -31,14 +30,14 @@ func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
generation int64
|
generation int64
|
||||||
specReplicas int32
|
specReplicas int32
|
||||||
status extensions.DeploymentStatus
|
status apps.DeploymentStatus
|
||||||
msg string
|
msg string
|
||||||
done bool
|
done bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
generation: 0,
|
generation: 0,
|
||||||
specReplicas: 1,
|
specReplicas: 1,
|
||||||
status: extensions.DeploymentStatus{
|
status: apps.DeploymentStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
Replicas: 1,
|
Replicas: 1,
|
||||||
UpdatedReplicas: 0,
|
UpdatedReplicas: 0,
|
||||||
|
@ -52,7 +51,7 @@ func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
{
|
{
|
||||||
generation: 1,
|
generation: 1,
|
||||||
specReplicas: 1,
|
specReplicas: 1,
|
||||||
status: extensions.DeploymentStatus{
|
status: apps.DeploymentStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
Replicas: 2,
|
Replicas: 2,
|
||||||
UpdatedReplicas: 1,
|
UpdatedReplicas: 1,
|
||||||
|
@ -66,7 +65,7 @@ func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
{
|
{
|
||||||
generation: 1,
|
generation: 1,
|
||||||
specReplicas: 2,
|
specReplicas: 2,
|
||||||
status: extensions.DeploymentStatus{
|
status: apps.DeploymentStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
Replicas: 2,
|
Replicas: 2,
|
||||||
UpdatedReplicas: 2,
|
UpdatedReplicas: 2,
|
||||||
|
@ -80,7 +79,7 @@ func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
{
|
{
|
||||||
generation: 1,
|
generation: 1,
|
||||||
specReplicas: 2,
|
specReplicas: 2,
|
||||||
status: extensions.DeploymentStatus{
|
status: apps.DeploymentStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
Replicas: 2,
|
Replicas: 2,
|
||||||
UpdatedReplicas: 2,
|
UpdatedReplicas: 2,
|
||||||
|
@ -94,7 +93,7 @@ func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
{
|
{
|
||||||
generation: 2,
|
generation: 2,
|
||||||
specReplicas: 2,
|
specReplicas: 2,
|
||||||
status: extensions.DeploymentStatus{
|
status: apps.DeploymentStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
Replicas: 2,
|
Replicas: 2,
|
||||||
UpdatedReplicas: 2,
|
UpdatedReplicas: 2,
|
||||||
|
@ -108,19 +107,19 @@ func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
d := &extensions.Deployment{
|
d := &apps.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Namespace: "bar",
|
Namespace: "bar",
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
UID: "8764ae47-9092-11e4-8393-42010af018ff",
|
UID: "8764ae47-9092-11e4-8393-42010af018ff",
|
||||||
Generation: test.generation,
|
Generation: test.generation,
|
||||||
},
|
},
|
||||||
Spec: extensions.DeploymentSpec{
|
Spec: apps.DeploymentSpec{
|
||||||
Replicas: &test.specReplicas,
|
Replicas: &test.specReplicas,
|
||||||
},
|
},
|
||||||
Status: test.status,
|
Status: test.status,
|
||||||
}
|
}
|
||||||
client := fake.NewSimpleClientset(d).Extensions()
|
client := fake.NewSimpleClientset(d).Apps()
|
||||||
dsv := &DeploymentStatusViewer{c: client}
|
dsv := &DeploymentStatusViewer{c: client}
|
||||||
msg, done, err := dsv.Status("bar", "foo", 0)
|
msg, done, err := dsv.Status("bar", "foo", 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -143,13 +142,13 @@ func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
func TestDaemonSetStatusViewerStatus(t *testing.T) {
|
func TestDaemonSetStatusViewerStatus(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
generation int64
|
generation int64
|
||||||
status extensions.DaemonSetStatus
|
status apps.DaemonSetStatus
|
||||||
msg string
|
msg string
|
||||||
done bool
|
done bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
generation: 0,
|
generation: 0,
|
||||||
status: extensions.DaemonSetStatus{
|
status: apps.DaemonSetStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
UpdatedNumberScheduled: 0,
|
UpdatedNumberScheduled: 0,
|
||||||
DesiredNumberScheduled: 1,
|
DesiredNumberScheduled: 1,
|
||||||
|
@ -161,7 +160,7 @@ func TestDaemonSetStatusViewerStatus(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
generation: 1,
|
generation: 1,
|
||||||
status: extensions.DaemonSetStatus{
|
status: apps.DaemonSetStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
UpdatedNumberScheduled: 2,
|
UpdatedNumberScheduled: 2,
|
||||||
DesiredNumberScheduled: 2,
|
DesiredNumberScheduled: 2,
|
||||||
|
@ -173,7 +172,7 @@ func TestDaemonSetStatusViewerStatus(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
generation: 1,
|
generation: 1,
|
||||||
status: extensions.DaemonSetStatus{
|
status: apps.DaemonSetStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
UpdatedNumberScheduled: 2,
|
UpdatedNumberScheduled: 2,
|
||||||
DesiredNumberScheduled: 2,
|
DesiredNumberScheduled: 2,
|
||||||
|
@ -185,7 +184,7 @@ func TestDaemonSetStatusViewerStatus(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
generation: 2,
|
generation: 2,
|
||||||
status: extensions.DaemonSetStatus{
|
status: apps.DaemonSetStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
UpdatedNumberScheduled: 2,
|
UpdatedNumberScheduled: 2,
|
||||||
DesiredNumberScheduled: 2,
|
DesiredNumberScheduled: 2,
|
||||||
|
@ -200,21 +199,21 @@ func TestDaemonSetStatusViewerStatus(t *testing.T) {
|
||||||
for i := range tests {
|
for i := range tests {
|
||||||
test := tests[i]
|
test := tests[i]
|
||||||
t.Logf("testing scenario %d", i)
|
t.Logf("testing scenario %d", i)
|
||||||
d := &extensions.DaemonSet{
|
d := &apps.DaemonSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Namespace: "bar",
|
Namespace: "bar",
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
UID: "8764ae47-9092-11e4-8393-42010af018ff",
|
UID: "8764ae47-9092-11e4-8393-42010af018ff",
|
||||||
Generation: test.generation,
|
Generation: test.generation,
|
||||||
},
|
},
|
||||||
Spec: extensions.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
UpdateStrategy: extensions.DaemonSetUpdateStrategy{
|
UpdateStrategy: apps.DaemonSetUpdateStrategy{
|
||||||
Type: extensions.RollingUpdateDaemonSetStrategyType,
|
Type: apps.RollingUpdateDaemonSetStrategyType,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: test.status,
|
Status: test.status,
|
||||||
}
|
}
|
||||||
client := fake.NewSimpleClientset(d).Extensions()
|
client := fake.NewSimpleClientset(d).Apps()
|
||||||
dsv := &DaemonSetStatusViewer{c: client}
|
dsv := &DaemonSetStatusViewer{c: client}
|
||||||
msg, done, err := dsv.Status("bar", "foo", 0)
|
msg, done, err := dsv.Status("bar", "foo", 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -249,14 +248,11 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
generation: 1,
|
generation: 1,
|
||||||
strategy: apps.StatefulSetUpdateStrategy{Type: apps.OnDeleteStatefulSetStrategyType},
|
strategy: apps.StatefulSetUpdateStrategy{Type: apps.OnDeleteStatefulSetStrategyType},
|
||||||
status: apps.StatefulSetStatus{
|
status: apps.StatefulSetStatus{
|
||||||
ObservedGeneration: func() *int64 {
|
ObservedGeneration: 1,
|
||||||
generation := int64(1)
|
Replicas: 0,
|
||||||
return &generation
|
ReadyReplicas: 1,
|
||||||
}(),
|
CurrentReplicas: 0,
|
||||||
Replicas: 0,
|
UpdatedReplicas: 0,
|
||||||
ReadyReplicas: 1,
|
|
||||||
CurrentReplicas: 0,
|
|
||||||
UpdatedReplicas: 0,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
msg: "",
|
msg: "",
|
||||||
|
@ -268,14 +264,11 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
generation: 2,
|
generation: 2,
|
||||||
strategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
|
strategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
|
||||||
status: apps.StatefulSetStatus{
|
status: apps.StatefulSetStatus{
|
||||||
ObservedGeneration: func() *int64 {
|
ObservedGeneration: 1,
|
||||||
generation := int64(1)
|
Replicas: 3,
|
||||||
return &generation
|
ReadyReplicas: 3,
|
||||||
}(),
|
CurrentReplicas: 3,
|
||||||
Replicas: 3,
|
UpdatedReplicas: 0,
|
||||||
ReadyReplicas: 3,
|
|
||||||
CurrentReplicas: 3,
|
|
||||||
UpdatedReplicas: 0,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
msg: "Waiting for statefulset spec update to be observed...\n",
|
msg: "Waiting for statefulset spec update to be observed...\n",
|
||||||
|
@ -287,14 +280,11 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
generation: 1,
|
generation: 1,
|
||||||
strategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
|
strategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
|
||||||
status: apps.StatefulSetStatus{
|
status: apps.StatefulSetStatus{
|
||||||
ObservedGeneration: func() *int64 {
|
ObservedGeneration: 2,
|
||||||
generation := int64(2)
|
Replicas: 3,
|
||||||
return &generation
|
ReadyReplicas: 2,
|
||||||
}(),
|
CurrentReplicas: 3,
|
||||||
Replicas: 3,
|
UpdatedReplicas: 0,
|
||||||
ReadyReplicas: 2,
|
|
||||||
CurrentReplicas: 3,
|
|
||||||
UpdatedReplicas: 0,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
msg: fmt.Sprintf("Waiting for %d pods to be ready...\n", 1),
|
msg: fmt.Sprintf("Waiting for %d pods to be ready...\n", 1),
|
||||||
|
@ -310,14 +300,11 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
return &apps.RollingUpdateStatefulSetStrategy{Partition: &partition}
|
return &apps.RollingUpdateStatefulSetStrategy{Partition: &partition}
|
||||||
}()},
|
}()},
|
||||||
status: apps.StatefulSetStatus{
|
status: apps.StatefulSetStatus{
|
||||||
ObservedGeneration: func() *int64 {
|
ObservedGeneration: 2,
|
||||||
generation := int64(2)
|
Replicas: 3,
|
||||||
return &generation
|
ReadyReplicas: 3,
|
||||||
}(),
|
CurrentReplicas: 2,
|
||||||
Replicas: 3,
|
UpdatedReplicas: 1,
|
||||||
ReadyReplicas: 3,
|
|
||||||
CurrentReplicas: 2,
|
|
||||||
UpdatedReplicas: 1,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
msg: fmt.Sprintf("partitioned roll out complete: %d new pods have been updated...\n", 1),
|
msg: fmt.Sprintf("partitioned roll out complete: %d new pods have been updated...\n", 1),
|
||||||
|
@ -333,14 +320,11 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
return &apps.RollingUpdateStatefulSetStrategy{Partition: &partition}
|
return &apps.RollingUpdateStatefulSetStrategy{Partition: &partition}
|
||||||
}()},
|
}()},
|
||||||
status: apps.StatefulSetStatus{
|
status: apps.StatefulSetStatus{
|
||||||
ObservedGeneration: func() *int64 {
|
ObservedGeneration: 2,
|
||||||
generation := int64(2)
|
Replicas: 3,
|
||||||
return &generation
|
ReadyReplicas: 3,
|
||||||
}(),
|
CurrentReplicas: 3,
|
||||||
Replicas: 3,
|
UpdatedReplicas: 0,
|
||||||
ReadyReplicas: 3,
|
|
||||||
CurrentReplicas: 3,
|
|
||||||
UpdatedReplicas: 0,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
msg: fmt.Sprintf("Waiting for partitioned roll out to finish: %d out of %d new pods have been updated...\n", 0, 1),
|
msg: fmt.Sprintf("Waiting for partitioned roll out to finish: %d out of %d new pods have been updated...\n", 0, 1),
|
||||||
|
@ -352,16 +336,13 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
generation: 1,
|
generation: 1,
|
||||||
strategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
|
strategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
|
||||||
status: apps.StatefulSetStatus{
|
status: apps.StatefulSetStatus{
|
||||||
ObservedGeneration: func() *int64 {
|
ObservedGeneration: 2,
|
||||||
generation := int64(2)
|
Replicas: 3,
|
||||||
return &generation
|
ReadyReplicas: 3,
|
||||||
}(),
|
CurrentReplicas: 3,
|
||||||
Replicas: 3,
|
UpdatedReplicas: 3,
|
||||||
ReadyReplicas: 3,
|
CurrentRevision: "foo",
|
||||||
CurrentReplicas: 3,
|
UpdateRevision: "foo",
|
||||||
UpdatedReplicas: 3,
|
|
||||||
CurrentRevision: "foo",
|
|
||||||
UpdateRevision: "foo",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
msg: fmt.Sprintf("statefulset rolling update complete %d pods at revision %s...\n", 3, "foo"),
|
msg: fmt.Sprintf("statefulset rolling update complete %d pods at revision %s...\n", 3, "foo"),
|
||||||
|
@ -375,7 +356,7 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
s.Status = test.status
|
s.Status = test.status
|
||||||
s.Spec.UpdateStrategy = test.strategy
|
s.Spec.UpdateStrategy = test.strategy
|
||||||
s.Generation = test.generation
|
s.Generation = test.generation
|
||||||
client := fake.NewSimpleClientset(s).AppsV1beta1()
|
client := fake.NewSimpleClientset(s).AppsV1()
|
||||||
dsv := &StatefulSetStatusViewer{c: client}
|
dsv := &StatefulSetStatusViewer{c: client}
|
||||||
msg, done, err := dsv.Status(s.Namespace, s.Name, 0)
|
msg, done, err := dsv.Status(s.Namespace, s.Name, 0)
|
||||||
if test.err && err == nil {
|
if test.err && err == nil {
|
||||||
|
@ -394,19 +375,19 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDaemonSetStatusViewerStatusWithWrongUpdateStrategyType(t *testing.T) {
|
func TestDaemonSetStatusViewerStatusWithWrongUpdateStrategyType(t *testing.T) {
|
||||||
d := &extensions.DaemonSet{
|
d := &apps.DaemonSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Namespace: "bar",
|
Namespace: "bar",
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
UID: "8764ae47-9092-11e4-8393-42010af018ff",
|
UID: "8764ae47-9092-11e4-8393-42010af018ff",
|
||||||
},
|
},
|
||||||
Spec: extensions.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
UpdateStrategy: extensions.DaemonSetUpdateStrategy{
|
UpdateStrategy: apps.DaemonSetUpdateStrategy{
|
||||||
Type: extensions.OnDeleteDaemonSetStrategyType,
|
Type: apps.OnDeleteDaemonSetStrategyType,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
client := fake.NewSimpleClientset(d).Extensions()
|
client := fake.NewSimpleClientset(d).Apps()
|
||||||
dsv := &DaemonSetStatusViewer{c: client}
|
dsv := &DaemonSetStatusViewer{c: client}
|
||||||
msg, done, err := dsv.Status("bar", "foo", 0)
|
msg, done, err := dsv.Status("bar", "foo", 0)
|
||||||
errMsg := "Status is available only for RollingUpdate strategy type"
|
errMsg := "Status is available only for RollingUpdate strategy type"
|
||||||
|
|
|
@ -32,8 +32,8 @@ go_test(
|
||||||
"//pkg/printers:go_default_library",
|
"//pkg/printers:go_default_library",
|
||||||
"//pkg/util/pointer:go_default_library",
|
"//pkg/util/pointer:go_default_library",
|
||||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||||
|
"//vendor/k8s.io/api/apps/v1:go_default_library",
|
||||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||||
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
|
@ -86,6 +86,7 @@ go_library(
|
||||||
"//pkg/util/slice:go_default_library",
|
"//pkg/util/slice:go_default_library",
|
||||||
"//vendor/github.com/fatih/camelcase:go_default_library",
|
"//vendor/github.com/fatih/camelcase:go_default_library",
|
||||||
"//vendor/github.com/golang/glog:go_default_library",
|
"//vendor/github.com/golang/glog:go_default_library",
|
||||||
|
"//vendor/k8s.io/api/apps/v1:go_default_library",
|
||||||
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
|
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
|
||||||
"//vendor/k8s.io/api/autoscaling/v2beta1:go_default_library",
|
"//vendor/k8s.io/api/autoscaling/v2beta1:go_default_library",
|
||||||
"//vendor/k8s.io/api/batch/v1:go_default_library",
|
"//vendor/k8s.io/api/batch/v1:go_default_library",
|
||||||
|
|
|
@ -34,7 +34,7 @@ import (
|
||||||
|
|
||||||
"github.com/fatih/camelcase"
|
"github.com/fatih/camelcase"
|
||||||
|
|
||||||
versionedextension "k8s.io/api/extensions/v1beta1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
@ -3084,7 +3084,7 @@ type DeploymentDescriber struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dd *DeploymentDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (string, error) {
|
func (dd *DeploymentDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (string, error) {
|
||||||
d, err := dd.external.ExtensionsV1beta1().Deployments(namespace).Get(name, metav1.GetOptions{})
|
d, err := dd.external.AppsV1().Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -3105,7 +3105,7 @@ func (dd *DeploymentDescriber) Describe(namespace, name string, describerSetting
|
||||||
return describeDeployment(d, selector, internalDeployment, events, dd)
|
return describeDeployment(d, selector, internalDeployment, events, dd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func describeDeployment(d *versionedextension.Deployment, selector labels.Selector, internalDeployment *extensions.Deployment, events *api.EventList, dd *DeploymentDescriber) (string, error) {
|
func describeDeployment(d *appsv1.Deployment, selector labels.Selector, internalDeployment *extensions.Deployment, events *api.EventList, dd *DeploymentDescriber) (string, error) {
|
||||||
return tabbedString(func(out io.Writer) error {
|
return tabbedString(func(out io.Writer) error {
|
||||||
w := NewPrefixWriter(out)
|
w := NewPrefixWriter(out)
|
||||||
w.Write(LEVEL_0, "Name:\t%s\n", d.ObjectMeta.Name)
|
w.Write(LEVEL_0, "Name:\t%s\n", d.ObjectMeta.Name)
|
||||||
|
@ -3129,10 +3129,10 @@ func describeDeployment(d *versionedextension.Deployment, selector labels.Select
|
||||||
w.Write(LEVEL_1, "%v \t%v\t%v\n", c.Type, c.Status, c.Reason)
|
w.Write(LEVEL_1, "%v \t%v\t%v\n", c.Type, c.Status, c.Reason)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oldRSs, _, newRS, err := deploymentutil.GetAllReplicaSets(d, dd.external.ExtensionsV1beta1())
|
oldRSs, _, newRS, err := deploymentutil.GetAllReplicaSets(d, dd.external.AppsV1())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
w.Write(LEVEL_0, "OldReplicaSets:\t%s\n", printReplicaSetsByLabels(oldRSs))
|
w.Write(LEVEL_0, "OldReplicaSets:\t%s\n", printReplicaSetsByLabels(oldRSs))
|
||||||
var newRSs []*versionedextension.ReplicaSet
|
var newRSs []*appsv1.ReplicaSet
|
||||||
if newRS != nil {
|
if newRS != nil {
|
||||||
newRSs = append(newRSs, newRS)
|
newRSs = append(newRSs, newRS)
|
||||||
}
|
}
|
||||||
|
@ -3146,7 +3146,7 @@ func describeDeployment(d *versionedextension.Deployment, selector labels.Select
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func printReplicaSetsByLabels(matchingRSs []*versionedextension.ReplicaSet) string {
|
func printReplicaSetsByLabels(matchingRSs []*appsv1.ReplicaSet) string {
|
||||||
// Format the matching ReplicaSets into strings.
|
// Format the matching ReplicaSets into strings.
|
||||||
rsStrings := make([]string, 0, len(matchingRSs))
|
rsStrings := make([]string, 0, len(matchingRSs))
|
||||||
for _, rs := range matchingRSs {
|
for _, rs := range matchingRSs {
|
||||||
|
|
|
@ -25,8 +25,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/api/extensions/v1beta1"
|
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -1345,12 +1345,12 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
|
||||||
|
|
||||||
func TestDescribeDeployment(t *testing.T) {
|
func TestDescribeDeployment(t *testing.T) {
|
||||||
fake := fake.NewSimpleClientset()
|
fake := fake.NewSimpleClientset()
|
||||||
versionedFake := versionedfake.NewSimpleClientset(&v1beta1.Deployment{
|
versionedFake := versionedfake.NewSimpleClientset(&appsv1.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Namespace: "foo",
|
Namespace: "foo",
|
||||||
},
|
},
|
||||||
Spec: v1beta1.DeploymentSpec{
|
Spec: appsv1.DeploymentSpec{
|
||||||
Replicas: utilpointer.Int32Ptr(1),
|
Replicas: utilpointer.Int32Ptr(1),
|
||||||
Selector: &metav1.LabelSelector{},
|
Selector: &metav1.LabelSelector{},
|
||||||
Template: v1.PodTemplateSpec{
|
Template: v1.PodTemplateSpec{
|
||||||
|
@ -1977,12 +1977,12 @@ func TestDescribeEvents(t *testing.T) {
|
||||||
},
|
},
|
||||||
"DeploymentDescriber": &DeploymentDescriber{
|
"DeploymentDescriber": &DeploymentDescriber{
|
||||||
fake.NewSimpleClientset(events),
|
fake.NewSimpleClientset(events),
|
||||||
versionedfake.NewSimpleClientset(&v1beta1.Deployment{
|
versionedfake.NewSimpleClientset(&appsv1.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Namespace: "foo",
|
Namespace: "foo",
|
||||||
},
|
},
|
||||||
Spec: v1beta1.DeploymentSpec{
|
Spec: appsv1.DeploymentSpec{
|
||||||
Replicas: utilpointer.Int32Ptr(1),
|
Replicas: utilpointer.Int32Ptr(1),
|
||||||
Selector: &metav1.LabelSelector{},
|
Selector: &metav1.LabelSelector{},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue