Skip to content

Commit

Permalink
Merge branch 'master' of github.com:vshn/appcat
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz.widera@vshn.ch committed Oct 18, 2024
2 parents f65a5c5 + c433fcf commit fe04df7
Show file tree
Hide file tree
Showing 37 changed files with 871 additions and 20 deletions.
9 changes: 8 additions & 1 deletion apis/vshn/v1/dbaas_vshn_keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package v1

import (
"fmt"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -334,3 +333,11 @@ func (v *VSHNKeycloak) GetPDBLabels() map[string]string {
func (v *VSHNKeycloak) GetSecurity() *Security {
return &v.Spec.Parameters.Security
}

func (v *VSHNKeycloak) GetWorkloadPodTemplateLabelsManager() PodTemplateLabelsManager {
return &StatefulSetManager{}
}

func (v *VSHNKeycloak) GetWorkloadName() string {
return v.GetName() + "-keycloakx"
}
13 changes: 10 additions & 3 deletions apis/vshn/v1/dbaas_vshn_mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package v1

import (
"fmt"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -99,8 +98,8 @@ type VSHNMariaDBServiceSpec struct {
// ServiceLevel defines the service level of this service. Either Best Effort or Guaranteed Availability is allowed.
ServiceLevel VSHNDBaaSServiceLevel `json:"serviceLevel,omitempty"`

// +kubebuilder:default="standalone"
// +kubebuilder:validation:Enum=replication;standalone
// Access defines additional users and databases for this instance.
Access []VSHNAccess `json:"access,omitempty"`
}

// VSHNMariaDBTLSSpec contains settings to control tls traffic of a service.
Expand Down Expand Up @@ -273,3 +272,11 @@ func (v *VSHNMariaDB) GetPDBLabels() map[string]string {
func (v *VSHNMariaDB) GetSecurity() *Security {
return &v.Spec.Parameters.Security
}

func (v *VSHNMariaDB) GetWorkloadPodTemplateLabelsManager() PodTemplateLabelsManager {
return &StatefulSetManager{}
}

func (v *VSHNMariaDB) GetWorkloadName() string {
return v.GetName()
}
12 changes: 10 additions & 2 deletions apis/vshn/v1/dbaas_vshn_postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package v1

import (
"fmt"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
sgv1 "github.com/vshn/appcat/v4/apis/stackgres/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -126,7 +125,7 @@ type VSHNPostgreSQLUpdateStrategy struct {

// VSHNPostgreSQLServiceSpec contains PostgreSQL DBaaS specific properties
type VSHNPostgreSQLServiceSpec struct {
// +kubebuilder:validation:Enum="12";"13";"14";"15"
// +kubebuilder:validation:Enum="12";"13";"14";"15";"16"
// +kubebuilder:default="15"

// MajorVersion contains supported version of PostgreSQL.
Expand Down Expand Up @@ -154,6 +153,7 @@ type VSHNPostgreSQLServiceSpec struct {
// +kubebuilder:default=false
VacuumEnabled bool `json:"vacuumEnabled,omitempty"`

// Access defines additional users and databases for this instance.
Access []VSHNAccess `json:"access,omitempty"`
}

Expand Down Expand Up @@ -397,3 +397,11 @@ func (v *VSHNPostgreSQL) GetPDBLabels() map[string]string {
func (v *VSHNPostgreSQL) GetSecurity() *Security {
return &v.Spec.Parameters.Security
}

func (v *VSHNPostgreSQL) GetWorkloadPodTemplateLabelsManager() PodTemplateLabelsManager {
return &StatefulSetManager{}
}

func (v *VSHNPostgreSQL) GetWorkloadName() string {
return v.GetName()
}
9 changes: 8 additions & 1 deletion apis/vshn/v1/dbaas_vshn_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package v1

import (
"fmt"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -298,3 +297,11 @@ func (v *VSHNRedis) GetPDBLabels() map[string]string {
func (v *VSHNRedis) GetSecurity() *Security {
return &v.Spec.Parameters.Security
}

func (v *VSHNRedis) GetWorkloadPodTemplateLabelsManager() PodTemplateLabelsManager {
return &StatefulSetManager{}
}

func (v *VSHNRedis) GetWorkloadName() string {
return "redis-master"
}
57 changes: 57 additions & 0 deletions apis/vshn/v1/non_gen_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package v1

import (
v1 "k8s.io/api/apps/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// +kubebuilder:skip
// +kubebuilder:skipclient
// +kubebuilder:skipdeepcopy
// +kubebuilder:object:generate=false
type PodTemplateLabelsManager interface {
SetPodTemplateLabels(map[string]string)
GetPodTemplateLabels() map[string]string
GetObject() client.Object
client.Object
}

// +kubebuilder:skip
// +kubebuilder:skipclient
// +kubebuilder:skipdeepcopy
// +kubebuilder:object:generate=false
type DeploymentManager struct {
v1.Deployment
}

// +kubebuilder:skip
// +kubebuilder:skipclient
// +kubebuilder:skipdeepcopy
// +kubebuilder:object:generate=false
type StatefulSetManager struct {
v1.StatefulSet
}

func (d *DeploymentManager) SetPodTemplateLabels(labels map[string]string) {
d.Spec.Template.SetLabels(labels)
}

func (s *StatefulSetManager) SetPodTemplateLabels(labels map[string]string) {
s.Spec.Template.SetLabels(labels)
}

func (d *DeploymentManager) GetPodTemplateLabels() map[string]string {
return d.Spec.Template.GetLabels()
}

func (s *StatefulSetManager) GetPodTemplateLabels() map[string]string {
return s.Spec.Template.GetLabels()
}

func (d *DeploymentManager) GetObject() client.Object {
return &d.Deployment
}

func (d *StatefulSetManager) GetObject() client.Object {
return &d.StatefulSet
}
12 changes: 11 additions & 1 deletion apis/vshn/v1/vshn_minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package v1

import (
"fmt"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -247,3 +246,14 @@ func (v *VSHNMinio) GetPDBLabels() map[string]string {
func (v *VSHNMinio) GetSecurity() *Security {
return &v.Spec.Parameters.Security
}

func (v *VSHNMinio) GetWorkloadPodTemplateLabelsManager() PodTemplateLabelsManager {
if v.GetInstances() == 1 {
return &DeploymentManager{}
}
return &StatefulSetManager{}
}

func (v *VSHNMinio) GetWorkloadName() string {
return v.GetName()
}
9 changes: 8 additions & 1 deletion apis/vshn/v1/vshn_nextcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package v1

import (
"fmt"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -310,3 +309,11 @@ func (v *VSHNNextcloud) GetPDBLabels() map[string]string {
func (v *VSHNNextcloud) GetSecurity() *Security {
return &v.Spec.Parameters.Security
}

func (v *VSHNNextcloud) GetWorkloadPodTemplateLabelsManager() PodTemplateLabelsManager {
return &DeploymentManager{}
}

func (v *VSHNNextcloud) GetWorkloadName() string {
return v.GetName()
}
9 changes: 8 additions & 1 deletion apis/vshn/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnkeycloaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9776,6 +9776,7 @@ spec:
description: Service contains PostgreSQL DBaaS specific properties
properties:
access:
description: Access defines additional users and databases for this instance.
items:
properties:
database:
Expand Down Expand Up @@ -9837,6 +9838,7 @@ spec:
- "13"
- "14"
- "15"
- "16"
type: string
pgBouncerSettings:
description: PgBouncerSettings passes additional configuration to the pgBouncer instance.
Expand Down
41 changes: 41 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnmariadbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4843,6 +4843,47 @@ spec:
service:
description: Service contains MariaDB DBaaS specific properties
properties:
access:
description: Access defines additional users and databases for this instance.
items:
properties:
database:
description: Database is the name of the database to create, defaults to user.
type: string
privileges:
description: |-
Privileges specifies the privileges to grant the user. Please check
the database's docs for available privileges.
items:
type: string
type: array
user:
description: |-
User specifies the username. If all other fields are left empty
then a new database with the same name and all permissions will be created.
type: string
writeConnectionSecretToRef:
description: |-
WriteConnectionSecretToReference specifies the namespace and name of a
Secret to which any connection details for this user should
be written.
If not specified, a secret with the name $claimname-$username will be
created in the namespace where the claim is located.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
- namespace
type: object
required:
- user
type: object
type: array
mariadbSettings:
description: MariadbSettings contains additional MariaDB settings.
type: string
Expand Down
2 changes: 2 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnnextclouds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9773,6 +9773,7 @@ spec:
description: Service contains PostgreSQL DBaaS specific properties
properties:
access:
description: Access defines additional users and databases for this instance.
items:
properties:
database:
Expand Down Expand Up @@ -9834,6 +9835,7 @@ spec:
- "13"
- "14"
- "15"
- "16"
type: string
pgBouncerSettings:
description: PgBouncerSettings passes additional configuration to the pgBouncer instance.
Expand Down
2 changes: 2 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnpostgresqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4966,6 +4966,7 @@ spec:
description: Service contains PostgreSQL DBaaS specific properties
properties:
access:
description: Access defines additional users and databases for this instance.
items:
properties:
database:
Expand Down Expand Up @@ -5027,6 +5028,7 @@ spec:
- "13"
- "14"
- "15"
- "16"
type: string
pgBouncerSettings:
description: PgBouncerSettings passes additional configuration to the pgBouncer instance.
Expand Down
3 changes: 3 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnkeycloaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11556,6 +11556,8 @@ spec:
properties
properties:
access:
description: Access defines additional users and databases
for this instance.
items:
properties:
database:
Expand Down Expand Up @@ -11620,6 +11622,7 @@ spec:
- "13"
- "14"
- "15"
- "16"
type: string
pgBouncerSettings:
description: PgBouncerSettings passes additional configuration
Expand Down
43 changes: 43 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnmariadbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5567,6 +5567,49 @@ spec:
service:
description: Service contains MariaDB DBaaS specific properties
properties:
access:
description: Access defines additional users and databases
for this instance.
items:
properties:
database:
description: Database is the name of the database to
create, defaults to user.
type: string
privileges:
description: |-
Privileges specifies the privileges to grant the user. Please check
the database's docs for available privileges.
items:
type: string
type: array
user:
description: |-
User specifies the username. If all other fields are left empty
then a new database with the same name and all permissions will be created.
type: string
writeConnectionSecretToRef:
description: |-
WriteConnectionSecretToReference specifies the namespace and name of a
Secret to which any connection details for this user should
be written.
If not specified, a secret with the name $claimname-$username will be
created in the namespace where the claim is located.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
- namespace
type: object
required:
- user
type: object
type: array
mariadbSettings:
description: MariadbSettings contains additional MariaDB settings.
type: string
Expand Down
Loading

0 comments on commit fe04df7

Please sign in to comment.