From dd3209d733929e92ff813cd0ce33f19c86aa8368 Mon Sep 17 00:00:00 2001 From: Neaj Morshad Date: Tue, 5 Nov 2024 17:43:29 +0600 Subject: [PATCH] Add mssql ops apis for reconfigure tls Signed-off-by: Neaj Morshad --- apis/ops/v1alpha1/mssqlserver_ops_types.go | 18 +++++- apis/ops/v1alpha1/openapi_generated.go | 61 ++++++++++++++++++- apis/ops/v1alpha1/zz_generated.deepcopy.go | 19 +++++- ...ops.kubedb.com_mssqlserveropsrequests.yaml | 4 ++ 4 files changed, 98 insertions(+), 4 deletions(-) diff --git a/apis/ops/v1alpha1/mssqlserver_ops_types.go b/apis/ops/v1alpha1/mssqlserver_ops_types.go index 9d7bb32fa1..4521390a5c 100644 --- a/apis/ops/v1alpha1/mssqlserver_ops_types.go +++ b/apis/ops/v1alpha1/mssqlserver_ops_types.go @@ -18,6 +18,8 @@ limitations under the License. package v1alpha1 import ( + dbapi "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" + core "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -66,7 +68,7 @@ type MSSQLServerOpsRequestSpec struct { // Specifies information necessary for custom configuration of MSSQLServer Configuration *MSSQLServerCustomConfigurationSpec `json:"configuration,omitempty"` // Specifies information necessary for configuring TLS - TLS *TLSSpec `json:"tls,omitempty"` + TLS *MSSQLServerTLSSpec `json:"tls,omitempty"` // Specifies information necessary for configuring authSecret of the database Authentication *AuthSpec `json:"authentication,omitempty"` // Specifies information necessary for restarting database @@ -119,6 +121,20 @@ type MSSQLServerCustomConfigurationSpec struct { RemoveCustomConfig bool `json:"removeCustomConfig,omitempty"` } +type MSSQLServerTLSSpec struct { + // SQLServerTLSSpec contains updated tls configurations for client and server. + // +optional + dbapi.SQLServerTLSConfig `json:",inline,omitempty"` + + // RotateCertificates tells operator to initiate certificate rotation + // +optional + RotateCertificates bool `json:"rotateCertificates,omitempty"` + + // Remove tells operator to remove TLS configuration + // +optional + Remove bool `json:"remove,omitempty"` +} + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // MSSQLServerOpsRequestList is a list of MSSQLServerOpsRequests diff --git a/apis/ops/v1alpha1/openapi_generated.go b/apis/ops/v1alpha1/openapi_generated.go index 1806f12ea9..85ff2f7702 100644 --- a/apis/ops/v1alpha1/openapi_generated.go +++ b/apis/ops/v1alpha1/openapi_generated.go @@ -552,6 +552,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerOpsRequestList": schema_apimachinery_apis_ops_v1alpha1_MSSQLServerOpsRequestList(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerOpsRequestSpec": schema_apimachinery_apis_ops_v1alpha1_MSSQLServerOpsRequestSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerReplicaReadinessCriteria": schema_apimachinery_apis_ops_v1alpha1_MSSQLServerReplicaReadinessCriteria(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerTLSSpec": schema_apimachinery_apis_ops_v1alpha1_MSSQLServerTLSSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerUpdateVersionSpec": schema_apimachinery_apis_ops_v1alpha1_MSSQLServerUpdateVersionSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerVerticalScalingSpec": schema_apimachinery_apis_ops_v1alpha1_MSSQLServerVerticalScalingSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerVolumeExpansionSpec": schema_apimachinery_apis_ops_v1alpha1_MSSQLServerVolumeExpansionSpec(ref), @@ -27992,7 +27993,7 @@ func schema_apimachinery_apis_ops_v1alpha1_MSSQLServerOpsRequestSpec(ref common. "tls": { SchemaProps: spec.SchemaProps{ Description: "Specifies information necessary for configuring TLS", - Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.TLSSpec"), + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerTLSSpec"), }, }, "authentication": { @@ -28025,7 +28026,7 @@ func schema_apimachinery_apis_ops_v1alpha1_MSSQLServerOpsRequestSpec(ref common. }, }, Dependencies: []string{ - "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kubedb.dev/apimachinery/apis/ops/v1alpha1.AuthSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerCustomConfigurationSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerHorizontalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerUpdateVersionSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerVerticalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerVolumeExpansionSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.TLSSpec"}, + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kubedb.dev/apimachinery/apis/ops/v1alpha1.AuthSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerCustomConfigurationSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerHorizontalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerTLSSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerUpdateVersionSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerVerticalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.MSSQLServerVolumeExpansionSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec"}, } } @@ -28040,6 +28041,62 @@ func schema_apimachinery_apis_ops_v1alpha1_MSSQLServerReplicaReadinessCriteria(r } } +func schema_apimachinery_apis_ops_v1alpha1_MSSQLServerTLSSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "issuerRef": { + SchemaProps: spec.SchemaProps{ + Description: "IssuerRef is a reference to a Certificate Issuer.", + Ref: ref("k8s.io/api/core/v1.TypedLocalObjectReference"), + }, + }, + "certificates": { + SchemaProps: spec.SchemaProps{ + Description: "Certificate provides server and/or client certificate options used by application pods. These options are passed to a cert-manager Certificate object. xref: https://github.com/jetstack/cert-manager/blob/v0.16.0/pkg/apis/certmanager/v1beta1/types_certificate.go#L82-L162", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/client-go/api/v1.CertificateSpec"), + }, + }, + }, + }, + }, + "clientTLS": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "rotateCertificates": { + SchemaProps: spec.SchemaProps{ + Description: "RotateCertificates tells operator to initiate certificate rotation", + Type: []string{"boolean"}, + Format: "", + }, + }, + "remove": { + SchemaProps: spec.SchemaProps{ + Description: "Remove tells operator to remove TLS configuration", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"clientTLS"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.TypedLocalObjectReference", "kmodules.xyz/client-go/api/v1.CertificateSpec"}, + } +} + func schema_apimachinery_apis_ops_v1alpha1_MSSQLServerUpdateVersionSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/ops/v1alpha1/zz_generated.deepcopy.go b/apis/ops/v1alpha1/zz_generated.deepcopy.go index a823bad1d8..69f6033260 100644 --- a/apis/ops/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ops/v1alpha1/zz_generated.deepcopy.go @@ -1864,7 +1864,7 @@ func (in *MSSQLServerOpsRequestSpec) DeepCopyInto(out *MSSQLServerOpsRequestSpec } if in.TLS != nil { in, out := &in.TLS, &out.TLS - *out = new(TLSSpec) + *out = new(MSSQLServerTLSSpec) (*in).DeepCopyInto(*out) } if in.Authentication != nil { @@ -1911,6 +1911,23 @@ func (in *MSSQLServerReplicaReadinessCriteria) DeepCopy() *MSSQLServerReplicaRea return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MSSQLServerTLSSpec) DeepCopyInto(out *MSSQLServerTLSSpec) { + *out = *in + in.SQLServerTLSConfig.DeepCopyInto(&out.SQLServerTLSConfig) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MSSQLServerTLSSpec. +func (in *MSSQLServerTLSSpec) DeepCopy() *MSSQLServerTLSSpec { + if in == nil { + return nil + } + out := new(MSSQLServerTLSSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MSSQLServerUpdateVersionSpec) DeepCopyInto(out *MSSQLServerUpdateVersionSpec) { *out = *in diff --git a/crds/ops.kubedb.com_mssqlserveropsrequests.yaml b/crds/ops.kubedb.com_mssqlserveropsrequests.yaml index 00a0fa2f0e..552725ac1f 100644 --- a/crds/ops.kubedb.com_mssqlserveropsrequests.yaml +++ b/crds/ops.kubedb.com_mssqlserveropsrequests.yaml @@ -178,6 +178,8 @@ spec: - alias type: object type: array + clientTLS: + type: boolean issuerRef: properties: apiGroup: @@ -195,6 +197,8 @@ spec: type: boolean rotateCertificates: type: boolean + required: + - clientTLS type: object type: enum: