Skip to content

Commit

Permalink
PVCViewers Controller: CRD
Browse files Browse the repository at this point in the history
The Spec will contain only one field for specifying which PVC to edit
its contents.

The Status will have two fields. `Conditions` which will mirror the
PodConditions of the underlying Pod and `Ready` which is a boolean that
will be true only if the Pod is has conditions Ready and
ContainersReady.

Signed-off-by: Kimonas Sotirchos <[email protected]>
Reviewed-by: Yannis Zarkadas <[email protected]>
Github-PR: kubeflow#34
  • Loading branch information
kimwnasptd committed Sep 2, 2021
1 parent dfba8ac commit 8380fbf
Show file tree
Hide file tree
Showing 3 changed files with 255 additions and 0 deletions.
35 changes: 35 additions & 0 deletions components/pvcviewer-controller/api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
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 v1alpha1 contains API Schema definitions for the volumes v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=kubeflow.org
package v1alpha1

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: "kubeflow.org", Version: "v1alpha1"}

// 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
)
77 changes: 77 additions & 0 deletions components/pvcviewer-controller/api/v1alpha1/pvcviewers_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
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 v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// PVCViewerSpec defines the desired state of PVCViewer
type PVCViewerSpec struct {
PVC string `json:"pvc"`
}

type PVCViewerCondition struct {
// Type is the type of the condition.
Type corev1.PodConditionType `json:"type"`

Status corev1.ConditionStatus `json:"status"`

// +optional
LastProbeTime *metav1.Time `json:"lastProbeTime,omitempty"`

// +optional
LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"`

// +optional
Reason string `json:"reason,omitempty"`

// +optional
Message string `json:"message,omitempty"`
}

// PVCViewerStatus defines the observed state of PVCViewer
type PVCViewerStatus struct {
Conditions []PVCViewerCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`

Ready bool `json:"ready"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// PVCViewer is the Schema for the pvcviewer API
type PVCViewer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec PVCViewerSpec `json:"spec,omitempty"`
Status PVCViewerStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&PVCViewer{}, &PVCViewerList{})
}
143 changes: 143 additions & 0 deletions components/pvcviewer-controller/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8380fbf

Please sign in to comment.