Skip to content

Commit

Permalink
Add empty controller and API for VerticaRestorePoints (#643)
Browse files Browse the repository at this point in the history
This PR build out the stub for an empty controller to handle the
VerticaRestorePointsQuery API. It does not include a webhook, as there
are no defined rules for transitioning the Custom Resource (CR), given
that the spec portion contains only two fields. The operator can observe
the new API, initiate a reconciliation iteration, and take no action, as
we have set nil for the actors during this implementation phase

---------

Co-authored-by: Matt Spilchen <[email protected]>
  • Loading branch information
chinhtranvan and Matt Spilchen authored Dec 20, 2023
1 parent d10d15b commit 2abd8f1
Show file tree
Hide file tree
Showing 26 changed files with 570 additions and 55 deletions.
11 changes: 8 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ repo: github.com/vertica/vertica-kubernetes
resources:
- api:
crdVersion: v1
namespaced: false
controller: true
domain: vertica.com
kind: VerticaDB
Expand All @@ -25,7 +24,6 @@ resources:
webhookVersion: v1
- api:
crdVersion: v1
namespaced: false
controller: true
domain: vertica.com
kind: VerticaAutoscaler
Expand All @@ -37,7 +35,6 @@ resources:
webhookVersion: v1
- api:
crdVersion: v1
namespaced: false
controller: true
domain: vertica.com
kind: EventTrigger
Expand All @@ -54,4 +51,12 @@ resources:
kind: VerticaDB
path: github.com/vertica/vertica-kubernetes/api/v1
version: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: vertica.com
kind: VerticaRestorePointsQuery
path: github.com/vertica/vertica-kubernetes/api/v1beta1
version: v1beta1
version: "3"
14 changes: 8 additions & 6 deletions api/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ const (
Group = "vertica.com"
Version = "v1beta1"

VerticaDBKind = "VerticaDB"
VerticaAutoscalerKind = "VerticaAutoscaler"
EventTriggerKind = "EventTrigger"
VerticaDBKind = "VerticaDB"
VerticaAutoscalerKind = "VerticaAutoscaler"
EventTriggerKind = "EventTrigger"
RestorePointsQueryKind = "VerticaRestorePointsQuery"
)

var (
Expand All @@ -43,7 +44,8 @@ var (
AddToScheme = SchemeBuilder.AddToScheme

// All supported group/kind by this operator
GkVDB = schema.GroupKind{Group: Group, Kind: VerticaDBKind}
GkVAS = schema.GroupKind{Group: Group, Kind: VerticaAutoscalerKind}
GkET = schema.GroupKind{Group: Group, Kind: EventTriggerKind}
GkVDB = schema.GroupKind{Group: Group, Kind: VerticaDBKind}
GkVAS = schema.GroupKind{Group: Group, Kind: VerticaAutoscalerKind}
GkET = schema.GroupKind{Group: Group, Kind: EventTriggerKind}
GkVRPQ = schema.GroupKind{Group: Group, Kind: RestorePointsQueryKind}
)
111 changes: 111 additions & 0 deletions api/v1beta1/verticarestorepointsquery_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
Copyright [2021-2023] Open Text.
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 v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

// VerticaRestorePointsQuerySpec defines the desired state of VerticaRestorePointsQuery
type VerticaRestorePointsQuerySpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
// The name of the VerticaDB CR that this VerticaRestorePointsQuery is defined for. The
// VerticaDB object must exist in the same namespace as this object.
VerticaDBName string `json:"verticaDBName"`

// +operator-sdk:csv:customresourcedefinitions:type=spec
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
// Optional parameter that will limit the query to only restore points
// from this archvie
ArchiveName string `json:"archiveName"`
}

const (
archiveNm = "backup" // constants for test purposes
)

// VerticaRestorePointsQueryStatus defines the observed state of VerticaRestorePointsQuery
type VerticaRestorePointsQueryStatus struct {
// +operator-sdk:csv:customresourcedefinitions:type=status
// RestorePoints used to list out the available restore points.
RestorePoints string `json:"restorePoints"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=vertica,shortName=vrpq
// +kubebuilder:subresource:status
// +operator-sdk:csv:customresourcedefinitions:resources={{Job,batch/v1,""}}

// VerticaRestorePointsQuery is the Schema for the verticarestorepointsqueries API
type VerticaRestorePointsQuery struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec VerticaRestorePointsQuerySpec `json:"spec,omitempty"`
Status VerticaRestorePointsQueryStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// VerticaRestorePointsQueryList contains a list of VerticaRestorePointsQuery
type VerticaRestorePointsQueryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VerticaRestorePointsQuery `json:"items"`
}

func init() {
SchemeBuilder.Register(&VerticaRestorePointsQuery{}, &VerticaRestorePointsQueryList{})
}

func (vrpq *VerticaRestorePointsQuery) ExtractNamespacedName() types.NamespacedName {
return types.NamespacedName{
Name: vrpq.ObjectMeta.Name,
Namespace: vrpq.ObjectMeta.Namespace,
}
}

func MakeSampleVrpqName() types.NamespacedName {
return types.NamespacedName{Name: "vrpq-sample", Namespace: "default"}
}

// MakeVrpq will make an VerticaRestorePointsQuery for test purposes
func MakeVrpq() *VerticaRestorePointsQuery {
VDBNm := MakeVDBName()
nm := MakeSampleVrpqName()
return &VerticaRestorePointsQuery{
TypeMeta: metav1.TypeMeta{
APIVersion: GroupVersion.String(),
Kind: RestorePointsQueryKind,
},
ObjectMeta: metav1.ObjectMeta{
Name: nm.Name,
Namespace: nm.Namespace,
UID: "zxcvbn-ghi-lkm",
},
Spec: VerticaRestorePointsQuerySpec{
VerticaDBName: VDBNm.Name,
ArchiveName: archiveNm,
},
}
}
16 changes: 13 additions & 3 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ import (

vapiV1 "github.com/vertica/vertica-kubernetes/api/v1"
vapiB1 "github.com/vertica/vertica-kubernetes/api/v1beta1"

"github.com/vertica/vertica-kubernetes/pkg/controllers/et"
"github.com/vertica/vertica-kubernetes/pkg/controllers/vas"
"github.com/vertica/vertica-kubernetes/pkg/controllers/vdb"
"github.com/vertica/vertica-kubernetes/pkg/controllers/vrpq"
vmeta "github.com/vertica/vertica-kubernetes/pkg/meta"
"github.com/vertica/vertica-kubernetes/pkg/opcfg"
"github.com/vertica/vertica-kubernetes/pkg/security"
Expand Down Expand Up @@ -129,6 +131,13 @@ func addReconcilersToManager(mgr manager.Manager, restCfg *rest.Config, oc *opcf
setupLog.Error(err, "unable to create controller", "controller", "EventTrigger")
os.Exit(1)
}
if err := (&vrpq.VerticaRestorePointsQueryReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "VerticaRestorePointsQuery")
os.Exit(1)
}
//+kubebuilder:scaffold:builder
}

Expand Down Expand Up @@ -257,9 +266,10 @@ func main() {
CertDir: CertDir,
Controller: v1alpha1.ControllerConfigurationSpec{
GroupKindConcurrency: map[string]int{
vapiB1.GkVDB.String(): oc.VerticaDBConcurrency,
vapiB1.GkVAS.String(): oc.VerticaAutoscalerConcurrency,
vapiB1.GkET.String(): oc.EventTriggerConcurrency,
vapiB1.GkVDB.String(): oc.VerticaDBConcurrency,
vapiB1.GkVAS.String(): oc.VerticaAutoscalerConcurrency,
vapiB1.GkET.String(): oc.EventTriggerConcurrency,
vapiB1.GkVRPQ.String(): oc.VerticaRestorePointsQueryConcurrency,
},
},
})
Expand Down
2 changes: 2 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ resources:
- bases/vertica.com_verticadbs.yaml
- bases/vertica.com_verticaautoscalers.yaml
- bases/vertica.com_eventtriggers.yaml
- bases/vertica.com_verticarestorepointsqueries.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
- patches/webhook_in_verticadbs.yaml
- patches/webhook_in_verticaautoscalers.yaml
- patches/webhook_in_eventtriggers.yaml
- patches/webhook_in_verticarestorepointsqueries.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] there was an optional patch to include an annotation that
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: verticarestorepointsqueries.vertica.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: verticarestorepointsqueries.vertica.com
spec:
conversion:
strategy: None
1 change: 1 addition & 0 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ spec:
- "--verticadb-concurrency=5"
- "--verticaautoscaler-concurrency=1"
- "--eventtrigger-concurrency=1"
- "--verticarestorepointsquery-concurrency=1"
Original file line number Diff line number Diff line change
Expand Up @@ -401,21 +401,16 @@ spec:
a path to one of the certSecrets.
displayName: Ca File
path: communal.caFile
- description: "The name of a secret that contains the credentials to connect
to the communal endpoint (only applies to s3://, gs:// or azb://). Certain
keys need to be set, depending on the endpoint type: - s3:// or gs:// -
If storing credentials in a secret, the secret must have the following keys
set: accesskey and secretkey. When using Google Cloud Storage, the IDs
set in the secret are taken from the hash-based message authentication code
(HMAC) keys. - azb:// - It must have the following keys set: accountName
- Name of the Azure account blobEndpoint - (Optional) Set this to the location
of the endpoint. If using an emulator like Azurite, it can be set to something
like 'http://<IP-addr>:<port>' accountKey - If accessing with an account
key set it here sharedAccessSignature - If accessing with a shared access
signature, set it here \n This field is optional. For AWS, authentication
to communal storage can be provided through an attached IAM profile: attached
to the EC2 instance or to a ServiceAccount with IRSA (see https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).
IRSA requires a Vertica server running at least with version >= 12.0.3."
- description: 'The name of an optional secret that contains the credentials
to connect to the communal endpoint. This can be omitted if the communal
storage uses some other form of authentication such as an attached IAM profile
in AWS. Certain keys need to be set, depending on the endpoint type. If
the communal storage starts with s3:// or gs://, the secret must have the
following keys set: accesskey and secretkey. If the communal storage starts
with azb://, the secret can have the following keys: accountName, blobEndpoint,
accountKey, or sharedAccessSignature. To store this secret outside of Kubernetes,
you can use a secret path reference prefix, such as gsm://. Everything after
the prefix is the name of the secret in the service you are storing.'
displayName: Credential Secret
path: communal.credentialSecret
x-descriptors:
Expand Down Expand Up @@ -596,19 +591,23 @@ spec:
x-descriptors:
- urn:alm:descriptor:io.kubernetes:StorageClass
- description: 'A secret that contains the TLS credentials to use for Vertica''s
node management agent (NMA). If this is empty, the operator will create
node management agent (NMA). If this is empty, the operator will create
a secret to use and add the name of the generate secret in this field. When
set, the secret must have the following keys defined: - tls.key: The private
key to be used by the HTTP server - tls.crt: The signed certificate chain
for the private key - ca.crt: The CA certificate'
set, the secret must have the following keys defined: tls.key, tls.crt and
ca.crt. To store this secret outside of Kubernetes, you can use a secret
path reference prefix, such as gsm://. Everything after the prefix is the
name of the secret in the service you are storing.'
displayName: NMATLSSecret
path: nmaTLSSecret
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: An optional name for a secret that contains the password for
the database's superuser. If this is not set, then we assume no such password
is set for the database. If this is set, it is up the user to create this
secret before deployment. The secret must have a key named password.
secret before deployment. The secret must have a key named password. To
store this secret outside of Kubernetes, you can use a secret path reference
prefix, such as gsm://. Everything after the prefix is the name of the secret
in the service you are storing.
displayName: Password Secret
path: passwordSecret
x-descriptors:
Expand Down Expand Up @@ -824,10 +823,10 @@ spec:
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:select:primary
- urn:alm:descriptor:com.tectonic.ui:select:secondary
- description: 'Like the nodePort parameter, except this controls the node port
to use for the http endpoint in the Vertica server. The same rules apply:
it must be defined within the range allocated by the control plane, if omitted
Kubernetes will choose the port automatically.'
- description: 'Like the clientNodePort parameter, except this controls the
node port to use for the http endpoint in the Vertica server. The same
rules apply: it must be defined within the range allocated by the control
plane, if omitted Kubernetes will choose the port automatically.'
displayName: Vertica HTTPNode Port
path: subclusters[0].verticaHTTPNodePort
x-descriptors:
Expand Down Expand Up @@ -982,10 +981,10 @@ spec:
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:select:primary
- urn:alm:descriptor:com.tectonic.ui:select:secondary
- description: 'Like the nodePort parameter, except this controls the node port
to use for the http endpoint in the Vertica server. The same rules apply:
it must be defined within the range allocated by the control plane, if omitted
Kubernetes will choose the port automatically.'
- description: 'Like the clientNodePort parameter, except this controls the
node port to use for the http endpoint in the Vertica server. The same
rules apply: it must be defined within the range allocated by the control
plane, if omitted Kubernetes will choose the port automatically.'
displayName: Vertica HTTPNode Port
path: temporarySubclusterRouting.template.verticaHTTPNodePort
x-descriptors:
Expand Down Expand Up @@ -1926,6 +1925,34 @@ spec:
displayName: Upgrade Status
path: upgradeStatus
version: v1beta1
- description: VerticaRestorePointsQuery is the Schema for the verticarestorepointsqueries
API
displayName: Vertica Restore Points Query
kind: VerticaRestorePointsQuery
name: verticarestorepointsqueries.vertica.com
resources:
- kind: Job
name: ""
version: batch/v1
specDescriptors:
- description: Optional parameter that will limit the query to only restore
points from this archvie
displayName: Archive Name
path: archiveName
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: The name of the VerticaDB CR that this VerticaRestorePointsQuery
is defined for. The VerticaDB object must exist in the same namespace as
this object.
displayName: Vertica DBName
path: verticaDBName
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
statusDescriptors:
- description: RestorePoints used to list out the available restore points.
displayName: Restore Points
path: restorePoints
version: v1beta1
description: |-
### What is Vertica?
Vertica is a unified analytics platform, based on a massively scalable architecture with the broadest set of analytical functions spanning event and time series, pattern matching, geospatial and end-to-end in-database machine learning. Vertica enables you to easily apply these powerful functions to the largest and most demanding analytical workloads, arming you and your customers with predictive business insights faster than any analytics data warehouse in the market. Vertica provides a unified analytics platform across major public clouds and on-premises data centers and integrates data in cloud object storage and HDFS without forcing you to move any of your data.
Expand Down
Loading

0 comments on commit 2abd8f1

Please sign in to comment.