Merge pull request #1886 from RainbowMango/pr_add_backendstore

Adds BackendStore to SearchRegistry API
This commit is contained in:
karmada-bot 2022-05-26 10:41:44 +08:00 committed by GitHub
commit c8e1b78ea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 290 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package search
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
)
@ -32,6 +33,10 @@ type ResourceRegistrySpec struct {
// ResourceSelectors specifies the resources type that should be cached by cache system.
// +required
ResourceSelectors []ResourceSelector `json:"resourceSelectors"`
// BackendStore specifies the location where to store the cached items.
// +optional
BackendStore *BackendStoreConfig `json:"backendStore,omitempty"`
}
// ResourceSelector specifies the resources type and its scope.
@ -50,6 +55,32 @@ type ResourceSelector struct {
Namespace string
}
// BackendStoreConfig specifies backend store.
type BackendStoreConfig struct {
// OpenSearch is a community-driven, open source search and analytics suite.
// Refer to website(https://opensearch.org/) for more details about OpenSearch.
// +optional
OpenSearch *OpenSearchConfig `json:"openSearch,omitempty"`
}
// OpenSearchConfig holds the necessary configuration for client to access and config an OpenSearch server.
type OpenSearchConfig struct {
// Addresses is a list of node endpoint(e.g. 'https://localhost:9200') to use.
// For the 'node' concept, please refer to:
// https://opensearch.org/docs/latest/opensearch/index/#clusters-and-nodes
// +required
Addresses []string `json:"addresses"`
// SecretRef represents the secret contains mandatory credentials to access the server.
// The secret should hold credentials as follows:
// - secret.data.userName
// - secret.data.password
// +required
SecretRef clusterv1alpha1.LocalSecretReference `json:"secretRef,omitempty"`
// More configurations such as transport, index should be added from here.
}
// ResourceRegistryStatus defines the observed state of ResourceRegistry
type ResourceRegistryStatus struct {
// Conditions contain the different condition statuses.

View File

@ -3,6 +3,7 @@ package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
)
@ -44,6 +45,10 @@ type ResourceRegistrySpec struct {
// ResourceSelectors specifies the resources type that should be cached by cache system.
// +required
ResourceSelectors []ResourceSelector `json:"resourceSelectors"`
// BackendStore specifies the location where to store the cached items.
// +optional
BackendStore *BackendStoreConfig `json:"backendStore,omitempty"`
}
// ResourceSelector specifies the resources type and its scope.
@ -62,6 +67,32 @@ type ResourceSelector struct {
Namespace string `json:"namespace,omitempty"`
}
// BackendStoreConfig specifies backend store.
type BackendStoreConfig struct {
// OpenSearch is a community-driven, open source search and analytics suite.
// Refer to website(https://opensearch.org/) for more details about OpenSearch.
// +optional
OpenSearch *OpenSearchConfig `json:"openSearch,omitempty"`
}
// OpenSearchConfig holds the necessary configuration for client to access and config an OpenSearch server.
type OpenSearchConfig struct {
// Addresses is a list of node endpoint(e.g. 'https://localhost:9200') to use.
// For the 'node' concept, please refer to:
// https://opensearch.org/docs/latest/opensearch/index/#clusters-and-nodes
// +required
Addresses []string `json:"addresses"`
// SecretRef represents the secret contains mandatory credentials to access the server.
// The secret should hold credentials as follows:
// - secret.data.userName
// - secret.data.password
// +required
SecretRef clusterv1alpha1.LocalSecretReference `json:"secretRef,omitempty"`
// More configurations such as transport, index should be added from here.
}
// ResourceRegistryStatus defines the observed state of ResourceRegistry
type ResourceRegistryStatus struct {
// Conditions contain the different condition statuses.

View File

@ -21,6 +21,26 @@ func init() {
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(s *runtime.Scheme) error {
if err := s.AddGeneratedConversionFunc((*BackendStoreConfig)(nil), (*search.BackendStoreConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_BackendStoreConfig_To_search_BackendStoreConfig(a.(*BackendStoreConfig), b.(*search.BackendStoreConfig), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*search.BackendStoreConfig)(nil), (*BackendStoreConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_search_BackendStoreConfig_To_v1alpha1_BackendStoreConfig(a.(*search.BackendStoreConfig), b.(*BackendStoreConfig), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*OpenSearchConfig)(nil), (*search.OpenSearchConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_OpenSearchConfig_To_search_OpenSearchConfig(a.(*OpenSearchConfig), b.(*search.OpenSearchConfig), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*search.OpenSearchConfig)(nil), (*OpenSearchConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_search_OpenSearchConfig_To_v1alpha1_OpenSearchConfig(a.(*search.OpenSearchConfig), b.(*OpenSearchConfig), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*ResourceRegistry)(nil), (*search.ResourceRegistry)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_ResourceRegistry_To_search_ResourceRegistry(a.(*ResourceRegistry), b.(*search.ResourceRegistry), scope)
}); err != nil {
@ -84,6 +104,48 @@ func RegisterConversions(s *runtime.Scheme) error {
return nil
}
func autoConvert_v1alpha1_BackendStoreConfig_To_search_BackendStoreConfig(in *BackendStoreConfig, out *search.BackendStoreConfig, s conversion.Scope) error {
out.OpenSearch = (*search.OpenSearchConfig)(unsafe.Pointer(in.OpenSearch))
return nil
}
// Convert_v1alpha1_BackendStoreConfig_To_search_BackendStoreConfig is an autogenerated conversion function.
func Convert_v1alpha1_BackendStoreConfig_To_search_BackendStoreConfig(in *BackendStoreConfig, out *search.BackendStoreConfig, s conversion.Scope) error {
return autoConvert_v1alpha1_BackendStoreConfig_To_search_BackendStoreConfig(in, out, s)
}
func autoConvert_search_BackendStoreConfig_To_v1alpha1_BackendStoreConfig(in *search.BackendStoreConfig, out *BackendStoreConfig, s conversion.Scope) error {
out.OpenSearch = (*OpenSearchConfig)(unsafe.Pointer(in.OpenSearch))
return nil
}
// Convert_search_BackendStoreConfig_To_v1alpha1_BackendStoreConfig is an autogenerated conversion function.
func Convert_search_BackendStoreConfig_To_v1alpha1_BackendStoreConfig(in *search.BackendStoreConfig, out *BackendStoreConfig, s conversion.Scope) error {
return autoConvert_search_BackendStoreConfig_To_v1alpha1_BackendStoreConfig(in, out, s)
}
func autoConvert_v1alpha1_OpenSearchConfig_To_search_OpenSearchConfig(in *OpenSearchConfig, out *search.OpenSearchConfig, s conversion.Scope) error {
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
out.SecretRef = in.SecretRef
return nil
}
// Convert_v1alpha1_OpenSearchConfig_To_search_OpenSearchConfig is an autogenerated conversion function.
func Convert_v1alpha1_OpenSearchConfig_To_search_OpenSearchConfig(in *OpenSearchConfig, out *search.OpenSearchConfig, s conversion.Scope) error {
return autoConvert_v1alpha1_OpenSearchConfig_To_search_OpenSearchConfig(in, out, s)
}
func autoConvert_search_OpenSearchConfig_To_v1alpha1_OpenSearchConfig(in *search.OpenSearchConfig, out *OpenSearchConfig, s conversion.Scope) error {
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
out.SecretRef = in.SecretRef
return nil
}
// Convert_search_OpenSearchConfig_To_v1alpha1_OpenSearchConfig is an autogenerated conversion function.
func Convert_search_OpenSearchConfig_To_v1alpha1_OpenSearchConfig(in *search.OpenSearchConfig, out *OpenSearchConfig, s conversion.Scope) error {
return autoConvert_search_OpenSearchConfig_To_v1alpha1_OpenSearchConfig(in, out, s)
}
func autoConvert_v1alpha1_ResourceRegistry_To_search_ResourceRegistry(in *ResourceRegistry, out *search.ResourceRegistry, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1alpha1_ResourceRegistrySpec_To_search_ResourceRegistrySpec(&in.Spec, &out.Spec, s); err != nil {
@ -141,6 +203,7 @@ func Convert_search_ResourceRegistryList_To_v1alpha1_ResourceRegistryList(in *se
func autoConvert_v1alpha1_ResourceRegistrySpec_To_search_ResourceRegistrySpec(in *ResourceRegistrySpec, out *search.ResourceRegistrySpec, s conversion.Scope) error {
out.TargetCluster = in.TargetCluster
out.ResourceSelectors = *(*[]search.ResourceSelector)(unsafe.Pointer(&in.ResourceSelectors))
out.BackendStore = (*search.BackendStoreConfig)(unsafe.Pointer(in.BackendStore))
return nil
}
@ -152,6 +215,7 @@ func Convert_v1alpha1_ResourceRegistrySpec_To_search_ResourceRegistrySpec(in *Re
func autoConvert_search_ResourceRegistrySpec_To_v1alpha1_ResourceRegistrySpec(in *search.ResourceRegistrySpec, out *ResourceRegistrySpec, s conversion.Scope) error {
out.TargetCluster = in.TargetCluster
out.ResourceSelectors = *(*[]ResourceSelector)(unsafe.Pointer(&in.ResourceSelectors))
out.BackendStore = (*BackendStoreConfig)(unsafe.Pointer(in.BackendStore))
return nil
}

View File

@ -10,6 +10,49 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BackendStoreConfig) DeepCopyInto(out *BackendStoreConfig) {
*out = *in
if in.OpenSearch != nil {
in, out := &in.OpenSearch, &out.OpenSearch
*out = new(OpenSearchConfig)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendStoreConfig.
func (in *BackendStoreConfig) DeepCopy() *BackendStoreConfig {
if in == nil {
return nil
}
out := new(BackendStoreConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *OpenSearchConfig) DeepCopyInto(out *OpenSearchConfig) {
*out = *in
if in.Addresses != nil {
in, out := &in.Addresses, &out.Addresses
*out = make([]string, len(*in))
copy(*out, *in)
}
out.SecretRef = in.SecretRef
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenSearchConfig.
func (in *OpenSearchConfig) DeepCopy() *OpenSearchConfig {
if in == nil {
return nil
}
out := new(OpenSearchConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceRegistry) DeepCopyInto(out *ResourceRegistry) {
*out = *in
@ -80,6 +123,11 @@ func (in *ResourceRegistrySpec) DeepCopyInto(out *ResourceRegistrySpec) {
*out = make([]ResourceSelector, len(*in))
copy(*out, *in)
}
if in.BackendStore != nil {
in, out := &in.BackendStore, &out.BackendStore
*out = new(BackendStoreConfig)
(*in).DeepCopyInto(*out)
}
return
}

View File

@ -10,6 +10,49 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BackendStoreConfig) DeepCopyInto(out *BackendStoreConfig) {
*out = *in
if in.OpenSearch != nil {
in, out := &in.OpenSearch, &out.OpenSearch
*out = new(OpenSearchConfig)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendStoreConfig.
func (in *BackendStoreConfig) DeepCopy() *BackendStoreConfig {
if in == nil {
return nil
}
out := new(BackendStoreConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *OpenSearchConfig) DeepCopyInto(out *OpenSearchConfig) {
*out = *in
if in.Addresses != nil {
in, out := &in.Addresses, &out.Addresses
*out = make([]string, len(*in))
copy(*out, *in)
}
out.SecretRef = in.SecretRef
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenSearchConfig.
func (in *OpenSearchConfig) DeepCopy() *OpenSearchConfig {
if in == nil {
return nil
}
out := new(OpenSearchConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceRegistry) DeepCopyInto(out *ResourceRegistry) {
*out = *in
@ -80,6 +123,11 @@ func (in *ResourceRegistrySpec) DeepCopyInto(out *ResourceRegistrySpec) {
*out = make([]ResourceSelector, len(*in))
copy(*out, *in)
}
if in.BackendStore != nil {
in, out := &in.BackendStore, &out.BackendStore
*out = new(BackendStoreConfig)
(*in).DeepCopyInto(*out)
}
return
}

View File

@ -69,6 +69,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.SpreadConstraint": schema_pkg_apis_policy_v1alpha1_SpreadConstraint(ref),
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.StaticClusterAssignment": schema_pkg_apis_policy_v1alpha1_StaticClusterAssignment(ref),
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.StaticClusterWeight": schema_pkg_apis_policy_v1alpha1_StaticClusterWeight(ref),
"github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.BackendStoreConfig": schema_pkg_apis_search_v1alpha1_BackendStoreConfig(ref),
"github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.OpenSearchConfig": schema_pkg_apis_search_v1alpha1_OpenSearchConfig(ref),
"github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.ResourceRegistry": schema_pkg_apis_search_v1alpha1_ResourceRegistry(ref),
"github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.ResourceRegistryList": schema_pkg_apis_search_v1alpha1_ResourceRegistryList(ref),
"github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.ResourceRegistrySpec": schema_pkg_apis_search_v1alpha1_ResourceRegistrySpec(ref),
@ -2977,6 +2979,65 @@ func schema_pkg_apis_policy_v1alpha1_StaticClusterWeight(ref common.ReferenceCal
}
}
func schema_pkg_apis_search_v1alpha1_BackendStoreConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "BackendStoreConfig specifies backend store.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"openSearch": {
SchemaProps: spec.SchemaProps{
Description: "OpenSearch is a community-driven, open source search and analytics suite. Refer to website(https://opensearch.org/) for more details about OpenSearch.",
Ref: ref("github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.OpenSearchConfig"),
},
},
},
},
},
Dependencies: []string{
"github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.OpenSearchConfig"},
}
}
func schema_pkg_apis_search_v1alpha1_OpenSearchConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "OpenSearchConfig holds the necessary configuration for client to access and config an OpenSearch server.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"addresses": {
SchemaProps: spec.SchemaProps{
Description: "Addresses is a list of node endpoint(e.g. 'https://localhost:9200') to use. For the 'node' concept, please refer to: https://opensearch.org/docs/latest/opensearch/index/#clusters-and-nodes",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
"secretRef": {
SchemaProps: spec.SchemaProps{
Description: "SecretRef represents the secret contains mandatory credentials to access the server. The secret should hold credentials as follows: - secret.data.userName - secret.data.password",
Default: map[string]interface{}{},
Ref: ref("github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.LocalSecretReference"),
},
},
},
Required: []string{"addresses"},
},
},
Dependencies: []string{
"github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.LocalSecretReference"},
}
}
func schema_pkg_apis_search_v1alpha1_ResourceRegistry(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@ -3104,12 +3165,18 @@ func schema_pkg_apis_search_v1alpha1_ResourceRegistrySpec(ref common.ReferenceCa
},
},
},
"backendStore": {
SchemaProps: spec.SchemaProps{
Description: "BackendStore specifies the location where to store the cached items.",
Ref: ref("github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.BackendStoreConfig"),
},
},
},
Required: []string{"targetCluster", "resourceSelectors"},
},
},
Dependencies: []string{
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinity", "github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.ResourceSelector"},
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinity", "github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.BackendStoreConfig", "github.com/karmada-io/karmada/pkg/apis/search/v1alpha1.ResourceSelector"},
}
}