2020-07-26 22:10:35 +00:00
/ *
2020-08-02 06:27:46 +00:00
2020-07-26 22:10:35 +00:00
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 .
* /
2020-08-02 06:27:46 +00:00
package v1
2020-07-26 22:10:35 +00:00
import (
2020-10-28 05:06:25 +00:00
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
2020-07-26 22:10:35 +00:00
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2020-10-28 06:57:38 +00:00
// Constants
const (
GRPCPortDelta = 10000
MasterHTTPPort = 9333
VolumeHTTPPort = 8444
FilerHTTPPort = 8888
FilerS3Port = 8333
MasterGRPCPort = MasterHTTPPort + GRPCPortDelta
VolumeGRPCPort = VolumeHTTPPort + GRPCPortDelta
FilerGRPCPort = FilerHTTPPort + GRPCPortDelta
)
2020-08-02 06:27:46 +00:00
// SeaweedSpec defines the desired state of Seaweed
type SeaweedSpec struct {
2020-07-26 22:10:35 +00:00
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
2020-07-26 22:26:27 +00:00
// MetricsAddress is Prometheus gateway address
MetricsAddress string ` json:"metricsAddress,omitempty" `
2020-08-05 05:13:36 +00:00
2020-10-17 09:25:23 +00:00
// Image
Image string ` json:"image,omitempty" `
2020-10-28 05:06:25 +00:00
// Version
Version string ` json:"version,omitempty" `
// Master
Master * MasterSpec ` json:"master,omitempty" `
2020-10-28 06:57:38 +00:00
2020-10-28 05:06:25 +00:00
// Volume
Volume * VolumeSpec ` json:"volume,omitempty" `
2020-10-28 06:57:38 +00:00
2020-10-28 05:06:25 +00:00
// Filer
Filer * FilerSpec ` json:"filer,omitempty" `
2020-10-28 06:57:38 +00:00
// SchedulerName of pods
SchedulerName string ` json:"schedulerName,omitempty" `
// Persistent volume reclaim policy
PVReclaimPolicy * corev1 . PersistentVolumeReclaimPolicy ` json:"pvReclaimPolicy,omitempty" `
// ImagePullPolicy of pods
ImagePullPolicy corev1 . PullPolicy ` json:"imagePullPolicy,omitempty" `
// ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images.
ImagePullSecrets [ ] corev1 . LocalObjectReference ` json:"imagePullSecrets,omitempty" `
// Whether enable PVC reclaim for orphan PVC left by statefulset scale-in
EnablePVReclaim * bool ` json:"enablePVReclaim,omitempty" `
// Whether Hostnetwork is enabled for pods
HostNetwork * bool ` json:"hostNetwork,omitempty" `
// Affinity of pods
Affinity * corev1 . Affinity ` json:"affinity,omitempty" `
// Base node selectors of Pods, components may add or override selectors upon this respectively
NodeSelector map [ string ] string ` json:"nodeSelector,omitempty" `
// Base annotations of Pods, components may add or override selectors upon this respectively
Annotations map [ string ] string ` json:"annotations,omitempty" `
// Base tolerations of Pods, components may add more tolerations upon this respectively
Tolerations [ ] corev1 . Toleration ` json:"tolerations,omitempty" `
// StatefulSetUpdateStrategy indicates the StatefulSetUpdateStrategy that will be
// employed to update Pods in the StatefulSet when a revision is made to
// Template.
StatefulSetUpdateStrategy appsv1 . StatefulSetUpdateStrategyType ` json:"statefulSetUpdateStrategy,omitempty" `
2020-10-28 05:09:01 +00:00
VolumeServerDiskCount int32 ` json:"volumeServerDiskCount,omitempty" `
2020-11-10 08:11:17 +00:00
// Ingresses
HostSuffix * string ` json:"hostSuffix,omitempty" `
2020-07-26 22:10:35 +00:00
}
2020-08-02 06:27:46 +00:00
// SeaweedStatus defines the observed state of Seaweed
type SeaweedStatus struct {
2020-07-26 22:10:35 +00:00
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}
2020-10-28 05:06:25 +00:00
// MasterSpec is the spec for masters
type MasterSpec struct {
ComponentSpec ` json:",inline" `
corev1 . ResourceRequirements ` json:",inline" `
// The desired ready replicas
// +kubebuilder:validation:Minimum=1
2020-10-28 06:57:38 +00:00
Replicas int32 ` json:"replicas" `
Service * ServiceSpec ` json:"service,omitempty" `
2020-10-28 11:19:17 +00:00
// Config in raw toml string
Config * string ` json:"config,omitempty" `
2020-10-30 06:42:00 +00:00
// Master-specific settings
2020-10-30 07:09:39 +00:00
2020-10-30 03:09:04 +00:00
VolumePreallocate * bool ` json:"volumePreallocate,omitempty" `
VolumeSizeLimitMB * int32 ` json:"volumeSizeLimitMB,omitempty" `
GarbageThreshold * string ` json:"garbageThreshold,omitempty" `
PulseSeconds * int32 ` json:"pulseSeconds,omitempty" `
DefaultReplication * string ` json:"defaultReplication,omitempty" `
2020-11-09 07:02:09 +00:00
// only for testing
ConcurrentStart * bool ` json:"concurrentStart,omitempty" `
2020-10-28 05:06:25 +00:00
}
// VolumeSpec is the spec for volume servers
type VolumeSpec struct {
ComponentSpec ` json:",inline" `
corev1 . ResourceRequirements ` json:",inline" `
// The desired ready replicas
// +kubebuilder:validation:Minimum=1
2020-10-28 06:57:38 +00:00
Replicas int32 ` json:"replicas" `
Service * ServiceSpec ` json:"service,omitempty" `
2020-10-30 06:42:00 +00:00
StorageClassName * string ` json:"storageClassName,omitempty" `
// Volume-specific settings
CompactionMBps * int32 ` json:"compactionMBps,omitempty" `
FileSizeLimitMB * int32 ` json:"fileSizeLimitMB,omitempty" `
FixJpgOrientation * bool ` json:"fixJpgOrientation,omitempty" `
IdleTimeout * int32 ` json:"idleTimeout,omitempty" `
MaxVolumeCounts * int32 ` json:"maxVolumeCounts,omitempty" `
MinFreeSpacePercent * int32 ` json:"minFreeSpacePercent,omitempty" `
2020-10-28 05:06:25 +00:00
}
// FilerSpec is the spec for filers
type FilerSpec struct {
ComponentSpec ` json:",inline" `
corev1 . ResourceRequirements ` json:",inline" `
// The desired ready replicas
2020-10-28 05:09:01 +00:00
// +kubebuilder:validation:Minimum=1
2020-10-28 06:57:38 +00:00
Replicas int32 ` json:"replicas" `
Service * ServiceSpec ` json:"service,omitempty" `
2020-10-30 06:42:00 +00:00
2020-10-28 11:19:17 +00:00
// Config in raw toml string
Config * string ` json:"config,omitempty" `
2020-10-30 06:42:00 +00:00
// Filer-specific settings
MaxMB * int32 ` json:"maxMB,omitempty" `
2020-10-28 05:06:25 +00:00
}
// ComponentSpec is the base spec of each component, the fields should always accessed by the Basic<Component>Spec() method to respect the cluster-level properties
type ComponentSpec struct {
// Version of the component. Override the cluster-level version if non-empty
Version * string ` json:"version,omitempty" `
// ImagePullPolicy of the component. Override the cluster-level imagePullPolicy if present
ImagePullPolicy * corev1 . PullPolicy ` json:"imagePullPolicy,omitempty" `
// ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images.
ImagePullSecrets [ ] corev1 . LocalObjectReference ` json:"imagePullSecrets,omitempty" `
// Whether Hostnetwork of the component is enabled. Override the cluster-level setting if present
HostNetwork * bool ` json:"hostNetwork,omitempty" `
// Affinity of the component. Override the cluster-level one if present
Affinity * corev1 . Affinity ` json:"affinity,omitempty" `
// PriorityClassName of the component. Override the cluster-level one if present
PriorityClassName * string ` json:"priorityClassName,omitempty" `
// SchedulerName of the component. Override the cluster-level one if present
SchedulerName * string ` json:"schedulerName,omitempty" `
// NodeSelector of the component. Merged into the cluster-level nodeSelector if non-empty
NodeSelector map [ string ] string ` json:"nodeSelector,omitempty" `
// Annotations of the component. Merged into the cluster-level annotations if non-empty
Annotations map [ string ] string ` json:"annotations,omitempty" `
// Tolerations of the component. Override the cluster-level tolerations if non-empty
Tolerations [ ] corev1 . Toleration ` json:"tolerations,omitempty" `
// List of environment variables to set in the container, like
// v1.Container.Env.
2020-10-28 06:57:38 +00:00
// Note that following env names cannot be used and may be overrided by operators
2020-10-28 05:06:25 +00:00
// - NAMESPACE
2020-10-28 06:57:38 +00:00
// - POD_IP
2020-10-28 05:06:25 +00:00
// - POD_NAME
Env [ ] corev1 . EnvVar ` json:"env,omitempty" `
// Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request.
// Value must be non-negative integer. The value zero indicates delete immediately.
// If this value is nil, the default grace period will be used instead.
// The grace period is the duration in seconds after the processes running in the pod are sent
// a termination signal and the time when the processes are forcibly halted with a kill signal.
// Set this value longer than the expected cleanup time for your process.
// Defaults to 30 seconds.
TerminationGracePeriodSeconds * int64 ` json:"terminationGracePeriodSeconds,omitempty" `
// StatefulSetUpdateStrategy indicates the StatefulSetUpdateStrategy that will be
// employed to update Pods in the StatefulSet when a revision is made to
// Template.
StatefulSetUpdateStrategy appsv1 . StatefulSetUpdateStrategyType ` json:"statefulSetUpdateStrategy,omitempty" `
}
2020-10-29 11:56:59 +00:00
// ServiceSpec is a subset of the original k8s spec
2020-10-28 06:57:38 +00:00
type ServiceSpec struct {
// Type of the real kubernetes service
Type corev1 . ServiceType ` json:"type,omitempty" `
// Additional annotations of the kubernetes service object
Annotations map [ string ] string ` json:"annotations,omitempty" `
// LoadBalancerIP is the loadBalancerIP of service
LoadBalancerIP * string ` json:"loadBalancerIP,omitempty" `
// ClusterIP is the clusterIP of service
ClusterIP * string ` json:"clusterIP,omitempty" `
}
2020-07-26 22:10:35 +00:00
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
2020-08-02 06:27:46 +00:00
// Seaweed is the Schema for the seaweeds API
type Seaweed struct {
2020-07-26 22:10:35 +00:00
metav1 . TypeMeta ` json:",inline" `
metav1 . ObjectMeta ` json:"metadata,omitempty" `
2020-08-02 06:27:46 +00:00
Spec SeaweedSpec ` json:"spec,omitempty" `
Status SeaweedStatus ` json:"status,omitempty" `
2020-07-26 22:10:35 +00:00
}
// +kubebuilder:object:root=true
2020-08-02 06:27:46 +00:00
// SeaweedList contains a list of Seaweed
type SeaweedList struct {
2020-07-26 22:10:35 +00:00
metav1 . TypeMeta ` json:",inline" `
metav1 . ListMeta ` json:"metadata,omitempty" `
2020-08-02 06:27:46 +00:00
Items [ ] Seaweed ` json:"items" `
2020-07-26 22:10:35 +00:00
}
func init ( ) {
2020-08-02 06:27:46 +00:00
SchemeBuilder . Register ( & Seaweed { } , & SeaweedList { } )
2020-07-26 22:10:35 +00:00
}