mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-21 01:26:28 +00:00
Created batch API group and copied Job there
Modeled after on first commit (2fbc5bb
) of piosz:hpa-ga (#20501).
This commit is contained in:
parent
ced1ddfcc7
commit
98a801a37b
@ -28,6 +28,7 @@ import (
|
|||||||
_ "k8s.io/kubernetes/pkg/api/install"
|
_ "k8s.io/kubernetes/pkg/api/install"
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
||||||
|
_ "k8s.io/kubernetes/pkg/apis/batch/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/metrics/install"
|
_ "k8s.io/kubernetes/pkg/apis/metrics/install"
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
_ "k8s.io/kubernetes/pkg/api/install"
|
_ "k8s.io/kubernetes/pkg/api/install"
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
||||||
|
_ "k8s.io/kubernetes/pkg/apis/batch/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/metrics/install"
|
_ "k8s.io/kubernetes/pkg/apis/metrics/install"
|
||||||
|
@ -43,7 +43,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
# TODO(lavalamp): get this list by listing the pkg/apis/ directory?
|
# TODO(lavalamp): get this list by listing the pkg/apis/ directory?
|
||||||
DEFAULT_GROUP_VERSIONS="v1 authorization/v1beta1 autoscaling/v1 extensions/v1beta1 componentconfig/v1alpha1 metrics/v1alpha1"
|
DEFAULT_GROUP_VERSIONS="v1 authorization/v1beta1 autoscaling/v1 batch/v1 extensions/v1beta1 componentconfig/v1alpha1 metrics/v1alpha1"
|
||||||
VERSIONS=${VERSIONS:-$DEFAULT_GROUP_VERSIONS}
|
VERSIONS=${VERSIONS:-$DEFAULT_GROUP_VERSIONS}
|
||||||
for ver in $VERSIONS; do
|
for ver in $VERSIONS; do
|
||||||
# Ensure that the version being processed is registered by setting
|
# Ensure that the version being processed is registered by setting
|
||||||
|
@ -62,6 +62,6 @@ function generate_deep_copies() {
|
|||||||
# Currently pkg/api/deep_copy_generated.go is generated by the new go2idl generator.
|
# Currently pkg/api/deep_copy_generated.go is generated by the new go2idl generator.
|
||||||
# All others (mentioned above) are still generated by the old reflection-based generator.
|
# All others (mentioned above) are still generated by the old reflection-based generator.
|
||||||
# TODO: Migrate these to the new generator.
|
# TODO: Migrate these to the new generator.
|
||||||
DEFAULT_VERSIONS="v1 authorization/__internal authorization/v1beta1 autoscaling/__internal autoscaling/v1 extensions/__internal extensions/v1beta1 componentconfig/__internal componentconfig/v1alpha1 metrics/__internal metrics/v1alpha1"
|
DEFAULT_VERSIONS="v1 authorization/__internal authorization/v1beta1 autoscaling/__internal autoscaling/v1 batch/__internal batch/v1 extensions/__internal extensions/v1beta1 componentconfig/__internal componentconfig/v1alpha1 metrics/__internal metrics/v1alpha1"
|
||||||
VERSIONS=${VERSIONS:-$DEFAULT_VERSIONS}
|
VERSIONS=${VERSIONS:-$DEFAULT_VERSIONS}
|
||||||
generate_deep_copies "$VERSIONS"
|
generate_deep_copies "$VERSIONS"
|
||||||
|
@ -50,7 +50,7 @@ kube::etcd::start
|
|||||||
|
|
||||||
# Start kube-apiserver
|
# Start kube-apiserver
|
||||||
kube::log::status "Starting kube-apiserver"
|
kube::log::status "Starting kube-apiserver"
|
||||||
KUBE_API_VERSIONS="v1,autoscaling/v1,extensions/v1beta1" "${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
|
KUBE_API_VERSIONS="v1,autoscaling/v1,batch/v1,extensions/v1beta1" "${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
|
||||||
--address="127.0.0.1" \
|
--address="127.0.0.1" \
|
||||||
--public-address-override="127.0.0.1" \
|
--public-address-override="127.0.0.1" \
|
||||||
--port="${API_PORT}" \
|
--port="${API_PORT}" \
|
||||||
@ -64,7 +64,7 @@ APISERVER_PID=$!
|
|||||||
kube::util::wait_for_url "http://127.0.0.1:${API_PORT}/healthz" "apiserver: "
|
kube::util::wait_for_url "http://127.0.0.1:${API_PORT}/healthz" "apiserver: "
|
||||||
|
|
||||||
SWAGGER_API_PATH="http://127.0.0.1:${API_PORT}/swaggerapi/"
|
SWAGGER_API_PATH="http://127.0.0.1:${API_PORT}/swaggerapi/"
|
||||||
DEFAULT_GROUP_VERSIONS="v1 autoscaling/v1 extensions/v1beta1"
|
DEFAULT_GROUP_VERSIONS="v1 autoscaling/v1 batch/v1 extensions/v1beta1"
|
||||||
VERSIONS=${VERSIONS:-$DEFAULT_GROUP_VERSIONS}
|
VERSIONS=${VERSIONS:-$DEFAULT_GROUP_VERSIONS}
|
||||||
|
|
||||||
kube::log::status "Updating " ${SWAGGER_ROOT_DIR}
|
kube::log::status "Updating " ${SWAGGER_ROOT_DIR}
|
||||||
|
@ -23,7 +23,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
|||||||
|
|
||||||
kube::golang::setup_env
|
kube::golang::setup_env
|
||||||
|
|
||||||
APIROOTS=${APIROOTS:-pkg/api pkg/apis/authorization pkg/apis/autoscaling pkg/apis/extensions pkg/apis/metrics}
|
APIROOTS=${APIROOTS:-pkg/api pkg/apis/authorization pkg/apis/autoscaling pkg/apis/batch pkg/apis/extensions pkg/apis/metrics}
|
||||||
_tmp="${KUBE_ROOT}/_tmp"
|
_tmp="${KUBE_ROOT}/_tmp"
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
@ -25,7 +25,7 @@ kube::golang::setup_env
|
|||||||
|
|
||||||
gendeepcopy=$(kube::util::find-binary "gendeepcopy")
|
gendeepcopy=$(kube::util::find-binary "gendeepcopy")
|
||||||
|
|
||||||
APIROOTS=${APIROOTS:-pkg/api pkg/apis/authorization pkg/apis/autoscaling pkg/apis/extensions pkg/apis/metrics}
|
APIROOTS=${APIROOTS:-pkg/api pkg/apis/authorization pkg/apis/autoscaling pkg/apis/batch pkg/apis/extensions pkg/apis/metrics}
|
||||||
_tmp="${KUBE_ROOT}/_tmp"
|
_tmp="${KUBE_ROOT}/_tmp"
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
@ -33,7 +33,7 @@ function generate_version() {
|
|||||||
echo "package ${group_version##*/}" >> "$TMPFILE"
|
echo "package ${group_version##*/}" >> "$TMPFILE"
|
||||||
cat >> "$TMPFILE" <<EOF
|
cat >> "$TMPFILE" <<EOF
|
||||||
|
|
||||||
// This file contains a collection of methods that can be used from go-resful to
|
// This file contains a collection of methods that can be used from go-restful to
|
||||||
// generate Swagger API documentation for its models. Please read this PR for more
|
// generate Swagger API documentation for its models. Please read this PR for more
|
||||||
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
|
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
|
||||||
//
|
//
|
||||||
@ -56,7 +56,7 @@ EOF
|
|||||||
mv "$TMPFILE" "pkg/$(kube::util::group-version-to-pkg-path "${group_version}")/types_swagger_doc_generated.go"
|
mv "$TMPFILE" "pkg/$(kube::util::group-version-to-pkg-path "${group_version}")/types_swagger_doc_generated.go"
|
||||||
}
|
}
|
||||||
|
|
||||||
GROUP_VERSIONS=(unversioned v1 authorization/v1beta1 autoscaling/v1 extensions/v1beta1)
|
GROUP_VERSIONS=(unversioned v1 authorization/v1beta1 autoscaling/v1 batch/v1 extensions/v1beta1)
|
||||||
# To avoid compile errors, remove the currently existing files.
|
# To avoid compile errors, remove the currently existing files.
|
||||||
for group_version in "${GROUP_VERSIONS[@]}"; do
|
for group_version in "${GROUP_VERSIONS[@]}"; do
|
||||||
rm -f "pkg/$(kube::util::group-version-to-pkg-path "${group_version}")/types_swagger_doc_generated.go"
|
rm -f "pkg/$(kube::util::group-version-to-pkg-path "${group_version}")/types_swagger_doc_generated.go"
|
||||||
|
129
pkg/apis/batch/install/install.go
Normal file
129
pkg/apis/batch/install/install.go
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
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 install installs the batch API group, making it available as
|
||||||
|
// an option to all of the API encoding/decoding machinery.
|
||||||
|
package install
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
"k8s.io/kubernetes/pkg/api/meta"
|
||||||
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
|
"k8s.io/kubernetes/pkg/apimachinery"
|
||||||
|
"k8s.io/kubernetes/pkg/apimachinery/registered"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/batch"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/batch/v1"
|
||||||
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/util/sets"
|
||||||
|
)
|
||||||
|
|
||||||
|
const importPrefix = "k8s.io/kubernetes/pkg/apis/batch"
|
||||||
|
|
||||||
|
var accessor = meta.NewAccessor()
|
||||||
|
|
||||||
|
// availableVersions lists all known external versions for this group from most preferred to least preferred
|
||||||
|
var availableVersions = []unversioned.GroupVersion{v1.SchemeGroupVersion}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registered.RegisterVersions(availableVersions)
|
||||||
|
externalVersions := []unversioned.GroupVersion{}
|
||||||
|
for _, v := range availableVersions {
|
||||||
|
if registered.IsAllowedVersion(v) {
|
||||||
|
externalVersions = append(externalVersions, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(externalVersions) == 0 {
|
||||||
|
glog.V(4).Infof("No version is registered for group %v", batch.GroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := registered.EnableVersions(externalVersions...); err != nil {
|
||||||
|
glog.V(4).Infof("%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := enableVersions(externalVersions); err != nil {
|
||||||
|
glog.V(4).Infof("%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: enableVersions should be centralized rather than spread in each API
|
||||||
|
// group.
|
||||||
|
// We can combine registered.RegisterVersions, registered.EnableVersions and
|
||||||
|
// registered.RegisterGroup once we have moved enableVersions there.
|
||||||
|
func enableVersions(externalVersions []unversioned.GroupVersion) error {
|
||||||
|
addVersionsToScheme(externalVersions...)
|
||||||
|
preferredExternalVersion := externalVersions[0]
|
||||||
|
|
||||||
|
groupMeta := apimachinery.GroupMeta{
|
||||||
|
GroupVersion: preferredExternalVersion,
|
||||||
|
GroupVersions: externalVersions,
|
||||||
|
RESTMapper: newRESTMapper(externalVersions),
|
||||||
|
SelfLinker: runtime.SelfLinker(accessor),
|
||||||
|
InterfacesFor: interfacesFor,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := registered.RegisterGroup(groupMeta); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
api.RegisterRESTMapper(groupMeta.RESTMapper)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper {
|
||||||
|
// the list of kinds that are scoped at the root of the api hierarchy
|
||||||
|
// if a kind is not enumerated here, it is assumed to have a namespace scope
|
||||||
|
rootScoped := sets.NewString()
|
||||||
|
|
||||||
|
ignoredKinds := sets.NewString()
|
||||||
|
|
||||||
|
return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped)
|
||||||
|
}
|
||||||
|
|
||||||
|
// interfacesFor returns the default Codec and ResourceVersioner for a given version
|
||||||
|
// string, or an error if the version is not known.
|
||||||
|
func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) {
|
||||||
|
switch version {
|
||||||
|
case v1.SchemeGroupVersion:
|
||||||
|
return &meta.VersionInterfaces{
|
||||||
|
ObjectConvertor: api.Scheme,
|
||||||
|
MetadataAccessor: accessor,
|
||||||
|
}, nil
|
||||||
|
default:
|
||||||
|
g, _ := registered.Group(batch.GroupName)
|
||||||
|
return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) {
|
||||||
|
// add the internal version to Scheme
|
||||||
|
batch.AddToScheme(api.Scheme)
|
||||||
|
// add the enabled external versions to Scheme
|
||||||
|
for _, v := range externalVersions {
|
||||||
|
if !registered.IsEnabledVersion(v) {
|
||||||
|
glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
switch v {
|
||||||
|
case v1.SchemeGroupVersion:
|
||||||
|
v1.AddToScheme(api.Scheme)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
pkg/apis/batch/register.go
Normal file
54
pkg/apis/batch/register.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
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 batch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GroupName is the group name use in this package
|
||||||
|
const GroupName = "batch"
|
||||||
|
|
||||||
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
|
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
||||||
|
|
||||||
|
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
|
||||||
|
func Kind(kind string) unversioned.GroupKind {
|
||||||
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resource takes an unqualified resource and returns back a Group qualified GroupResource
|
||||||
|
func Resource(resource string) unversioned.GroupResource {
|
||||||
|
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddToScheme(scheme *runtime.Scheme) {
|
||||||
|
// Add the API to Scheme.
|
||||||
|
addKnownTypes(scheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds the list of known types to api.Scheme.
|
||||||
|
func addKnownTypes(scheme *runtime.Scheme) {
|
||||||
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
|
&extensions.Job{},
|
||||||
|
&extensions.JobList{},
|
||||||
|
&api.ListOptions{},
|
||||||
|
)
|
||||||
|
}
|
52
pkg/apis/batch/v1/defaults.go
Normal file
52
pkg/apis/batch/v1/defaults.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
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 v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
func addDefaultingFuncs(scheme *runtime.Scheme) {
|
||||||
|
scheme.AddDefaultingFuncs(
|
||||||
|
func(obj *Job) {
|
||||||
|
labels := obj.Spec.Template.Labels
|
||||||
|
// TODO: support templates defined elsewhere when we support them in the API
|
||||||
|
if labels != nil {
|
||||||
|
if obj.Spec.Selector == nil {
|
||||||
|
obj.Spec.Selector = &LabelSelector{
|
||||||
|
MatchLabels: labels,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(obj.Labels) == 0 {
|
||||||
|
obj.Labels = labels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// For a non-parallel job, you can leave both `.spec.completions` and
|
||||||
|
// `.spec.parallelism` unset. When both are unset, both are defaulted to 1.
|
||||||
|
if obj.Spec.Completions == nil && obj.Spec.Parallelism == nil {
|
||||||
|
obj.Spec.Completions = new(int32)
|
||||||
|
*obj.Spec.Completions = 1
|
||||||
|
obj.Spec.Parallelism = new(int32)
|
||||||
|
*obj.Spec.Parallelism = 1
|
||||||
|
}
|
||||||
|
if obj.Spec.Parallelism == nil {
|
||||||
|
obj.Spec.Parallelism = new(int32)
|
||||||
|
*obj.Spec.Parallelism = 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
47
pkg/apis/batch/v1/register.go
Normal file
47
pkg/apis/batch/v1/register.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
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 v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GroupName is the group name use in this package
|
||||||
|
const GroupName = "batch"
|
||||||
|
|
||||||
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
|
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: "v1"}
|
||||||
|
|
||||||
|
func AddToScheme(scheme *runtime.Scheme) {
|
||||||
|
addKnownTypes(scheme)
|
||||||
|
addDefaultingFuncs(scheme)
|
||||||
|
addConversionFuncs(scheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds the list of known types to api.Scheme.
|
||||||
|
func addKnownTypes(scheme *runtime.Scheme) {
|
||||||
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
|
&Job{},
|
||||||
|
&JobList{},
|
||||||
|
&v1.ListOptions{},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||||
|
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
170
pkg/apis/batch/v1/types.go
Normal file
170
pkg/apis/batch/v1/types.go
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
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 v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Job represents the configuration of a single job.
|
||||||
|
type Job struct {
|
||||||
|
unversioned.TypeMeta `json:",inline"`
|
||||||
|
// Standard object's metadata.
|
||||||
|
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||||
|
v1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
|
// Spec is a structure defining the expected behavior of a job.
|
||||||
|
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
|
||||||
|
Spec JobSpec `json:"spec,omitempty"`
|
||||||
|
|
||||||
|
// Status is a structure describing current status of a job.
|
||||||
|
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
|
||||||
|
Status JobStatus `json:"status,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// JobList is a collection of jobs.
|
||||||
|
type JobList struct {
|
||||||
|
unversioned.TypeMeta `json:",inline"`
|
||||||
|
// Standard list metadata
|
||||||
|
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||||
|
unversioned.ListMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
|
// Items is the list of Job.
|
||||||
|
Items []Job `json:"items"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// JobSpec describes how the job execution will look like.
|
||||||
|
type JobSpec struct {
|
||||||
|
|
||||||
|
// Parallelism specifies the maximum desired number of pods the job should
|
||||||
|
// run at any given time. The actual number of pods running in steady state will
|
||||||
|
// be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism),
|
||||||
|
// i.e. when the work left to do is less than max parallelism.
|
||||||
|
// More info: http://releases.k8s.io/HEAD/docs/user-guide/jobs.md
|
||||||
|
Parallelism *int32 `json:"parallelism,omitempty"`
|
||||||
|
|
||||||
|
// Completions specifies the desired number of successfully finished pods the
|
||||||
|
// job should be run with. Setting to nil means that the success of any
|
||||||
|
// pod signals the success of all pods, and allows parallelism to have any positive
|
||||||
|
// value. Setting to 1 means that parallelism is limited to 1 and the success of that
|
||||||
|
// pod signals the success of the job.
|
||||||
|
Completions *int32 `json:"completions,omitempty"`
|
||||||
|
|
||||||
|
// Optional duration in seconds relative to the startTime that the job may be active
|
||||||
|
// before the system tries to terminate it; value must be positive integer
|
||||||
|
ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty"`
|
||||||
|
|
||||||
|
// Selector is a label query over pods that should match the pod count.
|
||||||
|
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
|
||||||
|
Selector *LabelSelector `json:"selector,omitempty"`
|
||||||
|
|
||||||
|
// Template is the object that describes the pod that will be created when
|
||||||
|
// executing a job.
|
||||||
|
// More info: http://releases.k8s.io/HEAD/docs/user-guide/jobs.md
|
||||||
|
Template v1.PodTemplateSpec `json:"template"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// JobStatus represents the current state of a Job.
|
||||||
|
type JobStatus struct {
|
||||||
|
|
||||||
|
// Conditions represent the latest available observations of an object's current state.
|
||||||
|
// More info: http://releases.k8s.io/HEAD/docs/user-guide/jobs.md
|
||||||
|
Conditions []JobCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
|
||||||
|
|
||||||
|
// StartTime represents time when the job was acknowledged by the Job Manager.
|
||||||
|
// It is not guaranteed to be set in happens-before order across separate operations.
|
||||||
|
// It is represented in RFC3339 form and is in UTC.
|
||||||
|
StartTime *unversioned.Time `json:"startTime,omitempty"`
|
||||||
|
|
||||||
|
// CompletionTime represents time when the job was completed. It is not guaranteed to
|
||||||
|
// be set in happens-before order across separate operations.
|
||||||
|
// It is represented in RFC3339 form and is in UTC.
|
||||||
|
CompletionTime *unversioned.Time `json:"completionTime,omitempty"`
|
||||||
|
|
||||||
|
// Active is the number of actively running pods.
|
||||||
|
Active int32 `json:"active,omitempty"`
|
||||||
|
|
||||||
|
// Succeeded is the number of pods which reached Phase Succeeded.
|
||||||
|
Succeeded int32 `json:"succeeded,omitempty"`
|
||||||
|
|
||||||
|
// Failed is the number of pods which reached Phase Failed.
|
||||||
|
Failed int32 `json:"failed,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JobConditionType string
|
||||||
|
|
||||||
|
// These are valid conditions of a job.
|
||||||
|
const (
|
||||||
|
// JobComplete means the job has completed its execution.
|
||||||
|
JobComplete JobConditionType = "Complete"
|
||||||
|
// JobFailed means the job has failed its execution.
|
||||||
|
JobFailed JobConditionType = "Failed"
|
||||||
|
)
|
||||||
|
|
||||||
|
// JobCondition describes current state of a job.
|
||||||
|
type JobCondition struct {
|
||||||
|
// Type of job condition, Complete or Failed.
|
||||||
|
Type JobConditionType `json:"type"`
|
||||||
|
// Status of the condition, one of True, False, Unknown.
|
||||||
|
Status v1.ConditionStatus `json:"status"`
|
||||||
|
// Last time the condition was checked.
|
||||||
|
LastProbeTime unversioned.Time `json:"lastProbeTime,omitempty"`
|
||||||
|
// Last time the condition transit from one status to another.
|
||||||
|
LastTransitionTime unversioned.Time `json:"lastTransitionTime,omitempty"`
|
||||||
|
// (brief) reason for the condition's last transition.
|
||||||
|
Reason string `json:"reason,omitempty"`
|
||||||
|
// Human readable message indicating details about last transition.
|
||||||
|
Message string `json:"message,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// A label selector is a label query over a set of resources. The result of matchLabels and
|
||||||
|
// matchExpressions are ANDed. An empty label selector matches all objects. A null
|
||||||
|
// label selector matches no objects.
|
||||||
|
type LabelSelector struct {
|
||||||
|
// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
|
||||||
|
// map is equivalent to an element of matchExpressions, whose key field is "key", the
|
||||||
|
// operator is "In", and the values array contains only "value". The requirements are ANDed.
|
||||||
|
MatchLabels map[string]string `json:"matchLabels,omitempty"`
|
||||||
|
// matchExpressions is a list of label selector requirements. The requirements are ANDed.
|
||||||
|
MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// A label selector requirement is a selector that contains values, a key, and an operator that
|
||||||
|
// relates the key and values.
|
||||||
|
type LabelSelectorRequirement struct {
|
||||||
|
// key is the label key that the selector applies to.
|
||||||
|
Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key"`
|
||||||
|
// operator represents a key's relationship to a set of values.
|
||||||
|
// Valid operators ard In, NotIn, Exists and DoesNotExist.
|
||||||
|
Operator LabelSelectorOperator `json:"operator"`
|
||||||
|
// values is an array of string values. If the operator is In or NotIn,
|
||||||
|
// the values array must be non-empty. If the operator is Exists or DoesNotExist,
|
||||||
|
// the values array must be empty. This array is replaced during a strategic
|
||||||
|
// merge patch.
|
||||||
|
Values []string `json:"values,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// A label selector operator is the set of operators that can be used in a selector requirement.
|
||||||
|
type LabelSelectorOperator string
|
||||||
|
|
||||||
|
const (
|
||||||
|
LabelSelectorOpIn LabelSelectorOperator = "In"
|
||||||
|
LabelSelectorOpNotIn LabelSelectorOperator = "NotIn"
|
||||||
|
LabelSelectorOpExists LabelSelectorOperator = "Exists"
|
||||||
|
LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
|
||||||
|
)
|
@ -24,6 +24,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/apimachinery/registered"
|
"k8s.io/kubernetes/pkg/apimachinery/registered"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/authorization/install"
|
_ "k8s.io/kubernetes/pkg/apis/authorization/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
||||||
|
_ "k8s.io/kubernetes/pkg/apis/batch/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/metrics/install"
|
_ "k8s.io/kubernetes/pkg/apis/metrics/install"
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/apimachinery/registered"
|
"k8s.io/kubernetes/pkg/apimachinery/registered"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/authorization/install"
|
_ "k8s.io/kubernetes/pkg/apis/authorization/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
||||||
|
_ "k8s.io/kubernetes/pkg/apis/batch/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user