-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
397 additions
and
1 deletion.
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
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,5 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- sharding.timebertt.dev_clusterrings.yaml |
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,118 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.13.0 | ||
name: clusterrings.sharding.timebertt.dev | ||
spec: | ||
group: sharding.timebertt.dev | ||
names: | ||
kind: ClusterRing | ||
listKind: ClusterRingList | ||
plural: clusterrings | ||
singular: clusterring | ||
scope: Cluster | ||
versions: | ||
- additionalPrinterColumns: | ||
- jsonPath: .status.availableShards | ||
name: Available | ||
type: string | ||
- jsonPath: .status.shards | ||
name: Shards | ||
type: string | ||
- jsonPath: .metadata.creationTimestamp | ||
name: Age | ||
type: date | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: 'ClusterRing declares a virtual ring of sharded controller instances. | ||
TODO(timebertt): implement validation for ClusterRings.' | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation | ||
of an object. Servers should convert recognized schemas to the latest | ||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this | ||
object represents. Servers may infer this from the endpoint the client | ||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: Spec contains the specification of the desired behavior of | ||
the ClusterRing. | ||
properties: | ||
kinds: | ||
description: Kinds specifies the list of object kinds that are distributed | ||
across shards in this ClusterRing. | ||
items: | ||
description: ClusterRingKind specifies an object kind that is distributed | ||
across shards in the ClusterRing. This kind is the controller's | ||
main kind, i.e., the kind of which it updates the object status. | ||
properties: | ||
apiGroup: | ||
description: APIGroup is the API group of the object. Specify | ||
"" for the core API group. | ||
type: string | ||
controlledKinds: | ||
description: ControlledKinds are additional object kinds that | ||
are distributed across shards in the ClusterRing. These kinds | ||
are controlled by the controller's main kind, i.e., they have | ||
an owner reference with controller=true back to the object | ||
kind of this ClusterRingKind. Typically, the controller also | ||
watches objects of this kind and enqueues the owning object | ||
(of the main kind) whenever the status of a controlled object | ||
changes. | ||
items: | ||
description: ObjectKind specifies an object kind that is distributed | ||
across shards in the ClusterRing. | ||
properties: | ||
apiGroup: | ||
description: APIGroup is the API group of the object. | ||
Specify "" for the core API group. | ||
type: string | ||
kind: | ||
description: Kind is the kind of the object. | ||
type: string | ||
required: | ||
- kind | ||
type: object | ||
type: array | ||
kind: | ||
description: Kind is the kind of the object. | ||
type: string | ||
required: | ||
- kind | ||
type: object | ||
type: array | ||
type: object | ||
status: | ||
description: Status contains the most recently observed status of the | ||
ClusterRing. | ||
properties: | ||
availableShards: | ||
description: AvailableShards is the total number of available shards | ||
of this ring. | ||
format: int32 | ||
type: integer | ||
observedGeneration: | ||
description: The generation observed by the ClusterRing controller. | ||
format: int64 | ||
type: integer | ||
shards: | ||
description: Shards is the total number of shards of this ring. | ||
format: int32 | ||
type: integer | ||
required: | ||
- availableShards | ||
- shards | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
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
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
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,95 @@ | ||
/* | ||
Copyright 2023 Tim Ebert. | ||
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 ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:resource:scope=Cluster | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:printcolumn:name="Available",type=string,JSONPath=`.status.availableShards` | ||
//+kubebuilder:printcolumn:name="Shards",type=string,JSONPath=`.status.shards` | ||
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" | ||
|
||
// ClusterRing declares a virtual ring of sharded controller instances. | ||
// TODO(timebertt): implement validation for ClusterRings. | ||
type ClusterRing struct { | ||
metav1.TypeMeta `json:",inline"` | ||
// Standard object's metadata. | ||
// +optional | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
// Spec contains the specification of the desired behavior of the ClusterRing. | ||
// +optional | ||
Spec ClusterRingSpec `json:"spec,omitempty"` | ||
// Status contains the most recently observed status of the ClusterRing. | ||
// +optional | ||
Status ClusterRingStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// ClusterRingList contains a list of ClusterRings. | ||
type ClusterRingList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
// Standard list metadata. | ||
// +optional | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
// Items is the list of ClusterRings. | ||
Items []ClusterRing `json:"items"` | ||
} | ||
|
||
// ClusterRingSpec defines the desired state of a ClusterRing. | ||
type ClusterRingSpec struct { | ||
// Kinds specifies the list of object kinds that are distributed across shards in this ClusterRing. | ||
// +optional | ||
Kinds []ClusterRingKind `json:"kinds,omitempty"` | ||
} | ||
|
||
// ClusterRingKind specifies an object kind that is distributed across shards in the ClusterRing. | ||
// This kind is the controller's main kind, i.e., the kind of which it updates the object status. | ||
type ClusterRingKind struct { | ||
ObjectKind `json:",inline"` | ||
|
||
// ControlledKinds are additional object kinds that are distributed across shards in the ClusterRing. | ||
// These kinds are controlled by the controller's main kind, i.e., they have an owner reference with controller=true | ||
// back to the object kind of this ClusterRingKind. Typically, the controller also watches objects of this kind and | ||
// enqueues the owning object (of the main kind) whenever the status of a controlled object changes. | ||
// +optional | ||
ControlledKinds []ObjectKind `json:"controlledKinds,omitempty"` | ||
} | ||
|
||
// ObjectKind specifies an object kind that is distributed across shards in the ClusterRing. | ||
type ObjectKind struct { | ||
// APIGroup is the API group of the object. Specify "" for the core API group. | ||
// +optional | ||
APIGroup string `json:"apiGroup,omitempty"` | ||
// Kind is the kind of the object. | ||
Kind string `json:"kind"` | ||
} | ||
|
||
// ClusterRingStatus defines the observed state of a ClusterRing. | ||
type ClusterRingStatus struct { | ||
// The generation observed by the ClusterRing controller. | ||
// +optional | ||
ObservedGeneration int64 `json:"observedGeneration,omitempty"` | ||
// Shards is the total number of shards of this ring. | ||
Shards int32 `json:"shards"` | ||
// AvailableShards is the total number of available shards of this ring. | ||
AvailableShards int32 `json:"availableShards"` | ||
} |
Oops, something went wrong.