Skip to content

Restore simplified relationships (updated) #3881

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

Merged
merged 35 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1ae1d97
Update registry to use service names for relationship names.
chadwcarlson Mar 20, 2024
53770e5
add-services/_index.md
chadwcarlson Mar 20, 2024
2dc7624
Merge branch 'ga-staging' into simplified-rels
chadwcarlson Mar 29, 2024
3488cf3
add-services/headless-chrome.md
chadwcarlson Mar 29, 2024
059742f
themes/../partials/examples/relationships.html
chadwcarlson Mar 29, 2024
5456008
themes/../partials/examples/servicedefn.html
chadwcarlson Mar 29, 2024
b80ffeb
themes/../shortcodes/endpoint-description.md
chadwcarlson Mar 29, 2024
9d07533
themes/../shortcodes/v2connect2app.md
chadwcarlson Mar 29, 2024
f8b3605
add-services/influxdb.md
chadwcarlson Mar 29, 2024
bc3d45f
Fix usage example indents and comment spacing.
chadwcarlson Mar 29, 2024
4d053ef
add-services/kafka
chadwcarlson Mar 29, 2024
20c70e6
add-services/memcached.
chadwcarlson Mar 29, 2024
5a1d374
Fix double = typo.
chadwcarlson Mar 29, 2024
7f0b133
add-services/mongodb.md
chadwcarlson Mar 29, 2024
fc733e8
endpoint-description > oracle-mysql fix
chadwcarlson Mar 29, 2024
8771be5
add-services/mysql/_index.md
chadwcarlson Mar 29, 2024
da9e817
add-services/mysql/mysql-replication.
chadwcarlson Mar 29, 2024
48170b5
add-services/network-storage
chadwcarlson Mar 29, 2024
907d7b3
add-services/opensearch.md
chadwcarlson Mar 29, 2024
e69ae10
add-services/postgresql
chadwcarlson Mar 29, 2024
d49de9e
add-services/rabbitmq.md
chadwcarlson Mar 29, 2024
74ac7f6
add-services/redis
chadwcarlson Mar 29, 2024
790efa5
add-services/solr.md
chadwcarlson Mar 29, 2024
ff036de
add-services/varnish
chadwcarlson Mar 29, 2024
d8d13d3
Fix random character mistake.
chadwcarlson Apr 1, 2024
b45500c
create-apps/_index.md
chadwcarlson Apr 1, 2024
9226f3e
create-apps/app-reference
chadwcarlson Apr 1, 2024
4cc9024
guides/drupal/redis.
chadwcarlson Apr 1, 2024
e0f2682
languages/elixir.
chadwcarlson Apr 1, 2024
93a9175
languages/java/migration
chadwcarlson Apr 1, 2024
2081c4e
languages/lisp.
chadwcarlson Apr 1, 2024
1672004
languages/ruby.
chadwcarlson Apr 1, 2024
17d5728
learn/tutorials/restrict-service-access
chadwcarlson Apr 1, 2024
30f18dd
create-apps/workers.
chadwcarlson Apr 1, 2024
aedecf3
[guides|get-started/stacks]/symfony/environment-variables
chadwcarlson Apr 1, 2024
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
38 changes: 19 additions & 19 deletions shared/data/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"description": "",
"disk": false,
"docs": {
"relationship_name": "chromeheadlessbrowser",
"service_name": "chromeheadless",
"relationship_name": "chrome-headless",
"service_name": "chrome-headless",
"url": "/add-services/headless-chrome.html"
},
"endpoint": "http",
Expand Down Expand Up @@ -100,7 +100,7 @@
"description": "A manufacture service for Elasticsearch",
"disk": true,
"docs": {
"relationship_name": "essearch",
"relationship_name": "elasticsearch",
"service_name": "elasticsearch",
"url": "/add-services/elasticsearch.html"
},
Expand Down Expand Up @@ -276,7 +276,7 @@
"description": "",
"disk": true,
"docs": {
"relationship_name": "influxdbdatabase",
"relationship_name": "influxdb",
"service_name": "influxdb",
"url": "/add-services/influxdb.html"
},
Expand Down Expand Up @@ -355,7 +355,7 @@
"description": "",
"disk": true,
"docs": {
"relationship_name": "kafkaqueue",
"relationship_name": "kafka",
"service_name": "kafka",
"url": "/add-services/kafka.html"
},
Expand Down Expand Up @@ -431,7 +431,7 @@
"repo_name": "mariadb",
"disk": true,
"docs": {
"relationship_name": "mariadbdatabase",
"relationship_name": "mariadb",
"service_name": "mariadb",
"url": "/add-services/mysql.html"
},
Expand Down Expand Up @@ -491,7 +491,7 @@
"repo_name": "mariadb",
"disk": true,
"docs": {
"relationship_name": "mysqldatabase",
"relationship_name": "mysql",
"service_name": "mysql",
"url": "/add-services/mysql.html"
},
Expand Down Expand Up @@ -547,7 +547,7 @@
"repo_name": "memcached",
"disk": false,
"docs": {
"relationship_name": "memcachedcache",
"relationship_name": "memcached",
"service_name": "memcached",
"url": "/add-services/memcached.html"
},
Expand All @@ -573,7 +573,7 @@
"repo_name": "mongodb",
"disk": true,
"docs": {
"relationship_name": "mongodbdatabase",
"relationship_name": "mongodb",
"service_name": "mongodb",
"url": "/add-services/mongodb.html"
},
Expand All @@ -598,8 +598,8 @@
"repo_name": "mongodb",
"disk": true,
"docs": {
"relationship_name": "mongodbdatabase",
"service_name": "mongodb",
"relationship_name": "mongodb-enterprise",
"service_name": "mongodb-enterprise",
"url": "/add-services/mongodb.html"
},
"endpoint": "mongodb",
Expand Down Expand Up @@ -712,7 +712,7 @@
"description": "A manufacture service for OpenSearch",
"disk": true,
"docs": {
"relationship_name": "ossearch",
"relationship_name": "opensearch",
"service_name": "opensearch",
"url": "/add-services/opensearch.html"
},
Expand Down Expand Up @@ -754,7 +754,7 @@
"repo_name": "oracle-mysql",
"disk": true,
"docs": {
"relationship_name": "oracledatabase",
"relationship_name": "oracle-mysql",
"service_name": "oracle-mysql",
"url": "/add-services/mysql.html"
},
Expand Down Expand Up @@ -844,7 +844,7 @@
"repo_name": "postgresql",
"disk": true,
"docs": {
"relationship_name": "postgresqldatabase",
"relationship_name": "postgresql",
"service_name": "postgresql",
"url": "/add-services/postgresql.html"
},
Expand Down Expand Up @@ -946,7 +946,7 @@
"repo_name": "rabbitmq",
"disk": true,
"docs": {
"relationship_name": "rabbitmqqueue",
"relationship_name": "rabbitmq",
"service_name": "rabbitmq",
"url": "/add-services/rabbitmq.html"
},
Expand Down Expand Up @@ -1002,7 +1002,7 @@
"repo_name": "redis",
"disk": false,
"docs": {
"relationship_name": "rediscache",
"relationship_name": "redis",
"service_name": "redis",
"url": "/add-services/redis.html"
},
Expand Down Expand Up @@ -1150,7 +1150,7 @@
"repo_name": "solr",
"disk": true,
"docs": {
"relationship_name": "solrsearch",
"relationship_name": "solr",
"service_name": "solr",
"url": "/add-services/solr.html"
},
Expand Down Expand Up @@ -1206,7 +1206,7 @@
"repo_name": "varnish",
"disk": false,
"docs": {
"relationship_name": "varnishstats",
"relationship_name": "varnish",
"service_name": "varnish",
"url": "/add-services/varnish.html"
},
Expand Down Expand Up @@ -1236,7 +1236,7 @@
"description": "",
"disk": true,
"docs": {
"relationship_name": "vault_secret",
"relationship_name": "vault-kms",
"service_name": "vault-kms",
"url": "/add-services/vault.html"
},
Expand Down
72 changes: 36 additions & 36 deletions sites/platform/src/add-services/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ All service configuration happens in the `{{< vendor/configfile "services" >}}`
Configure your service in the following pattern:

```yaml {configFile="services"}
{{% snippet name="SERVICE_NAME" config="service" %}}
# The name of the service container. Must be unique within a project.
SERVICE_NAME:
type: {{<variable "SERVICE_TYPE" >}}:{{<variable "VERSION" >}}
# Other options...
{{% /snippet %}}
```

An example service configuration for two databases might look like this:

```yaml {configFile="services"}
{{% snippet name="database1" config="service" %}}
# The name of the service container. Must be unique within a project.
mariadb:
type: mariadb:{{% latest "mariadb" %}}
disk: 2048
{{% /snippet %}}
{{% snippet name="database2" config="service" globKey="false" %}}
# The name of the service container. Must be unique within a project.
postgresql:
type: postgresql:{{% latest "postgresql" %}}
disk: 1024
{{% /snippet %}}
```

This YAML file is a dictionary defining all of the services you want to use.
The top-level key is a custom service name ({{<variable "SERVICE_NAME" >}}; in the example, `database1` and `database2`), which you use to identify the service in step 2.
The top-level key is a custom service name ({{<variable "SERVICE_NAME" >}}; in the example, `mariadb` and `postgresql`), which you use to identify the service in step 2.

You can give it any name you want with lowercase alphanumeric characters, hyphens, and underscores.

Expand All @@ -70,7 +70,7 @@ The following table presents the keys you can define for each service:
| `disk` | `integer` | For some services | The size in [MB](/glossary.md#mb) of the [persistent disk](#disk) allocated to the service. Can't be set for memory-resident-only services such as `memcache` and `redis`. Limited by your plan settings. |
| `size` | `string` | | How many CPU and memory [resources to allocate](#size) to the service. Possible values are `AUTO`, `S`, `M`, `L`, `XL`, `2XL`, and `4XL`. Limited by your plan settings.<BR><BR>When `AUTO` applies, available resources are automatically balanced out based on the number of containers on your plan, so that no container is oversized compared to the others. To view the actual sizes of your containers, check the **Environment Configuration** section in your deployment [activity logs](../increase-observability/logs/access-logs.md#activity-logs). |
| `configuration` | dictionary | For some services | Some services have additional specific configuration options that can be defined here, such as specific endpoints. See the given service page for more details. |
| `relationships` | dictionary | For some services | Some services require a relationship to your app. The content of the dictionary has the same type as the `relationships` dictionary for [app configuration](../create-apps/app-reference.md#relationships). The `endpoint_name` for apps is always `http`. |
| `relationships` | dictionary | For some services | Some services require a relationship to your app. The content of the dictionary has the same type as the `relationships` dictionary for [app configuration](/create-apps/app-reference.md#relationships). The `endpoint_name` for apps is always `http`. |

##### Disk

Expand All @@ -90,46 +90,46 @@ Note that service containers in preview environments are always set to size `S`.

### 2. Connect the service

Once you have configured a service, you need to create a relationship to connect it to an app.
This is done in your [app configuration for relationships](../create-apps/app-reference.md#relationships).

The relationship follows this pattern:
To connect the service, use the following configuration:

```yaml {configFile="app"}
{{% snippet name="<APP_NAME>" config="app" root="false"%}}

# Other options...

# Relationships enable an app container's access to a service.
# The example below shows simplified configuration leveraging a default service (identified from the relationship name) and a default endpoint.
# See the Application reference for all options for defining relationships and endpoints.
relationships:
{{< variable "RELATIONSHIP_NAME" >}}: "{{< variable "SERVICE_NAME" >}}:{{< variable "ENDPOINT" >}}"
{{% /snippet %}}
{{% snippet name="SERVICE_NAME" config="service" placeholder="true"%}}
type: {{<variable "SERVICE_TYPE" >}}:{{<variable "VERSION" >}}
# Other options...
{{% /snippet %}}
{{<variable "SERVICE_NAME" >}}:
```

You can define `<SERVICE_NAME>` as you like, so long as it's unique between all defined services
and matches in both the application and services configuration.

The example above leverages [default endpoint](/create-apps/app-reference#relationships) configuration for relationships.
That is, it uses default endpoints behind-the-scenes, providing a [relationship](/create-apps/app-reference#relationships)
(the network address a service is accessible from) that is identical to the _name_ of that service.

Depending on your needs, instead of default endpoint configuration,
you can use [explicit endpoint configuration](/create-apps/app-reference#relationships).

An example relationship to connect to the databases given in the [example in step 1](#1-configure-the-service):

```yaml {configFile="app"}
{{< snippet name="<APP_NAME>" config="app" root="false">}}

# Other options...

# Relationships enable an app container's to a service.
# Relationships enable an app container's access to a service.
relationships:
mysql_database: "database1:mysql"
postgresql_database: "database2:postgresql"
{{% /snippet %}}
{{% snippet name="database1" config="service" placeholder="true" %}}
mariadb:
postgresql:
```

```yaml {configFile="services"}
mariadb:
type: mariadb:{{% latest "mariadb" %}}
disk: 2048
{{% /snippet %}}
{{% snippet name="database2" config="service" globKey="false" placeholder="true" %}}
postgresql:
type: postgresql:{{% latest "postgresql" %}}
disk: 1024
{{% /snippet %}}
```

As with the service name, you can give the relationship any name you want
Expand Down Expand Up @@ -201,17 +201,17 @@ To get the credentials for a given service, run the following command:
You get output like the following:

```yaml
database:
mariadb:
-
username: user
scheme: mysql
service: database
service: mariadb
fragment: null
ip: 198.51.100.37
hostname: abcdefghijklm1234567890123.database.service._.eu.{{< vendor/urlraw "hostname" >}}
hostname: abcdefghijklm1234567890123.mariadb.service._.eu.{{< vendor/urlraw "hostname" >}}
public: false
cluster: abcdefgh1234567-main-abcd123
host: database.internal
host: mariadb.internal
rel: mysql
query:
is_master: true
Expand All @@ -220,10 +220,10 @@ database:
type: 'mariadb:10.6'
port: 3306
host_mapped: false
url: 'mysql://user:@database.internal:3306/main'
url: 'mysql://user:@mariadb.internal:3306/main'
```

With this example, you can connect to the `database` relationship
With this example, you can connect to the `mariadb` relationship
with the user `user`, an empty password, and the database name `main` (from the `path`).
The `url` property shows a full database connection that can be used from your app.

Expand Down
6 changes: 3 additions & 3 deletions sites/platform/src/add-services/headless-chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Puppeteer can be used to generate PDFs and screenshots of web pages, automate fo
"ip": "123.456.78.90",
"hostname": "azertyuiopqsdfghjklm.chromeheadless.service._.eu-1.{{< vendor/urlraw "hostname" >}}",
"cluster": "azertyuiop-main-7rqtwti",
"host": "chromeheadlessbrowser.internal",
"host": "chromeheadless.internal",
"rel": "http",
"scheme": "http",
"type": "chrome-headless:{{< latest "chrome-headless" >}}",
Expand Down Expand Up @@ -103,7 +103,7 @@ Using the [Node.js Config Reader library](../development/variables/use-variables
const platformsh = require('platformsh-config');

const config = platformsh.config();
const credentials = config.credentials('chromeheadlessbrowser');
const credentials = config.credentials('chromeheadless');
```

and use them to define the `browserURL` parameter of `puppeteer.connect()` within an `async` function:
Expand All @@ -112,7 +112,7 @@ and use them to define the `browserURL` parameter of `puppeteer.connect()` withi
exports.getBrowser = async function (url) {
try {
// Connect to chrome-headless using pre-formatted puppeteer credentials
const formattedURL = config.formattedCredentials('chromeheadlessbrowser', 'puppeteer');
const formattedURL = config.formattedCredentials('chromeheadless', 'puppeteer');
const browser = await puppeteer.connect({browserURL: formattedURL});

...
Expand Down
Loading
Loading