cassandra: crd types and boilerplate

API types for Cassandra have been added under /pkg/apis/cassandra.rook.io/types.go
Other files are some necessary boilerplate.

Signed-off-by: Yannis Zarkadas <yanniszarkadas@gmail.com>
This commit is contained in:
Yannis Zarkadas committed 2018-12-05 12:41:04 +02:00
1 parent 18b2da5fc5
commit bb64ffafe2
4 files changed
+227

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
/*
Copyright 2018 The Rook Authors. All rights reserved.
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 cassandrarookio
const (
// GroupName for the cassandra operator's CRDs
GroupName = "cassandra.rook.io"
)
@@ -0,0 +1,21 @@
/*
Copyright 2018 The Rook Authors. All rights reserved.
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
// Package v1alpha1 is the v1alpha1 version of the API.
// +groupName=cassandra.rook.io
package v1alpha1
@@ -0,0 +1,61 @@
/*
Copyright 2018 The Rook Authors. All rights reserved.
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 (
"github.com/rook/rook/pkg/apis/cassandra.rook.io"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const (
CustomResourceGroup = "cassandra.rook.io"
Version = "v1alpha1"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: cassandrarookio.GroupName, Version: Version}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
// SchemeBuilder 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,
&Cluster{},
&ClusterList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
@@ -0,0 +1,123 @@
/*
Copyright 2018 The Rook Authors. All rights reserved.
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 (
rook "github.com/rook/rook/pkg/apis/rook.io/v1alpha2"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
APIVersion = CustomResourceGroup + "/" + Version
)
// ***************************************************************************
// IMPORTANT FOR CODE GENERATION
// If the types in this file are updated, you will need to run
// `make codegen` to generate the new types under the client/clientset folder.
// ***************************************************************************
// Kubernetes API Conventions:
// https://github.com/kubernetes/community/blob/af5c40530f50c3b36c13438187b311102093ede5/contributors/devel/api-conventions.md
// Applicable Here:
// * Optional fields use a pointer to correctly handle empty values.
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Cluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec ClusterSpec `json:"spec"`
Status ClusterStatus `json:"status"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ClusterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Cluster `json:"items"`
}
// ClusterSpec is the desired state for a Cassandra Cluster.
type ClusterSpec struct {
// Version of Cassandra to use.
Version string `json:"version"`
// Repository to pull the image from.
Repository *string `json:"repository,omitempty"`
// Mode selects an operating mode.
Mode ClusterMode `json:"mode,omitempty"`
// Datacenter that will make up this cluster.
Datacenter DatacenterSpec `json:"datacenter"`
// User-provided image for the sidecar that replaces default.
SidecarImage *ImageSpec `json:"sidecarImage,omitempty"`
}
type ClusterMode string
const (
ClusterModeCassandra ClusterMode = "cassandra"
ClusterModeScylla ClusterMode = "scylla"
)
// DatacenterSpec is the desired state for a Cassandra Datacenter.
type DatacenterSpec struct {
// Name of the Cassandra Datacenter. Used in the cassandra-rackdc.properties file.
Name string `json:"name"`
// Racks of the specific Datacenter.
Racks []RackSpec `json:"racks"`
}
// RackSpec is the desired state for a Cassandra Rack.
type RackSpec struct {
// Name of the Cassandra Rack. Used in the cassandra-rackdc.properties file.
Name string `json:"name"`
// Members is the number of Cassandra instances in this rack.
Members int32 `json:"members"`
// User-provided ConfigMap applied to the specific statefulset.
ConfigMapName *string `json:"configMapName,omitempty"`
// Storage describes the underlying storage that Cassandra will consume.
Storage rook.StorageScopeSpec `json:"storage"`
// Placement describes restrictions for the nodes Cassandra is scheduled on.
Placement *rook.Placement `json:"placement,omitempty"`
// Resources the Cassandra Pods will use.
Resources corev1.ResourceRequirements `json:"resources"`
}
// ImageSpec is the desired state for a container image.
type ImageSpec struct {
// Version of the image.
Version string `json:"version"`
// Repository to pull the image from.
Repository string `json:"repository"`
}
// ClusterStatus is the status of a Cassandra Cluster
type ClusterStatus struct {
Racks map[string]*RackStatus `json:"racks,omitempty"`
}
// RackStatus is the status of a Cassandra Rack
type RackStatus struct {
// Members is the current number of members requested in the specific Rack
Members int32 `json:"members"`
// ReadyMembers is the number of ready members in the specific Rack
ReadyMembers int32 `json:"readyMembers"`
}