Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the SQL backend #17057

Merged
merged 5 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 1 addition & 63 deletions docs/pages/reference/backends.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ no need to configure a backend.

| Data type | Description | Supported storage backends |
| - | - | - |
| core cluster state | Cluster configuration (e.g. users, roles, auth connectors) and identity (e.g. certificate authorities, registered nodes, trusted clusters). | Local directory (SQLite), etcd, AWS DynamoDB, GCP Firestore, self-hosted PostgreSQL/CockroachDB (Preview) |
| core cluster state | Cluster configuration (e.g. users, roles, auth connectors) and identity (e.g. certificate authorities, registered nodes, trusted clusters). | Local directory (SQLite), etcd, AWS DynamoDB, GCP Firestore |
| audit events | JSON-encoded events from the audit log (e.g. user logins, RBAC changes) | Local directory, AWS DynamoDB, GCP Firestore |
| session recordings | Raw terminal recordings of interactive user sessions | Local directory, AWS S3 (and any S3-compatible product), GCP Cloud Storage |
| teleport instance state | ID and credentials of a non-auth teleport instance (e.g. node, proxy) | Local directory |
Expand Down Expand Up @@ -684,68 +684,6 @@ teleport:
Teleport will default to a local file system for the audit log, i.e.
`/var/lib/teleport/log` on an auth server.

## PostgreSQL/CockroachDB (Preview)

The PostgreSQL/CockroachDB backend supports storing Teleport cluster state
in a self-hosted database instance.

<Admonition
type="tip"
title="NOTE"
>
The PostgreSQL/CockroachDB backend is currently in Preview.
</Admonition>

Connections require mutual TLS authentication. Be sure to configure your
database instance to support certificate authentication before configuring
the Teleport PostgreSQL/CockroachDB backend.
See [PostgreSQL Certificate Authentication](https://www.postgresql.org/docs/current/auth-cert.html) to configure PostgreSQL
or [Authenticating to CockroachDB Self-Hosted Clusters](https://www.cockroachlabs.com/docs/stable/authentication.html) to configure CockroachDB.

Once your self-hosted database instance has been configured to support
certificate authentication, configure all Teleport Auth servers to use the backend
by setting the storage section in the Teleport configuration file.

```yaml
teleport:
storage:
# Type of backend: either "postgres" or "cockroachdb".
type: cockroachdb
# The host:port of the database instance.
addr: "cockroachdb.example.com:26257"
# Optional database name. Defaults to "teleport".
database: "teleport"
# Authentication settings.
tls:
# Path to the database user's certificate.
client_cert_file: "/path/to/certs/client.dbuser.crt"
# Path to the database user's private key.
client_key_file: "/path/to/certs/client.dbuser.key"
# Path to the trusted certificate authority
# used to generate the client certificates.
ca_file: "/path/to/cockroachdb.cas"
```

Teleport will attempt to create a new database if the configured database does
not exist. Creating a database requires `CREATEDB` privileges for the Teleport
user. See PostgreSQL's [CREATE ROLE](https://www.postgresql.org/docs/current/sql-createrole.html)
documentation for details.

```shell
$ psql -d postgres
postgres=# CREATE ROLE dbuser CREATEDB;
```

If you do not wish to grant `CREATEDB` privileges to the Teleport user, be
sure to create a database and grant all privileges on the database
to the Teleport user before starting Teleport.

```shell
$ psql -d postgres
postgres=# CREATE DATABASE teleport;
postgres=# GRANT ALL PRIVILEGES ON DATABASE teleport TO dbuser;
```

## SQLite

The Auth Service uses the SQLite backend when no `type` is specified in the
Expand Down
34 changes: 2 additions & 32 deletions lib/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"strings"
"time"

"github.com/gravitational/teleport/api/types"
"github.com/gravitational/trace"

"github.com/jonboulle/clockwork"

"github.com/gravitational/teleport/api/types"
)

// Forever means that object TTL will not expire unless deleted
Expand Down Expand Up @@ -232,36 +232,6 @@ func (p Params) GetString(key string) string {
return s
}

// Cleanse fixes an issue with yamlv2 decoding nested sections to
// map[interface{}]interface{} rather than map[string]interface{}.
// ObjectToStruct will fail on the former. yamlv3 corrects this behavior.
// All non-string keys are dropped.
func (p Params) Cleanse() {
for key, value := range p {
if mapValue, ok := value.(map[interface{}]interface{}); ok {
p[key] = convertParams(mapValue)
}
}
}

// convertParams converts from a map[interface{}]interface{} to
// map[string]interface{} recursively. All non-string keys are dropped.
// This function is called by Params.Cleanse.
func convertParams(from map[interface{}]interface{}) (to map[string]interface{}) {
to = make(map[string]interface{}, len(from))
for key, value := range from {
strKey, ok := key.(string)
if !ok {
continue
}
if mapValue, ok := value.(map[interface{}]interface{}); ok {
value = convertParams(mapValue)
}
to[strKey] = value
}
return to
}

// NoLimit specifies no limits
const NoLimit = 0

Expand Down
25 changes: 0 additions & 25 deletions lib/backend/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,3 @@ func TestRangeEnd(t *testing.T) {
})
}
}

func TestParamsCleanse(t *testing.T) {
source := Params{
"Addr": "localhost:345",
"TLS": map[interface{}]interface{}{
"CAFile": "/path/to/file",
"Certs": map[interface{}]interface{}{
"Cert": "cert.crt",
"Key": "key.crt",
},
},
}
expect := Params{
"Addr": "localhost:345",
"TLS": map[string]interface{}{
"CAFile": "/path/to/file",
"Certs": map[string]interface{}{
"Cert": "cert.crt",
"Key": "key.crt",
},
},
}
source.Cleanse()
require.Equal(t, source, expect)
}
91 changes: 0 additions & 91 deletions lib/backend/postgres/azure.go

This file was deleted.

Loading