diff --git a/pkg/apis/cpo.opensource.cybertec.at/v1/crds.go b/pkg/apis/cpo.opensource.cybertec.at/v1/crds.go index 73132338..4b07713c 100644 --- a/pkg/apis/cpo.opensource.cybertec.at/v1/crds.go +++ b/pkg/apis/cpo.opensource.cybertec.at/v1/crds.go @@ -1186,6 +1186,15 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{ "region": { Type: "string", }, + "account": { + Type: "string", + }, + "key": { + Type: "string", + }, + "keyType": { + Type: "string", + }, "schedule": { Type: "object", Properties: map[string]apiextv1.JSONSchemaProps{ diff --git a/pkg/apis/cpo.opensource.cybertec.at/v1/postgresql_type.go b/pkg/apis/cpo.opensource.cybertec.at/v1/postgresql_type.go index 98b9e3ce..4582d203 100644 --- a/pkg/apis/cpo.opensource.cybertec.at/v1/postgresql_type.go +++ b/pkg/apis/cpo.opensource.cybertec.at/v1/postgresql_type.go @@ -288,6 +288,9 @@ type Repo struct { Resource string `json:"resource"` Endpoint string `json:"endpoint"` Region string `json:"region"` + Account string `json:"account"` + Key string `json:"key"` + KeyType string `json:"keyType"` Schedule map[string]string `json:"schedule"` Volume `json:"volume,omitempty"` } diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 3af900a8..dd8c4373 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -2935,11 +2935,7 @@ func ensurePath(file string, defaultDir string, defaultFile string) string { func (c *Cluster) generatePgbackrestConfigmap() (*v1.ConfigMap, error) { config := "[db]\npg1-path = /home/postgres/pgdata/pgroot/data\npg1-port = 5432\npg1-socket-path = /var/run/postgresql/\n" config += "\n[global]\nlog-path = /home/postgres/pgdata/pgbackrest/log\nspool-path = /home/postgres/pgdata/pgbackrest/spool-path" - config += "\ntls-server-address=*" - config += "\ntls-server-ca-file = /etc/pgbackrest/certs/pgbackrest.ca-roots" - config += "\ntls-server-cert-file = /etc/pgbackrest/certs/pgbackrest-client.crt" - config += "\ntls-server-key-file = /etc/pgbackrest/certs/pgbackrest-client.key" - config += "\ntls-server-auth = " + c.clientCommonName() + "=*" + if c.Postgresql.Spec.Backup != nil && c.Postgresql.Spec.Backup.Pgbackrest != nil { if global := c.Postgresql.Spec.Backup.Pgbackrest.Global; global != nil { for k, v := range global { @@ -2950,20 +2946,43 @@ func (c *Cluster) generatePgbackrestConfigmap() (*v1.ConfigMap, error) { if len(repos) >= 1 { for i, repo := range repos { - if repo.Storage == "pvc" { + switch repo.Storage { + case "pvc": c.logger.Debugf("DEBUG_OUTPUT %s %s", c.clusterName().Name, c.Namespace) + config += "\ntls-server-address=*" + config += "\ntls-server-ca-file = /etc/pgbackrest/certs/pgbackrest.ca-roots" + config += "\ntls-server-cert-file = /etc/pgbackrest/certs/pgbackrest-client.crt" + config += "\ntls-server-key-file = /etc/pgbackrest/certs/pgbackrest-client.key" + config += "\ntls-server-auth = " + c.clientCommonName() + "=*" config += "\nrepo" + fmt.Sprintf("%d", i+1) + "-host = " + c.clusterName().Name + "-pgbackrest-repo-host-0." + c.serviceName(ClusterPods) + "." + c.Namespace + ".svc." + c.OpConfig.ClusterDomain config += "\nrepo" + fmt.Sprintf("%d", i+1) + "-host-ca-file = /etc/pgbackrest/certs/pgbackrest.ca-roots" config += "\nrepo" + fmt.Sprintf("%d", i+1) + "-host-cert-file = /etc/pgbackrest/certs/pgbackrest-client.crt" config += "\nrepo" + fmt.Sprintf("%d", i+1) + "-host-key-file = /etc/pgbackrest/certs/pgbackrest-client.key" config += "\nrepo" + fmt.Sprintf("%d", i+1) + "-host-type = tls" config += "\nrepo" + fmt.Sprintf("%d", i+1) + "-host-user = postgres" - } else { + + case "s3": config += fmt.Sprintf("\n%s-%s-bucket = %s", repo.Name, repo.Storage, repo.Resource) config += fmt.Sprintf("\n%s-%s-endpoint = %s", repo.Name, repo.Storage, repo.Endpoint) config += fmt.Sprintf("\n%s-%s-region = %s", repo.Name, repo.Storage, repo.Region) config += fmt.Sprintf("\n%s-type = %s", repo.Name, repo.Storage) + + case "gcs": + config += fmt.Sprintf("\n%s-%s-bucket = %s", repo.Name, repo.Storage, repo.Resource) + config += fmt.Sprintf("\n%s-%s-key = /etc/pgbackrest/conf.d/%s", repo.Name, repo.Storage, repo.Key) + config += fmt.Sprintf("\n%s-%s-key-type = %s", repo.Name, repo.Storage, repo.KeyType) + config += fmt.Sprintf("\n%s-type = %s", repo.Name, repo.Storage) + + case "azure": + config += fmt.Sprintf("\n%s-%s-container = %s", repo.Name, repo.Storage, repo.Resource) + config += fmt.Sprintf("\n%s-%s-endpoint = %s", repo.Name, repo.Storage, repo.Endpoint) + config += fmt.Sprintf("\n%s-%s-key = %s", repo.Name, repo.Storage, repo.Key) + config += fmt.Sprintf("\n%s-%s-account = %s", repo.Name, repo.Storage, repo.Account) + + config += fmt.Sprintf("\n%s-type = %s", repo.Name, repo.Storage) + default: } + } } }