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

feat: support multiple configurations via configmaps #230

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

boonware
Copy link
Collaborator

Description

Currently the operator supports only one definition of configuration YAML in the InstanaAgent custom resource. This PR adds support for defining multiple configurations and merging them.

Problem

Consider the the problem of deploying the operator to monitor multiple DB2 instances in a cluster. To configure the DB2 plugin, the following configuration is needed:

com.instana.plugin.db2:
  remote:
    - ...

Note that this supports a list of configurations, one for each DB2 instance. This configuration may not be known at deployment time for the operator. Automation for deploying each DB2 instance must update this configuration by inserting its own details into the list, however, this will result in consistency problems if multiple automation instances try to update their details at the same time.

Solution

  • The problem described above is solved by allowing configuration sections to be defined in a ConfigMap with the special label instana.io/agent-config=true. The operator uses the Kubernetes API to find all such resources in the cluster, and merges their configuration into the configuration_yaml field read from InstanaAgent custom resource.
  • The merge strategy for the configuration_yaml data is as follows:
    1. If the field is present in a config map but not present in the custom resource, then the field is copied from the config map into the custom resource.
    2. If the field is present in a config map and present in the custom resource, and if the type of the field is a list then the list entries from the config map are appended to the corresponding list in the custom resource.
    3. If the field is present in a config map and present in the custom resource, and if the type of the field is not a list, no change is made to the custom resource.
    4. If the field is present in the custom resource but not present in the config map, no change is made to the custom resource.

Example

  • Consider the InstanaAgent custom resource with the following YAML in the configuration_yaml field:
key1: value1
  • Consider one ConfigMap with the following YAML in its configuration_yaml field under data:
key2: value2
com.instana.plugin.db2:
  remote:
    - host: host1
  • Consider another ConfigMap with the following YAML in its configuration_yaml field under data:
com.instana.plugin.db2:
  remote:
    - host: host2
  • The configuration YAML, as loaded by the operator, will be as follows:
key1: value1
key2: value2
com.instana.plugin.db2:
  remote:
    - host: host1
    - host: host2

Signed-off-by: J. Harte <[email protected]>
Signed-off-by: J. Harte <[email protected]>
Signed-off-by: J. Harte <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant