Dependency

A Project can have other Projects as dependencies. Dependency can be either optional or required.

A most common scenario of using dependency is sharing resources between multiple projects or instances.

  • Project-A implements a database (e.g. Postgresql) and Project-B, Project-C access the database, instead of having database Pod in each Project.

  • Project-A implements a database and multiple instances of Project-B access the database.

There’re few steps to set up the dependency.

  • Project-A creates a ConfigMap or Secret with database connection information (service name, user, password, etc).

  • Project-A adds dependency.staroid.com/export label in the ConfigMap or Secret.

  • Project-B adds dependency.staroid.com/import label in the ConfigMap or Secret.

  • Project-B adds Project-A in deploy.dependencies staroid.yaml, under deploy.

For example

Project-A’s ConfigMap

kind: ConfigMap
apiVersion: v1
metadata:
  name: my-db-credentials
  labels:
    dependency.staroid.com/export: db-config  # Doesn't have to be the same to metadata.name
data:
  user: db_user
  pw: db_passwd
  my-db-namespace: "{{.Namespace}}"           # go template is supported.

Project-B’s ConfigMap can looks like

kind: ConfigMap
apiVersion: v1
metadata:
  name: app-db-config # Note that configmap name doesn't have to be the same with the one in Project-A.
  labels:
    dependency.staroid.com/import: db-config  # ConfigMap has the same value in label 'dependency.staroid.com/import' will be imported.
data:
  user: default_user        # will be overrided by Project-A's my-db-credentials when launch.
  pw: default_password      # will be overrided by Project-A's my-db-credentials when launch.
  my-db-namespace: default  # will be overrided by Project-A's my-db-credentials when launch.

Project-B also need to add Project-A (e.g. my-org/project-a) in staroid.yaml

...

deploy:
  dependencies:
  - project: my-org/project-a
    level: REQUIRED  # REQUIRED or OPTIONAL

...

When user launch Project-B, Launch Dialog will ask user to select an instance of Project-A running in the same Kubernetes cluster.

If Project-C (my-org/project-c) can implement the same functionality to Project-A and export the same information (e.g. fork of Project-A), Project-C can configure deploy.implements staroid.yaml, under deploy to make it available to Project-B.

...

deploy:
  implements: my-org/project-a

...

When user launch Project-B, Launch Dialog will ask user to select an instance of Project-A and Project-C running in the same Kubernetes cluster.

Template variable

Go template in data of an exported ConfigMap, stringData of an exported Secret will be evaluated with following variable.

Namespace

Current namespace of ConfigMap or Secret.