From 5a803d5c042da91637667bb386dbc213d8e266a5 Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Wed, 1 Nov 2023 17:38:17 +0100 Subject: [PATCH] Add API package for sharding including constants --- pkg/apis/sharding/doc.go | 19 +++++++++++++ pkg/apis/sharding/v1alpha1/constants.go | 37 +++++++++++++++++++++++++ pkg/apis/sharding/v1alpha1/doc.go | 19 +++++++++++++ pkg/apis/sharding/v1alpha1/register.go | 30 ++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 pkg/apis/sharding/doc.go create mode 100644 pkg/apis/sharding/v1alpha1/constants.go create mode 100644 pkg/apis/sharding/v1alpha1/doc.go create mode 100644 pkg/apis/sharding/v1alpha1/register.go diff --git a/pkg/apis/sharding/doc.go b/pkg/apis/sharding/doc.go new file mode 100644 index 00000000..b6cc46ce --- /dev/null +++ b/pkg/apis/sharding/doc.go @@ -0,0 +1,19 @@ +/* +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. +*/ + +// +groupName=sharding.timebertt.dev + +package sharding // import "github.com/timebertt/kubernetes-controller-sharding/pkg/apis/sharding" diff --git a/pkg/apis/sharding/v1alpha1/constants.go b/pkg/apis/sharding/v1alpha1/constants.go new file mode 100644 index 00000000..42b12d27 --- /dev/null +++ b/pkg/apis/sharding/v1alpha1/constants.go @@ -0,0 +1,37 @@ +/* +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 + +// This file contains API-related constants for the sharding implementation, e.g. well-known annotations and labels. + +const ( + // alphaPrefix is a common prefix for all well-known annotations and labels. + // We use the kubernetes.io domain here for interoperability with other approaches evaluated in the thesis. + // If we want to make the approach implemented in this repository production-ready, this should eventually be changed + // to "alpha.sharding.timebertt.dev". + alphaPrefix = "sharding.alpha.kubernetes.io/" + + // LabelRing is the label on Lease objects that identifies the ring that the shard belongs to. + LabelRing = alphaPrefix + "ring" + // LabelState is the label on Lease objects that reflects the state of a shard for observability purposes. + // This label is maintained by the shardlease controller. + LabelState = alphaPrefix + "state" + + // IdentityShardLeaseController is the identity that the shardlease controller uses to acquire leases of unavailable + // shards. + IdentityShardLeaseController = "shardlease-controller" +) diff --git a/pkg/apis/sharding/v1alpha1/doc.go b/pkg/apis/sharding/v1alpha1/doc.go new file mode 100644 index 00000000..50a54629 --- /dev/null +++ b/pkg/apis/sharding/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +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. +*/ + +// +k8s:defaulter-gen=TypeMeta + +package v1alpha1 // import "github.com/timebertt/kubernetes-controller-sharding/pkg/apis/sharding/v1alpha1" diff --git a/pkg/apis/sharding/v1alpha1/register.go b/pkg/apis/sharding/v1alpha1/register.go new file mode 100644 index 00000000..13fdfbc9 --- /dev/null +++ b/pkg/apis/sharding/v1alpha1/register.go @@ -0,0 +1,30 @@ +/* +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 contains API Schema definitions for the sharding v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=sharding.timebertt.dev +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name used in this package. +const GroupName = "sharding.timebertt.dev" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}