Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Add v1alpha2 API #179

Merged
merged 1 commit into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions controller/pkg/apis/kubebenchjob/v1alpha2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2019 The Kubeflow 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.

// +k8s:deepcopy-gen=package,register
// +k8s:defaulter-gen=TypeMeta
// +k8s:openapi-gen=true

// Package v1alpha2 is the v1alpha2 version of the API.
// +groupName=kubeflow.org
package v1alpha2
66 changes: 66 additions & 0 deletions controller/pkg/apis/kubebenchjob/v1alpha2/resgiter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2019 The Kubeflow 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 v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

const (
// GroupName is the group name use in this package.
GroupName = "kubeflow.org"
// GroupVersion is the version.
GroupVersion = "v1alpha2"
// Kind is the kind name.
Kind = "KubebenchJob"
// Plural is the Plural for KubebenchJob.
Plural = "kubebenchjobs"
// Singular is the singular for KubebenchJob.
Singular = "kubebenchjob"
)

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)

func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
}

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&KubebenchJob{},
&KubebenchJobList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
108 changes: 108 additions & 0 deletions controller/pkg/apis/kubebenchjob/v1alpha2/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright 2019 The Kubeflow 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 v1alpha2

import (
argov1alpha1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +resource:path=kubebenchjob

// KubebenchJob is the definition of a KubebenchJob resource
type KubebenchJob struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KubebenchJobSpec `json:"spec,omitempty"`
Status KubebenchJobStatus `json:"status,omitempty"`
}

// KubebenchJobSpec is the specification of a KubebenchJob
type KubebenchJobSpec struct {
ServiceAccountName string `json:"serviceAccountName,omitempty"`
Volumes []corev1.Volume `json:"volumes,omitempty"`
ManagedVolumes ManagedVolumes `json:"managedVolumes,omitempty"`
WorkflowAgent WorkflowAgentSpec `json:"workflowAgent,omitempty"`
Tasks []Task `json:"tasks"`
}

// ManagedVolumes is the volumes managed by the Kubebench workflow
type ManagedVolumes struct {
ExperimentVolume *corev1.Volume `json:"experimentVolume,omitempty"`
WorkflowVolume *corev1.Volume `json:"workflowVolume,omitempty"`
}

// WorkflowAgentSpec is the specification of Kubebench workflow agent
type WorkflowAgentSpec struct {
Container *corev1.Container `json:"container,omitempty"`
}

// Task is a task in a Kubebench workflow
type Task struct {
Name string `json:"name"`
Container *corev1.Container `json:"container,omitempty"`
Resource *ResourceSpec `json:"resource,omitempty"`
Dependencies []string `json:"dependencies,omitempty"`
}

// ResourceSpec is the specification of a resouce-type task in a benchmark workflow
type ResourceSpec struct {
Manifest *string `json:"manifest,omitempty"`
ManifestFrom *ManifestSource `json:"manifestFrom,omitempty"`
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
Options *ResourceOptions `json:"options,omitempty"`
}

// ManifestSource is the source of a k8s manifest
type ManifestSource struct {
Path *string `json:"path,omitempty"`
}

// ResourceOptions is the options of a resource-type task
type ResourceOptions struct {
MountManagedVolumes bool `json:"mountManagedVolumes,omitempty"`
AutoDelete bool `json:"autoDelete,omitempty"`
AutoWatch *AutoWatchSpec `json:"autoWatch,omitempty"`
NumCopies int `json:"numCopies,omitempty"`
}

// AutoWatchSpec is the specification of auto-watch functionality
type AutoWatchSpec struct {
Timeout string `json:"timeout,omitempty"`
}

// KubebenchJobStatus is the observed status of a KubebenchJob
type KubebenchJobStatus struct {
argov1alpha1.WorkflowStatus `json:",inline"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// KubebenchJobList contains a list of KubebenchJob
type KubebenchJobList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KubebenchJob `json:"items"`
}

// KubebenchConfig is the Kubebench configuration
type KubebenchConfig struct {
DefaultWorkflowAgent WorkflowAgentSpec `json:"defaultWorkflowAgent,omitempty"`
DefaultManagedVolumes ManagedVolumes `json:"defaultManagedVolumes,omitempty"`
}
Loading