generated from cybozu-go/neco-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from cybozu-go/add-imageprefetch-crd
Create a template for the ImagePrefetch CRD
- Loading branch information
Showing
20 changed files
with
772 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
domain: ofen.cybozu.io | ||
domain: cybozu.io | ||
layout: | ||
- go.kubebuilder.io/v4 | ||
projectName: ofen | ||
repo: github.com/cybozu-go/ofen | ||
resources: | ||
- api: | ||
crdVersion: v1 | ||
namespaced: true | ||
controller: true | ||
domain: cybozu.io | ||
group: ofen | ||
kind: ImagePrefetch | ||
path: github.com/cybozu-go/ofen/api/v1 | ||
version: v1 | ||
version: "3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Package v1 contains API Schema definitions for the ofen v1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=ofen.cybozu.io | ||
package v1 | ||
|
||
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: "ofen.cybozu.io", Version: "v1"} | ||
|
||
// 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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package v1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// ImagePrefetchSpec defines the desired state of ImagePrefetch | ||
type ImagePrefetchSpec struct { | ||
// Images is a list of container images that will be pre-downloaded to the target nodes | ||
Images []string `json:"images"` | ||
|
||
// NodeSelector is a map of key-value pairs that specify which nodes should have the images pre-downloaded | ||
// +optional | ||
NodeSelector map[string]string `json:"nodeSelector,omitempty"` | ||
|
||
// Replicas is the number of nodes that should download the specified images | ||
// +optional | ||
Replicas int `json:"replicas,omitempty"` | ||
|
||
// ImagePullSecrets is a list of secret names that contain credentials for authenticating with container registries | ||
// +optional | ||
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` | ||
} | ||
|
||
// ImagePrefetchStatus defines the observed state of ImagePrefetch | ||
type ImagePrefetchStatus struct { | ||
// The generation observed by the controller. | ||
// +optional | ||
ObservedGeneration int64 `json:"observedGeneration,omitempty"` | ||
|
||
// Conditions represent the latest available observations of an object's state | ||
// +listType=map | ||
// +listMapKey=type | ||
// +optional | ||
Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
|
||
// DesiredNodes represents the number of nodes that should have the images pre-downloaded | ||
// +optional | ||
// +kubebuilder:default:=0 | ||
DesiredNodes int `json:"desiredNodes,omitempty"` | ||
|
||
// ImagePulledNodes represents the number of nodes that have successfully pre-downloaded the images | ||
// +optional | ||
// +kubebuilder:default:=0 | ||
ImagePulledNodes int `json:"imagePulledNodes,omitempty"` | ||
|
||
// ImagePullingNodes represents the number of nodes that are currently downloading the images | ||
// +optional | ||
// +kubebuilder:default:=0 | ||
ImagePullingNodes int `json:"imagePullingNodes,omitempty"` | ||
|
||
// ImagePullFailedNodes represents the number of nodes that failed to download the images | ||
// +optional | ||
// +kubebuilder:default:=0 | ||
ImagePullFailedNodes int `json:"imagePullFailedNodes,omitempty"` | ||
} | ||
|
||
const ( | ||
ConditionReady = "Ready" | ||
ConditionProgressing = "Progressing" | ||
ConditionImageDownloadFailed = "ImageDownloadFailed" | ||
) | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// ImagePrefetch is the Schema for the imageprefetches API | ||
type ImagePrefetch struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec ImagePrefetchSpec `json:"spec,omitempty"` | ||
Status ImagePrefetchStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// ImagePrefetchList contains a list of ImagePrefetch | ||
type ImagePrefetchList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []ImagePrefetch `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&ImagePrefetch{}, &ImagePrefetchList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.