Skip to content

Proposals

Anton Kremenetsky edited this page May 16, 2025 · 2 revisions

Review

The section with a proposals in review.

Many-to-many (nested) relations in manifests

Consider the problem where under a single resource there are several nested entities. For instance, under a node set can be more than one node.

Groups

Ability to make groups of elements using special resource Core.group. Special context {{LOCAL}} to have access to internal resources in the scope of current iteration.

Name: FooElement
SchemaVersion: 1
Version: "0.0.1"

Requires:
  Core: [">= 0.0.0", "< 1.0.0"] 

Resources:
  Core.artifacts:
    controller:
      source: "https://github.com/orgs/infraguys/images/controller.img"
    template:
      source: "https://github.com/orgs/infraguys/templates/template.j2"

  Core.groups:
    replicas: 3
    resources:
        Core.nodes:
          controller:
            cores: 1
            ram: 1024
            image: "{{RESOURCE.Core.artifacts.controller.image_uuid}}"
            node_type: "VM"

        Core.configs:
          controller_conf:
            path: "/etc/controller/controller.env"
            target:
              kind: "node"
              # Accessing to the node in the current scope
              node: "{{LOCAL.Core.nodes.controller.uuid}}"
            body:
              kind: "template"
              template: "{{RESOURCE.Core.artifacts.template.location}}"
              params:
                # Accessing to the node in the current scope
                node_ip: "{{LOCAL.Core.nodes.controller.ipv4}}"
            on_change:
              kind: "command"
              command: "systemctl restart controller.service"

Context

Key features:

  • Explicitly define contexts using special resource Core.contexts. The Core.contexts resources allows to define data structure in convenient format.
  • A new kind for configuration template_context that can work with contexts and use the same templates.
Name: FooElement
SchemaVersion: 1
Version: "0.0.1"

Requires:
  Core: [">= 0.0.0", "< 1.0.0"] 

Resources:
  Core.artifacts:
    controller:
      source: "https://github.com/orgs/infraguys/images/controller.img"
    template:
      source: "https://github.com/orgs/infraguys/templates/template.j2"

  Core.sets:
    controller:
      replicas: 3
      cores: 1
      ram: 1024
      image: "{{RESOURCE.Core.artifacts.controller.image_uuid}}"
      node_type: "VM"

  # NOTE(akremenetsky): In my opinion it's very closes to `Values` functionality
  Core.contexts:
    # Use a special context to form data in convient format.
    controller:
      # `set_getter`. A context to get data from a set and prepare it for the configuration.
      # The context will form matching among nodes and its ip addresses and hostnames.
      kind: "set_getter"
      set: "{{RESOURCE.Core.sets.controller.uuid}}"
      attributes:
        - hostname
        - ipv4
    controller_data_fetcher:
      kind: "http"
      cmd: "https://github.com/orgs/infraguys/data/binary"

  Core.configs:
    controller_conf:
      path: "/etc/controller/controller.env"
      target:
        # Work with sets
        kind: "set"
        set: "{{LOCAL.Core.sets.controller.uuid}}"
      body:
        # Special kind to work with sets and contexts  
        kind: "template_context"

        # The same template as for the node case.
        template: "{{RESOURCE.Core.artifacts.template.location}}"

        params:
          # Reference to the context. The `template_context` know how to
          # match IP addresses from the context with the template
          node_ip: "{{RESOURCE.Core.contexts.controller.ipv4}}"
      on_change:
        kind: "command"
        command: "systemctl restart controller.service"

Config context

Key features

  • The same as the case above but the context is an internal entity of the configuration.
Name: FooElement
SchemaVersion: 1
Version: "0.0.1"

Requires:
  Core: [">= 0.0.0", "< 1.0.0"] 

Resources:
  Core.artifacts:
    controller:
      source: "https://github.com/orgs/infraguys/images/controller.img"
    template:
      source: "https://github.com/orgs/infraguys/templates/template.j2"

  Core.sets:
    controller:
      replicas: 3
      cores: 1
      ram: 1024
      image: "{{RESOURCE.Core.artifacts.controller.image_uuid}}"
      node_type: "VM"

  # NOTE(akremenetsky): In my opinion it's very closes to `Values` functionality
  Core.contexts:
    # Use a special context to form data in convient format.
    controller:
      # `set_getter`. A context to get data from a set and prepare it for the configuration.
      # The context will form matching among nodes and its ip addresses and hostnames.
      kind: "set_getter"
      set: "{{RESOURCE.Core.sets.controller.uuid}}"
      attributes:
        - hostname
        - ipv4
    controller_data_fetcher:
      kind: "http"
      cmd: "https://github.com/orgs/infraguys/data/binary"

  Core.configs:
    controller_conf:
      # Local context definition.
      context:
        # `set_getter`. A context to get data from a set and prepare it for the configuration.
        # The context will form matching among nodes and its ip addresses and hostnames.
        kind: "set_getter"
        set: "{{RESOURCE.Core.sets.controller.uuid}}"
        attributes:
          - hostname
          - ipv4
      path: "/etc/controller/controller.env"
      target:
        # Work with sets
        kind: "set"
        set: "{{LOCAL.Core.sets.controller.uuid}}"
      body:
        # Special kind to work with sets and contexts  
        kind: "template_context"

        # The same template as for the node case.
        template: "{{RESOURCE.Core.artifacts.template.location}}"

        params:
          # Reference to the context. The `template_context` know how to
          # match IP addresses from the context with the template.
          node_ip: "{{SELF.context.ipv4}}"
      on_change:
        kind: "command"
        command: "systemctl restart controller.service"

Clone this wiki locally