Services

List the Redis, RabbitMQ and databases your apps use once for the organization, and let each deployment share the running instance or get a copy of its own.

Several apps need the same Redis, RabbitMQ or database. A service is that thing, listed once for the organization. A deployment either shares the instance that is already running, or gets an own copy that is created with the deployment and removed with it.

Either way the apps keep their configuration. A service has a connection Secret with a fixed name (redis-connection), and the deployment's namespace holds a Secret and a Service of that name, whether they point at the shared instance or at its own copy.

What a service is

Services in the sidebar lists them: name, kind, source, where the shared instance runs, how many deployments use it (and how many of those share), and the connection Secret.

FieldMeaning
Name1 to 48 lowercase letters, digits and dashes. It is also the name of the Service apps connect to.
KindCache, Queue, Database or Other, for grouping.
SourceThe app the service is made from, which says its chart or folder. Add the chart or folder as an app first.
Connection secretThe Secret that holds the connection details. Defaults to the name followed by -connection.
Shared instanceOptional. The environment the shared instance runs in, its namespace there, and the Service in front of it (the service's name by default). Leave it empty and the service can only be an own copy.
api() { curl -fsS -H "Authorization: Bearer $WARDN_TOKEN" -H 'Content-Type: application/json' "$@"; }

api -X POST "$WARDN_API_URL/api/v1/services" -d '{
  "name": "redis",
  "kind": "cache",
  "appId": "'$APP_ID'",
  "shared": {"environmentId": "'$STAGING_ID'", "namespace": "shared-services"}
}'

A service that deployments use cannot be deleted.

How a deployment uses a service

On New deployment, Services lists the services the apps use. For each, choose Shared (in staging) or Own copy. The column on the right says what that means: Copied from staging, with a DNS alias or Created here, removed with the deployment. The same choice is on an existing deployment's settings.

Shared

Wardn does not render anything for a shared service. Before it applies the deployment, the cluster's operator does two things in the deployment's namespace, acting as the deployment's service account (wardn-deployer):

  1. It copies the connection Secret from the shared instance's namespace, under the same name. The copy is made inside the operator, in memory: the server never reads the Secret's value, and the value is not logged or sent anywhere. The copy is refreshed on every apply, so a rotated Secret reaches the deployment at its next apply.
  2. It makes a Service of type ExternalName with the service's name that points at the instance (redis-master.shared-services.svc.cluster.local), so the apps' existing configuration works unchanged.

What this needs:

  • The same cluster. A shared service is copied inside one cluster, so the deployment's cluster must be in the environment the instance runs in. Wardn refuses to share a service otherwise, and suggests an own copy.
  • Read access to that one Secret. The service account can do only what its role in the cluster lets it. Give wardn-deployer in the deployment's namespace get on the connection Secret in the instance's namespace, and nothing more. When it cannot read it the apply fails and says so.
  • The Secret exists. The instance has to have made it before the first apply.

Wardn marks what it makes with wardn.dev/shared-for and wardn.dev/shared-service labels and only ever changes or removes objects that carry them for that deployment. A Secret or Service somebody else made under the same name stops the apply rather than being overwritten. When a deployment stops sharing a service, the next apply removes its copy and alias.

Own copy

An own copy is the service's app, added to the deployment. It is rendered and applied into the deployment's namespace like any of its apps, so it is pruned with the deployment and carries its volumes with it. Switching a deployment back to shared removes the app, unless it is the deployment's only one.

Permissions

PermissionAllowsHeld by
service:readSee the organization's services.Owner, Admin, Organization reader
service:manageAdd, change and remove services. Never held by an agent.Owner, Admin

On this page