From 27307948994fcaca2915da5e4f70dc4b6acda8f8 Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Wed, 8 May 2024 15:06:47 +0000 Subject: [PATCH 1/2] [Feature] [Analytics] Enable TLS and Service --- .golangci.yaml | 2 + CHANGELOG.md | 1 + docs/api/ArangoMLExtension.V1Alpha1.md | 13 +- docs/api/ArangoMLExtension.V1Beta1.md | 13 +- docs/api/GraphAnalyticsEngine.V1Alpha1.md | 180 +++++++++++++++++- pkg/apis/analytics/v1alpha1/conditions.go | 10 +- pkg/apis/analytics/v1alpha1/gae_spec.go | 10 + .../analytics/v1alpha1/gae_spec_deployment.go | 74 +++++++ .../v1alpha1/gae_spec_deployment_service.go | 58 ++++++ pkg/apis/analytics/v1alpha1/gae_status.go | 8 +- .../v1alpha1/gae_status_arangodb_ref.go | 32 ++++ .../v1alpha1/gae_status_reconciliation.go} | 25 ++- .../v1alpha1/zz_generated.deepcopy.go | 132 ++++++++++++- .../ml/v1alpha1/extension_spec_deployment.go | 5 +- .../extension_spec_deployment_service.go | 3 +- pkg/apis/ml/v1alpha1/extension_status.go | 4 +- pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go | 28 +-- pkg/apis/ml/v1beta1/conditions.go | 26 +-- .../ml/v1beta1/extension_spec_deployment.go | 5 +- .../extension_spec_deployment_service.go | 1 + pkg/apis/ml/v1beta1/extension_status.go | 2 +- pkg/apis/ml/v1beta1/zz_generated.deepcopy.go | 28 +-- .../v1/tls.go} | 8 +- pkg/apis/shared/v1/zz_generated.deepcopy.go | 26 +++ pkg/apis/shared/validate.go | 7 +- ...graphanalyticsengine.schema.generated.yaml | 33 ++++ .../crds/ml-extension.schema.generated.yaml | 3 + pkg/util/k8sutil/util.go | 6 +- 28 files changed, 618 insertions(+), 125 deletions(-) create mode 100644 pkg/apis/analytics/v1alpha1/gae_spec_deployment.go create mode 100644 pkg/apis/analytics/v1alpha1/gae_spec_deployment_service.go create mode 100644 pkg/apis/analytics/v1alpha1/gae_status_arangodb_ref.go rename pkg/apis/{ml/v1alpha1/extension_spec_deployment_tls.go => analytics/v1alpha1/gae_status_reconciliation.go} (55%) rename pkg/apis/{ml/v1beta1/extension_spec_deployment_tls.go => shared/v1/tls.go} (84%) diff --git a/.golangci.yaml b/.golangci.yaml index 65679941c..d93af2179 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -67,6 +67,8 @@ linters-settings: alias: schedulerPodResourcesApiv1alpha1 - pkg: github.com/arangodb/kube-arangodb/pkg/apis/shared alias: shared + - pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/analytics/shared + alias: analyticsShared - pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared alias: mlShared - pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared/test diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dbb4e5dc..4b9860f11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - (Feature) (ML) Release V1Beta1 API - (Maintenance) Update Go to 1.22.3 - (Feature) (Analytics) GAE Integration +- (Feature) (Analytics) Enable TLS and Service ## [1.2.40](https://github.com/arangodb/kube-arangodb/tree/1.2.40) (2024-04-10) - (Feature) Add Core fields to the Scheduler Container Spec diff --git a/docs/api/ArangoMLExtension.V1Alpha1.md b/docs/api/ArangoMLExtension.V1Alpha1.md index f1edff9b2..de7fce438 100644 --- a/docs/api/ArangoMLExtension.V1Alpha1.md +++ b/docs/api/ArangoMLExtension.V1Alpha1.md @@ -98,7 +98,7 @@ Links: ### .spec.deployment.gpu -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment.go#L55) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment.go#L56) GPU defined if GPU Jobs are enabled. @@ -231,7 +231,7 @@ Links: ### .spec.deployment.port -Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment.go#L58) +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment.go#L59) Port defines on which port the container will be listening for connections @@ -262,7 +262,7 @@ Links: ### .spec.deployment.replicas -Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment.go#L39) +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment.go#L40) Replicas defines the number of replicas running specified components. No replicas created if no components are defined. @@ -305,7 +305,7 @@ Links: ### .spec.deployment.service.type -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment_service.go#L37) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment_service.go#L38) Type determines how the Service is exposed @@ -317,6 +317,7 @@ Possible Values: * `"NodePort"` - service will be exposed on one port of every node, in addition to 'ClusterIP' type * `"LoadBalancer"` - service will be exposed via an external load balancer (if the cloud provider supports it), in addition to 'NodePort' type * `"ExternalName"` - service consists of only a reference to an external name that kubedns or equivalent will return as a CNAME record, with no exposing or proxying of any pods involved +* `"None"` - service is not created *** @@ -361,7 +362,7 @@ Links: ### .spec.deployment.tls.altNames -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment_tls.go#L28) +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/tls.go#L28) AltNames define TLS AltNames used when TLS on the ArangoDB is enabled @@ -369,7 +370,7 @@ AltNames define TLS AltNames used when TLS on the ArangoDB is enabled ### .spec.deployment.tls.enabled -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1alpha1/extension_spec_deployment_tls.go#L25) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/tls.go#L25) Enabled define if TLS Should be enabled. If is not set then default is taken from ArangoDeployment settings diff --git a/docs/api/ArangoMLExtension.V1Beta1.md b/docs/api/ArangoMLExtension.V1Beta1.md index 93278a7da..644045321 100644 --- a/docs/api/ArangoMLExtension.V1Beta1.md +++ b/docs/api/ArangoMLExtension.V1Beta1.md @@ -98,7 +98,7 @@ Links: ### .spec.deployment.gpu -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment.go#L55) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment.go#L56) GPU defined if GPU Jobs are enabled. @@ -231,7 +231,7 @@ Links: ### .spec.deployment.port -Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment.go#L58) +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment.go#L59) Port defines on which port the container will be listening for connections @@ -262,7 +262,7 @@ Links: ### .spec.deployment.replicas -Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment.go#L39) +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment.go#L40) Replicas defines the number of replicas running specified components. No replicas created if no components are defined. @@ -305,7 +305,7 @@ Links: ### .spec.deployment.service.type -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment_service.go#L37) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment_service.go#L38) Type determines how the Service is exposed @@ -317,6 +317,7 @@ Possible Values: * `"NodePort"` - service will be exposed on one port of every node, in addition to 'ClusterIP' type * `"LoadBalancer"` - service will be exposed via an external load balancer (if the cloud provider supports it), in addition to 'NodePort' type * `"ExternalName"` - service consists of only a reference to an external name that kubedns or equivalent will return as a CNAME record, with no exposing or proxying of any pods involved +* `"None"` - service is not created *** @@ -361,7 +362,7 @@ Links: ### .spec.deployment.tls.altNames -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment_tls.go#L28) +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/tls.go#L28) AltNames define TLS AltNames used when TLS on the ArangoDB is enabled @@ -369,7 +370,7 @@ AltNames define TLS AltNames used when TLS on the ArangoDB is enabled ### .spec.deployment.tls.enabled -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/ml/v1beta1/extension_spec_deployment_tls.go#L25) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/tls.go#L25) Enabled define if TLS Should be enabled. If is not set then default is taken from ArangoDeployment settings diff --git a/docs/api/GraphAnalyticsEngine.V1Alpha1.md b/docs/api/GraphAnalyticsEngine.V1Alpha1.md index dd79dfcb5..85c82c8c8 100644 --- a/docs/api/GraphAnalyticsEngine.V1Alpha1.md +++ b/docs/api/GraphAnalyticsEngine.V1Alpha1.md @@ -8,6 +8,48 @@ title: GraphAnalyticsEngine V1Alpha1 ## Spec +### .spec.deployment.port + +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_spec_deployment.go#L42) + +Port defines on which port the container will be listening for connections + +*** + +### .spec.deployment.service.type + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_spec_deployment_service.go#L38) + +Type determines how the Service is exposed + +Links: +* [Kubernetes Documentation](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) + +Possible Values: +* `"ClusterIP"` (default) - service will only be accessible inside the cluster, via the cluster IP +* `"NodePort"` - service will be exposed on one port of every node, in addition to 'ClusterIP' type +* `"LoadBalancer"` - service will be exposed via an external load balancer (if the cloud provider supports it), in addition to 'NodePort' type +* `"ExternalName"` - service consists of only a reference to an external name that kubedns or equivalent will return as a CNAME record, with no exposing or proxying of any pods involved +* `"None"` - service is not created + +*** + +### .spec.deployment.tls.altNames + +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/tls.go#L28) + +AltNames define TLS AltNames used when TLS on the ArangoDB is enabled + +*** + +### .spec.deployment.tls.enabled + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/tls.go#L25) + +Enabled define if TLS Should be enabled. If is not set then default is taken from ArangoDeployment settings + +*** + ### .spec.deploymentName Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_spec.go#L30) @@ -16,15 +58,143 @@ DeploymentName define deployment name used in the object. Immutable ## Status +### .status.arangoDB.deployment.checksum + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L61) + +UID keeps the information about object Checksum + +*** + +### .status.arangoDB.deployment.name + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L52) + +Name of the object + +*** + +### .status.arangoDB.deployment.namespace + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L55) + +Namespace of the object. Should default to the namespace of the parent object + +*** + +### .status.arangoDB.deployment.uid + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L58) + +UID keeps the information about object UID + +*** + +### .status.arangoDB.secret.checksum + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L61) + +UID keeps the information about object Checksum + +*** + +### .status.arangoDB.secret.name + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L52) + +Name of the object + +*** + +### .status.arangoDB.secret.namespace + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L55) + +Namespace of the object. Should default to the namespace of the parent object + +*** + +### .status.arangoDB.secret.uid + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L58) + +UID keeps the information about object UID + +*** + +### .status.arangoDB.tls.checksum + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L61) + +UID keeps the information about object Checksum + +*** + +### .status.arangoDB.tls.name + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L52) + +Name of the object + +*** + +### .status.arangoDB.tls.namespace + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L55) + +Namespace of the object. Should default to the namespace of the parent object + +*** + +### .status.arangoDB.tls.uid + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L58) + +UID keeps the information about object UID + +*** + ### .status.conditions -Type: `api.Conditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_status.go#L31) +Type: `api.Conditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_status.go#L30) Conditions specific to the entire extension *** -### .status.deployment.checksum +### .status.reconciliation.service.checksum + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L61) + +UID keeps the information about object Checksum + +*** + +### .status.reconciliation.service.name + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L52) + +Name of the object + +*** + +### .status.reconciliation.service.namespace + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L55) + +Namespace of the object. Should default to the namespace of the parent object + +*** + +### .status.reconciliation.service.uid + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L58) + +UID keeps the information about object UID + +*** + +### .status.reconciliation.statefulSet.checksum Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L61) @@ -32,7 +202,7 @@ UID keeps the information about object Checksum *** -### .status.deployment.name +### .status.reconciliation.statefulSet.name Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L52) @@ -40,7 +210,7 @@ Name of the object *** -### .status.deployment.namespace +### .status.reconciliation.statefulSet.namespace Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L55) @@ -48,7 +218,7 @@ Namespace of the object. Should default to the namespace of the parent object *** -### .status.deployment.uid +### .status.reconciliation.statefulSet.uid Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L58) diff --git a/pkg/apis/analytics/v1alpha1/conditions.go b/pkg/apis/analytics/v1alpha1/conditions.go index 1e7909ab3..8e24ada4e 100644 --- a/pkg/apis/analytics/v1alpha1/conditions.go +++ b/pkg/apis/analytics/v1alpha1/conditions.go @@ -23,8 +23,10 @@ package v1alpha1 import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" const ( - LicenseValidCondition api.ConditionType = "LicenseValid" - DeploymentFoundCondition api.ConditionType = "DeploymentFound" - ReadyCondition api.ConditionType = "Ready" - SpecValidCondition api.ConditionType = "SpecValid" + LicenseValidCondition api.ConditionType = "LicenseValid" + DeploymentFoundCondition api.ConditionType = "DeploymentFound" + ReadyCondition api.ConditionType = "Ready" + SpecValidCondition api.ConditionType = "SpecValid" + StatefulSetReadyCondition api.ConditionType = "StatefulSetReady" + TLSEnabledCondition api.ConditionType = "TLSEnabled" ) diff --git a/pkg/apis/analytics/v1alpha1/gae_spec.go b/pkg/apis/analytics/v1alpha1/gae_spec.go index d550ab5a6..2fd94bc60 100644 --- a/pkg/apis/analytics/v1alpha1/gae_spec.go +++ b/pkg/apis/analytics/v1alpha1/gae_spec.go @@ -28,6 +28,16 @@ import ( type GraphAnalyticsEngineSpec struct { // DeploymentName define deployment name used in the object. Immutable DeploymentName *string `json:"deploymentName,omitempty"` + + // Deployment specifies how the GAE will be deployed into cluster + Deployment *GraphAnalyticsEngineSpecDeployment `json:"deployment,omitempty"` +} + +func (a *GraphAnalyticsEngineSpec) GetDeployment() *GraphAnalyticsEngineSpecDeployment { + if a == nil || a.Deployment == nil { + return nil + } + return a.Deployment } func (g *GraphAnalyticsEngineSpec) Validate() error { diff --git a/pkg/apis/analytics/v1alpha1/gae_spec_deployment.go b/pkg/apis/analytics/v1alpha1/gae_spec_deployment.go new file mode 100644 index 000000000..2ad008485 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/gae_spec_deployment.go @@ -0,0 +1,74 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package v1alpha1 + +import ( + shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" + sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" +) + +const ( + GraphAnalyticsEngineSpecDeploymentApi = "api" + + GraphAnalyticsEngineDeploymentComponentDefaultPort = 8502 +) + +type GraphAnalyticsEngineSpecDeployment struct { + // Service defines how components will be exposed + Service *GraphAnalyticsEngineSpecDeploymentService `json:"service,omitempty"` + + // TLS defined TLS Settings + TLS *sharedApi.TLS `json:"tls,omitempty"` + + // Port defines on which port the container will be listening for connections + Port *int32 `json:"port,omitempty"` +} + +func (g *GraphAnalyticsEngineSpecDeployment) GetPort(def int32) int32 { + if g == nil || g.Port == nil { + return def + } + return *g.Port +} + +func (g *GraphAnalyticsEngineSpecDeployment) GetService() *GraphAnalyticsEngineSpecDeploymentService { + if g == nil { + return nil + } + return g.Service +} + +func (g *GraphAnalyticsEngineSpecDeployment) GetTLS() *sharedApi.TLS { + if g == nil { + return nil + } + return g.TLS +} + +func (g *GraphAnalyticsEngineSpecDeployment) Validate() error { + if g == nil { + return nil + } + + return shared.WithErrors( + shared.PrefixResourceErrors("service", shared.ValidateOptional(g.GetService(), func(s GraphAnalyticsEngineSpecDeploymentService) error { return s.Validate() })), + ) +} diff --git a/pkg/apis/analytics/v1alpha1/gae_spec_deployment_service.go b/pkg/apis/analytics/v1alpha1/gae_spec_deployment_service.go new file mode 100644 index 000000000..9dafd70b5 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/gae_spec_deployment_service.go @@ -0,0 +1,58 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package v1alpha1 + +import ( + core "k8s.io/api/core/v1" + + shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" +) + +type GraphAnalyticsEngineSpecDeploymentService struct { + // Type determines how the Service is exposed + // +doc/enum: ClusterIP|service will only be accessible inside the cluster, via the cluster IP + // +doc/enum: NodePort|service will be exposed on one port of every node, in addition to 'ClusterIP' type + // +doc/enum: LoadBalancer|service will be exposed via an external load balancer (if the cloud provider supports it), in addition to 'NodePort' type + // +doc/enum: ExternalName|service consists of only a reference to an external name that kubedns or equivalent will return as a CNAME record, with no exposing or proxying of any pods involved + // +doc/enum: None|service is not created + // +doc/default: ClusterIP + // +doc/link: Kubernetes Documentation|https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + Type *core.ServiceType `json:"type,omitempty"` +} + +func (g *GraphAnalyticsEngineSpecDeploymentService) GetType() core.ServiceType { + if g == nil || g.Type == nil { + return core.ServiceTypeClusterIP + } + + return *g.Type +} + +func (g *GraphAnalyticsEngineSpecDeploymentService) Validate() error { + if g == nil { + return nil + } + + errs := []error{ + shared.PrefixResourceErrors("type", shared.ValidateServiceType(g.GetType())), + } + return shared.WithErrors(errs...) +} diff --git a/pkg/apis/analytics/v1alpha1/gae_status.go b/pkg/apis/analytics/v1alpha1/gae_status.go index b4d7090c3..0133f014d 100644 --- a/pkg/apis/analytics/v1alpha1/gae_status.go +++ b/pkg/apis/analytics/v1alpha1/gae_status.go @@ -22,7 +22,6 @@ package v1alpha1 import ( api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" - sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" ) type GraphAnalyticsEngineStatus struct { @@ -30,6 +29,9 @@ type GraphAnalyticsEngineStatus struct { // +doc/type: api.Conditions Conditions api.ConditionList `json:"conditions,omitempty"` - // Deployment keeps the ArangoDeployment reference - Deployment *sharedApi.Object `json:"deployment,omitempty"` + // ArangoDB keeps the information about local arangodb reference + ArangoDB *GraphAnalyticsEngineStatusArangoDBRef `json:"arangoDB,omitempty"` + + // Reconciliation keeps the information about reconciliation process. For internal use. + Reconciliation *GraphAnalyticsEngineStatusReconciliation `json:"reconciliation,omitempty"` } diff --git a/pkg/apis/analytics/v1alpha1/gae_status_arangodb_ref.go b/pkg/apis/analytics/v1alpha1/gae_status_arangodb_ref.go new file mode 100644 index 000000000..6ff7bfdb2 --- /dev/null +++ b/pkg/apis/analytics/v1alpha1/gae_status_arangodb_ref.go @@ -0,0 +1,32 @@ +// +// DISCLAIMER +// +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package v1alpha1 + +import sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" + +type GraphAnalyticsEngineStatusArangoDBRef struct { + // Secret keeps the information about ArangoDB deployment + Secret *sharedApi.Object `json:"secret,omitempty"` + // TLS keeps information about TLS Secret rendered from ArangoDB deployment + TLS *sharedApi.Object `json:"tls,omitempty"` + // Deployment keeps the ArangoDeployment reference + Deployment *sharedApi.Object `json:"deployment,omitempty"` +} diff --git a/pkg/apis/ml/v1alpha1/extension_spec_deployment_tls.go b/pkg/apis/analytics/v1alpha1/gae_status_reconciliation.go similarity index 55% rename from pkg/apis/ml/v1alpha1/extension_spec_deployment_tls.go rename to pkg/apis/analytics/v1alpha1/gae_status_reconciliation.go index 50b9ede3c..9c19122d5 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_deployment_tls.go +++ b/pkg/apis/analytics/v1alpha1/gae_status_reconciliation.go @@ -20,26 +20,23 @@ package v1alpha1 -type ArangoMLExtensionSpecDeploymentTLS struct { - // Enabled define if TLS Should be enabled. If is not set then default is taken from ArangoDeployment settings - Enabled *bool `json:"enabled,omitempty"` +import sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" - // AltNames define TLS AltNames used when TLS on the ArangoDB is enabled - AltNames []string `json:"altNames,omitempty"` +type GraphAnalyticsEngineStatusReconciliation struct { + StatefulSet *sharedApi.Object `json:"statefulSet,omitempty"` + Service *sharedApi.Object `json:"service,omitempty"` } -func (a *ArangoMLExtensionSpecDeploymentTLS) IsEnabled() bool { - if a == nil || a.Enabled == nil { - return true +func (g *GraphAnalyticsEngineStatusReconciliation) GetStatefulSet() *sharedApi.Object { + if g == nil { + return nil } - - return *a.Enabled + return g.StatefulSet } -func (a *ArangoMLExtensionSpecDeploymentTLS) GetAltNames() []string { - if a == nil || a.AltNames == nil { +func (g *GraphAnalyticsEngineStatusReconciliation) GetService() *sharedApi.Object { + if g == nil { return nil } - - return a.AltNames + return g.Service } diff --git a/pkg/apis/analytics/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/analytics/v1alpha1/zz_generated.deepcopy.go index 4cb2181a9..f4134de44 100644 --- a/pkg/apis/analytics/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/analytics/v1alpha1/zz_generated.deepcopy.go @@ -26,8 +26,9 @@ package v1alpha1 import ( - v1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" - sharedv1 "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" + deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + v1 "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" + corev1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -100,6 +101,11 @@ func (in *GraphAnalyticsEngineSpec) DeepCopyInto(out *GraphAnalyticsEngineSpec) *out = new(string) **out = **in } + if in.Deployment != nil { + in, out := &in.Deployment, &out.Deployment + *out = new(GraphAnalyticsEngineSpecDeployment) + (*in).DeepCopyInto(*out) + } return } @@ -113,19 +119,76 @@ func (in *GraphAnalyticsEngineSpec) DeepCopy() *GraphAnalyticsEngineSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GraphAnalyticsEngineSpecDeployment) DeepCopyInto(out *GraphAnalyticsEngineSpecDeployment) { + *out = *in + if in.Service != nil { + in, out := &in.Service, &out.Service + *out = new(GraphAnalyticsEngineSpecDeploymentService) + (*in).DeepCopyInto(*out) + } + if in.TLS != nil { + in, out := &in.TLS, &out.TLS + *out = new(v1.TLS) + (*in).DeepCopyInto(*out) + } + if in.Port != nil { + in, out := &in.Port, &out.Port + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphAnalyticsEngineSpecDeployment. +func (in *GraphAnalyticsEngineSpecDeployment) DeepCopy() *GraphAnalyticsEngineSpecDeployment { + if in == nil { + return nil + } + out := new(GraphAnalyticsEngineSpecDeployment) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GraphAnalyticsEngineSpecDeploymentService) DeepCopyInto(out *GraphAnalyticsEngineSpecDeploymentService) { + *out = *in + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(corev1.ServiceType) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphAnalyticsEngineSpecDeploymentService. +func (in *GraphAnalyticsEngineSpecDeploymentService) DeepCopy() *GraphAnalyticsEngineSpecDeploymentService { + if in == nil { + return nil + } + out := new(GraphAnalyticsEngineSpecDeploymentService) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GraphAnalyticsEngineStatus) DeepCopyInto(out *GraphAnalyticsEngineStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make(v1.ConditionList, len(*in)) + *out = make(deploymentv1.ConditionList, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.Deployment != nil { - in, out := &in.Deployment, &out.Deployment - *out = new(sharedv1.Object) + if in.ArangoDB != nil { + in, out := &in.ArangoDB, &out.ArangoDB + *out = new(GraphAnalyticsEngineStatusArangoDBRef) + (*in).DeepCopyInto(*out) + } + if in.Reconciliation != nil { + in, out := &in.Reconciliation, &out.Reconciliation + *out = new(GraphAnalyticsEngineStatusReconciliation) (*in).DeepCopyInto(*out) } return @@ -140,3 +203,60 @@ func (in *GraphAnalyticsEngineStatus) DeepCopy() *GraphAnalyticsEngineStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GraphAnalyticsEngineStatusArangoDBRef) DeepCopyInto(out *GraphAnalyticsEngineStatusArangoDBRef) { + *out = *in + if in.Secret != nil { + in, out := &in.Secret, &out.Secret + *out = new(v1.Object) + (*in).DeepCopyInto(*out) + } + if in.TLS != nil { + in, out := &in.TLS, &out.TLS + *out = new(v1.Object) + (*in).DeepCopyInto(*out) + } + if in.Deployment != nil { + in, out := &in.Deployment, &out.Deployment + *out = new(v1.Object) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphAnalyticsEngineStatusArangoDBRef. +func (in *GraphAnalyticsEngineStatusArangoDBRef) DeepCopy() *GraphAnalyticsEngineStatusArangoDBRef { + if in == nil { + return nil + } + out := new(GraphAnalyticsEngineStatusArangoDBRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GraphAnalyticsEngineStatusReconciliation) DeepCopyInto(out *GraphAnalyticsEngineStatusReconciliation) { + *out = *in + if in.StatefulSet != nil { + in, out := &in.StatefulSet, &out.StatefulSet + *out = new(v1.Object) + (*in).DeepCopyInto(*out) + } + if in.Service != nil { + in, out := &in.Service, &out.Service + *out = new(v1.Object) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphAnalyticsEngineStatusReconciliation. +func (in *GraphAnalyticsEngineStatusReconciliation) DeepCopy() *GraphAnalyticsEngineStatusReconciliation { + if in == nil { + return nil + } + out := new(GraphAnalyticsEngineStatusReconciliation) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/ml/v1alpha1/extension_spec_deployment.go b/pkg/apis/ml/v1alpha1/extension_spec_deployment.go index 2573eeeb5..623bbba23 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_deployment.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_deployment.go @@ -24,6 +24,7 @@ import ( schedulerContainerApiv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container" schedulerPodApiv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" + sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" "github.com/arangodb/kube-arangodb/pkg/util/errors" ) @@ -42,7 +43,7 @@ type ArangoMLExtensionSpecDeployment struct { Service *ArangoMLExtensionSpecDeploymentService `json:"service,omitempty"` // TLS defined TLS Settings for extension - TLS *ArangoMLExtensionSpecDeploymentTLS `json:"tls,omitempty"` + TLS *sharedApi.TLS `json:"tls,omitempty"` // Pod defines base template for pods *schedulerPodApiv1alpha1.Pod @@ -102,7 +103,7 @@ func (s *ArangoMLExtensionSpecDeployment) GetService() *ArangoMLExtensionSpecDep return s.Service } -func (s *ArangoMLExtensionSpecDeployment) GetTLS() *ArangoMLExtensionSpecDeploymentTLS { +func (s *ArangoMLExtensionSpecDeployment) GetTLS() *sharedApi.TLS { if s == nil { return nil } diff --git a/pkg/apis/ml/v1alpha1/extension_spec_deployment_service.go b/pkg/apis/ml/v1alpha1/extension_spec_deployment_service.go index cd4835851..48f58bf5e 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_deployment_service.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_deployment_service.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ type ArangoMLExtensionSpecDeploymentService struct { // +doc/enum: NodePort|service will be exposed on one port of every node, in addition to 'ClusterIP' type // +doc/enum: LoadBalancer|service will be exposed via an external load balancer (if the cloud provider supports it), in addition to 'NodePort' type // +doc/enum: ExternalName|service consists of only a reference to an external name that kubedns or equivalent will return as a CNAME record, with no exposing or proxying of any pods involved + // +doc/enum: None|service is not created // +doc/default: ClusterIP // +doc/link: Kubernetes Documentation|https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types Type *core.ServiceType `json:"type,omitempty"` diff --git a/pkg/apis/ml/v1alpha1/extension_status.go b/pkg/apis/ml/v1alpha1/extension_status.go index 9a18ab0ce..d1c135c07 100644 --- a/pkg/apis/ml/v1alpha1/extension_status.go +++ b/pkg/apis/ml/v1alpha1/extension_status.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,5 +40,5 @@ type ArangoMLExtensionStatus struct { ArangoDB *ArangoMLExtensionStatusArangoDBRef `json:"arangoDB,omitempty"` // Reconciliation keeps the information about reconciliation process. For internal use. - Reconciliation *ArangoMLExtensionStatusReconciliation `json:"reconciliation"` + Reconciliation *ArangoMLExtensionStatusReconciliation `json:"reconciliation,omitempty"` } diff --git a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go index ffde846bd..fc298c3cf 100644 --- a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go @@ -382,7 +382,7 @@ func (in *ArangoMLExtensionSpecDeployment) DeepCopyInto(out *ArangoMLExtensionSp } if in.TLS != nil { in, out := &in.TLS, &out.TLS - *out = new(ArangoMLExtensionSpecDeploymentTLS) + *out = new(sharedv1.TLS) (*in).DeepCopyInto(*out) } if in.Pod != nil { @@ -439,32 +439,6 @@ func (in *ArangoMLExtensionSpecDeploymentService) DeepCopy() *ArangoMLExtensionS return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ArangoMLExtensionSpecDeploymentTLS) DeepCopyInto(out *ArangoMLExtensionSpecDeploymentTLS) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.AltNames != nil { - in, out := &in.AltNames, &out.AltNames - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoMLExtensionSpecDeploymentTLS. -func (in *ArangoMLExtensionSpecDeploymentTLS) DeepCopy() *ArangoMLExtensionSpecDeploymentTLS { - if in == nil { - return nil - } - out := new(ArangoMLExtensionSpecDeploymentTLS) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArangoMLExtensionSpecMetadataService) DeepCopyInto(out *ArangoMLExtensionSpecMetadataService) { *out = *in diff --git a/pkg/apis/ml/v1beta1/conditions.go b/pkg/apis/ml/v1beta1/conditions.go index 7667d0835..06708119c 100644 --- a/pkg/apis/ml/v1beta1/conditions.go +++ b/pkg/apis/ml/v1beta1/conditions.go @@ -23,17 +23,17 @@ package v1beta1 import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" const ( - ReadyCondition api.ConditionType = "Ready" - SpecValidCondition api.ConditionType = "SpecValid" - ExtensionFoundCondition api.ConditionType = "ExtensionFound" - ExtensionStorageFoundCondition api.ConditionType = "StorageFound" - ExtensionDeploymentFoundCondition api.ConditionType = "DeploymentFound" - ExtensionBootstrapCompletedCondition api.ConditionType = "BootstrapCompleted" - ExtensionMetadataServiceValidCondition api.ConditionType = "MetadataServiceValid" - ExtensionServiceAccountReadyCondition api.ConditionType = "ServiceAccountReady" - ExtensionStatefulSetReadyCondition api.ConditionType = "ExtensionDeploymentReady" - ExtensionTLSEnabledCondition api.ConditionType = "TLSEnabled" - LicenseValidCondition api.ConditionType = "LicenseValid" - CronJobSyncedCondition api.ConditionType = "CronJobSynced" - BatchJobSyncedCondition api.ConditionType = "BatchJobSynced" + ReadyCondition api.ConditionType = "Ready" + SpecValidCondition api.ConditionType = "SpecValid" + ExtensionFoundCondition api.ConditionType = "ExtensionFound" + StorageFoundCondition api.ConditionType = "StorageFound" + DeploymentFoundCondition api.ConditionType = "DeploymentFound" + BootstrapCompletedCondition api.ConditionType = "BootstrapCompleted" + MetadataServiceValidCondition api.ConditionType = "MetadataServiceValid" + ServiceAccountReadyCondition api.ConditionType = "ServiceAccountReady" + StatefulSetReadyCondition api.ConditionType = "StatefulSetReady" + TLSEnabledCondition api.ConditionType = "TLSEnabled" + LicenseValidCondition api.ConditionType = "LicenseValid" + CronJobSyncedCondition api.ConditionType = "CronJobSynced" + BatchJobSyncedCondition api.ConditionType = "BatchJobSynced" ) diff --git a/pkg/apis/ml/v1beta1/extension_spec_deployment.go b/pkg/apis/ml/v1beta1/extension_spec_deployment.go index 56a8745a0..e44abba60 100644 --- a/pkg/apis/ml/v1beta1/extension_spec_deployment.go +++ b/pkg/apis/ml/v1beta1/extension_spec_deployment.go @@ -24,6 +24,7 @@ import ( schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container" schedulerPodApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/pod" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" + sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" "github.com/arangodb/kube-arangodb/pkg/util/errors" ) @@ -42,7 +43,7 @@ type ArangoMLExtensionSpecDeployment struct { Service *ArangoMLExtensionSpecDeploymentService `json:"service,omitempty"` // TLS defined TLS Settings for extension - TLS *ArangoMLExtensionSpecDeploymentTLS `json:"tls,omitempty"` + TLS *sharedApi.TLS `json:"tls,omitempty"` // Pod defines base template for pods *schedulerPodApi.Pod @@ -102,7 +103,7 @@ func (s *ArangoMLExtensionSpecDeployment) GetService() *ArangoMLExtensionSpecDep return s.Service } -func (s *ArangoMLExtensionSpecDeployment) GetTLS() *ArangoMLExtensionSpecDeploymentTLS { +func (s *ArangoMLExtensionSpecDeployment) GetTLS() *sharedApi.TLS { if s == nil { return nil } diff --git a/pkg/apis/ml/v1beta1/extension_spec_deployment_service.go b/pkg/apis/ml/v1beta1/extension_spec_deployment_service.go index 9d2c9beb6..9e2e5409c 100644 --- a/pkg/apis/ml/v1beta1/extension_spec_deployment_service.go +++ b/pkg/apis/ml/v1beta1/extension_spec_deployment_service.go @@ -32,6 +32,7 @@ type ArangoMLExtensionSpecDeploymentService struct { // +doc/enum: NodePort|service will be exposed on one port of every node, in addition to 'ClusterIP' type // +doc/enum: LoadBalancer|service will be exposed via an external load balancer (if the cloud provider supports it), in addition to 'NodePort' type // +doc/enum: ExternalName|service consists of only a reference to an external name that kubedns or equivalent will return as a CNAME record, with no exposing or proxying of any pods involved + // +doc/enum: None|service is not created // +doc/default: ClusterIP // +doc/link: Kubernetes Documentation|https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types Type *core.ServiceType `json:"type,omitempty"` diff --git a/pkg/apis/ml/v1beta1/extension_status.go b/pkg/apis/ml/v1beta1/extension_status.go index 6200c8f5b..b1eedf0c8 100644 --- a/pkg/apis/ml/v1beta1/extension_status.go +++ b/pkg/apis/ml/v1beta1/extension_status.go @@ -40,5 +40,5 @@ type ArangoMLExtensionStatus struct { ArangoDB *ArangoMLExtensionStatusArangoDBRef `json:"arangoDB,omitempty"` // Reconciliation keeps the information about reconciliation process. For internal use. - Reconciliation *ArangoMLExtensionStatusReconciliation `json:"reconciliation"` + Reconciliation *ArangoMLExtensionStatusReconciliation `json:"reconciliation,omitempty"` } diff --git a/pkg/apis/ml/v1beta1/zz_generated.deepcopy.go b/pkg/apis/ml/v1beta1/zz_generated.deepcopy.go index b7d876368..2c3b33937 100644 --- a/pkg/apis/ml/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/ml/v1beta1/zz_generated.deepcopy.go @@ -151,7 +151,7 @@ func (in *ArangoMLExtensionSpecDeployment) DeepCopyInto(out *ArangoMLExtensionSp } if in.TLS != nil { in, out := &in.TLS, &out.TLS - *out = new(ArangoMLExtensionSpecDeploymentTLS) + *out = new(v1.TLS) (*in).DeepCopyInto(*out) } if in.Pod != nil { @@ -208,32 +208,6 @@ func (in *ArangoMLExtensionSpecDeploymentService) DeepCopy() *ArangoMLExtensionS return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ArangoMLExtensionSpecDeploymentTLS) DeepCopyInto(out *ArangoMLExtensionSpecDeploymentTLS) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.AltNames != nil { - in, out := &in.AltNames, &out.AltNames - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoMLExtensionSpecDeploymentTLS. -func (in *ArangoMLExtensionSpecDeploymentTLS) DeepCopy() *ArangoMLExtensionSpecDeploymentTLS { - if in == nil { - return nil - } - out := new(ArangoMLExtensionSpecDeploymentTLS) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArangoMLExtensionSpecMetadataService) DeepCopyInto(out *ArangoMLExtensionSpecMetadataService) { *out = *in diff --git a/pkg/apis/ml/v1beta1/extension_spec_deployment_tls.go b/pkg/apis/shared/v1/tls.go similarity index 84% rename from pkg/apis/ml/v1beta1/extension_spec_deployment_tls.go rename to pkg/apis/shared/v1/tls.go index 2e663247f..853919d9b 100644 --- a/pkg/apis/ml/v1beta1/extension_spec_deployment_tls.go +++ b/pkg/apis/shared/v1/tls.go @@ -18,9 +18,9 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package v1beta1 +package v1 -type ArangoMLExtensionSpecDeploymentTLS struct { +type TLS struct { // Enabled define if TLS Should be enabled. If is not set then default is taken from ArangoDeployment settings Enabled *bool `json:"enabled,omitempty"` @@ -28,7 +28,7 @@ type ArangoMLExtensionSpecDeploymentTLS struct { AltNames []string `json:"altNames,omitempty"` } -func (a *ArangoMLExtensionSpecDeploymentTLS) IsEnabled() bool { +func (a *TLS) IsEnabled() bool { if a == nil || a.Enabled == nil { return true } @@ -36,7 +36,7 @@ func (a *ArangoMLExtensionSpecDeploymentTLS) IsEnabled() bool { return *a.Enabled } -func (a *ArangoMLExtensionSpecDeploymentTLS) GetAltNames() []string { +func (a *TLS) GetAltNames() []string { if a == nil || a.AltNames == nil { return nil } diff --git a/pkg/apis/shared/v1/zz_generated.deepcopy.go b/pkg/apis/shared/v1/zz_generated.deepcopy.go index 27caeebad..dc3842836 100644 --- a/pkg/apis/shared/v1/zz_generated.deepcopy.go +++ b/pkg/apis/shared/v1/zz_generated.deepcopy.go @@ -136,3 +136,29 @@ func (in *ServiceAccountRole) DeepCopy() *ServiceAccountRole { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TLS) DeepCopyInto(out *TLS) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.AltNames != nil { + in, out := &in.AltNames, &out.AltNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLS. +func (in *TLS) DeepCopy() *TLS { + if in == nil { + return nil + } + out := new(TLS) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/shared/validate.go b/pkg/apis/shared/validate.go index 08e946f2f..7d221de38 100644 --- a/pkg/apis/shared/validate.go +++ b/pkg/apis/shared/validate.go @@ -35,6 +35,10 @@ var ( resourceNameRE = regexp.MustCompile(`^([0-9\-\.a-z])+$`) ) +const ( + ServiceTypeNone core.ServiceType = "None" +) + // ValidateResourceName validates a kubernetes resource name. // If not valid, an error is returned. // See https://kubernetes.io/docs/concepts/overview/working-with-objects/names/ @@ -146,7 +150,8 @@ func ValidateServiceType(st core.ServiceType) error { case core.ServiceTypeClusterIP, core.ServiceTypeNodePort, core.ServiceTypeLoadBalancer, - core.ServiceTypeExternalName: + core.ServiceTypeExternalName, + ServiceTypeNone: return nil } return errors.Errorf("Unsupported service type %s", st) diff --git a/pkg/crd/crds/analytics-graphanalyticsengine.schema.generated.yaml b/pkg/crd/crds/analytics-graphanalyticsengine.schema.generated.yaml index b2777f63d..74610de7f 100644 --- a/pkg/crd/crds/analytics-graphanalyticsengine.schema.generated.yaml +++ b/pkg/crd/crds/analytics-graphanalyticsengine.schema.generated.yaml @@ -3,6 +3,39 @@ v1alpha1: properties: spec: properties: + deployment: + description: Deployment specifies how the GAE will be deployed into cluster + properties: + port: + description: Port defines on which port the container will be listening for connections + format: int32 + type: integer + service: + description: Service defines how components will be exposed + properties: + type: + description: Type determines how the Service is exposed + enum: + - ClusterIP + - NodePort + - LoadBalancer + - ExternalName + - None + type: string + type: object + tls: + description: TLS defined TLS Settings + properties: + altNames: + description: AltNames define TLS AltNames used when TLS on the ArangoDB is enabled + items: + type: string + type: array + enabled: + description: Enabled define if TLS Should be enabled. If is not set then default is taken from ArangoDeployment settings + type: boolean + type: object + type: object deploymentName: description: DeploymentName define deployment name used in the object. Immutable type: string diff --git a/pkg/crd/crds/ml-extension.schema.generated.yaml b/pkg/crd/crds/ml-extension.schema.generated.yaml index f8a55b348..781802d1f 100644 --- a/pkg/crd/crds/ml-extension.schema.generated.yaml +++ b/pkg/crd/crds/ml-extension.schema.generated.yaml @@ -856,6 +856,7 @@ v1alpha1: - NodePort - LoadBalancer - ExternalName + - None type: string type: object serviceAccountName: @@ -13944,10 +13945,12 @@ v1beta1: tls: properties: altNames: + description: AltNames define TLS AltNames used when TLS on the ArangoDB is enabled items: type: string type: array enabled: + description: Enabled define if TLS Should be enabled. If is not set then default is taken from ArangoDeployment settings type: boolean type: object tolerations: diff --git a/pkg/util/k8sutil/util.go b/pkg/util/k8sutil/util.go index 44e3f52af..34ffd78cd 100644 --- a/pkg/util/k8sutil/util.go +++ b/pkg/util/k8sutil/util.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -52,10 +52,14 @@ const ( LabelValueArangoActive = "true" // LabelKeyArangoMLStatefulSet is the key of the label used to define k8s StatefulSet for ML Extension LabelKeyArangoMLStatefulSet = "ml.arangodb.com/statefulset" + // LabelKeyAnalyticsGAEStatefulSet is the key of the label used to define k8s StatefulSet for Analytics GAE + LabelKeyAnalyticsGAEStatefulSet = "analytics.arangodb.com/statefulset" // AppName is the value for the "app" label AppName = "arangodb" // AppArangoML is the value for the "app" label AppArangoML = "arangoml" + // AppAnalytics is the value for the "app" label + AppAnalytics = "analytics" ) // AddOwnerRefToObject adds given owner reference to given object From 54b83932deed1be9a94fbb5d79e214842a4c5f63 Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Thu, 9 May 2024 07:17:58 +0000 Subject: [PATCH 2/2] Add handler --- chart/kube-arangodb/templates/analytics-operator/role.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chart/kube-arangodb/templates/analytics-operator/role.yaml b/chart/kube-arangodb/templates/analytics-operator/role.yaml index 2c7813f23..84e6cba2f 100644 --- a/chart/kube-arangodb/templates/analytics-operator/role.yaml +++ b/chart/kube-arangodb/templates/analytics-operator/role.yaml @@ -28,9 +28,14 @@ rules: - "get" - "list" - "watch" + - apiGroups: ["apps"] + resources: + - "statefulsets" + verbs: ["*"] - apiGroups: [ "" ] resources: - "secrets" + - "services" verbs: [ "*" ] {{- end }} {{- end }} \ No newline at end of file