Commit c7b53794 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #39683 from soltysh/move_deployments

Automatic merge from submit-queue Add apps/v1beta1 deployments with new defaults This pull introduces deployments under `apps/v1beta1` and fixes #23597 and #23304. TODO: * [x] - create new type `apps/v1beta1.Deployment` * [x] - update kubectl (stop, scale) * [ ] - ~~new `kubectl run` generator~~ - this will only duplicate half of generator code, I suggest replacing current to use new endpoint * [ ] - ~~create extended tests~~ - I've added integration and cmd tests verifying new endpoints * [ ] - ~~create `hack/test-update-storage-objects.sh`~~ - see above This is currently blocked by https://github.com/kubernetes/kubernetes/pull/38071, due to conflicting name `v1beta1.Deployment`. ```release-note Introduce apps/v1beta1.Deployments resource with modified defaults compared to extensions/v1beta1.Deployments. ``` @kargakis @mfojtik @kubernetes/sig-apps-misc
parents 50943d17 18f756ce
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -17,7 +17,9 @@ go_library( ...@@ -17,7 +17,9 @@ go_library(
deps = [ deps = [
"//cmd/kube-apiserver/app/options:go_default_library", "//cmd/kube-apiserver/app/options:go_default_library",
"//pkg/api:go_default_library", "//pkg/api:go_default_library",
"//pkg/apis/apps:go_default_library",
"//pkg/apis/batch:go_default_library", "//pkg/apis/batch:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/capabilities:go_default_library", "//pkg/capabilities:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library", "//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/informers/informers_generated/internalversion:go_default_library", "//pkg/client/informers/informers_generated/internalversion:go_default_library",
......
...@@ -49,7 +49,9 @@ import ( ...@@ -49,7 +49,9 @@ import (
serverstorage "k8s.io/apiserver/pkg/server/storage" serverstorage "k8s.io/apiserver/pkg/server/storage"
"k8s.io/kubernetes/cmd/kube-apiserver/app/options" "k8s.io/kubernetes/cmd/kube-apiserver/app/options"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/capabilities" "k8s.io/kubernetes/pkg/capabilities"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion" informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
...@@ -243,6 +245,8 @@ func BuildMasterConfig(s *options.ServerRunOptions) (*master.Config, informers.S ...@@ -243,6 +245,8 @@ func BuildMasterConfig(s *options.ServerRunOptions) (*master.Config, informers.S
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("error in initializing storage factory: %s", err) return nil, nil, fmt.Errorf("error in initializing storage factory: %s", err)
} }
// keep Deployments in extensions for backwards compatibility, we'll have to migrate at some point, eventually
storageFactory.AddCohabitatingResources(extensions.Resource("deployments"), apps.Resource("deployments"))
for _, override := range s.Etcd.EtcdServersOverrides { for _, override := range s.Etcd.EtcdServersOverrides {
tokens := strings.Split(override, "#") tokens := strings.Split(override, "#")
if len(tokens) != 2 { if len(tokens) != 2 {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -63,6 +63,7 @@ pkg/api/v1/service ...@@ -63,6 +63,7 @@ pkg/api/v1/service
pkg/apis/abac/v0 pkg/apis/abac/v0
pkg/apis/abac/v1beta1 pkg/apis/abac/v1beta1
pkg/apis/apps/install pkg/apis/apps/install
pkg/apis/apps/v1beta1
pkg/apis/authentication/install pkg/apis/authentication/install
pkg/apis/authorization/install pkg/apis/authorization/install
pkg/apis/autoscaling/install pkg/apis/autoscaling/install
......
...@@ -1133,7 +1133,7 @@ run_kubectl_get_tests() { ...@@ -1133,7 +1133,7 @@ run_kubectl_get_tests() {
kube::test::if_has_string "${output_message}" "/apis/apps/v1beta1/namespaces/default/statefulsets 200 OK" kube::test::if_has_string "${output_message}" "/apis/apps/v1beta1/namespaces/default/statefulsets 200 OK"
kube::test::if_has_string "${output_message}" "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers 200" kube::test::if_has_string "${output_message}" "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers 200"
kube::test::if_has_string "${output_message}" "/apis/batch/v1/namespaces/default/jobs 200 OK" kube::test::if_has_string "${output_message}" "/apis/batch/v1/namespaces/default/jobs 200 OK"
kube::test::if_has_string "${output_message}" "/apis/extensions/v1beta1/namespaces/default/deployments 200 OK" kube::test::if_has_string "${output_message}" "/apis/apps/v1beta1/namespaces/default/deployments 200 OK"
kube::test::if_has_string "${output_message}" "/apis/extensions/v1beta1/namespaces/default/replicasets 200 OK" kube::test::if_has_string "${output_message}" "/apis/extensions/v1beta1/namespaces/default/replicasets 200 OK"
### Test --allow-missing-template-keys ### Test --allow-missing-template-keys
...@@ -2270,6 +2270,11 @@ run_deployment_tests() { ...@@ -2270,6 +2270,11 @@ run_deployment_tests() {
kubectl create deployment test-nginx --image=gcr.io/google-containers/nginx:test-cmd kubectl create deployment test-nginx --image=gcr.io/google-containers/nginx:test-cmd
# Post-Condition: Deployment has 2 replicas defined in its spec. # Post-Condition: Deployment has 2 replicas defined in its spec.
kube::test::get_object_assert 'deploy test-nginx' "{{$container_name_field}}" 'nginx' kube::test::get_object_assert 'deploy test-nginx' "{{$container_name_field}}" 'nginx'
# Ensure we can interact with deployments through extensions and apps endpoints
output_message=$(kubectl get deployment.extensions -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}")
kube::test::if_has_string "${output_message}" 'extensions/v1beta1'
output_message=$(kubectl get deployment.apps -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}")
kube::test::if_has_string "${output_message}" 'apps/v1beta1'
# Clean up # Clean up
kubectl delete deployment test-nginx "${kube_flags[@]}" kubectl delete deployment test-nginx "${kube_flags[@]}"
...@@ -2882,7 +2887,7 @@ runTests() { ...@@ -2882,7 +2887,7 @@ runTests() {
kube::test::get_object_assert rolebinding/sarole "{{range.subjects}}{{.namespace}}:{{end}}" 'otherns:' kube::test::get_object_assert rolebinding/sarole "{{range.subjects}}{{.namespace}}:{{end}}" 'otherns:'
kube::test::get_object_assert rolebinding/sarole "{{range.subjects}}{{.name}}:{{end}}" 'sa-name:' kube::test::get_object_assert rolebinding/sarole "{{range.subjects}}{{.name}}:{{end}}" 'sa-name:'
fi fi
if kube::test::if_supports_resource "${roles}" ; then if kube::test::if_supports_resource "${roles}" ; then
kubectl create "${kube_flags[@]}" role pod-admin --verb=* --resource=pods kubectl create "${kube_flags[@]}" role pod-admin --verb=* --resource=pods
kube::test::get_object_assert role/pod-admin "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" '\*:' kube::test::get_object_assert role/pod-admin "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" '\*:'
......
...@@ -105,6 +105,8 @@ func TestDefaulting(t *testing.T) { ...@@ -105,6 +105,8 @@ func TestDefaulting(t *testing.T) {
{Group: "extensions", Version: "v1beta1", Kind: "DaemonSetList"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "DaemonSetList"}: {},
{Group: "extensions", Version: "v1beta1", Kind: "Deployment"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "Deployment"}: {},
{Group: "extensions", Version: "v1beta1", Kind: "DeploymentList"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "DeploymentList"}: {},
{Group: "apps", Version: "v1beta1", Kind: "Deployment"}: {},
{Group: "apps", Version: "v1beta1", Kind: "DeploymentList"}: {},
{Group: "extensions", Version: "v1beta1", Kind: "ReplicaSet"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "ReplicaSet"}: {},
{Group: "extensions", Version: "v1beta1", Kind: "ReplicaSetList"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "ReplicaSetList"}: {},
{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "ClusterRoleBinding"}: {}, {Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "ClusterRoleBinding"}: {},
......
...@@ -474,6 +474,13 @@ func coreFuncs(t apitesting.TestingCommon) []interface{} { ...@@ -474,6 +474,13 @@ func coreFuncs(t apitesting.TestingCommon) []interface{} {
func extensionFuncs(t apitesting.TestingCommon) []interface{} { func extensionFuncs(t apitesting.TestingCommon) []interface{} {
return []interface{}{ return []interface{}{
func(j *extensions.DeploymentSpec, c fuzz.Continue) {
c.FuzzNoCustom(j) // fuzz self without calling this function again
rhl := int32(c.Rand.Int31())
pds := int32(c.Rand.Int31())
j.RevisionHistoryLimit = &rhl
j.ProgressDeadlineSeconds = &pds
},
func(j *extensions.DeploymentStrategy, c fuzz.Continue) { func(j *extensions.DeploymentStrategy, c fuzz.Continue) {
c.FuzzNoCustom(j) // fuzz self without calling this function again c.FuzzNoCustom(j) // fuzz self without calling this function again
// Ensure that strategyType is one of valid values. // Ensure that strategyType is one of valid values.
......
...@@ -18,6 +18,7 @@ go_library( ...@@ -18,6 +18,7 @@ go_library(
tags = ["automanaged"], tags = ["automanaged"],
deps = [ deps = [
"//pkg/api:go_default_library", "//pkg/api:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/conversion", "//vendor:k8s.io/apimachinery/pkg/conversion",
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
......
...@@ -19,6 +19,7 @@ package apps ...@@ -19,6 +19,7 @@ package apps
import ( import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/apis/extensions"
) )
var ( var (
...@@ -46,6 +47,10 @@ func Resource(resource string) schema.GroupResource { ...@@ -46,6 +47,10 @@ func Resource(resource string) schema.GroupResource {
func addKnownTypes(scheme *runtime.Scheme) error { func addKnownTypes(scheme *runtime.Scheme) error {
// TODO this will get cleaned up with the scheme types are fixed // TODO this will get cleaned up with the scheme types are fixed
scheme.AddKnownTypes(SchemeGroupVersion, scheme.AddKnownTypes(SchemeGroupVersion,
&extensions.Deployment{},
&extensions.DeploymentList{},
&extensions.DeploymentRollback{},
&extensions.Scale{},
&StatefulSet{}, &StatefulSet{},
&StatefulSetList{}, &StatefulSetList{},
) )
......
...@@ -5,6 +5,7 @@ licenses(["notice"]) ...@@ -5,6 +5,7 @@ licenses(["notice"])
load( load(
"@io_bazel_rules_go//go:def.bzl", "@io_bazel_rules_go//go:def.bzl",
"go_library", "go_library",
"go_test",
) )
go_library( go_library(
...@@ -27,7 +28,9 @@ go_library( ...@@ -27,7 +28,9 @@ go_library(
"//pkg/api:go_default_library", "//pkg/api:go_default_library",
"//pkg/api/v1:go_default_library", "//pkg/api/v1:go_default_library",
"//pkg/apis/apps:go_default_library", "//pkg/apis/apps:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//vendor:github.com/gogo/protobuf/proto", "//vendor:github.com/gogo/protobuf/proto",
"//vendor:github.com/gogo/protobuf/sortkeys",
"//vendor:github.com/ugorji/go/codec", "//vendor:github.com/ugorji/go/codec",
"//vendor:k8s.io/apimachinery/pkg/api/resource", "//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
...@@ -51,3 +54,18 @@ filegroup( ...@@ -51,3 +54,18 @@ filegroup(
srcs = [":package-srcs"], srcs = [":package-srcs"],
tags = ["automanaged"], tags = ["automanaged"],
) )
go_test(
name = "go_default_xtest",
srcs = ["defaults_test.go"],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/install:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/apis/apps/install:go_default_library",
"//pkg/apis/apps/v1beta1:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/util/intstr",
],
)
...@@ -22,9 +22,11 @@ import ( ...@@ -22,9 +22,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion" "k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
v1 "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/extensions"
) )
func addConversionFuncs(scheme *runtime.Scheme) error { func addConversionFuncs(scheme *runtime.Scheme) error {
...@@ -35,21 +37,49 @@ func addConversionFuncs(scheme *runtime.Scheme) error { ...@@ -35,21 +37,49 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
err := scheme.AddConversionFuncs( err := scheme.AddConversionFuncs(
Convert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec, Convert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec,
Convert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec, Convert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec,
// extensions
// TODO: below conversions should be dropped in favor of auto-generated
// ones, see https://github.com/kubernetes/kubernetextensionsssues/39865
Convert_v1beta1_ScaleStatus_To_extensions_ScaleStatus,
Convert_extensions_ScaleStatus_To_v1beta1_ScaleStatus,
Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec,
Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec,
Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy,
Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy,
Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment,
Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment,
) )
if err != nil { if err != nil {
return err return err
} }
return scheme.AddFieldLabelConversionFunc("apps/v1beta1", "StatefulSet", // Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
err = scheme.AddFieldLabelConversionFunc("apps/v1beta1", "StatefulSet",
func(label, value string) (string, string, error) { func(label, value string) (string, string, error) {
switch label { switch label {
case "metadata.name", "metadata.namespace", "status.successful": case "metadata.name", "metadata.namespace", "status.successful":
return label, value, nil return label, value, nil
default: default:
return "", "", fmt.Errorf("field label not supported: %s", label) return "", "", fmt.Errorf("field label not supported for StatefulSet: %s", label)
} }
}, })
) if err != nil {
return err
}
err = api.Scheme.AddFieldLabelConversionFunc("apps/v1beta1", "Deployment",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "metadata.namespace":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for Deployment", label)
}
})
if err != nil {
return err
}
return nil
} }
func Convert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec(in *StatefulSetSpec, out *apps.StatefulSetSpec, s conversion.Scope) error { func Convert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec(in *StatefulSetSpec, out *apps.StatefulSetSpec, s conversion.Scope) error {
...@@ -112,3 +142,156 @@ func Convert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec(in *apps.StatefulSe ...@@ -112,3 +142,156 @@ func Convert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec(in *apps.StatefulSe
out.ServiceName = in.ServiceName out.ServiceName = in.ServiceName
return nil return nil
} }
func Convert_extensions_ScaleStatus_To_v1beta1_ScaleStatus(in *extensions.ScaleStatus, out *ScaleStatus, s conversion.Scope) error {
out.Replicas = int32(in.Replicas)
out.Selector = nil
out.TargetSelector = ""
if in.Selector != nil {
if in.Selector.MatchExpressions == nil || len(in.Selector.MatchExpressions) == 0 {
out.Selector = in.Selector.MatchLabels
}
selector, err := metav1.LabelSelectorAsSelector(in.Selector)
if err != nil {
return fmt.Errorf("invalid label selector: %v", err)
}
out.TargetSelector = selector.String()
}
return nil
}
func Convert_v1beta1_ScaleStatus_To_extensions_ScaleStatus(in *ScaleStatus, out *extensions.ScaleStatus, s conversion.Scope) error {
out.Replicas = in.Replicas
// Normally when 2 fields map to the same internal value we favor the old field, since
// old clients can't be expected to know about new fields but clients that know about the
// new field can be expected to know about the old field (though that's not quite true, due
// to kubectl apply). However, these fields are readonly, so any non-nil value should work.
if in.TargetSelector != "" {
labelSelector, err := metav1.ParseToLabelSelector(in.TargetSelector)
if err != nil {
out.Selector = nil
return fmt.Errorf("failed to parse target selector: %v", err)
}
out.Selector = labelSelector
} else if in.Selector != nil {
out.Selector = new(metav1.LabelSelector)
selector := make(map[string]string)
for key, val := range in.Selector {
selector[key] = val
}
out.Selector.MatchLabels = selector
} else {
out.Selector = nil
}
return nil
}
func Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentSpec, out *extensions.DeploymentSpec, s conversion.Scope) error {
if in.Replicas != nil {
out.Replicas = *in.Replicas
}
out.Selector = in.Selector
if err := v1.Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
return err
}
if err := Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
return err
}
out.RevisionHistoryLimit = in.RevisionHistoryLimit
out.MinReadySeconds = in.MinReadySeconds
out.Paused = in.Paused
if in.RollbackTo != nil {
out.RollbackTo = new(extensions.RollbackConfig)
out.RollbackTo.Revision = in.RollbackTo.Revision
} else {
out.RollbackTo = nil
}
if in.ProgressDeadlineSeconds != nil {
out.ProgressDeadlineSeconds = new(int32)
*out.ProgressDeadlineSeconds = *in.ProgressDeadlineSeconds
}
return nil
}
func Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.DeploymentSpec, out *DeploymentSpec, s conversion.Scope) error {
out.Replicas = &in.Replicas
out.Selector = in.Selector
if err := v1.Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
return err
}
if err := Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
return err
}
if in.RevisionHistoryLimit != nil {
out.RevisionHistoryLimit = new(int32)
*out.RevisionHistoryLimit = int32(*in.RevisionHistoryLimit)
}
out.MinReadySeconds = int32(in.MinReadySeconds)
out.Paused = in.Paused
if in.RollbackTo != nil {
out.RollbackTo = new(RollbackConfig)
out.RollbackTo.Revision = int64(in.RollbackTo.Revision)
} else {
out.RollbackTo = nil
}
if in.ProgressDeadlineSeconds != nil {
out.ProgressDeadlineSeconds = new(int32)
*out.ProgressDeadlineSeconds = *in.ProgressDeadlineSeconds
}
return nil
}
func Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(in *extensions.DeploymentStrategy, out *DeploymentStrategy, s conversion.Scope) error {
out.Type = DeploymentStrategyType(in.Type)
if in.RollingUpdate != nil {
out.RollingUpdate = new(RollingUpdateDeployment)
if err := Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
return err
}
} else {
out.RollingUpdate = nil
}
return nil
}
func Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(in *DeploymentStrategy, out *extensions.DeploymentStrategy, s conversion.Scope) error {
out.Type = extensions.DeploymentStrategyType(in.Type)
if in.RollingUpdate != nil {
out.RollingUpdate = new(extensions.RollingUpdateDeployment)
if err := Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
return err
}
} else {
out.RollingUpdate = nil
}
return nil
}
func Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in *RollingUpdateDeployment, out *extensions.RollingUpdateDeployment, s conversion.Scope) error {
if err := s.Convert(in.MaxUnavailable, &out.MaxUnavailable, 0); err != nil {
return err
}
if err := s.Convert(in.MaxSurge, &out.MaxSurge, 0); err != nil {
return err
}
return nil
}
func Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in *extensions.RollingUpdateDeployment, out *RollingUpdateDeployment, s conversion.Scope) error {
if out.MaxUnavailable == nil {
out.MaxUnavailable = &intstr.IntOrString{}
}
if err := s.Convert(&in.MaxUnavailable, out.MaxUnavailable, 0); err != nil {
return err
}
if out.MaxSurge == nil {
out.MaxSurge = &intstr.IntOrString{}
}
if err := s.Convert(&in.MaxSurge, out.MaxSurge, 0); err != nil {
return err
}
return nil
}
...@@ -19,12 +19,14 @@ package v1beta1 ...@@ -19,12 +19,14 @@ package v1beta1
import ( import (
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"
"k8s.io/apimachinery/pkg/util/intstr"
) )
func addDefaultingFuncs(scheme *runtime.Scheme) error { func addDefaultingFuncs(scheme *runtime.Scheme) error {
RegisterDefaults(scheme) RegisterDefaults(scheme)
return scheme.AddDefaultingFuncs( return scheme.AddDefaultingFuncs(
SetDefaults_StatefulSet, SetDefaults_StatefulSet,
SetDefaults_Deployment,
) )
} }
...@@ -45,3 +47,57 @@ func SetDefaults_StatefulSet(obj *StatefulSet) { ...@@ -45,3 +47,57 @@ func SetDefaults_StatefulSet(obj *StatefulSet) {
*obj.Spec.Replicas = 1 *obj.Spec.Replicas = 1
} }
} }
// SetDefaults_Deployment sets additional defaults compared to its counterpart
// in extensions. These addons are:
// - MaxUnavailable during rolling update set to 25% (1 in extensions)
// - MaxSurge value during rolling update set to 25% (1 in extensions)
// - RevisionHistoryLimit set to 2 (not set in extensions)
// - ProgressDeadlineSeconds set to 600s (not set in extensions)
func SetDefaults_Deployment(obj *Deployment) {
// Default labels and selector to labels from pod template spec.
labels := obj.Spec.Template.Labels
if labels != nil {
if obj.Spec.Selector == nil {
obj.Spec.Selector = &metav1.LabelSelector{MatchLabels: labels}
}
if len(obj.Labels) == 0 {
obj.Labels = labels
}
}
// Set DeploymentSpec.Replicas to 1 if it is not set.
if obj.Spec.Replicas == nil {
obj.Spec.Replicas = new(int32)
*obj.Spec.Replicas = 1
}
strategy := &obj.Spec.Strategy
// Set default DeploymentStrategyType as RollingUpdate.
if strategy.Type == "" {
strategy.Type = RollingUpdateDeploymentStrategyType
}
if strategy.Type == RollingUpdateDeploymentStrategyType {
if strategy.RollingUpdate == nil {
rollingUpdate := RollingUpdateDeployment{}
strategy.RollingUpdate = &rollingUpdate
}
if strategy.RollingUpdate.MaxUnavailable == nil {
// Set default MaxUnavailable as 25% by default.
maxUnavailable := intstr.FromString("25%")
strategy.RollingUpdate.MaxUnavailable = &maxUnavailable
}
if strategy.RollingUpdate.MaxSurge == nil {
// Set default MaxSurge as 25% by default.
maxSurge := intstr.FromString("25%")
strategy.RollingUpdate.MaxSurge = &maxSurge
}
}
if obj.Spec.RevisionHistoryLimit == nil {
obj.Spec.RevisionHistoryLimit = new(int32)
*obj.Spec.RevisionHistoryLimit = 2
}
if obj.Spec.ProgressDeadlineSeconds == nil {
obj.Spec.ProgressDeadlineSeconds = new(int32)
*obj.Spec.ProgressDeadlineSeconds = 600
}
}
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1_test
import (
"reflect"
"testing"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/kubernetes/pkg/api"
_ "k8s.io/kubernetes/pkg/api/install"
"k8s.io/kubernetes/pkg/api/v1"
_ "k8s.io/kubernetes/pkg/apis/apps/install"
. "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
)
func TestSetDefaultDeployment(t *testing.T) {
defaultIntOrString := intstr.FromString("25%")
differentIntOrString := intstr.FromInt(5)
period := int64(v1.DefaultTerminationGracePeriodSeconds)
defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst,
RestartPolicy: v1.RestartPolicyAlways,
SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName,
},
}
tests := []struct {
original *Deployment
expected *Deployment
}{
{
original: &Deployment{},
expected: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(1),
Strategy: DeploymentStrategy{
Type: RollingUpdateDeploymentStrategyType,
RollingUpdate: &RollingUpdateDeployment{
MaxSurge: &defaultIntOrString,
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: newInt32(600),
Template: defaultTemplate,
},
},
},
{
original: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(5),
Strategy: DeploymentStrategy{
RollingUpdate: &RollingUpdateDeployment{
MaxSurge: &differentIntOrString,
},
},
},
},
expected: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(5),
Strategy: DeploymentStrategy{
Type: RollingUpdateDeploymentStrategyType,
RollingUpdate: &RollingUpdateDeployment{
MaxSurge: &differentIntOrString,
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: newInt32(600),
Template: defaultTemplate,
},
},
},
{
original: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(3),
Strategy: DeploymentStrategy{
Type: RollingUpdateDeploymentStrategyType,
RollingUpdate: nil,
},
},
},
expected: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(3),
Strategy: DeploymentStrategy{
Type: RollingUpdateDeploymentStrategyType,
RollingUpdate: &RollingUpdateDeployment{
MaxSurge: &defaultIntOrString,
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: newInt32(600),
Template: defaultTemplate,
},
},
},
{
original: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(5),
Strategy: DeploymentStrategy{
Type: RecreateDeploymentStrategyType,
},
RevisionHistoryLimit: newInt32(0),
},
},
expected: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(5),
Strategy: DeploymentStrategy{
Type: RecreateDeploymentStrategyType,
},
RevisionHistoryLimit: newInt32(0),
ProgressDeadlineSeconds: newInt32(600),
Template: defaultTemplate,
},
},
},
{
original: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(5),
Strategy: DeploymentStrategy{
Type: RecreateDeploymentStrategyType,
},
ProgressDeadlineSeconds: newInt32(30),
RevisionHistoryLimit: newInt32(2),
},
},
expected: &Deployment{
Spec: DeploymentSpec{
Replicas: newInt32(5),
Strategy: DeploymentStrategy{
Type: RecreateDeploymentStrategyType,
},
ProgressDeadlineSeconds: newInt32(30),
RevisionHistoryLimit: newInt32(2),
Template: defaultTemplate,
},
},
},
}
for _, test := range tests {
original := test.original
expected := test.expected
obj2 := roundTrip(t, runtime.Object(original))
got, ok := obj2.(*Deployment)
if !ok {
t.Errorf("unexpected object: %v", got)
t.FailNow()
}
if !reflect.DeepEqual(got.Spec, expected.Spec) {
t.Errorf("object mismatch!\nexpected:\n\t%+v\ngot:\n\t%+v", got.Spec, expected.Spec)
}
}
}
func TestDefaultDeploymentAvailability(t *testing.T) {
d := roundTrip(t, runtime.Object(&Deployment{})).(*Deployment)
maxUnavailable, err := intstr.GetValueFromIntOrPercent(d.Spec.Strategy.RollingUpdate.MaxUnavailable, int(*(d.Spec.Replicas)), false)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if *(d.Spec.Replicas)-int32(maxUnavailable) <= 0 {
t.Fatalf("the default value of maxUnavailable can lead to no active replicas during rolling update")
}
}
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
data, err := runtime.Encode(api.Codecs.LegacyCodec(SchemeGroupVersion), obj)
if err != nil {
t.Errorf("%v\n %#v", err, obj)
return nil
}
obj2, err := runtime.Decode(api.Codecs.UniversalDecoder(), data)
if err != nil {
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
return nil
}
obj3 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
err = api.Scheme.Convert(obj2, obj3, nil)
if err != nil {
t.Errorf("%v\nSource: %#v", err, obj2)
return nil
}
return obj3
}
func newInt32(val int32) *int32 {
p := new(int32)
*p = val
return p
}
...@@ -27,10 +27,241 @@ import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; ...@@ -27,10 +27,241 @@ import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
import "k8s.io/apimachinery/pkg/util/intstr/generated.proto"; import "k8s.io/apimachinery/pkg/util/intstr/generated.proto";
import "k8s.io/apiserver/pkg/apis/example/v1/generated.proto"; import "k8s.io/apiserver/pkg/apis/example/v1/generated.proto";
import "k8s.io/kubernetes/pkg/api/v1/generated.proto"; import "k8s.io/kubernetes/pkg/api/v1/generated.proto";
import "k8s.io/kubernetes/pkg/apis/extensions/v1beta1/generated.proto";
// Package-wide variables from generator "generated". // Package-wide variables from generator "generated".
option go_package = "v1beta1"; option go_package = "v1beta1";
// Deployment enables declarative updates for Pods and ReplicaSets.
message Deployment {
// Standard object metadata.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// Specification of the desired behavior of the Deployment.
// +optional
optional DeploymentSpec spec = 2;
// Most recently observed status of the Deployment.
// +optional
optional DeploymentStatus status = 3;
}
// DeploymentCondition describes the state of a deployment at a certain point.
message DeploymentCondition {
// Type of deployment condition.
optional string type = 1;
// Status of the condition, one of True, False, Unknown.
optional string status = 2;
// The last time this condition was updated.
optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastUpdateTime = 6;
// Last time the condition transitioned from one status to another.
optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 7;
// The reason for the condition's last transition.
optional string reason = 4;
// A human readable message indicating details about the transition.
optional string message = 5;
}
// DeploymentList is a list of Deployments.
message DeploymentList {
// Standard list metadata.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
// Items is the list of Deployments.
repeated Deployment items = 2;
}
// DeploymentRollback stores the information required to rollback a deployment.
message DeploymentRollback {
// Required: This must match the Name of a deployment.
optional string name = 1;
// The annotations to be updated to a deployment
// +optional
map<string, string> updatedAnnotations = 2;
// The config of this deployment rollback.
optional RollbackConfig rollbackTo = 3;
}
// DeploymentSpec is the specification of the desired behavior of the Deployment.
message DeploymentSpec {
// Number of desired pods. This is a pointer to distinguish between explicit
// zero and not specified. Defaults to 1.
// +optional
optional int32 replicas = 1;
// Label selector for pods. Existing ReplicaSets whose pods are
// selected by this will be the ones affected by this deployment.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 2;
// Template describes the pods that will be created.
optional k8s.io.kubernetes.pkg.api.v1.PodTemplateSpec template = 3;
// The deployment strategy to use to replace existing pods with new ones.
// +optional
optional DeploymentStrategy strategy = 4;
// Minimum number of seconds for which a newly created pod should be ready
// without any of its container crashing, for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
// +optional
optional int32 minReadySeconds = 5;
// The number of old ReplicaSets to retain to allow rollback.
// This is a pointer to distinguish between explicit zero and not specified.
// Defaults to 2.
// +optional
optional int32 revisionHistoryLimit = 6;
// Indicates that the deployment is paused.
// +optional
optional bool paused = 7;
// The config this deployment is rolling back to. Will be cleared after rollback is done.
// +optional
optional RollbackConfig rollbackTo = 8;
// The maximum time in seconds for a deployment to make progress before it
// is considered to be failed. The deployment controller will continue to
// process failed deployments and a condition with a ProgressDeadlineExceeded
// reason will be surfaced in the deployment status. Once autoRollback is
// implemented, the deployment controller will automatically rollback failed
// deployments. Note that progress will not be estimated during the time a
// deployment is paused. Defaults to 600s.
optional int32 progressDeadlineSeconds = 9;
}
// DeploymentStatus is the most recently observed status of the Deployment.
message DeploymentStatus {
// The generation observed by the deployment controller.
// +optional
optional int64 observedGeneration = 1;
// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
// +optional
optional int32 replicas = 2;
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
// +optional
optional int32 updatedReplicas = 3;
// Total number of ready pods targeted by this deployment.
// +optional
optional int32 readyReplicas = 7;
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
// +optional
optional int32 availableReplicas = 4;
// Total number of unavailable pods targeted by this deployment.
// +optional
optional int32 unavailableReplicas = 5;
// Represents the latest available observations of a deployment's current state.
repeated DeploymentCondition conditions = 6;
}
// DeploymentStrategy describes how to replace existing pods with new ones.
message DeploymentStrategy {
// Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
// +optional
optional string type = 1;
// Rolling update config params. Present only if DeploymentStrategyType =
// RollingUpdate.
// ---
// TODO: Update this to follow our convention for oneOf, whatever we decide it
// to be.
// +optional
optional RollingUpdateDeployment rollingUpdate = 2;
}
message RollbackConfig {
// The revision to rollback to. If set to 0, rollbck to the last revision.
// +optional
optional int64 revision = 1;
}
// Spec to control the desired behavior of rolling update.
message RollingUpdateDeployment {
// The maximum number of pods that can be unavailable during the update.
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
// Absolute number is calculated from percentage by rounding down.
// This can not be 0 if MaxSurge is 0.
// Defaults to 25%.
// Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods
// immediately when the rolling update starts. Once new pods are ready, old RC
// can be scaled down further, followed by scaling up the new RC, ensuring
// that the total number of pods available at all times during the update is at
// least 70% of desired pods.
// +optional
optional k8s.io.apimachinery.pkg.util.intstr.IntOrString maxUnavailable = 1;
// The maximum number of pods that can be scheduled above the desired number of
// pods.
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
// This can not be 0 if MaxUnavailable is 0.
// Absolute number is calculated from percentage by rounding up.
// Defaults to 25%.
// Example: when this is set to 30%, the new RC can be scaled up immediately when
// the rolling update starts, such that the total number of old and new pods do not exceed
// 130% of desired pods. Once old pods have been killed,
// new RC can be scaled up further, ensuring that total number of pods running
// at any time during the update is atmost 130% of desired pods.
// +optional
optional k8s.io.apimachinery.pkg.util.intstr.IntOrString maxSurge = 2;
}
// Scale represents a scaling request for a resource.
message Scale {
// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional
optional ScaleSpec spec = 2;
// current status of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. Read-only.
// +optional
optional ScaleStatus status = 3;
}
// ScaleSpec describes the attributes of a scale subresource
message ScaleSpec {
// desired number of instances for the scaled object.
// +optional
optional int32 replicas = 1;
}
// ScaleStatus represents the current status of a scale subresource.
message ScaleStatus {
// actual number of observed instances of the scaled object.
optional int32 replicas = 1;
// label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
// +optional
map<string, string> selector = 2;
// label selector for pods that should match the replicas count. This is a serializated
// version of both map-based and more expressive set-based selectors. This is done to
// avoid introspection in the clients. The string will be in the same format as the
// query-param syntax. If the target type only supports map-based selectors, both this
// field and map-based selector field are populated.
// More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
// +optional
optional string targetSelector = 3;
}
// StatefulSet represents a set of pods with consistent identities. // StatefulSet represents a set of pods with consistent identities.
// Identities are defined as: // Identities are defined as:
// - Network: A single stable DNS and hostname. // - Network: A single stable DNS and hostname.
......
...@@ -41,12 +41,13 @@ var ( ...@@ -41,12 +41,13 @@ var (
// Adds the list of known types to api.Scheme. // Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error { func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion, scheme.AddKnownTypes(SchemeGroupVersion,
&Deployment{},
&DeploymentList{},
&DeploymentRollback{},
&Scale{},
&StatefulSet{}, &StatefulSet{},
&StatefulSetList{}, &StatefulSetList{},
) )
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil return nil
} }
func (obj *StatefulSet) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
func (obj *StatefulSetList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -27,6 +27,143 @@ package v1beta1 ...@@ -27,6 +27,143 @@ package v1beta1
// Those methods can be generated by using hack/update-generated-swagger-docs.sh // Those methods can be generated by using hack/update-generated-swagger-docs.sh
// AUTO-GENERATED FUNCTIONS START HERE // AUTO-GENERATED FUNCTIONS START HERE
var map_Deployment = map[string]string{
"": "Deployment enables declarative updates for Pods and ReplicaSets.",
"metadata": "Standard object metadata.",
"spec": "Specification of the desired behavior of the Deployment.",
"status": "Most recently observed status of the Deployment.",
}
func (Deployment) SwaggerDoc() map[string]string {
return map_Deployment
}
var map_DeploymentCondition = map[string]string{
"": "DeploymentCondition describes the state of a deployment at a certain point.",
"type": "Type of deployment condition.",
"status": "Status of the condition, one of True, False, Unknown.",
"lastUpdateTime": "The last time this condition was updated.",
"lastTransitionTime": "Last time the condition transitioned from one status to another.",
"reason": "The reason for the condition's last transition.",
"message": "A human readable message indicating details about the transition.",
}
func (DeploymentCondition) SwaggerDoc() map[string]string {
return map_DeploymentCondition
}
var map_DeploymentList = map[string]string{
"": "DeploymentList is a list of Deployments.",
"metadata": "Standard list metadata.",
"items": "Items is the list of Deployments.",
}
func (DeploymentList) SwaggerDoc() map[string]string {
return map_DeploymentList
}
var map_DeploymentRollback = map[string]string{
"": "DeploymentRollback stores the information required to rollback a deployment.",
"name": "Required: This must match the Name of a deployment.",
"updatedAnnotations": "The annotations to be updated to a deployment",
"rollbackTo": "The config of this deployment rollback.",
}
func (DeploymentRollback) SwaggerDoc() map[string]string {
return map_DeploymentRollback
}
var map_DeploymentSpec = map[string]string{
"": "DeploymentSpec is the specification of the desired behavior of the Deployment.",
"replicas": "Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.",
"selector": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment.",
"template": "Template describes the pods that will be created.",
"strategy": "The deployment strategy to use to replace existing pods with new ones.",
"minReadySeconds": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
"revisionHistoryLimit": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 2.",
"paused": "Indicates that the deployment is paused.",
"rollbackTo": "The config this deployment is rolling back to. Will be cleared after rollback is done.",
"progressDeadlineSeconds": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Once autoRollback is implemented, the deployment controller will automatically rollback failed deployments. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.",
}
func (DeploymentSpec) SwaggerDoc() map[string]string {
return map_DeploymentSpec
}
var map_DeploymentStatus = map[string]string{
"": "DeploymentStatus is the most recently observed status of the Deployment.",
"observedGeneration": "The generation observed by the deployment controller.",
"replicas": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
"updatedReplicas": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.",
"readyReplicas": "Total number of ready pods targeted by this deployment.",
"availableReplicas": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.",
"unavailableReplicas": "Total number of unavailable pods targeted by this deployment.",
"conditions": "Represents the latest available observations of a deployment's current state.",
}
func (DeploymentStatus) SwaggerDoc() map[string]string {
return map_DeploymentStatus
}
var map_DeploymentStrategy = map[string]string{
"": "DeploymentStrategy describes how to replace existing pods with new ones.",
"type": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.",
"rollingUpdate": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate.",
}
func (DeploymentStrategy) SwaggerDoc() map[string]string {
return map_DeploymentStrategy
}
var map_RollbackConfig = map[string]string{
"revision": "The revision to rollback to. If set to 0, rollbck to the last revision.",
}
func (RollbackConfig) SwaggerDoc() map[string]string {
return map_RollbackConfig
}
var map_RollingUpdateDeployment = map[string]string{
"": "Spec to control the desired behavior of rolling update.",
"maxUnavailable": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old RC can be scaled down further, followed by scaling up the new RC, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods.",
"maxSurge": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new RC can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new RC can be scaled up further, ensuring that total number of pods running at any time during the update is atmost 130% of desired pods.",
}
func (RollingUpdateDeployment) SwaggerDoc() map[string]string {
return map_RollingUpdateDeployment
}
var map_Scale = map[string]string{
"": "Scale represents a scaling request for a resource.",
"metadata": "Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.",
"spec": "defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.",
"status": "current status of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. Read-only.",
}
func (Scale) SwaggerDoc() map[string]string {
return map_Scale
}
var map_ScaleSpec = map[string]string{
"": "ScaleSpec describes the attributes of a scale subresource",
"replicas": "desired number of instances for the scaled object.",
}
func (ScaleSpec) SwaggerDoc() map[string]string {
return map_ScaleSpec
}
var map_ScaleStatus = map[string]string{
"": "ScaleStatus represents the current status of a scale subresource.",
"replicas": "actual number of observed instances of the scaled object.",
"selector": "label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
"targetSelector": "label selector for pods that should match the replicas count. This is a serializated version of both map-based and more expressive set-based selectors. This is done to avoid introspection in the clients. The string will be in the same format as the query-param syntax. If the target type only supports map-based selectors, both this field and map-based selector field are populated. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
}
func (ScaleStatus) SwaggerDoc() map[string]string {
return map_ScaleStatus
}
var map_StatefulSet = map[string]string{ var map_StatefulSet = map[string]string{
"": "StatefulSet represents a set of pods with consistent identities. Identities are defined as:\n - Network: A single stable DNS and hostname.\n - Storage: As many VolumeClaims as requested.\nThe StatefulSet guarantees that a given network identity will always map to the same storage identity.", "": "StatefulSet represents a set of pods with consistent identities. Identities are defined as:\n - Network: A single stable DNS and hostname.\n - Storage: As many VolumeClaims as requested.\nThe StatefulSet guarantees that a given network identity will always map to the same storage identity.",
"spec": "Spec defines the desired identities of pods in this set.", "spec": "Spec defines the desired identities of pods in this set.",
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion" conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
intstr "k8s.io/apimachinery/pkg/util/intstr"
api_v1 "k8s.io/kubernetes/pkg/api/v1" api_v1 "k8s.io/kubernetes/pkg/api/v1"
reflect "reflect" reflect "reflect"
) )
...@@ -36,6 +37,18 @@ func init() { ...@@ -36,6 +37,18 @@ func init() {
// to allow building arbitrary schemes. // to allow building arbitrary schemes.
func RegisterDeepCopies(scheme *runtime.Scheme) error { func RegisterDeepCopies(scheme *runtime.Scheme) error {
return scheme.AddGeneratedDeepCopyFuncs( return scheme.AddGeneratedDeepCopyFuncs(
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_Deployment, InType: reflect.TypeOf(&Deployment{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentCondition, InType: reflect.TypeOf(&DeploymentCondition{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentList, InType: reflect.TypeOf(&DeploymentList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentRollback, InType: reflect.TypeOf(&DeploymentRollback{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentSpec, InType: reflect.TypeOf(&DeploymentSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentStatus, InType: reflect.TypeOf(&DeploymentStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentStrategy, InType: reflect.TypeOf(&DeploymentStrategy{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_RollbackConfig, InType: reflect.TypeOf(&RollbackConfig{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_RollingUpdateDeployment, InType: reflect.TypeOf(&RollingUpdateDeployment{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_Scale, InType: reflect.TypeOf(&Scale{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_ScaleSpec, InType: reflect.TypeOf(&ScaleSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_ScaleStatus, InType: reflect.TypeOf(&ScaleStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSet, InType: reflect.TypeOf(&StatefulSet{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSet, InType: reflect.TypeOf(&StatefulSet{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSetList, InType: reflect.TypeOf(&StatefulSetList{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSetList, InType: reflect.TypeOf(&StatefulSetList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSetSpec, InType: reflect.TypeOf(&StatefulSetSpec{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSetSpec, InType: reflect.TypeOf(&StatefulSetSpec{})},
...@@ -43,6 +56,218 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { ...@@ -43,6 +56,218 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
) )
} }
func DeepCopy_v1beta1_Deployment(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Deployment)
out := out.(*Deployment)
*out = *in
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
return err
} else {
out.ObjectMeta = *newVal.(*v1.ObjectMeta)
}
if err := DeepCopy_v1beta1_DeploymentSpec(&in.Spec, &out.Spec, c); err != nil {
return err
}
if err := DeepCopy_v1beta1_DeploymentStatus(&in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentCondition)
out := out.(*DeploymentCondition)
*out = *in
out.LastUpdateTime = in.LastUpdateTime.DeepCopy()
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
return nil
}
}
func DeepCopy_v1beta1_DeploymentList(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentList)
out := out.(*DeploymentList)
*out = *in
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Deployment, len(*in))
for i := range *in {
if err := DeepCopy_v1beta1_Deployment(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentRollback(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentRollback)
out := out.(*DeploymentRollback)
*out = *in
if in.UpdatedAnnotations != nil {
in, out := &in.UpdatedAnnotations, &out.UpdatedAnnotations
*out = make(map[string]string)
for key, val := range *in {
(*out)[key] = val
}
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentSpec)
out := out.(*DeploymentSpec)
*out = *in
if in.Replicas != nil {
in, out := &in.Replicas, &out.Replicas
*out = new(int32)
**out = **in
}
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
if newVal, err := c.DeepCopy(*in); err != nil {
return err
} else {
*out = newVal.(*v1.LabelSelector)
}
}
if err := api_v1.DeepCopy_v1_PodTemplateSpec(&in.Template, &out.Template, c); err != nil {
return err
}
if err := DeepCopy_v1beta1_DeploymentStrategy(&in.Strategy, &out.Strategy, c); err != nil {
return err
}
if in.RevisionHistoryLimit != nil {
in, out := &in.RevisionHistoryLimit, &out.RevisionHistoryLimit
*out = new(int32)
**out = **in
}
if in.RollbackTo != nil {
in, out := &in.RollbackTo, &out.RollbackTo
*out = new(RollbackConfig)
**out = **in
}
if in.ProgressDeadlineSeconds != nil {
in, out := &in.ProgressDeadlineSeconds, &out.ProgressDeadlineSeconds
*out = new(int32)
**out = **in
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentStatus)
out := out.(*DeploymentStatus)
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]DeploymentCondition, len(*in))
for i := range *in {
if err := DeepCopy_v1beta1_DeploymentCondition(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentStrategy(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentStrategy)
out := out.(*DeploymentStrategy)
*out = *in
if in.RollingUpdate != nil {
in, out := &in.RollingUpdate, &out.RollingUpdate
*out = new(RollingUpdateDeployment)
if err := DeepCopy_v1beta1_RollingUpdateDeployment(*in, *out, c); err != nil {
return err
}
}
return nil
}
}
func DeepCopy_v1beta1_RollbackConfig(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*RollbackConfig)
out := out.(*RollbackConfig)
*out = *in
return nil
}
}
func DeepCopy_v1beta1_RollingUpdateDeployment(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*RollingUpdateDeployment)
out := out.(*RollingUpdateDeployment)
*out = *in
if in.MaxUnavailable != nil {
in, out := &in.MaxUnavailable, &out.MaxUnavailable
*out = new(intstr.IntOrString)
**out = **in
}
if in.MaxSurge != nil {
in, out := &in.MaxSurge, &out.MaxSurge
*out = new(intstr.IntOrString)
**out = **in
}
return nil
}
}
func DeepCopy_v1beta1_Scale(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Scale)
out := out.(*Scale)
*out = *in
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
return err
} else {
out.ObjectMeta = *newVal.(*v1.ObjectMeta)
}
if err := DeepCopy_v1beta1_ScaleStatus(&in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_v1beta1_ScaleSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScaleSpec)
out := out.(*ScaleSpec)
*out = *in
return nil
}
}
func DeepCopy_v1beta1_ScaleStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScaleStatus)
out := out.(*ScaleStatus)
*out = *in
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = make(map[string]string)
for key, val := range *in {
(*out)[key] = val
}
}
return nil
}
}
func DeepCopy_v1beta1_StatefulSet(in interface{}, out interface{}, c *conversion.Cloner) error { func DeepCopy_v1beta1_StatefulSet(in interface{}, out interface{}, c *conversion.Cloner) error {
{ {
in := in.(*StatefulSet) in := in.(*StatefulSet)
......
...@@ -29,11 +29,151 @@ import ( ...@@ -29,11 +29,151 @@ import (
// Public to allow building arbitrary schemes. // Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters. // All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error { func RegisterDefaults(scheme *runtime.Scheme) error {
scheme.AddTypeDefaultingFunc(&Deployment{}, func(obj interface{}) { SetObjectDefaults_Deployment(obj.(*Deployment)) })
scheme.AddTypeDefaultingFunc(&DeploymentList{}, func(obj interface{}) { SetObjectDefaults_DeploymentList(obj.(*DeploymentList)) })
scheme.AddTypeDefaultingFunc(&StatefulSet{}, func(obj interface{}) { SetObjectDefaults_StatefulSet(obj.(*StatefulSet)) }) scheme.AddTypeDefaultingFunc(&StatefulSet{}, func(obj interface{}) { SetObjectDefaults_StatefulSet(obj.(*StatefulSet)) })
scheme.AddTypeDefaultingFunc(&StatefulSetList{}, func(obj interface{}) { SetObjectDefaults_StatefulSetList(obj.(*StatefulSetList)) }) scheme.AddTypeDefaultingFunc(&StatefulSetList{}, func(obj interface{}) { SetObjectDefaults_StatefulSetList(obj.(*StatefulSetList)) })
return nil return nil
} }
func SetObjectDefaults_Deployment(in *Deployment) {
SetDefaults_Deployment(in)
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
for i := range in.Spec.Template.Spec.Volumes {
a := &in.Spec.Template.Spec.Volumes[i]
v1.SetDefaults_Volume(a)
if a.VolumeSource.Secret != nil {
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
}
if a.VolumeSource.ISCSI != nil {
v1.SetDefaults_ISCSIVolumeSource(a.VolumeSource.ISCSI)
}
if a.VolumeSource.RBD != nil {
v1.SetDefaults_RBDVolumeSource(a.VolumeSource.RBD)
}
if a.VolumeSource.DownwardAPI != nil {
v1.SetDefaults_DownwardAPIVolumeSource(a.VolumeSource.DownwardAPI)
for j := range a.VolumeSource.DownwardAPI.Items {
b := &a.VolumeSource.DownwardAPI.Items[j]
if b.FieldRef != nil {
v1.SetDefaults_ObjectFieldSelector(b.FieldRef)
}
}
}
if a.VolumeSource.ConfigMap != nil {
v1.SetDefaults_ConfigMapVolumeSource(a.VolumeSource.ConfigMap)
}
if a.VolumeSource.AzureDisk != nil {
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
}
if a.VolumeSource.Projected != nil {
v1.SetDefaults_ProjectedVolumeSource(a.VolumeSource.Projected)
for j := range a.VolumeSource.Projected.Sources {
b := &a.VolumeSource.Projected.Sources[j]
if b.DownwardAPI != nil {
for k := range b.DownwardAPI.Items {
c := &b.DownwardAPI.Items[k]
if c.FieldRef != nil {
v1.SetDefaults_ObjectFieldSelector(c.FieldRef)
}
}
}
}
}
}
for i := range in.Spec.Template.Spec.InitContainers {
a := &in.Spec.Template.Spec.InitContainers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
v1.SetDefaults_ContainerPort(b)
}
for j := range a.Env {
b := &a.Env[j]
if b.ValueFrom != nil {
if b.ValueFrom.FieldRef != nil {
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
}
}
}
v1.SetDefaults_ResourceList(&a.Resources.Limits)
v1.SetDefaults_ResourceList(&a.Resources.Requests)
if a.LivenessProbe != nil {
v1.SetDefaults_Probe(a.LivenessProbe)
if a.LivenessProbe.Handler.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
}
}
if a.ReadinessProbe != nil {
v1.SetDefaults_Probe(a.ReadinessProbe)
if a.ReadinessProbe.Handler.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
}
}
if a.Lifecycle != nil {
if a.Lifecycle.PostStart != nil {
if a.Lifecycle.PostStart.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
}
}
if a.Lifecycle.PreStop != nil {
if a.Lifecycle.PreStop.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
}
}
}
}
for i := range in.Spec.Template.Spec.Containers {
a := &in.Spec.Template.Spec.Containers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
v1.SetDefaults_ContainerPort(b)
}
for j := range a.Env {
b := &a.Env[j]
if b.ValueFrom != nil {
if b.ValueFrom.FieldRef != nil {
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
}
}
}
v1.SetDefaults_ResourceList(&a.Resources.Limits)
v1.SetDefaults_ResourceList(&a.Resources.Requests)
if a.LivenessProbe != nil {
v1.SetDefaults_Probe(a.LivenessProbe)
if a.LivenessProbe.Handler.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
}
}
if a.ReadinessProbe != nil {
v1.SetDefaults_Probe(a.ReadinessProbe)
if a.ReadinessProbe.Handler.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
}
}
if a.Lifecycle != nil {
if a.Lifecycle.PostStart != nil {
if a.Lifecycle.PostStart.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
}
}
if a.Lifecycle.PreStop != nil {
if a.Lifecycle.PreStop.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
}
}
}
}
}
func SetObjectDefaults_DeploymentList(in *DeploymentList) {
for i := range in.Items {
a := &in.Items[i]
SetObjectDefaults_Deployment(a)
}
}
func SetObjectDefaults_StatefulSet(in *StatefulSet) { func SetObjectDefaults_StatefulSet(in *StatefulSet) {
SetDefaults_StatefulSet(in) SetDefaults_StatefulSet(in)
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec) v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
......
...@@ -539,15 +539,3 @@ func newInt32(val int32) *int32 { ...@@ -539,15 +539,3 @@ func newInt32(val int32) *int32 {
*p = val *p = val
return p return p
} }
func newString(val string) *string {
p := new(string)
*p = val
return p
}
func newBool(val bool) *bool {
b := new(bool)
*b = val
return b
}
...@@ -2808,9 +2808,3 @@ func TestIsValidSysctlPattern(t *testing.T) { ...@@ -2808,9 +2808,3 @@ func TestIsValidSysctlPattern(t *testing.T) {
} }
} }
} }
func newBool(val bool) *bool {
p := new(bool)
*p = val
return p
}
...@@ -11,8 +11,10 @@ go_library( ...@@ -11,8 +11,10 @@ go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"apps_client.go", "apps_client.go",
"deployment.go",
"doc.go", "doc.go",
"generated_expansion.go", "generated_expansion.go",
"scale.go",
"statefulset.go", "statefulset.go",
], ],
tags = ["automanaged"], tags = ["automanaged"],
......
...@@ -25,6 +25,8 @@ import ( ...@@ -25,6 +25,8 @@ import (
type AppsV1beta1Interface interface { type AppsV1beta1Interface interface {
RESTClient() rest.Interface RESTClient() rest.Interface
DeploymentsGetter
ScalesGetter
StatefulSetsGetter StatefulSetsGetter
} }
...@@ -33,6 +35,14 @@ type AppsV1beta1Client struct { ...@@ -33,6 +35,14 @@ type AppsV1beta1Client struct {
restClient rest.Interface restClient rest.Interface
} }
func (c *AppsV1beta1Client) Deployments(namespace string) DeploymentInterface {
return newDeployments(c, namespace)
}
func (c *AppsV1beta1Client) Scales(namespace string) ScaleInterface {
return newScales(c, namespace)
}
func (c *AppsV1beta1Client) StatefulSets(namespace string) StatefulSetInterface { func (c *AppsV1beta1Client) StatefulSets(namespace string) StatefulSetInterface {
return newStatefulSets(c, namespace) return newStatefulSets(c, namespace)
} }
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
scheme "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/scheme"
)
// DeploymentsGetter has a method to return a DeploymentInterface.
// A group's client should implement this interface.
type DeploymentsGetter interface {
Deployments(namespace string) DeploymentInterface
}
// DeploymentInterface has methods to work with Deployment resources.
type DeploymentInterface interface {
Create(*v1beta1.Deployment) (*v1beta1.Deployment, error)
Update(*v1beta1.Deployment) (*v1beta1.Deployment, error)
UpdateStatus(*v1beta1.Deployment) (*v1beta1.Deployment, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1beta1.Deployment, error)
List(opts v1.ListOptions) (*v1beta1.DeploymentList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error)
DeploymentExpansion
}
// deployments implements DeploymentInterface
type deployments struct {
client rest.Interface
ns string
}
// newDeployments returns a Deployments
func newDeployments(c *AppsV1beta1Client, namespace string) *deployments {
return &deployments{
client: c.RESTClient(),
ns: namespace,
}
}
// Create takes the representation of a deployment and creates it. Returns the server's representation of the deployment, and an error, if there is any.
func (c *deployments) Create(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Post().
Namespace(c.ns).
Resource("deployments").
Body(deployment).
Do().
Into(result)
return
}
// Update takes the representation of a deployment and updates it. Returns the server's representation of the deployment, and an error, if there is any.
func (c *deployments) Update(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Put().
Namespace(c.ns).
Resource("deployments").
Name(deployment.Name).
Body(deployment).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *deployments) UpdateStatus(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Put().
Namespace(c.ns).
Resource("deployments").
Name(deployment.Name).
SubResource("status").
Body(deployment).
Do().
Into(result)
return
}
// Delete takes name of the deployment and deletes it. Returns an error if one occurs.
func (c *deployments) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("deployments").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *deployments) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("deployments").
VersionedParams(&listOptions, scheme.ParameterCodec).
Body(options).
Do().
Error()
}
// Get takes name of the deployment, and returns the corresponding deployment object, and an error if there is any.
func (c *deployments) Get(name string, options v1.GetOptions) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Get().
Namespace(c.ns).
Resource("deployments").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of Deployments that match those selectors.
func (c *deployments) List(opts v1.ListOptions) (result *v1beta1.DeploymentList, err error) {
result = &v1beta1.DeploymentList{}
err = c.client.Get().
Namespace(c.ns).
Resource("deployments").
VersionedParams(&opts, scheme.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested deployments.
func (c *deployments) Watch(opts v1.ListOptions) (watch.Interface, error) {
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("deployments").
VersionedParams(&opts, scheme.ParameterCodec).
Watch()
}
// Patch applies the patch and returns the patched deployment.
func (c *deployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("deployments").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
...@@ -12,6 +12,8 @@ go_library( ...@@ -12,6 +12,8 @@ go_library(
srcs = [ srcs = [
"doc.go", "doc.go",
"fake_apps_client.go", "fake_apps_client.go",
"fake_deployment.go",
"fake_scale.go",
"fake_statefulset.go", "fake_statefulset.go",
], ],
tags = ["automanaged"], tags = ["automanaged"],
......
...@@ -26,6 +26,14 @@ type FakeAppsV1beta1 struct { ...@@ -26,6 +26,14 @@ type FakeAppsV1beta1 struct {
*testing.Fake *testing.Fake
} }
func (c *FakeAppsV1beta1) Deployments(namespace string) v1beta1.DeploymentInterface {
return &FakeDeployments{c, namespace}
}
func (c *FakeAppsV1beta1) Scales(namespace string) v1beta1.ScaleInterface {
return &FakeScales{c, namespace}
}
func (c *FakeAppsV1beta1) StatefulSets(namespace string) v1beta1.StatefulSetInterface { func (c *FakeAppsV1beta1) StatefulSets(namespace string) v1beta1.StatefulSetInterface {
return &FakeStatefulSets{c, namespace} return &FakeStatefulSets{c, namespace}
} }
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
)
// FakeDeployments implements DeploymentInterface
type FakeDeployments struct {
Fake *FakeAppsV1beta1
ns string
}
var deploymentsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta1", Resource: "deployments"}
func (c *FakeDeployments) Create(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(deploymentsResource, c.ns, deployment), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
func (c *FakeDeployments) Update(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(deploymentsResource, c.ns, deployment), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
func (c *FakeDeployments) UpdateStatus(deployment *v1beta1.Deployment) (*v1beta1.Deployment, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(deploymentsResource, "status", c.ns, deployment), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
func (c *FakeDeployments) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(deploymentsResource, c.ns, name), &v1beta1.Deployment{})
return err
}
func (c *FakeDeployments) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(deploymentsResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1beta1.DeploymentList{})
return err
}
func (c *FakeDeployments) Get(name string, options v1.GetOptions) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(deploymentsResource, c.ns, name), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
func (c *FakeDeployments) List(opts v1.ListOptions) (result *v1beta1.DeploymentList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(deploymentsResource, c.ns, opts), &v1beta1.DeploymentList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1beta1.DeploymentList{}
for _, item := range obj.(*v1beta1.DeploymentList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested deployments.
func (c *FakeDeployments) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(deploymentsResource, c.ns, opts))
}
// Patch applies the patch and returns the patched deployment.
func (c *FakeDeployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, data, subresources...), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
// FakeScales implements ScaleInterface
type FakeScales struct {
Fake *FakeAppsV1beta1
ns string
}
...@@ -16,4 +16,8 @@ limitations under the License. ...@@ -16,4 +16,8 @@ limitations under the License.
package v1beta1 package v1beta1
type DeploymentExpansion interface{}
type ScaleExpansion interface{}
type StatefulSetExpansion interface{} type StatefulSetExpansion interface{}
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
rest "k8s.io/client-go/rest"
)
// ScalesGetter has a method to return a ScaleInterface.
// A group's client should implement this interface.
type ScalesGetter interface {
Scales(namespace string) ScaleInterface
}
// ScaleInterface has methods to work with Scale resources.
type ScaleInterface interface {
ScaleExpansion
}
// scales implements ScaleInterface
type scales struct {
client rest.Interface
ns string
}
// newScales returns a Scales
func newScales(c *AppsV1beta1Client, namespace string) *scales {
return &scales{
client: c.RESTClient(),
ns: namespace,
}
}
...@@ -10,6 +10,7 @@ load( ...@@ -10,6 +10,7 @@ load(
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"deployment.go",
"interface.go", "interface.go",
"statefulset.go", "statefulset.go",
], ],
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v1beta1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
apps_v1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
internalinterfaces "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions/internalinterfaces"
v1beta1 "k8s.io/kubernetes/pkg/client/listers/apps/v1beta1"
time "time"
)
// DeploymentInformer provides access to a shared informer and lister for
// Deployments.
type DeploymentInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1beta1.DeploymentLister
}
type deploymentInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newDeploymentInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.AppsV1beta1().Deployments(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.AppsV1beta1().Deployments(v1.NamespaceAll).Watch(options)
},
},
&apps_v1beta1.Deployment{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *deploymentInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&apps_v1beta1.Deployment{}, newDeploymentInformer)
}
func (f *deploymentInformer) Lister() v1beta1.DeploymentLister {
return v1beta1.NewDeploymentLister(f.Informer().GetIndexer())
}
...@@ -24,6 +24,8 @@ import ( ...@@ -24,6 +24,8 @@ import (
// Interface provides access to all the informers in this group version. // Interface provides access to all the informers in this group version.
type Interface interface { type Interface interface {
// Deployments returns a DeploymentInformer.
Deployments() DeploymentInformer
// StatefulSets returns a StatefulSetInformer. // StatefulSets returns a StatefulSetInformer.
StatefulSets() StatefulSetInformer StatefulSets() StatefulSetInformer
} }
...@@ -37,6 +39,11 @@ func New(f internalinterfaces.SharedInformerFactory) Interface { ...@@ -37,6 +39,11 @@ func New(f internalinterfaces.SharedInformerFactory) Interface {
return &version{f} return &version{f}
} }
// Deployments returns a DeploymentInformer.
func (v *version) Deployments() DeploymentInformer {
return &deploymentInformer{factory: v.SharedInformerFactory}
}
// StatefulSets returns a StatefulSetInformer. // StatefulSets returns a StatefulSetInformer.
func (v *version) StatefulSets() StatefulSetInformer { func (v *version) StatefulSets() StatefulSetInformer {
return &statefulSetInformer{factory: v.SharedInformerFactory} return &statefulSetInformer{factory: v.SharedInformerFactory}
......
...@@ -63,6 +63,8 @@ func (f *genericInformer) Lister() cache.GenericLister { ...@@ -63,6 +63,8 @@ func (f *genericInformer) Lister() cache.GenericLister {
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource { switch resource {
// Group=Apps, Version=V1beta1 // Group=Apps, Version=V1beta1
case v1beta1.SchemeGroupVersion.WithResource("deployments"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().Deployments().Informer()}, nil
case v1beta1.SchemeGroupVersion.WithResource("statefulsets"): case v1beta1.SchemeGroupVersion.WithResource("statefulsets"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().StatefulSets().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().StatefulSets().Informer()}, nil
......
...@@ -10,7 +10,9 @@ load( ...@@ -10,7 +10,9 @@ load(
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"deployment.go",
"expansion_generated.go", "expansion_generated.go",
"scale.go",
"statefulset.go", "statefulset.go",
"statefulset_expansion.go", "statefulset_expansion.go",
], ],
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package v1beta1
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
apps "k8s.io/kubernetes/pkg/apis/apps"
v1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
)
// DeploymentLister helps list Deployments.
type DeploymentLister interface {
// List lists all Deployments in the indexer.
List(selector labels.Selector) (ret []*v1beta1.Deployment, err error)
// Deployments returns an object that can list and get Deployments.
Deployments(namespace string) DeploymentNamespaceLister
DeploymentListerExpansion
}
// deploymentLister implements the DeploymentLister interface.
type deploymentLister struct {
indexer cache.Indexer
}
// NewDeploymentLister returns a new DeploymentLister.
func NewDeploymentLister(indexer cache.Indexer) DeploymentLister {
return &deploymentLister{indexer: indexer}
}
// List lists all Deployments in the indexer.
func (s *deploymentLister) List(selector labels.Selector) (ret []*v1beta1.Deployment, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.Deployment))
})
return ret, err
}
// Deployments returns an object that can list and get Deployments.
func (s *deploymentLister) Deployments(namespace string) DeploymentNamespaceLister {
return deploymentNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// DeploymentNamespaceLister helps list and get Deployments.
type DeploymentNamespaceLister interface {
// List lists all Deployments in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1beta1.Deployment, err error)
// Get retrieves the Deployment from the indexer for a given namespace and name.
Get(name string) (*v1beta1.Deployment, error)
DeploymentNamespaceListerExpansion
}
// deploymentNamespaceLister implements the DeploymentNamespaceLister
// interface.
type deploymentNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all Deployments in the indexer for a given namespace.
func (s deploymentNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Deployment, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.Deployment))
})
return ret, err
}
// Get retrieves the Deployment from the indexer for a given namespace and name.
func (s deploymentNamespaceLister) Get(name string) (*v1beta1.Deployment, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(apps.Resource("deployment"), name)
}
return obj.(*v1beta1.Deployment), nil
}
...@@ -17,3 +17,19 @@ limitations under the License. ...@@ -17,3 +17,19 @@ limitations under the License.
// This file was automatically generated by lister-gen // This file was automatically generated by lister-gen
package v1beta1 package v1beta1
// DeploymentListerExpansion allows custom methods to be added to
// DeploymentLister.
type DeploymentListerExpansion interface{}
// DeploymentNamespaceListerExpansion allows custom methods to be added to
// DeploymentNamespaeLister.
type DeploymentNamespaceListerExpansion interface{}
// ScaleListerExpansion allows custom methods to be added to
// ScaleLister.
type ScaleListerExpansion interface{}
// ScaleNamespaceListerExpansion allows custom methods to be added to
// ScaleNamespaeLister.
type ScaleNamespaceListerExpansion interface{}
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package v1beta1
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
apps "k8s.io/kubernetes/pkg/apis/apps"
v1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
)
// ScaleLister helps list Scales.
type ScaleLister interface {
// List lists all Scales in the indexer.
List(selector labels.Selector) (ret []*v1beta1.Scale, err error)
// Scales returns an object that can list and get Scales.
Scales(namespace string) ScaleNamespaceLister
ScaleListerExpansion
}
// scaleLister implements the ScaleLister interface.
type scaleLister struct {
indexer cache.Indexer
}
// NewScaleLister returns a new ScaleLister.
func NewScaleLister(indexer cache.Indexer) ScaleLister {
return &scaleLister{indexer: indexer}
}
// List lists all Scales in the indexer.
func (s *scaleLister) List(selector labels.Selector) (ret []*v1beta1.Scale, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.Scale))
})
return ret, err
}
// Scales returns an object that can list and get Scales.
func (s *scaleLister) Scales(namespace string) ScaleNamespaceLister {
return scaleNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ScaleNamespaceLister helps list and get Scales.
type ScaleNamespaceLister interface {
// List lists all Scales in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1beta1.Scale, err error)
// Get retrieves the Scale from the indexer for a given namespace and name.
Get(name string) (*v1beta1.Scale, error)
ScaleNamespaceListerExpansion
}
// scaleNamespaceLister implements the ScaleNamespaceLister
// interface.
type scaleNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all Scales in the indexer for a given namespace.
func (s scaleNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Scale, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.Scale))
})
return ret, err
}
// Get retrieves the Scale from the indexer for a given namespace and name.
func (s scaleNamespaceLister) Get(name string) (*v1beta1.Scale, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(apps.Resource("scale"), name)
}
return obj.(*v1beta1.Scale), nil
}
...@@ -421,6 +421,7 @@ func getRESTMappings(mapper meta.RESTMapper, pruneResources *[]pruneResource) (n ...@@ -421,6 +421,7 @@ func getRESTMappings(mapper meta.RESTMapper, pruneResources *[]pruneResource) (n
{"extensions", "v1beta1", "Ingress", true}, {"extensions", "v1beta1", "Ingress", true},
{"extensions", "v1beta1", "ReplicaSet", true}, {"extensions", "v1beta1", "ReplicaSet", true},
{"apps", "v1beta1", "StatefulSet", true}, {"apps", "v1beta1", "StatefulSet", true},
{"apps", "v1beta1", "Deployment", true},
} }
} }
......
...@@ -552,7 +552,8 @@ func (f *ring0Factory) Generators(cmdName string) map[string]kubectl.Generator { ...@@ -552,7 +552,8 @@ func (f *ring0Factory) Generators(cmdName string) map[string]kubectl.Generator {
func (f *ring0Factory) CanBeExposed(kind schema.GroupKind) error { func (f *ring0Factory) CanBeExposed(kind schema.GroupKind) error {
switch kind { switch kind {
case api.Kind("ReplicationController"), api.Kind("Service"), api.Kind("Pod"), extensions.Kind("Deployment"), extensions.Kind("ReplicaSet"): case api.Kind("ReplicationController"), api.Kind("Service"), api.Kind("Pod"),
extensions.Kind("Deployment"), apps.Kind("Deployment"), extensions.Kind("ReplicaSet"):
// nothing to do here // nothing to do here
default: default:
return fmt.Errorf("cannot expose a %s", kind) return fmt.Errorf("cannot expose a %s", kind)
...@@ -562,7 +563,8 @@ func (f *ring0Factory) CanBeExposed(kind schema.GroupKind) error { ...@@ -562,7 +563,8 @@ func (f *ring0Factory) CanBeExposed(kind schema.GroupKind) error {
func (f *ring0Factory) CanBeAutoscaled(kind schema.GroupKind) error { func (f *ring0Factory) CanBeAutoscaled(kind schema.GroupKind) error {
switch kind { switch kind {
case api.Kind("ReplicationController"), extensions.Kind("Deployment"), extensions.Kind("ReplicaSet"): case api.Kind("ReplicationController"), extensions.Kind("ReplicaSet"),
extensions.Kind("Deployment"), apps.Kind("Deployment"):
// nothing to do here // nothing to do here
default: default:
return fmt.Errorf("cannot autoscale a %v", kind) return fmt.Errorf("cannot autoscale a %v", kind)
......
...@@ -28,6 +28,7 @@ import ( ...@@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util" deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
...@@ -46,7 +47,7 @@ type HistoryViewer interface { ...@@ -46,7 +47,7 @@ type HistoryViewer interface {
func HistoryViewerFor(kind schema.GroupKind, c clientset.Interface) (HistoryViewer, error) { func HistoryViewerFor(kind schema.GroupKind, c clientset.Interface) (HistoryViewer, error) {
switch kind { switch kind {
case extensions.Kind("Deployment"): case extensions.Kind("Deployment"), apps.Kind("Deployment"):
return &DeploymentHistoryViewer{c}, nil return &DeploymentHistoryViewer{c}, nil
} }
return nil, fmt.Errorf("no history viewer has been implemented for %q", kind) return nil, fmt.Errorf("no history viewer has been implemented for %q", kind)
......
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
externalextensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" externalextensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
...@@ -44,7 +45,7 @@ type Rollbacker interface { ...@@ -44,7 +45,7 @@ type Rollbacker interface {
func RollbackerFor(kind schema.GroupKind, c clientset.Interface) (Rollbacker, error) { func RollbackerFor(kind schema.GroupKind, c clientset.Interface) (Rollbacker, error) {
switch kind { switch kind {
case extensions.Kind("Deployment"): case extensions.Kind("Deployment"), apps.Kind("Deployment"):
return &DeploymentRollbacker{c}, nil return &DeploymentRollbacker{c}, nil
} }
return nil, fmt.Errorf("no rollbacker has been implemented for %q", kind) return nil, fmt.Errorf("no rollbacker has been implemented for %q", kind)
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
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/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
extensionsclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion" extensionsclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion"
...@@ -34,7 +35,7 @@ type StatusViewer interface { ...@@ -34,7 +35,7 @@ type StatusViewer interface {
func StatusViewerFor(kind schema.GroupKind, c internalclientset.Interface) (StatusViewer, error) { func StatusViewerFor(kind schema.GroupKind, c internalclientset.Interface) (StatusViewer, error) {
switch kind { switch kind {
case extensions.Kind("Deployment"): case extensions.Kind("Deployment"), apps.Kind("Deployment"):
return &DeploymentStatusViewer{c.Extensions()}, nil return &DeploymentStatusViewer{c.Extensions()}, nil
case extensions.Kind("DaemonSet"): case extensions.Kind("DaemonSet"):
return &DaemonSetStatusViewer{c.Extensions()}, nil return &DaemonSetStatusViewer{c.Extensions()}, nil
......
...@@ -26,7 +26,7 @@ import ( ...@@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
batch "k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
) )
......
...@@ -60,7 +60,7 @@ func ScalerFor(kind schema.GroupKind, c internalclientset.Interface) (Scaler, er ...@@ -60,7 +60,7 @@ func ScalerFor(kind schema.GroupKind, c internalclientset.Interface) (Scaler, er
return &JobScaler{c.Batch()}, nil // Either kind of job can be scaled with Batch interface. return &JobScaler{c.Batch()}, nil // Either kind of job can be scaled with Batch interface.
case apps.Kind("StatefulSet"): case apps.Kind("StatefulSet"):
return &StatefulSetScaler{c.Apps()}, nil return &StatefulSetScaler{c.Apps()}, nil
case extensions.Kind("Deployment"): case extensions.Kind("Deployment"), apps.Kind("Deployment"):
return &DeploymentScaler{c.Extensions()}, nil return &DeploymentScaler{c.Extensions()}, nil
} }
return nil, fmt.Errorf("no scaler has been implemented for %q", kind) return nil, fmt.Errorf("no scaler has been implemented for %q", kind)
......
...@@ -90,7 +90,7 @@ func ReaperFor(kind schema.GroupKind, c internalclientset.Interface) (Reaper, er ...@@ -90,7 +90,7 @@ func ReaperFor(kind schema.GroupKind, c internalclientset.Interface) (Reaper, er
case apps.Kind("StatefulSet"): case apps.Kind("StatefulSet"):
return &StatefulSetReaper{c.Apps(), c.Core(), Interval, Timeout}, nil return &StatefulSetReaper{c.Apps(), c.Core(), Interval, Timeout}, nil
case extensions.Kind("Deployment"): case extensions.Kind("Deployment"), apps.Kind("Deployment"):
return &DeploymentReaper{c.Extensions(), c.Extensions(), Interval, Timeout}, nil return &DeploymentReaper{c.Extensions(), c.Extensions(), Interval, Timeout}, nil
} }
......
...@@ -33,7 +33,7 @@ import ( ...@@ -33,7 +33,7 @@ import (
"k8s.io/kubernetes/cmd/kube-apiserver/app/options" "k8s.io/kubernetes/cmd/kube-apiserver/app/options"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
apiv1 "k8s.io/kubernetes/pkg/api/v1" apiv1 "k8s.io/kubernetes/pkg/api/v1"
appsapi "k8s.io/kubernetes/pkg/apis/apps/v1beta1" appsv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
authenticationv1 "k8s.io/kubernetes/pkg/apis/authentication/v1" authenticationv1 "k8s.io/kubernetes/pkg/apis/authentication/v1"
authenticationv1beta1 "k8s.io/kubernetes/pkg/apis/authentication/v1beta1" authenticationv1beta1 "k8s.io/kubernetes/pkg/apis/authentication/v1beta1"
authorizationapiv1 "k8s.io/kubernetes/pkg/apis/authorization/v1" authorizationapiv1 "k8s.io/kubernetes/pkg/apis/authorization/v1"
...@@ -367,7 +367,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig { ...@@ -367,7 +367,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
authenticationv1.SchemeGroupVersion, authenticationv1.SchemeGroupVersion,
authenticationv1beta1.SchemeGroupVersion, authenticationv1beta1.SchemeGroupVersion,
autoscalingapiv1.SchemeGroupVersion, autoscalingapiv1.SchemeGroupVersion,
appsapi.SchemeGroupVersion, appsv1beta1.SchemeGroupVersion,
policyapiv1beta1.SchemeGroupVersion, policyapiv1beta1.SchemeGroupVersion,
rbacv1beta1.SchemeGroupVersion, rbacv1beta1.SchemeGroupVersion,
rbacapi.SchemeGroupVersion, rbacapi.SchemeGroupVersion,
......
...@@ -118,6 +118,7 @@ func describerMap(c clientset.Interface) map[schema.GroupKind]printers.Describer ...@@ -118,6 +118,7 @@ func describerMap(c clientset.Interface) map[schema.GroupKind]printers.Describer
batch.Kind("Job"): &JobDescriber{c}, batch.Kind("Job"): &JobDescriber{c},
batch.Kind("CronJob"): &CronJobDescriber{c}, batch.Kind("CronJob"): &CronJobDescriber{c},
apps.Kind("StatefulSet"): &StatefulSetDescriber{c}, apps.Kind("StatefulSet"): &StatefulSetDescriber{c},
apps.Kind("Deployment"): &DeploymentDescriber{c, versionedClientsetForDeployment(c)},
certificates.Kind("CertificateSigningRequest"): &CertificateSigningRequestDescriber{c}, certificates.Kind("CertificateSigningRequest"): &CertificateSigningRequestDescriber{c},
storage.Kind("StorageClass"): &StorageClassDescriber{c}, storage.Kind("StorageClass"): &StorageClassDescriber{c},
policy.Kind("PodDisruptionBudget"): &PodDisruptionBudgetDescriber{c}, policy.Kind("PodDisruptionBudget"): &PodDisruptionBudgetDescriber{c},
......
...@@ -16,6 +16,7 @@ go_library( ...@@ -16,6 +16,7 @@ go_library(
"//pkg/apis/apps:go_default_library", "//pkg/apis/apps:go_default_library",
"//pkg/apis/apps/v1beta1:go_default_library", "//pkg/apis/apps/v1beta1:go_default_library",
"//pkg/registry/apps/petset/storage:go_default_library", "//pkg/registry/apps/petset/storage:go_default_library",
"//pkg/registry/extensions/deployment/storage:go_default_library",
"//vendor:k8s.io/apiserver/pkg/registry/generic", "//vendor:k8s.io/apiserver/pkg/registry/generic",
"//vendor:k8s.io/apiserver/pkg/registry/rest", "//vendor:k8s.io/apiserver/pkg/registry/rest",
"//vendor:k8s.io/apiserver/pkg/server", "//vendor:k8s.io/apiserver/pkg/server",
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/apis/apps"
appsapiv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1" appsapiv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
statefulsetstore "k8s.io/kubernetes/pkg/registry/apps/petset/storage" statefulsetstore "k8s.io/kubernetes/pkg/registry/apps/petset/storage"
deploymentstore "k8s.io/kubernetes/pkg/registry/extensions/deployment/storage"
) )
type RESTStorageProvider struct{} type RESTStorageProvider struct{}
...@@ -44,6 +45,13 @@ func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorag ...@@ -44,6 +45,13 @@ func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorag
version := appsapiv1beta1.SchemeGroupVersion version := appsapiv1beta1.SchemeGroupVersion
storage := map[string]rest.Storage{} storage := map[string]rest.Storage{}
if apiResourceConfigSource.ResourceEnabled(version.WithResource("deployments")) {
deploymentStorage := deploymentstore.NewStorage(restOptionsGetter)
storage["deployments"] = deploymentStorage.Deployment
storage["deployments/status"] = deploymentStorage.Status
storage["deployments/rollback"] = deploymentStorage.Rollback
storage["deployments/scale"] = deploymentStorage.Scale
}
if apiResourceConfigSource.ResourceEnabled(version.WithResource("statefulsets")) { if apiResourceConfigSource.ResourceEnabled(version.WithResource("statefulsets")) {
statefulsetStorage, statefulsetStatusStorage := statefulsetstore.NewREST(restOptionsGetter) statefulsetStorage, statefulsetStatusStorage := statefulsetstore.NewREST(restOptionsGetter)
storage["statefulsets"] = statefulsetStorage storage["statefulsets"] = statefulsetStorage
......
...@@ -92,8 +92,8 @@ func init() { ...@@ -92,8 +92,8 @@ func init() {
addControllerRole(rbac.ClusterRole{ addControllerRole(rbac.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + "deployment-controller"}, ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + "deployment-controller"},
Rules: []rbac.PolicyRule{ Rules: []rbac.PolicyRule{
rbac.NewRule("get", "list", "watch", "update").Groups(extensionsGroup).Resources("deployments").RuleOrDie(), rbac.NewRule("get", "list", "watch", "update").Groups(extensionsGroup, appsGroup).Resources("deployments").RuleOrDie(),
rbac.NewRule("update").Groups(extensionsGroup).Resources("deployments/status").RuleOrDie(), rbac.NewRule("update").Groups(extensionsGroup, appsGroup).Resources("deployments/status").RuleOrDie(),
rbac.NewRule("get", "list", "watch", "create", "update", "patch", "delete").Groups(extensionsGroup).Resources("replicasets").RuleOrDie(), rbac.NewRule("get", "list", "watch", "create", "update", "patch", "delete").Groups(extensionsGroup).Resources("replicasets").RuleOrDie(),
// TODO: remove "update" once // TODO: remove "update" once
// https://github.com/kubernetes/kubernetes/issues/36897 is resolved. // https://github.com/kubernetes/kubernetes/issues/36897 is resolved.
...@@ -104,7 +104,7 @@ func init() { ...@@ -104,7 +104,7 @@ func init() {
addControllerRole(rbac.ClusterRole{ addControllerRole(rbac.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + "disruption-controller"}, ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + "disruption-controller"},
Rules: []rbac.PolicyRule{ Rules: []rbac.PolicyRule{
rbac.NewRule("get", "list", "watch").Groups(extensionsGroup).Resources("deployments").RuleOrDie(), rbac.NewRule("get", "list", "watch").Groups(extensionsGroup, appsGroup).Resources("deployments").RuleOrDie(),
rbac.NewRule("get", "list", "watch").Groups(extensionsGroup).Resources("replicasets").RuleOrDie(), rbac.NewRule("get", "list", "watch").Groups(extensionsGroup).Resources("replicasets").RuleOrDie(),
rbac.NewRule("get", "list", "watch").Groups(legacyGroup).Resources("replicationcontrollers").RuleOrDie(), rbac.NewRule("get", "list", "watch").Groups(legacyGroup).Resources("replicationcontrollers").RuleOrDie(),
rbac.NewRule("get", "list", "watch").Groups(policyGroup).Resources("poddisruptionbudgets").RuleOrDie(), rbac.NewRule("get", "list", "watch").Groups(policyGroup).Resources("poddisruptionbudgets").RuleOrDie(),
...@@ -138,7 +138,7 @@ func init() { ...@@ -138,7 +138,7 @@ func init() {
rbac.NewRule("get", "update").Groups(legacyGroup).Resources("replicationcontrollers/scale").RuleOrDie(), rbac.NewRule("get", "update").Groups(legacyGroup).Resources("replicationcontrollers/scale").RuleOrDie(),
// TODO this should be removable when the HPA contoller is fixed // TODO this should be removable when the HPA contoller is fixed
rbac.NewRule("get", "update").Groups(extensionsGroup).Resources("replicationcontrollers/scale").RuleOrDie(), rbac.NewRule("get", "update").Groups(extensionsGroup).Resources("replicationcontrollers/scale").RuleOrDie(),
rbac.NewRule("get", "update").Groups(extensionsGroup).Resources("deployments/scale", "replicasets/scale").RuleOrDie(), rbac.NewRule("get", "update").Groups(extensionsGroup, appsGroup).Resources("deployments/scale", "replicasets/scale").RuleOrDie(),
rbac.NewRule("list").Groups(legacyGroup).Resources("pods").RuleOrDie(), rbac.NewRule("list").Groups(legacyGroup).Resources("pods").RuleOrDie(),
// TODO: Remove the root /proxy permission in 1.7; MetricsClient no longer requires root proxy access as of 1.6 (fixed in https://github.com/kubernetes/kubernetes/pull/39636) // TODO: Remove the root /proxy permission in 1.7; MetricsClient no longer requires root proxy access as of 1.6 (fixed in https://github.com/kubernetes/kubernetes/pull/39636)
rbac.NewRule("proxy").Groups(legacyGroup).Resources("services").Names("https:heapster:", "http:heapster:").RuleOrDie(), rbac.NewRule("proxy").Groups(legacyGroup).Resources("services").Names("https:heapster:", "http:heapster:").RuleOrDie(),
......
...@@ -127,14 +127,16 @@ func ClusterRoles() []rbac.ClusterRole { ...@@ -127,14 +127,16 @@ func ClusterRoles() []rbac.ClusterRole {
rbac.NewRule(Read...).Groups(legacyGroup).Resources("namespaces").RuleOrDie(), rbac.NewRule(Read...).Groups(legacyGroup).Resources("namespaces").RuleOrDie(),
rbac.NewRule("impersonate").Groups(legacyGroup).Resources("serviceaccounts").RuleOrDie(), rbac.NewRule("impersonate").Groups(legacyGroup).Resources("serviceaccounts").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(appsGroup).Resources("statefulsets").RuleOrDie(), rbac.NewRule(ReadWrite...).Groups(appsGroup).Resources("statefulsets",
"deployments", "deployments/scale", "deployments/rollback").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(), rbac.NewRule(ReadWrite...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(batchGroup).Resources("jobs", "cronjobs", "scheduledjobs").RuleOrDie(), rbac.NewRule(ReadWrite...).Groups(batchGroup).Resources("jobs", "cronjobs", "scheduledjobs").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(extensionsGroup).Resources("daemonsets", "deployments", "deployments/scale", rbac.NewRule(ReadWrite...).Groups(extensionsGroup).Resources("daemonsets",
"ingresses", "replicasets", "replicasets/scale", "replicationcontrollers/scale").RuleOrDie(), "deployments", "deployments/scale", "deployments/rollback", "ingresses",
"replicasets", "replicasets/scale", "replicationcontrollers/scale").RuleOrDie(),
// additional admin powers // additional admin powers
rbac.NewRule("create").Groups(authorizationGroup).Resources("localsubjectaccessreviews").RuleOrDie(), rbac.NewRule("create").Groups(authorizationGroup).Resources("localsubjectaccessreviews").RuleOrDie(),
...@@ -157,14 +159,16 @@ func ClusterRoles() []rbac.ClusterRole { ...@@ -157,14 +159,16 @@ func ClusterRoles() []rbac.ClusterRole {
rbac.NewRule(Read...).Groups(legacyGroup).Resources("namespaces").RuleOrDie(), rbac.NewRule(Read...).Groups(legacyGroup).Resources("namespaces").RuleOrDie(),
rbac.NewRule("impersonate").Groups(legacyGroup).Resources("serviceaccounts").RuleOrDie(), rbac.NewRule("impersonate").Groups(legacyGroup).Resources("serviceaccounts").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(appsGroup).Resources("statefulsets").RuleOrDie(), rbac.NewRule(ReadWrite...).Groups(appsGroup).Resources("statefulsets",
"deployments", "deployments/scale", "deployments/rollback").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(), rbac.NewRule(ReadWrite...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(batchGroup).Resources("jobs", "cronjobs", "scheduledjobs").RuleOrDie(), rbac.NewRule(ReadWrite...).Groups(batchGroup).Resources("jobs", "cronjobs", "scheduledjobs").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(extensionsGroup).Resources("daemonsets", "deployments", "deployments/scale", rbac.NewRule(ReadWrite...).Groups(extensionsGroup).Resources("daemonsets",
"ingresses", "replicasets", "replicasets/scale", "replicationcontrollers/scale").RuleOrDie(), "deployments", "deployments/scale", "deployments/rollback", "ingresses",
"replicasets", "replicasets/scale", "replicationcontrollers/scale").RuleOrDie(),
}, },
}, },
{ {
...@@ -180,7 +184,7 @@ func ClusterRoles() []rbac.ClusterRole { ...@@ -180,7 +184,7 @@ func ClusterRoles() []rbac.ClusterRole {
// indicator of which namespaces you have access to. // indicator of which namespaces you have access to.
rbac.NewRule(Read...).Groups(legacyGroup).Resources("namespaces").RuleOrDie(), rbac.NewRule(Read...).Groups(legacyGroup).Resources("namespaces").RuleOrDie(),
rbac.NewRule(Read...).Groups(appsGroup).Resources("statefulsets").RuleOrDie(), rbac.NewRule(Read...).Groups(appsGroup).Resources("statefulsets", "deployments", "deployments/scale").RuleOrDie(),
rbac.NewRule(Read...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(), rbac.NewRule(Read...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(),
...@@ -320,6 +324,7 @@ func ClusterRoles() []rbac.ClusterRole { ...@@ -320,6 +324,7 @@ func ClusterRoles() []rbac.ClusterRole {
"podsecuritypolicies", "podsecuritypolicies",
"replicasets", "replicasets",
).RuleOrDie(), ).RuleOrDie(),
rbac.NewRule("list", "watch").Groups(appsGroup).Resources("deployments").RuleOrDie(),
rbac.NewRule("list", "watch").Groups(batchGroup).Resources("jobs", "cronjobs").RuleOrDie(), rbac.NewRule("list", "watch").Groups(batchGroup).Resources("jobs", "cronjobs").RuleOrDie(),
rbac.NewRule("list", "watch").Groups(appsGroup).Resources("statefulsets").RuleOrDie(), rbac.NewRule("list", "watch").Groups(appsGroup).Resources("statefulsets").RuleOrDie(),
rbac.NewRule("list", "watch").Groups(policyGroup).Resources("poddisruptionbudgets").RuleOrDie(), rbac.NewRule("list", "watch").Groups(policyGroup).Resources("poddisruptionbudgets").RuleOrDie(),
......
...@@ -117,6 +117,12 @@ var viewEscalatingNamespaceResources = []rbac.PolicyRule{ ...@@ -117,6 +117,12 @@ var viewEscalatingNamespaceResources = []rbac.PolicyRule{
rbac.NewRule(bootstrappolicy.Read...).Groups("").Resources("services/proxy").RuleOrDie(), rbac.NewRule(bootstrappolicy.Read...).Groups("").Resources("services/proxy").RuleOrDie(),
} }
// ungettableResources is the list of rules that don't allow to view (GET) them
// this is purposefully separate list to distinguish from escalating privs
var ungettableResources = []rbac.PolicyRule{
rbac.NewRule(bootstrappolicy.Read...).Groups("apps", "extensions").Resources("deployments/rollback").RuleOrDie(),
}
func TestEditViewRelationship(t *testing.T) { func TestEditViewRelationship(t *testing.T) {
readVerbs := sets.NewString(bootstrappolicy.Read...) readVerbs := sets.NewString(bootstrappolicy.Read...)
semanticRoles := getSemanticRoles(bootstrappolicy.ClusterRoles()) semanticRoles := getSemanticRoles(bootstrappolicy.ClusterRoles())
...@@ -142,6 +148,14 @@ func TestEditViewRelationship(t *testing.T) { ...@@ -142,6 +148,14 @@ func TestEditViewRelationship(t *testing.T) {
} }
semanticRoles.view.Rules = append(semanticRoles.view.Rules, viewEscalatingNamespaceResources...) semanticRoles.view.Rules = append(semanticRoles.view.Rules, viewEscalatingNamespaceResources...)
// confirm that the view role doesn't have ungettable resources
for _, rule := range ungettableResources {
if covers, _ := rbacregistryvalidation.Covers(semanticRoles.view.Rules, []rbac.PolicyRule{rule}); covers {
t.Errorf("view has ungettable resource: %#v", rule)
}
}
semanticRoles.view.Rules = append(semanticRoles.view.Rules, ungettableResources...)
// at this point, we should have a two way covers relationship // at this point, we should have a two way covers relationship
if covers, miss := rbacregistryvalidation.Covers(semanticRoles.edit.Rules, semanticRoles.view.Rules); !covers { if covers, miss := rbacregistryvalidation.Covers(semanticRoles.edit.Rules, semanticRoles.view.Rules); !covers {
t.Errorf("edit has lost rules for: %#v", miss) t.Errorf("edit has lost rules for: %#v", miss)
......
...@@ -81,6 +81,9 @@ items: ...@@ -81,6 +81,9 @@ items:
- apiGroups: - apiGroups:
- apps - apps
resources: resources:
- deployments
- deployments/rollback
- deployments/scale
- statefulsets - statefulsets
verbs: verbs:
- create - create
...@@ -124,6 +127,7 @@ items: ...@@ -124,6 +127,7 @@ items:
resources: resources:
- daemonsets - daemonsets
- deployments - deployments
- deployments/rollback
- deployments/scale - deployments/scale
- ingresses - ingresses
- replicasets - replicasets
...@@ -259,6 +263,9 @@ items: ...@@ -259,6 +263,9 @@ items:
- apiGroups: - apiGroups:
- apps - apps
resources: resources:
- deployments
- deployments/rollback
- deployments/scale
- statefulsets - statefulsets
verbs: verbs:
- create - create
...@@ -302,6 +309,7 @@ items: ...@@ -302,6 +309,7 @@ items:
resources: resources:
- daemonsets - daemonsets
- deployments - deployments
- deployments/rollback
- deployments/scale - deployments/scale
- ingresses - ingresses
- replicasets - replicasets
...@@ -496,6 +504,13 @@ items: ...@@ -496,6 +504,13 @@ items:
- list - list
- watch - watch
- apiGroups: - apiGroups:
- apps
resources:
- deployments
verbs:
- list
- watch
- apiGroups:
- batch - batch
resources: resources:
- cronjobs - cronjobs
...@@ -937,6 +952,8 @@ items: ...@@ -937,6 +952,8 @@ items:
- apiGroups: - apiGroups:
- apps - apps
resources: resources:
- deployments
- deployments/scale
- statefulsets - statefulsets
verbs: verbs:
- get - get
......
...@@ -197,6 +197,7 @@ items: ...@@ -197,6 +197,7 @@ items:
name: system:controller:deployment-controller name: system:controller:deployment-controller
rules: rules:
- apiGroups: - apiGroups:
- apps
- extensions - extensions
resources: resources:
- deployments - deployments
...@@ -206,6 +207,7 @@ items: ...@@ -206,6 +207,7 @@ items:
- update - update
- watch - watch
- apiGroups: - apiGroups:
- apps
- extensions - extensions
resources: resources:
- deployments/status - deployments/status
...@@ -251,6 +253,7 @@ items: ...@@ -251,6 +253,7 @@ items:
name: system:controller:disruption-controller name: system:controller:disruption-controller
rules: rules:
- apiGroups: - apiGroups:
- apps
- extensions - extensions
resources: resources:
- deployments - deployments
...@@ -415,6 +418,7 @@ items: ...@@ -415,6 +418,7 @@ items:
- get - get
- update - update
- apiGroups: - apiGroups:
- apps
- extensions - extensions
resources: resources:
- deployments/scale - deployments/scale
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v1beta1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
kubernetes "k8s.io/client-go/kubernetes"
v1beta1 "k8s.io/client-go/listers/apps/v1beta1"
apps_v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// DeploymentInformer provides access to a shared informer and lister for
// Deployments.
type DeploymentInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1beta1.DeploymentLister
}
type deploymentInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newDeploymentInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.AppsV1beta1().Deployments(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.AppsV1beta1().Deployments(v1.NamespaceAll).Watch(options)
},
},
&apps_v1beta1.Deployment{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *deploymentInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&apps_v1beta1.Deployment{}, newDeploymentInformer)
}
func (f *deploymentInformer) Lister() v1beta1.DeploymentLister {
return v1beta1.NewDeploymentLister(f.Informer().GetIndexer())
}
...@@ -24,6 +24,8 @@ import ( ...@@ -24,6 +24,8 @@ import (
// Interface provides access to all the informers in this group version. // Interface provides access to all the informers in this group version.
type Interface interface { type Interface interface {
// Deployments returns a DeploymentInformer.
Deployments() DeploymentInformer
// StatefulSets returns a StatefulSetInformer. // StatefulSets returns a StatefulSetInformer.
StatefulSets() StatefulSetInformer StatefulSets() StatefulSetInformer
} }
...@@ -37,6 +39,11 @@ func New(f internalinterfaces.SharedInformerFactory) Interface { ...@@ -37,6 +39,11 @@ func New(f internalinterfaces.SharedInformerFactory) Interface {
return &version{f} return &version{f}
} }
// Deployments returns a DeploymentInformer.
func (v *version) Deployments() DeploymentInformer {
return &deploymentInformer{factory: v.SharedInformerFactory}
}
// StatefulSets returns a StatefulSetInformer. // StatefulSets returns a StatefulSetInformer.
func (v *version) StatefulSets() StatefulSetInformer { func (v *version) StatefulSets() StatefulSetInformer {
return &statefulSetInformer{factory: v.SharedInformerFactory} return &statefulSetInformer{factory: v.SharedInformerFactory}
......
...@@ -63,6 +63,8 @@ func (f *genericInformer) Lister() cache.GenericLister { ...@@ -63,6 +63,8 @@ func (f *genericInformer) Lister() cache.GenericLister {
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource { switch resource {
// Group=Apps, Version=V1beta1 // Group=Apps, Version=V1beta1
case v1beta1.SchemeGroupVersion.WithResource("deployments"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().Deployments().Informer()}, nil
case v1beta1.SchemeGroupVersion.WithResource("statefulsets"): case v1beta1.SchemeGroupVersion.WithResource("statefulsets"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().StatefulSets().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().StatefulSets().Informer()}, nil
......
...@@ -25,6 +25,8 @@ import ( ...@@ -25,6 +25,8 @@ import (
type AppsV1beta1Interface interface { type AppsV1beta1Interface interface {
RESTClient() rest.Interface RESTClient() rest.Interface
DeploymentsGetter
ScalesGetter
StatefulSetsGetter StatefulSetsGetter
} }
...@@ -33,6 +35,14 @@ type AppsV1beta1Client struct { ...@@ -33,6 +35,14 @@ type AppsV1beta1Client struct {
restClient rest.Interface restClient rest.Interface
} }
func (c *AppsV1beta1Client) Deployments(namespace string) DeploymentInterface {
return newDeployments(c, namespace)
}
func (c *AppsV1beta1Client) Scales(namespace string) ScaleInterface {
return newScales(c, namespace)
}
func (c *AppsV1beta1Client) StatefulSets(namespace string) StatefulSetInterface { func (c *AppsV1beta1Client) StatefulSets(namespace string) StatefulSetInterface {
return newStatefulSets(c, namespace) return newStatefulSets(c, namespace)
} }
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
scheme "k8s.io/client-go/kubernetes/scheme"
v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
rest "k8s.io/client-go/rest"
)
// DeploymentsGetter has a method to return a DeploymentInterface.
// A group's client should implement this interface.
type DeploymentsGetter interface {
Deployments(namespace string) DeploymentInterface
}
// DeploymentInterface has methods to work with Deployment resources.
type DeploymentInterface interface {
Create(*v1beta1.Deployment) (*v1beta1.Deployment, error)
Update(*v1beta1.Deployment) (*v1beta1.Deployment, error)
UpdateStatus(*v1beta1.Deployment) (*v1beta1.Deployment, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1beta1.Deployment, error)
List(opts v1.ListOptions) (*v1beta1.DeploymentList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error)
DeploymentExpansion
}
// deployments implements DeploymentInterface
type deployments struct {
client rest.Interface
ns string
}
// newDeployments returns a Deployments
func newDeployments(c *AppsV1beta1Client, namespace string) *deployments {
return &deployments{
client: c.RESTClient(),
ns: namespace,
}
}
// Create takes the representation of a deployment and creates it. Returns the server's representation of the deployment, and an error, if there is any.
func (c *deployments) Create(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Post().
Namespace(c.ns).
Resource("deployments").
Body(deployment).
Do().
Into(result)
return
}
// Update takes the representation of a deployment and updates it. Returns the server's representation of the deployment, and an error, if there is any.
func (c *deployments) Update(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Put().
Namespace(c.ns).
Resource("deployments").
Name(deployment.Name).
Body(deployment).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *deployments) UpdateStatus(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Put().
Namespace(c.ns).
Resource("deployments").
Name(deployment.Name).
SubResource("status").
Body(deployment).
Do().
Into(result)
return
}
// Delete takes name of the deployment and deletes it. Returns an error if one occurs.
func (c *deployments) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("deployments").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *deployments) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("deployments").
VersionedParams(&listOptions, scheme.ParameterCodec).
Body(options).
Do().
Error()
}
// Get takes name of the deployment, and returns the corresponding deployment object, and an error if there is any.
func (c *deployments) Get(name string, options v1.GetOptions) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Get().
Namespace(c.ns).
Resource("deployments").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of Deployments that match those selectors.
func (c *deployments) List(opts v1.ListOptions) (result *v1beta1.DeploymentList, err error) {
result = &v1beta1.DeploymentList{}
err = c.client.Get().
Namespace(c.ns).
Resource("deployments").
VersionedParams(&opts, scheme.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested deployments.
func (c *deployments) Watch(opts v1.ListOptions) (watch.Interface, error) {
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("deployments").
VersionedParams(&opts, scheme.ParameterCodec).
Watch()
}
// Patch applies the patch and returns the patched deployment.
func (c *deployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("deployments").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
...@@ -26,6 +26,14 @@ type FakeAppsV1beta1 struct { ...@@ -26,6 +26,14 @@ type FakeAppsV1beta1 struct {
*testing.Fake *testing.Fake
} }
func (c *FakeAppsV1beta1) Deployments(namespace string) v1beta1.DeploymentInterface {
return &FakeDeployments{c, namespace}
}
func (c *FakeAppsV1beta1) Scales(namespace string) v1beta1.ScaleInterface {
return &FakeScales{c, namespace}
}
func (c *FakeAppsV1beta1) StatefulSets(namespace string) v1beta1.StatefulSetInterface { func (c *FakeAppsV1beta1) StatefulSets(namespace string) v1beta1.StatefulSetInterface {
return &FakeStatefulSets{c, namespace} return &FakeStatefulSets{c, namespace}
} }
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
testing "k8s.io/client-go/testing"
)
// FakeDeployments implements DeploymentInterface
type FakeDeployments struct {
Fake *FakeAppsV1beta1
ns string
}
var deploymentsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta1", Resource: "deployments"}
func (c *FakeDeployments) Create(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(deploymentsResource, c.ns, deployment), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
func (c *FakeDeployments) Update(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(deploymentsResource, c.ns, deployment), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
func (c *FakeDeployments) UpdateStatus(deployment *v1beta1.Deployment) (*v1beta1.Deployment, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(deploymentsResource, "status", c.ns, deployment), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
func (c *FakeDeployments) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(deploymentsResource, c.ns, name), &v1beta1.Deployment{})
return err
}
func (c *FakeDeployments) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(deploymentsResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1beta1.DeploymentList{})
return err
}
func (c *FakeDeployments) Get(name string, options v1.GetOptions) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(deploymentsResource, c.ns, name), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
func (c *FakeDeployments) List(opts v1.ListOptions) (result *v1beta1.DeploymentList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(deploymentsResource, c.ns, opts), &v1beta1.DeploymentList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1beta1.DeploymentList{}
for _, item := range obj.(*v1beta1.DeploymentList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested deployments.
func (c *FakeDeployments) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(deploymentsResource, c.ns, opts))
}
// Patch applies the patch and returns the patched deployment.
func (c *FakeDeployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, data, subresources...), &v1beta1.Deployment{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Deployment), err
}
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
// FakeScales implements ScaleInterface
type FakeScales struct {
Fake *FakeAppsV1beta1
ns string
}
...@@ -16,4 +16,8 @@ limitations under the License. ...@@ -16,4 +16,8 @@ limitations under the License.
package v1beta1 package v1beta1
type DeploymentExpansion interface{}
type ScaleExpansion interface{}
type StatefulSetExpansion interface{} type StatefulSetExpansion interface{}
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
rest "k8s.io/client-go/rest"
)
// ScalesGetter has a method to return a ScaleInterface.
// A group's client should implement this interface.
type ScalesGetter interface {
Scales(namespace string) ScaleInterface
}
// ScaleInterface has methods to work with Scale resources.
type ScaleInterface interface {
ScaleExpansion
}
// scales implements ScaleInterface
type scales struct {
client rest.Interface
ns string
}
// newScales returns a Scales
func newScales(c *AppsV1beta1Client, namespace string) *scales {
return &scales{
client: c.RESTClient(),
ns: namespace,
}
}
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package v1beta1
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
apps "k8s.io/client-go/pkg/apis/apps"
v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
"k8s.io/client-go/tools/cache"
)
// DeploymentLister helps list Deployments.
type DeploymentLister interface {
// List lists all Deployments in the indexer.
List(selector labels.Selector) (ret []*v1beta1.Deployment, err error)
// Deployments returns an object that can list and get Deployments.
Deployments(namespace string) DeploymentNamespaceLister
DeploymentListerExpansion
}
// deploymentLister implements the DeploymentLister interface.
type deploymentLister struct {
indexer cache.Indexer
}
// NewDeploymentLister returns a new DeploymentLister.
func NewDeploymentLister(indexer cache.Indexer) DeploymentLister {
return &deploymentLister{indexer: indexer}
}
// List lists all Deployments in the indexer.
func (s *deploymentLister) List(selector labels.Selector) (ret []*v1beta1.Deployment, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.Deployment))
})
return ret, err
}
// Deployments returns an object that can list and get Deployments.
func (s *deploymentLister) Deployments(namespace string) DeploymentNamespaceLister {
return deploymentNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// DeploymentNamespaceLister helps list and get Deployments.
type DeploymentNamespaceLister interface {
// List lists all Deployments in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1beta1.Deployment, err error)
// Get retrieves the Deployment from the indexer for a given namespace and name.
Get(name string) (*v1beta1.Deployment, error)
DeploymentNamespaceListerExpansion
}
// deploymentNamespaceLister implements the DeploymentNamespaceLister
// interface.
type deploymentNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all Deployments in the indexer for a given namespace.
func (s deploymentNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Deployment, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.Deployment))
})
return ret, err
}
// Get retrieves the Deployment from the indexer for a given namespace and name.
func (s deploymentNamespaceLister) Get(name string) (*v1beta1.Deployment, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(apps.Resource("deployment"), name)
}
return obj.(*v1beta1.Deployment), nil
}
...@@ -17,3 +17,19 @@ limitations under the License. ...@@ -17,3 +17,19 @@ limitations under the License.
// This file was automatically generated by lister-gen // This file was automatically generated by lister-gen
package v1beta1 package v1beta1
// DeploymentListerExpansion allows custom methods to be added to
// DeploymentLister.
type DeploymentListerExpansion interface{}
// DeploymentNamespaceListerExpansion allows custom methods to be added to
// DeploymentNamespaeLister.
type DeploymentNamespaceListerExpansion interface{}
// ScaleListerExpansion allows custom methods to be added to
// ScaleLister.
type ScaleListerExpansion interface{}
// ScaleNamespaceListerExpansion allows custom methods to be added to
// ScaleNamespaeLister.
type ScaleNamespaceListerExpansion interface{}
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package v1beta1
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
apps "k8s.io/client-go/pkg/apis/apps"
v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
"k8s.io/client-go/tools/cache"
)
// ScaleLister helps list Scales.
type ScaleLister interface {
// List lists all Scales in the indexer.
List(selector labels.Selector) (ret []*v1beta1.Scale, err error)
// Scales returns an object that can list and get Scales.
Scales(namespace string) ScaleNamespaceLister
ScaleListerExpansion
}
// scaleLister implements the ScaleLister interface.
type scaleLister struct {
indexer cache.Indexer
}
// NewScaleLister returns a new ScaleLister.
func NewScaleLister(indexer cache.Indexer) ScaleLister {
return &scaleLister{indexer: indexer}
}
// List lists all Scales in the indexer.
func (s *scaleLister) List(selector labels.Selector) (ret []*v1beta1.Scale, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.Scale))
})
return ret, err
}
// Scales returns an object that can list and get Scales.
func (s *scaleLister) Scales(namespace string) ScaleNamespaceLister {
return scaleNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ScaleNamespaceLister helps list and get Scales.
type ScaleNamespaceLister interface {
// List lists all Scales in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1beta1.Scale, err error)
// Get retrieves the Scale from the indexer for a given namespace and name.
Get(name string) (*v1beta1.Scale, error)
ScaleNamespaceListerExpansion
}
// scaleNamespaceLister implements the ScaleNamespaceLister
// interface.
type scaleNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all Scales in the indexer for a given namespace.
func (s scaleNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Scale, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.Scale))
})
return ret, err
}
// Get retrieves the Scale from the indexer for a given namespace and name.
func (s scaleNamespaceLister) Get(name string) (*v1beta1.Scale, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(apps.Resource("scale"), name)
}
return obj.(*v1beta1.Scale), nil
}
...@@ -19,6 +19,7 @@ package apps ...@@ -19,6 +19,7 @@ package apps
import ( import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/pkg/apis/extensions"
) )
var ( var (
...@@ -46,6 +47,10 @@ func Resource(resource string) schema.GroupResource { ...@@ -46,6 +47,10 @@ func Resource(resource string) schema.GroupResource {
func addKnownTypes(scheme *runtime.Scheme) error { func addKnownTypes(scheme *runtime.Scheme) error {
// TODO this will get cleaned up with the scheme types are fixed // TODO this will get cleaned up with the scheme types are fixed
scheme.AddKnownTypes(SchemeGroupVersion, scheme.AddKnownTypes(SchemeGroupVersion,
&extensions.Deployment{},
&extensions.DeploymentList{},
&extensions.DeploymentRollback{},
&extensions.Scale{},
&StatefulSet{}, &StatefulSet{},
&StatefulSetList{}, &StatefulSetList{},
) )
......
...@@ -22,9 +22,11 @@ import ( ...@@ -22,9 +22,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion" "k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/pkg/api" "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1" "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/apps" "k8s.io/client-go/pkg/apis/apps"
"k8s.io/client-go/pkg/apis/extensions"
) )
func addConversionFuncs(scheme *runtime.Scheme) error { func addConversionFuncs(scheme *runtime.Scheme) error {
...@@ -35,21 +37,49 @@ func addConversionFuncs(scheme *runtime.Scheme) error { ...@@ -35,21 +37,49 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
err := scheme.AddConversionFuncs( err := scheme.AddConversionFuncs(
Convert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec, Convert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec,
Convert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec, Convert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec,
// extensions
// TODO: below conversions should be dropped in favor of auto-generated
// ones, see https://github.com/kubernetes/kubernetextensionsssues/39865
Convert_v1beta1_ScaleStatus_To_extensions_ScaleStatus,
Convert_extensions_ScaleStatus_To_v1beta1_ScaleStatus,
Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec,
Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec,
Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy,
Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy,
Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment,
Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment,
) )
if err != nil { if err != nil {
return err return err
} }
return scheme.AddFieldLabelConversionFunc("apps/v1beta1", "StatefulSet", // Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
err = scheme.AddFieldLabelConversionFunc("apps/v1beta1", "StatefulSet",
func(label, value string) (string, string, error) { func(label, value string) (string, string, error) {
switch label { switch label {
case "metadata.name", "metadata.namespace", "status.successful": case "metadata.name", "metadata.namespace", "status.successful":
return label, value, nil return label, value, nil
default: default:
return "", "", fmt.Errorf("field label not supported: %s", label) return "", "", fmt.Errorf("field label not supported for StatefulSet: %s", label)
} }
}, })
) if err != nil {
return err
}
err = api.Scheme.AddFieldLabelConversionFunc("apps/v1beta1", "Deployment",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "metadata.namespace":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for Deployment", label)
}
})
if err != nil {
return err
}
return nil
} }
func Convert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec(in *StatefulSetSpec, out *apps.StatefulSetSpec, s conversion.Scope) error { func Convert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec(in *StatefulSetSpec, out *apps.StatefulSetSpec, s conversion.Scope) error {
...@@ -112,3 +142,156 @@ func Convert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec(in *apps.StatefulSe ...@@ -112,3 +142,156 @@ func Convert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec(in *apps.StatefulSe
out.ServiceName = in.ServiceName out.ServiceName = in.ServiceName
return nil return nil
} }
func Convert_extensions_ScaleStatus_To_v1beta1_ScaleStatus(in *extensions.ScaleStatus, out *ScaleStatus, s conversion.Scope) error {
out.Replicas = int32(in.Replicas)
out.Selector = nil
out.TargetSelector = ""
if in.Selector != nil {
if in.Selector.MatchExpressions == nil || len(in.Selector.MatchExpressions) == 0 {
out.Selector = in.Selector.MatchLabels
}
selector, err := metav1.LabelSelectorAsSelector(in.Selector)
if err != nil {
return fmt.Errorf("invalid label selector: %v", err)
}
out.TargetSelector = selector.String()
}
return nil
}
func Convert_v1beta1_ScaleStatus_To_extensions_ScaleStatus(in *ScaleStatus, out *extensions.ScaleStatus, s conversion.Scope) error {
out.Replicas = in.Replicas
// Normally when 2 fields map to the same internal value we favor the old field, since
// old clients can't be expected to know about new fields but clients that know about the
// new field can be expected to know about the old field (though that's not quite true, due
// to kubectl apply). However, these fields are readonly, so any non-nil value should work.
if in.TargetSelector != "" {
labelSelector, err := metav1.ParseToLabelSelector(in.TargetSelector)
if err != nil {
out.Selector = nil
return fmt.Errorf("failed to parse target selector: %v", err)
}
out.Selector = labelSelector
} else if in.Selector != nil {
out.Selector = new(metav1.LabelSelector)
selector := make(map[string]string)
for key, val := range in.Selector {
selector[key] = val
}
out.Selector.MatchLabels = selector
} else {
out.Selector = nil
}
return nil
}
func Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentSpec, out *extensions.DeploymentSpec, s conversion.Scope) error {
if in.Replicas != nil {
out.Replicas = *in.Replicas
}
out.Selector = in.Selector
if err := v1.Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
return err
}
if err := Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
return err
}
out.RevisionHistoryLimit = in.RevisionHistoryLimit
out.MinReadySeconds = in.MinReadySeconds
out.Paused = in.Paused
if in.RollbackTo != nil {
out.RollbackTo = new(extensions.RollbackConfig)
out.RollbackTo.Revision = in.RollbackTo.Revision
} else {
out.RollbackTo = nil
}
if in.ProgressDeadlineSeconds != nil {
out.ProgressDeadlineSeconds = new(int32)
*out.ProgressDeadlineSeconds = *in.ProgressDeadlineSeconds
}
return nil
}
func Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.DeploymentSpec, out *DeploymentSpec, s conversion.Scope) error {
out.Replicas = &in.Replicas
out.Selector = in.Selector
if err := v1.Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
return err
}
if err := Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
return err
}
if in.RevisionHistoryLimit != nil {
out.RevisionHistoryLimit = new(int32)
*out.RevisionHistoryLimit = int32(*in.RevisionHistoryLimit)
}
out.MinReadySeconds = int32(in.MinReadySeconds)
out.Paused = in.Paused
if in.RollbackTo != nil {
out.RollbackTo = new(RollbackConfig)
out.RollbackTo.Revision = int64(in.RollbackTo.Revision)
} else {
out.RollbackTo = nil
}
if in.ProgressDeadlineSeconds != nil {
out.ProgressDeadlineSeconds = new(int32)
*out.ProgressDeadlineSeconds = *in.ProgressDeadlineSeconds
}
return nil
}
func Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(in *extensions.DeploymentStrategy, out *DeploymentStrategy, s conversion.Scope) error {
out.Type = DeploymentStrategyType(in.Type)
if in.RollingUpdate != nil {
out.RollingUpdate = new(RollingUpdateDeployment)
if err := Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
return err
}
} else {
out.RollingUpdate = nil
}
return nil
}
func Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(in *DeploymentStrategy, out *extensions.DeploymentStrategy, s conversion.Scope) error {
out.Type = extensions.DeploymentStrategyType(in.Type)
if in.RollingUpdate != nil {
out.RollingUpdate = new(extensions.RollingUpdateDeployment)
if err := Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
return err
}
} else {
out.RollingUpdate = nil
}
return nil
}
func Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in *RollingUpdateDeployment, out *extensions.RollingUpdateDeployment, s conversion.Scope) error {
if err := s.Convert(in.MaxUnavailable, &out.MaxUnavailable, 0); err != nil {
return err
}
if err := s.Convert(in.MaxSurge, &out.MaxSurge, 0); err != nil {
return err
}
return nil
}
func Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in *extensions.RollingUpdateDeployment, out *RollingUpdateDeployment, s conversion.Scope) error {
if out.MaxUnavailable == nil {
out.MaxUnavailable = &intstr.IntOrString{}
}
if err := s.Convert(&in.MaxUnavailable, out.MaxUnavailable, 0); err != nil {
return err
}
if out.MaxSurge == nil {
out.MaxSurge = &intstr.IntOrString{}
}
if err := s.Convert(&in.MaxSurge, out.MaxSurge, 0); err != nil {
return err
}
return nil
}
...@@ -19,12 +19,14 @@ package v1beta1 ...@@ -19,12 +19,14 @@ package v1beta1
import ( import (
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"
"k8s.io/apimachinery/pkg/util/intstr"
) )
func addDefaultingFuncs(scheme *runtime.Scheme) error { func addDefaultingFuncs(scheme *runtime.Scheme) error {
RegisterDefaults(scheme) RegisterDefaults(scheme)
return scheme.AddDefaultingFuncs( return scheme.AddDefaultingFuncs(
SetDefaults_StatefulSet, SetDefaults_StatefulSet,
SetDefaults_Deployment,
) )
} }
...@@ -45,3 +47,57 @@ func SetDefaults_StatefulSet(obj *StatefulSet) { ...@@ -45,3 +47,57 @@ func SetDefaults_StatefulSet(obj *StatefulSet) {
*obj.Spec.Replicas = 1 *obj.Spec.Replicas = 1
} }
} }
// SetDefaults_Deployment sets additional defaults compared to its counterpart
// in extensions. These addons are:
// - MaxUnavailable during rolling update set to 25% (1 in extensions)
// - MaxSurge value during rolling update set to 25% (1 in extensions)
// - RevisionHistoryLimit set to 2 (not set in extensions)
// - ProgressDeadlineSeconds set to 600s (not set in extensions)
func SetDefaults_Deployment(obj *Deployment) {
// Default labels and selector to labels from pod template spec.
labels := obj.Spec.Template.Labels
if labels != nil {
if obj.Spec.Selector == nil {
obj.Spec.Selector = &metav1.LabelSelector{MatchLabels: labels}
}
if len(obj.Labels) == 0 {
obj.Labels = labels
}
}
// Set DeploymentSpec.Replicas to 1 if it is not set.
if obj.Spec.Replicas == nil {
obj.Spec.Replicas = new(int32)
*obj.Spec.Replicas = 1
}
strategy := &obj.Spec.Strategy
// Set default DeploymentStrategyType as RollingUpdate.
if strategy.Type == "" {
strategy.Type = RollingUpdateDeploymentStrategyType
}
if strategy.Type == RollingUpdateDeploymentStrategyType {
if strategy.RollingUpdate == nil {
rollingUpdate := RollingUpdateDeployment{}
strategy.RollingUpdate = &rollingUpdate
}
if strategy.RollingUpdate.MaxUnavailable == nil {
// Set default MaxUnavailable as 25% by default.
maxUnavailable := intstr.FromString("25%")
strategy.RollingUpdate.MaxUnavailable = &maxUnavailable
}
if strategy.RollingUpdate.MaxSurge == nil {
// Set default MaxSurge as 25% by default.
maxSurge := intstr.FromString("25%")
strategy.RollingUpdate.MaxSurge = &maxSurge
}
}
if obj.Spec.RevisionHistoryLimit == nil {
obj.Spec.RevisionHistoryLimit = new(int32)
*obj.Spec.RevisionHistoryLimit = 2
}
if obj.Spec.ProgressDeadlineSeconds == nil {
obj.Spec.ProgressDeadlineSeconds = new(int32)
*obj.Spec.ProgressDeadlineSeconds = 600
}
}
...@@ -27,10 +27,241 @@ import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; ...@@ -27,10 +27,241 @@ import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
import "k8s.io/apimachinery/pkg/util/intstr/generated.proto"; import "k8s.io/apimachinery/pkg/util/intstr/generated.proto";
import "k8s.io/apiserver/pkg/apis/example/v1/generated.proto"; import "k8s.io/apiserver/pkg/apis/example/v1/generated.proto";
import "k8s.io/kubernetes/pkg/api/v1/generated.proto"; import "k8s.io/kubernetes/pkg/api/v1/generated.proto";
import "k8s.io/kubernetes/pkg/apis/extensions/v1beta1/generated.proto";
// Package-wide variables from generator "generated". // Package-wide variables from generator "generated".
option go_package = "v1beta1"; option go_package = "v1beta1";
// Deployment enables declarative updates for Pods and ReplicaSets.
message Deployment {
// Standard object metadata.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// Specification of the desired behavior of the Deployment.
// +optional
optional DeploymentSpec spec = 2;
// Most recently observed status of the Deployment.
// +optional
optional DeploymentStatus status = 3;
}
// DeploymentCondition describes the state of a deployment at a certain point.
message DeploymentCondition {
// Type of deployment condition.
optional string type = 1;
// Status of the condition, one of True, False, Unknown.
optional string status = 2;
// The last time this condition was updated.
optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastUpdateTime = 6;
// Last time the condition transitioned from one status to another.
optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 7;
// The reason for the condition's last transition.
optional string reason = 4;
// A human readable message indicating details about the transition.
optional string message = 5;
}
// DeploymentList is a list of Deployments.
message DeploymentList {
// Standard list metadata.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
// Items is the list of Deployments.
repeated Deployment items = 2;
}
// DeploymentRollback stores the information required to rollback a deployment.
message DeploymentRollback {
// Required: This must match the Name of a deployment.
optional string name = 1;
// The annotations to be updated to a deployment
// +optional
map<string, string> updatedAnnotations = 2;
// The config of this deployment rollback.
optional RollbackConfig rollbackTo = 3;
}
// DeploymentSpec is the specification of the desired behavior of the Deployment.
message DeploymentSpec {
// Number of desired pods. This is a pointer to distinguish between explicit
// zero and not specified. Defaults to 1.
// +optional
optional int32 replicas = 1;
// Label selector for pods. Existing ReplicaSets whose pods are
// selected by this will be the ones affected by this deployment.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 2;
// Template describes the pods that will be created.
optional k8s.io.kubernetes.pkg.api.v1.PodTemplateSpec template = 3;
// The deployment strategy to use to replace existing pods with new ones.
// +optional
optional DeploymentStrategy strategy = 4;
// Minimum number of seconds for which a newly created pod should be ready
// without any of its container crashing, for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
// +optional
optional int32 minReadySeconds = 5;
// The number of old ReplicaSets to retain to allow rollback.
// This is a pointer to distinguish between explicit zero and not specified.
// Defaults to 2.
// +optional
optional int32 revisionHistoryLimit = 6;
// Indicates that the deployment is paused.
// +optional
optional bool paused = 7;
// The config this deployment is rolling back to. Will be cleared after rollback is done.
// +optional
optional RollbackConfig rollbackTo = 8;
// The maximum time in seconds for a deployment to make progress before it
// is considered to be failed. The deployment controller will continue to
// process failed deployments and a condition with a ProgressDeadlineExceeded
// reason will be surfaced in the deployment status. Once autoRollback is
// implemented, the deployment controller will automatically rollback failed
// deployments. Note that progress will not be estimated during the time a
// deployment is paused. Defaults to 600s.
optional int32 progressDeadlineSeconds = 9;
}
// DeploymentStatus is the most recently observed status of the Deployment.
message DeploymentStatus {
// The generation observed by the deployment controller.
// +optional
optional int64 observedGeneration = 1;
// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
// +optional
optional int32 replicas = 2;
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
// +optional
optional int32 updatedReplicas = 3;
// Total number of ready pods targeted by this deployment.
// +optional
optional int32 readyReplicas = 7;
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
// +optional
optional int32 availableReplicas = 4;
// Total number of unavailable pods targeted by this deployment.
// +optional
optional int32 unavailableReplicas = 5;
// Represents the latest available observations of a deployment's current state.
repeated DeploymentCondition conditions = 6;
}
// DeploymentStrategy describes how to replace existing pods with new ones.
message DeploymentStrategy {
// Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
// +optional
optional string type = 1;
// Rolling update config params. Present only if DeploymentStrategyType =
// RollingUpdate.
// ---
// TODO: Update this to follow our convention for oneOf, whatever we decide it
// to be.
// +optional
optional RollingUpdateDeployment rollingUpdate = 2;
}
message RollbackConfig {
// The revision to rollback to. If set to 0, rollbck to the last revision.
// +optional
optional int64 revision = 1;
}
// Spec to control the desired behavior of rolling update.
message RollingUpdateDeployment {
// The maximum number of pods that can be unavailable during the update.
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
// Absolute number is calculated from percentage by rounding down.
// This can not be 0 if MaxSurge is 0.
// Defaults to 25%.
// Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods
// immediately when the rolling update starts. Once new pods are ready, old RC
// can be scaled down further, followed by scaling up the new RC, ensuring
// that the total number of pods available at all times during the update is at
// least 70% of desired pods.
// +optional
optional k8s.io.apimachinery.pkg.util.intstr.IntOrString maxUnavailable = 1;
// The maximum number of pods that can be scheduled above the desired number of
// pods.
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
// This can not be 0 if MaxUnavailable is 0.
// Absolute number is calculated from percentage by rounding up.
// Defaults to 25%.
// Example: when this is set to 30%, the new RC can be scaled up immediately when
// the rolling update starts, such that the total number of old and new pods do not exceed
// 130% of desired pods. Once old pods have been killed,
// new RC can be scaled up further, ensuring that total number of pods running
// at any time during the update is atmost 130% of desired pods.
// +optional
optional k8s.io.apimachinery.pkg.util.intstr.IntOrString maxSurge = 2;
}
// Scale represents a scaling request for a resource.
message Scale {
// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional
optional ScaleSpec spec = 2;
// current status of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. Read-only.
// +optional
optional ScaleStatus status = 3;
}
// ScaleSpec describes the attributes of a scale subresource
message ScaleSpec {
// desired number of instances for the scaled object.
// +optional
optional int32 replicas = 1;
}
// ScaleStatus represents the current status of a scale subresource.
message ScaleStatus {
// actual number of observed instances of the scaled object.
optional int32 replicas = 1;
// label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
// +optional
map<string, string> selector = 2;
// label selector for pods that should match the replicas count. This is a serializated
// version of both map-based and more expressive set-based selectors. This is done to
// avoid introspection in the clients. The string will be in the same format as the
// query-param syntax. If the target type only supports map-based selectors, both this
// field and map-based selector field are populated.
// More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
// +optional
optional string targetSelector = 3;
}
// StatefulSet represents a set of pods with consistent identities. // StatefulSet represents a set of pods with consistent identities.
// Identities are defined as: // Identities are defined as:
// - Network: A single stable DNS and hostname. // - Network: A single stable DNS and hostname.
......
...@@ -41,12 +41,13 @@ var ( ...@@ -41,12 +41,13 @@ var (
// Adds the list of known types to api.Scheme. // Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error { func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion, scheme.AddKnownTypes(SchemeGroupVersion,
&Deployment{},
&DeploymentList{},
&DeploymentRollback{},
&Scale{},
&StatefulSet{}, &StatefulSet{},
&StatefulSetList{}, &StatefulSetList{},
) )
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil return nil
} }
func (obj *StatefulSet) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
func (obj *StatefulSetList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -27,6 +27,143 @@ package v1beta1 ...@@ -27,6 +27,143 @@ package v1beta1
// Those methods can be generated by using hack/update-generated-swagger-docs.sh // Those methods can be generated by using hack/update-generated-swagger-docs.sh
// AUTO-GENERATED FUNCTIONS START HERE // AUTO-GENERATED FUNCTIONS START HERE
var map_Deployment = map[string]string{
"": "Deployment enables declarative updates for Pods and ReplicaSets.",
"metadata": "Standard object metadata.",
"spec": "Specification of the desired behavior of the Deployment.",
"status": "Most recently observed status of the Deployment.",
}
func (Deployment) SwaggerDoc() map[string]string {
return map_Deployment
}
var map_DeploymentCondition = map[string]string{
"": "DeploymentCondition describes the state of a deployment at a certain point.",
"type": "Type of deployment condition.",
"status": "Status of the condition, one of True, False, Unknown.",
"lastUpdateTime": "The last time this condition was updated.",
"lastTransitionTime": "Last time the condition transitioned from one status to another.",
"reason": "The reason for the condition's last transition.",
"message": "A human readable message indicating details about the transition.",
}
func (DeploymentCondition) SwaggerDoc() map[string]string {
return map_DeploymentCondition
}
var map_DeploymentList = map[string]string{
"": "DeploymentList is a list of Deployments.",
"metadata": "Standard list metadata.",
"items": "Items is the list of Deployments.",
}
func (DeploymentList) SwaggerDoc() map[string]string {
return map_DeploymentList
}
var map_DeploymentRollback = map[string]string{
"": "DeploymentRollback stores the information required to rollback a deployment.",
"name": "Required: This must match the Name of a deployment.",
"updatedAnnotations": "The annotations to be updated to a deployment",
"rollbackTo": "The config of this deployment rollback.",
}
func (DeploymentRollback) SwaggerDoc() map[string]string {
return map_DeploymentRollback
}
var map_DeploymentSpec = map[string]string{
"": "DeploymentSpec is the specification of the desired behavior of the Deployment.",
"replicas": "Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.",
"selector": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment.",
"template": "Template describes the pods that will be created.",
"strategy": "The deployment strategy to use to replace existing pods with new ones.",
"minReadySeconds": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
"revisionHistoryLimit": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 2.",
"paused": "Indicates that the deployment is paused.",
"rollbackTo": "The config this deployment is rolling back to. Will be cleared after rollback is done.",
"progressDeadlineSeconds": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Once autoRollback is implemented, the deployment controller will automatically rollback failed deployments. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.",
}
func (DeploymentSpec) SwaggerDoc() map[string]string {
return map_DeploymentSpec
}
var map_DeploymentStatus = map[string]string{
"": "DeploymentStatus is the most recently observed status of the Deployment.",
"observedGeneration": "The generation observed by the deployment controller.",
"replicas": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
"updatedReplicas": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.",
"readyReplicas": "Total number of ready pods targeted by this deployment.",
"availableReplicas": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.",
"unavailableReplicas": "Total number of unavailable pods targeted by this deployment.",
"conditions": "Represents the latest available observations of a deployment's current state.",
}
func (DeploymentStatus) SwaggerDoc() map[string]string {
return map_DeploymentStatus
}
var map_DeploymentStrategy = map[string]string{
"": "DeploymentStrategy describes how to replace existing pods with new ones.",
"type": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.",
"rollingUpdate": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate.",
}
func (DeploymentStrategy) SwaggerDoc() map[string]string {
return map_DeploymentStrategy
}
var map_RollbackConfig = map[string]string{
"revision": "The revision to rollback to. If set to 0, rollbck to the last revision.",
}
func (RollbackConfig) SwaggerDoc() map[string]string {
return map_RollbackConfig
}
var map_RollingUpdateDeployment = map[string]string{
"": "Spec to control the desired behavior of rolling update.",
"maxUnavailable": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old RC can be scaled down further, followed by scaling up the new RC, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods.",
"maxSurge": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new RC can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new RC can be scaled up further, ensuring that total number of pods running at any time during the update is atmost 130% of desired pods.",
}
func (RollingUpdateDeployment) SwaggerDoc() map[string]string {
return map_RollingUpdateDeployment
}
var map_Scale = map[string]string{
"": "Scale represents a scaling request for a resource.",
"metadata": "Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.",
"spec": "defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.",
"status": "current status of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. Read-only.",
}
func (Scale) SwaggerDoc() map[string]string {
return map_Scale
}
var map_ScaleSpec = map[string]string{
"": "ScaleSpec describes the attributes of a scale subresource",
"replicas": "desired number of instances for the scaled object.",
}
func (ScaleSpec) SwaggerDoc() map[string]string {
return map_ScaleSpec
}
var map_ScaleStatus = map[string]string{
"": "ScaleStatus represents the current status of a scale subresource.",
"replicas": "actual number of observed instances of the scaled object.",
"selector": "label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
"targetSelector": "label selector for pods that should match the replicas count. This is a serializated version of both map-based and more expressive set-based selectors. This is done to avoid introspection in the clients. The string will be in the same format as the query-param syntax. If the target type only supports map-based selectors, both this field and map-based selector field are populated. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
}
func (ScaleStatus) SwaggerDoc() map[string]string {
return map_ScaleStatus
}
var map_StatefulSet = map[string]string{ var map_StatefulSet = map[string]string{
"": "StatefulSet represents a set of pods with consistent identities. Identities are defined as:\n - Network: A single stable DNS and hostname.\n - Storage: As many VolumeClaims as requested.\nThe StatefulSet guarantees that a given network identity will always map to the same storage identity.", "": "StatefulSet represents a set of pods with consistent identities. Identities are defined as:\n - Network: A single stable DNS and hostname.\n - Storage: As many VolumeClaims as requested.\nThe StatefulSet guarantees that a given network identity will always map to the same storage identity.",
"spec": "Spec defines the desired identities of pods in this set.", "spec": "Spec defines the desired identities of pods in this set.",
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion" conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
intstr "k8s.io/apimachinery/pkg/util/intstr"
api_v1 "k8s.io/client-go/pkg/api/v1" api_v1 "k8s.io/client-go/pkg/api/v1"
reflect "reflect" reflect "reflect"
) )
...@@ -36,6 +37,18 @@ func init() { ...@@ -36,6 +37,18 @@ func init() {
// to allow building arbitrary schemes. // to allow building arbitrary schemes.
func RegisterDeepCopies(scheme *runtime.Scheme) error { func RegisterDeepCopies(scheme *runtime.Scheme) error {
return scheme.AddGeneratedDeepCopyFuncs( return scheme.AddGeneratedDeepCopyFuncs(
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_Deployment, InType: reflect.TypeOf(&Deployment{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentCondition, InType: reflect.TypeOf(&DeploymentCondition{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentList, InType: reflect.TypeOf(&DeploymentList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentRollback, InType: reflect.TypeOf(&DeploymentRollback{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentSpec, InType: reflect.TypeOf(&DeploymentSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentStatus, InType: reflect.TypeOf(&DeploymentStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_DeploymentStrategy, InType: reflect.TypeOf(&DeploymentStrategy{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_RollbackConfig, InType: reflect.TypeOf(&RollbackConfig{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_RollingUpdateDeployment, InType: reflect.TypeOf(&RollingUpdateDeployment{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_Scale, InType: reflect.TypeOf(&Scale{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_ScaleSpec, InType: reflect.TypeOf(&ScaleSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_ScaleStatus, InType: reflect.TypeOf(&ScaleStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSet, InType: reflect.TypeOf(&StatefulSet{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSet, InType: reflect.TypeOf(&StatefulSet{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSetList, InType: reflect.TypeOf(&StatefulSetList{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSetList, InType: reflect.TypeOf(&StatefulSetList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSetSpec, InType: reflect.TypeOf(&StatefulSetSpec{})}, conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1beta1_StatefulSetSpec, InType: reflect.TypeOf(&StatefulSetSpec{})},
...@@ -43,6 +56,218 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { ...@@ -43,6 +56,218 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
) )
} }
func DeepCopy_v1beta1_Deployment(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Deployment)
out := out.(*Deployment)
*out = *in
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
return err
} else {
out.ObjectMeta = *newVal.(*v1.ObjectMeta)
}
if err := DeepCopy_v1beta1_DeploymentSpec(&in.Spec, &out.Spec, c); err != nil {
return err
}
if err := DeepCopy_v1beta1_DeploymentStatus(&in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentCondition)
out := out.(*DeploymentCondition)
*out = *in
out.LastUpdateTime = in.LastUpdateTime.DeepCopy()
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
return nil
}
}
func DeepCopy_v1beta1_DeploymentList(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentList)
out := out.(*DeploymentList)
*out = *in
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Deployment, len(*in))
for i := range *in {
if err := DeepCopy_v1beta1_Deployment(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentRollback(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentRollback)
out := out.(*DeploymentRollback)
*out = *in
if in.UpdatedAnnotations != nil {
in, out := &in.UpdatedAnnotations, &out.UpdatedAnnotations
*out = make(map[string]string)
for key, val := range *in {
(*out)[key] = val
}
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentSpec)
out := out.(*DeploymentSpec)
*out = *in
if in.Replicas != nil {
in, out := &in.Replicas, &out.Replicas
*out = new(int32)
**out = **in
}
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
if newVal, err := c.DeepCopy(*in); err != nil {
return err
} else {
*out = newVal.(*v1.LabelSelector)
}
}
if err := api_v1.DeepCopy_v1_PodTemplateSpec(&in.Template, &out.Template, c); err != nil {
return err
}
if err := DeepCopy_v1beta1_DeploymentStrategy(&in.Strategy, &out.Strategy, c); err != nil {
return err
}
if in.RevisionHistoryLimit != nil {
in, out := &in.RevisionHistoryLimit, &out.RevisionHistoryLimit
*out = new(int32)
**out = **in
}
if in.RollbackTo != nil {
in, out := &in.RollbackTo, &out.RollbackTo
*out = new(RollbackConfig)
**out = **in
}
if in.ProgressDeadlineSeconds != nil {
in, out := &in.ProgressDeadlineSeconds, &out.ProgressDeadlineSeconds
*out = new(int32)
**out = **in
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentStatus)
out := out.(*DeploymentStatus)
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]DeploymentCondition, len(*in))
for i := range *in {
if err := DeepCopy_v1beta1_DeploymentCondition(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
}
return nil
}
}
func DeepCopy_v1beta1_DeploymentStrategy(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentStrategy)
out := out.(*DeploymentStrategy)
*out = *in
if in.RollingUpdate != nil {
in, out := &in.RollingUpdate, &out.RollingUpdate
*out = new(RollingUpdateDeployment)
if err := DeepCopy_v1beta1_RollingUpdateDeployment(*in, *out, c); err != nil {
return err
}
}
return nil
}
}
func DeepCopy_v1beta1_RollbackConfig(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*RollbackConfig)
out := out.(*RollbackConfig)
*out = *in
return nil
}
}
func DeepCopy_v1beta1_RollingUpdateDeployment(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*RollingUpdateDeployment)
out := out.(*RollingUpdateDeployment)
*out = *in
if in.MaxUnavailable != nil {
in, out := &in.MaxUnavailable, &out.MaxUnavailable
*out = new(intstr.IntOrString)
**out = **in
}
if in.MaxSurge != nil {
in, out := &in.MaxSurge, &out.MaxSurge
*out = new(intstr.IntOrString)
**out = **in
}
return nil
}
}
func DeepCopy_v1beta1_Scale(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Scale)
out := out.(*Scale)
*out = *in
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
return err
} else {
out.ObjectMeta = *newVal.(*v1.ObjectMeta)
}
if err := DeepCopy_v1beta1_ScaleStatus(&in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_v1beta1_ScaleSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScaleSpec)
out := out.(*ScaleSpec)
*out = *in
return nil
}
}
func DeepCopy_v1beta1_ScaleStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScaleStatus)
out := out.(*ScaleStatus)
*out = *in
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = make(map[string]string)
for key, val := range *in {
(*out)[key] = val
}
}
return nil
}
}
func DeepCopy_v1beta1_StatefulSet(in interface{}, out interface{}, c *conversion.Cloner) error { func DeepCopy_v1beta1_StatefulSet(in interface{}, out interface{}, c *conversion.Cloner) error {
{ {
in := in.(*StatefulSet) in := in.(*StatefulSet)
......
...@@ -29,11 +29,151 @@ import ( ...@@ -29,11 +29,151 @@ import (
// Public to allow building arbitrary schemes. // Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters. // All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error { func RegisterDefaults(scheme *runtime.Scheme) error {
scheme.AddTypeDefaultingFunc(&Deployment{}, func(obj interface{}) { SetObjectDefaults_Deployment(obj.(*Deployment)) })
scheme.AddTypeDefaultingFunc(&DeploymentList{}, func(obj interface{}) { SetObjectDefaults_DeploymentList(obj.(*DeploymentList)) })
scheme.AddTypeDefaultingFunc(&StatefulSet{}, func(obj interface{}) { SetObjectDefaults_StatefulSet(obj.(*StatefulSet)) }) scheme.AddTypeDefaultingFunc(&StatefulSet{}, func(obj interface{}) { SetObjectDefaults_StatefulSet(obj.(*StatefulSet)) })
scheme.AddTypeDefaultingFunc(&StatefulSetList{}, func(obj interface{}) { SetObjectDefaults_StatefulSetList(obj.(*StatefulSetList)) }) scheme.AddTypeDefaultingFunc(&StatefulSetList{}, func(obj interface{}) { SetObjectDefaults_StatefulSetList(obj.(*StatefulSetList)) })
return nil return nil
} }
func SetObjectDefaults_Deployment(in *Deployment) {
SetDefaults_Deployment(in)
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
for i := range in.Spec.Template.Spec.Volumes {
a := &in.Spec.Template.Spec.Volumes[i]
v1.SetDefaults_Volume(a)
if a.VolumeSource.Secret != nil {
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
}
if a.VolumeSource.ISCSI != nil {
v1.SetDefaults_ISCSIVolumeSource(a.VolumeSource.ISCSI)
}
if a.VolumeSource.RBD != nil {
v1.SetDefaults_RBDVolumeSource(a.VolumeSource.RBD)
}
if a.VolumeSource.DownwardAPI != nil {
v1.SetDefaults_DownwardAPIVolumeSource(a.VolumeSource.DownwardAPI)
for j := range a.VolumeSource.DownwardAPI.Items {
b := &a.VolumeSource.DownwardAPI.Items[j]
if b.FieldRef != nil {
v1.SetDefaults_ObjectFieldSelector(b.FieldRef)
}
}
}
if a.VolumeSource.ConfigMap != nil {
v1.SetDefaults_ConfigMapVolumeSource(a.VolumeSource.ConfigMap)
}
if a.VolumeSource.AzureDisk != nil {
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
}
if a.VolumeSource.Projected != nil {
v1.SetDefaults_ProjectedVolumeSource(a.VolumeSource.Projected)
for j := range a.VolumeSource.Projected.Sources {
b := &a.VolumeSource.Projected.Sources[j]
if b.DownwardAPI != nil {
for k := range b.DownwardAPI.Items {
c := &b.DownwardAPI.Items[k]
if c.FieldRef != nil {
v1.SetDefaults_ObjectFieldSelector(c.FieldRef)
}
}
}
}
}
}
for i := range in.Spec.Template.Spec.InitContainers {
a := &in.Spec.Template.Spec.InitContainers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
v1.SetDefaults_ContainerPort(b)
}
for j := range a.Env {
b := &a.Env[j]
if b.ValueFrom != nil {
if b.ValueFrom.FieldRef != nil {
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
}
}
}
v1.SetDefaults_ResourceList(&a.Resources.Limits)
v1.SetDefaults_ResourceList(&a.Resources.Requests)
if a.LivenessProbe != nil {
v1.SetDefaults_Probe(a.LivenessProbe)
if a.LivenessProbe.Handler.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
}
}
if a.ReadinessProbe != nil {
v1.SetDefaults_Probe(a.ReadinessProbe)
if a.ReadinessProbe.Handler.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
}
}
if a.Lifecycle != nil {
if a.Lifecycle.PostStart != nil {
if a.Lifecycle.PostStart.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
}
}
if a.Lifecycle.PreStop != nil {
if a.Lifecycle.PreStop.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
}
}
}
}
for i := range in.Spec.Template.Spec.Containers {
a := &in.Spec.Template.Spec.Containers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
v1.SetDefaults_ContainerPort(b)
}
for j := range a.Env {
b := &a.Env[j]
if b.ValueFrom != nil {
if b.ValueFrom.FieldRef != nil {
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
}
}
}
v1.SetDefaults_ResourceList(&a.Resources.Limits)
v1.SetDefaults_ResourceList(&a.Resources.Requests)
if a.LivenessProbe != nil {
v1.SetDefaults_Probe(a.LivenessProbe)
if a.LivenessProbe.Handler.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
}
}
if a.ReadinessProbe != nil {
v1.SetDefaults_Probe(a.ReadinessProbe)
if a.ReadinessProbe.Handler.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
}
}
if a.Lifecycle != nil {
if a.Lifecycle.PostStart != nil {
if a.Lifecycle.PostStart.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
}
}
if a.Lifecycle.PreStop != nil {
if a.Lifecycle.PreStop.HTTPGet != nil {
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
}
}
}
}
}
func SetObjectDefaults_DeploymentList(in *DeploymentList) {
for i := range in.Items {
a := &in.Items[i]
SetObjectDefaults_Deployment(a)
}
}
func SetObjectDefaults_StatefulSet(in *StatefulSet) { func SetObjectDefaults_StatefulSet(in *StatefulSet) {
SetDefaults_StatefulSet(in) SetDefaults_StatefulSet(in)
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec) v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
......
...@@ -193,7 +193,7 @@ func waitForDeployment(c *fedclientset.Clientset, namespace string, deploymentNa ...@@ -193,7 +193,7 @@ func waitForDeployment(c *fedclientset.Clientset, namespace string, deploymentNa
} }
specReplicas, statusReplicas := int32(0), int32(0) specReplicas, statusReplicas := int32(0), int32(0)
for _, cluster := range clusters { for _, cluster := range clusters {
dep, err := cluster.Deployments(namespace).Get(deploymentName, metav1.GetOptions{}) dep, err := cluster.Extensions().Deployments(namespace).Get(deploymentName, metav1.GetOptions{})
if err != nil && !errors.IsNotFound(err) { if err != nil && !errors.IsNotFound(err) {
By(fmt.Sprintf("Failed getting deployment: %q/%q/%q, err: %v", cluster.name, namespace, deploymentName, err)) By(fmt.Sprintf("Failed getting deployment: %q/%q/%q, err: %v", cluster.name, namespace, deploymentName, err))
return false, err return false, err
......
...@@ -138,6 +138,60 @@ var hpaV1 string = ` ...@@ -138,6 +138,60 @@ var hpaV1 string = `
} }
` `
var deploymentExtensions string = `
{
"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata": {
"name": "test-deployment1",
"namespace": "default"
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"labels": {
"app": "nginx0"
}
},
"spec": {
"containers": [{
"name": "nginx",
"image": "gcr.io/google-containers/nginx:1.7.9"
}]
}
}
}
}
`
var deploymentApps string = `
{
"apiVersion": "apps/v1beta1",
"kind": "Deployment",
"metadata": {
"name": "test-deployment2",
"namespace": "default"
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"labels": {
"app": "nginx0"
}
},
"spec": {
"containers": [{
"name": "nginx",
"image": "gcr.io/google-containers/nginx:1.7.9"
}]
}
}
}
}
`
func autoscalingPath(resource, namespace, name string) string { func autoscalingPath(resource, namespace, name string) string {
return testapi.Autoscaling.ResourcePath(resource, namespace, name) return testapi.Autoscaling.ResourcePath(resource, namespace, name)
} }
...@@ -150,6 +204,10 @@ func extensionsPath(resource, namespace, name string) string { ...@@ -150,6 +204,10 @@ func extensionsPath(resource, namespace, name string) string {
return testapi.Extensions.ResourcePath(resource, namespace, name) return testapi.Extensions.ResourcePath(resource, namespace, name)
} }
func appsPath(resource, namespace, name string) string {
return testapi.Apps.ResourcePath(resource, namespace, name)
}
func TestAutoscalingGroupBackwardCompatibility(t *testing.T) { func TestAutoscalingGroupBackwardCompatibility(t *testing.T) {
_, s := framework.RunAMaster(nil) _, s := framework.RunAMaster(nil)
defer s.Close() defer s.Close()
...@@ -195,6 +253,59 @@ func TestAutoscalingGroupBackwardCompatibility(t *testing.T) { ...@@ -195,6 +253,59 @@ func TestAutoscalingGroupBackwardCompatibility(t *testing.T) {
} }
} }
func TestAppsGroupBackwardCompatibility(t *testing.T) {
_, s := framework.RunAMaster(nil)
defer s.Close()
transport := http.DefaultTransport
requests := []struct {
verb string
URL string
body string
expectedStatusCodes map[int]bool
expectedVersion string
}{
// Post to extensions endpoint and get back from both: extensions and apps
{"POST", extensionsPath("deployments", metav1.NamespaceDefault, ""), deploymentExtensions, integration.Code201, ""},
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
{"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
// Post to apps endpoint and get back from both: apps and extensions
{"POST", appsPath("deployments", metav1.NamespaceDefault, ""), deploymentApps, integration.Code201, ""},
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
{"DELETE", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
}
for _, r := range requests {
bodyBytes := bytes.NewReader([]byte(r.body))
req, err := http.NewRequest(r.verb, s.URL+r.URL, bodyBytes)
if err != nil {
t.Logf("case %v", r)
t.Fatalf("unexpected error: %v", err)
}
func() {
resp, err := transport.RoundTrip(req)
defer resp.Body.Close()
if err != nil {
t.Logf("case %v", r)
t.Fatalf("unexpected error: %v", err)
}
b, _ := ioutil.ReadAll(resp.Body)
body := string(b)
if _, ok := r.expectedStatusCodes[resp.StatusCode]; !ok {
t.Logf("case %v", r)
t.Errorf("Expected status one of %v, but got %v", r.expectedStatusCodes, resp.StatusCode)
t.Errorf("Body: %v", body)
}
if !strings.Contains(body, "\"apiVersion\":\""+r.expectedVersion) {
t.Logf("case %v", r)
t.Errorf("Expected version %v, got body %v", r.expectedVersion, body)
}
}()
}
}
func TestAccept(t *testing.T) { func TestAccept(t *testing.T) {
_, s := framework.RunAMaster(nil) _, s := framework.RunAMaster(nil)
defer s.Close() defer s.Close()
......
...@@ -12606,6 +12606,7 @@ go_library( ...@@ -12606,6 +12606,7 @@ go_library(
go_library( go_library(
name = "k8s.io/client-go/informers/apps/v1beta1", name = "k8s.io/client-go/informers/apps/v1beta1",
srcs = [ srcs = [
"k8s.io/client-go/informers/apps/v1beta1/deployment.go",
"k8s.io/client-go/informers/apps/v1beta1/interface.go", "k8s.io/client-go/informers/apps/v1beta1/interface.go",
"k8s.io/client-go/informers/apps/v1beta1/statefulset.go", "k8s.io/client-go/informers/apps/v1beta1/statefulset.go",
], ],
...@@ -13066,8 +13067,10 @@ go_library( ...@@ -13066,8 +13067,10 @@ go_library(
name = "k8s.io/client-go/kubernetes/typed/apps/v1beta1", name = "k8s.io/client-go/kubernetes/typed/apps/v1beta1",
srcs = [ srcs = [
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/apps_client.go", "k8s.io/client-go/kubernetes/typed/apps/v1beta1/apps_client.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/deployment.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/doc.go", "k8s.io/client-go/kubernetes/typed/apps/v1beta1/doc.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/generated_expansion.go", "k8s.io/client-go/kubernetes/typed/apps/v1beta1/generated_expansion.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/scale.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/statefulset.go", "k8s.io/client-go/kubernetes/typed/apps/v1beta1/statefulset.go",
], ],
tags = ["automanaged"], tags = ["automanaged"],
...@@ -13087,6 +13090,8 @@ go_library( ...@@ -13087,6 +13090,8 @@ go_library(
srcs = [ srcs = [
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake/doc.go", "k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake/doc.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake/fake_apps_client.go", "k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake/fake_apps_client.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake/fake_deployment.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake/fake_scale.go",
"k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake/fake_statefulset.go", "k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake/fake_statefulset.go",
], ],
tags = ["automanaged"], tags = ["automanaged"],
...@@ -13801,7 +13806,9 @@ go_library( ...@@ -13801,7 +13806,9 @@ go_library(
go_library( go_library(
name = "k8s.io/client-go/listers/apps/v1beta1", name = "k8s.io/client-go/listers/apps/v1beta1",
srcs = [ srcs = [
"k8s.io/client-go/listers/apps/v1beta1/deployment.go",
"k8s.io/client-go/listers/apps/v1beta1/expansion_generated.go", "k8s.io/client-go/listers/apps/v1beta1/expansion_generated.go",
"k8s.io/client-go/listers/apps/v1beta1/scale.go",
"k8s.io/client-go/listers/apps/v1beta1/statefulset.go", "k8s.io/client-go/listers/apps/v1beta1/statefulset.go",
"k8s.io/client-go/listers/apps/v1beta1/statefulset_expansion.go", "k8s.io/client-go/listers/apps/v1beta1/statefulset_expansion.go",
], ],
...@@ -14151,6 +14158,7 @@ go_library( ...@@ -14151,6 +14158,7 @@ go_library(
"//vendor:k8s.io/apimachinery/pkg/runtime", "//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema", "//vendor:k8s.io/apimachinery/pkg/runtime/schema",
"//vendor:k8s.io/client-go/pkg/api", "//vendor:k8s.io/client-go/pkg/api",
"//vendor:k8s.io/client-go/pkg/apis/extensions",
], ],
) )
...@@ -14186,6 +14194,7 @@ go_library( ...@@ -14186,6 +14194,7 @@ go_library(
tags = ["automanaged"], tags = ["automanaged"],
deps = [ deps = [
"//vendor:github.com/gogo/protobuf/proto", "//vendor:github.com/gogo/protobuf/proto",
"//vendor:github.com/gogo/protobuf/sortkeys",
"//vendor:github.com/ugorji/go/codec", "//vendor:github.com/ugorji/go/codec",
"//vendor:k8s.io/apimachinery/pkg/api/resource", "//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
...@@ -14197,6 +14206,7 @@ go_library( ...@@ -14197,6 +14206,7 @@ go_library(
"//vendor:k8s.io/client-go/pkg/api", "//vendor:k8s.io/client-go/pkg/api",
"//vendor:k8s.io/client-go/pkg/api/v1", "//vendor:k8s.io/client-go/pkg/api/v1",
"//vendor:k8s.io/client-go/pkg/apis/apps", "//vendor:k8s.io/client-go/pkg/apis/apps",
"//vendor:k8s.io/client-go/pkg/apis/extensions",
], ],
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment