Adding a deployment example

This commit is contained in:
nikhiljindal 2015-09-21 16:29:47 -07:00
parent 634de8c6c7
commit bf6068c125
2 changed files with 35 additions and 1 deletions

View File

@ -29,6 +29,8 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/apis/experimental"
expValidation "k8s.io/kubernetes/pkg/apis/experimental/validation"
"k8s.io/kubernetes/pkg/capabilities"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/yaml"
@ -99,6 +101,11 @@ func validateObject(obj runtime.Object) (errors []error) {
t.Namespace = api.NamespaceDefault
}
errors = validation.ValidateResourceQuota(t)
case *experimental.Deployment:
if t.Namespace == "" {
t.Namespace = api.NamespaceDefault
}
errors = expValidation.ValidateDeployment(t)
default:
return []error{fmt.Errorf("no validation defined for %#v", obj)}
}
@ -343,6 +350,9 @@ func TestExampleObjectSchemas(t *testing.T) {
"../examples/fibre_channel": {
"fc": &api.Pod{},
},
"../examples/experimental": {
"deployment": &experimental.Deployment{},
},
}
capabilities.SetForTests(capabilities.Capabilities{
@ -369,7 +379,11 @@ func TestExampleObjectSchemas(t *testing.T) {
}
//TODO: Add validate method for &schedulerapi.Policy
} else {
if err := testapi.Default.Codec().DecodeInto(data, expectedType); err != nil {
codec, err := testapi.GetCodecForObject(expectedType)
if err != nil {
t.Errorf("Could not get codec for %s: %s", expectedType, err)
}
if err := codec.DecodeInto(data, expectedType); err != nil {
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
return
}

View File

@ -0,0 +1,20 @@
apiVersion: v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
name: nginx-deployment
spec:
replicas: 3
selector:
name: nginx
template:
metadata:
labels:
name: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80