Initial commit.

This commit is contained in:
2023-02-19 20:46:21 +00:00
commit 984e1a0f7b
45 changed files with 11131 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
/*
Copyright 2023.
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 contains API Schema definitions for the jobsmanager v1beta1 API group
// +kubebuilder:object:generate=true
// +groupName=jobsmanager.raczylo.com
package v1beta1
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)
var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "jobsmanager.raczylo.com", Version: "v1beta1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
+137
View File
@@ -0,0 +1,137 @@
/*
Copyright 2023.
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 (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type ManagedJobDependencies struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default=""
Group string `json:"group"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=""
Job string `json:"job"`
}
type ManagedJobDefinition struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=40
// +kubebuilder:validation:Pattern=[a-z0-9-]+
Name string `json:"name"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=false
Parallel bool `json:"parallel"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=5
Image string `json:"image"`
// +kubebuilder:validation:Optional
Args []string `json:"args,omitempty"`
// +kubebuilder:validation:Optional
Params ManagedJobParameters `json:"params"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=pending
Status string `json:"status"`
// +optional
Dependencies ManagedJobDependencies `json:"dependencies"`
// +optional
CompiledParams ManagedJobParameters `json:"compiledParams"`
}
type ManagedJobGroup struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=40
// +kubebuilder:validation:Pattern=[a-z0-9-]+
Name string `json:"name"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=false
Parallel bool `json:"parallel"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
Jobs []*ManagedJobDefinition `json:"jobs"`
// +kubebuilder:validation:Optional
Params ManagedJobParameters `json:"params"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=pending
Status string `json:"status"`
}
type ManagedJobParameters struct {
// +kubebuilder:validation:Optional
FromEnv []corev1.EnvFromSource `json:"fromEnv,omitempty"`
// +kubebuilder:validation:Optional
Env []corev1.EnvVar `json:"env,omitempty"`
// +kubebuilder:validation:Optional
Volumes []corev1.Volume `json:"volumes,omitempty"`
// +kubebuilder:validation:Optional
VolumeMounts []corev1.VolumeMount `json:"volumeMount,omitempty"`
// +kubebuilder:validation:Optional
ServiceAccount string `json:"serviceAccount,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=OnFailure
RestartPolicy string `json:"restartPolicy,omitempty"`
// +kubebuilder:validation:Optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
// +kubebuilder:validation:Optional
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
// +kubebuilder:validation:Optional
Labels map[string]string `json:"labels,omitempty"`
}
// ManagedJobSpec defines the desired state of ManagedJob
type ManagedJobSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:default=1
// +kubebuilder:validation:Minimum=1
Retries int `json:"retries"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
Groups []*ManagedJobGroup `json:"groups"`
// +kubebuilder:validation:Optional
Params ManagedJobParameters `json:"params"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=pending
Status string `json:"status"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// ManagedJob is the Schema for the managedjobs API
type ManagedJob struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ManagedJobSpec `json:"spec,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=pending
Status string `json:"status"`
}
//+kubebuilder:object:root=true
// ManagedJobList contains a list of ManagedJob
type ManagedJobList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ManagedJob `json:"items"`
}
func init() {
SchemeBuilder.Register(&ManagedJob{}, &ManagedJobList{})
}
+232
View File
@@ -0,0 +1,232 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*
Copyright 2023.
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.
*/
// Code generated by controller-gen. DO NOT EDIT.
package v1beta1
import (
"k8s.io/api/core/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedJob) DeepCopyInto(out *ManagedJob) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJob.
func (in *ManagedJob) DeepCopy() *ManagedJob {
if in == nil {
return nil
}
out := new(ManagedJob)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ManagedJob) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedJobDefinition) DeepCopyInto(out *ManagedJobDefinition) {
*out = *in
if in.Args != nil {
in, out := &in.Args, &out.Args
*out = make([]string, len(*in))
copy(*out, *in)
}
in.Params.DeepCopyInto(&out.Params)
out.Dependencies = in.Dependencies
in.CompiledParams.DeepCopyInto(&out.CompiledParams)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJobDefinition.
func (in *ManagedJobDefinition) DeepCopy() *ManagedJobDefinition {
if in == nil {
return nil
}
out := new(ManagedJobDefinition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedJobDependencies) DeepCopyInto(out *ManagedJobDependencies) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJobDependencies.
func (in *ManagedJobDependencies) DeepCopy() *ManagedJobDependencies {
if in == nil {
return nil
}
out := new(ManagedJobDependencies)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedJobGroup) DeepCopyInto(out *ManagedJobGroup) {
*out = *in
if in.Jobs != nil {
in, out := &in.Jobs, &out.Jobs
*out = make([]*ManagedJobDefinition, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(ManagedJobDefinition)
(*in).DeepCopyInto(*out)
}
}
}
in.Params.DeepCopyInto(&out.Params)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJobGroup.
func (in *ManagedJobGroup) DeepCopy() *ManagedJobGroup {
if in == nil {
return nil
}
out := new(ManagedJobGroup)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedJobList) DeepCopyInto(out *ManagedJobList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ManagedJob, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJobList.
func (in *ManagedJobList) DeepCopy() *ManagedJobList {
if in == nil {
return nil
}
out := new(ManagedJobList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ManagedJobList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedJobParameters) DeepCopyInto(out *ManagedJobParameters) {
*out = *in
if in.FromEnv != nil {
in, out := &in.FromEnv, &out.FromEnv
*out = make([]v1.EnvFromSource, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Env != nil {
in, out := &in.Env, &out.Env
*out = make([]v1.EnvVar, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Volumes != nil {
in, out := &in.Volumes, &out.Volumes
*out = make([]v1.Volume, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.VolumeMounts != nil {
in, out := &in.VolumeMounts, &out.VolumeMounts
*out = make([]v1.VolumeMount, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.ImagePullSecrets != nil {
in, out := &in.ImagePullSecrets, &out.ImagePullSecrets
*out = make([]v1.LocalObjectReference, len(*in))
copy(*out, *in)
}
if in.Labels != nil {
in, out := &in.Labels, &out.Labels
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJobParameters.
func (in *ManagedJobParameters) DeepCopy() *ManagedJobParameters {
if in == nil {
return nil
}
out := new(ManagedJobParameters)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedJobSpec) DeepCopyInto(out *ManagedJobSpec) {
*out = *in
if in.Groups != nil {
in, out := &in.Groups, &out.Groups
*out = make([]*ManagedJobGroup, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(ManagedJobGroup)
(*in).DeepCopyInto(*out)
}
}
}
in.Params.DeepCopyInto(&out.Params)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJobSpec.
func (in *ManagedJobSpec) DeepCopy() *ManagedJobSpec {
if in == nil {
return nil
}
out := new(ManagedJobSpec)
in.DeepCopyInto(out)
return out
}