This is an automated email from the ASF dual-hosted git repository. eamonford pushed a commit to branch async-history in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git
commit 6ebf49f12bf9803fd052a02b15063d3beacc394c Author: thomas loubrieu <[email protected]> AuthorDate: Wed Aug 5 10:38:57 2020 -0700 SDAP-266: add README note on synchronization of configmap with local path (#14) Co-authored-by: thomas loubrieu <[email protected]> --- config_operator/README.md | 14 ++++++++++++-- config_operator/config_operator/main.py | 17 ++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/config_operator/README.md b/config_operator/README.md index 5f02804..d102d10 100644 --- a/config_operator/README.md +++ b/config_operator/README.md @@ -2,13 +2,23 @@ ## Purpose -Component which synchonizes local configuration in a directory, on a file system, or configuration files managed in a git repository with kubernetes configMap. -This helps to make a configuration managed by the operators in a single place (git, host file system) available in the kubernetes cluster. +Component which synchonizes configuration in a remote **GIT** repository with kubernetes configMap. +This helps to make a configuration managed by the operators in a single place (git) available in the kubernetes cluster. For SDAP, it is used to make the configuration of the collections to be ingested available to the ingester service pods. The component runs as a kubernetes operator (see containerization section) +To synchronize a configuration from a **local directory** on kubernetes hosts, you should use the following commands: + + kubectl create configmap collections-config --from-file=/opt/sdap-collection-config/ -n <namespace> + +To update the configmap from the same directory run: + + kubectl create configmap collections-config --from-file=/opt/sdap-collection-config/ -o yaml --dry-run | kubectl replace -n <namespace> -f - + + + # Developers git clone ... diff --git a/config_operator/config_operator/main.py b/config_operator/config_operator/main.py index 45d530f..fbbbe6b 100644 --- a/config_operator/config_operator/main.py +++ b/config_operator/config_operator/main.py @@ -1,14 +1,16 @@ import logging import asyncio import kopf -from config_operator.config_source import RemoteGitConfig +from config_operator.config_source import RemoteGitConfig, LocalDirConfig from config_operator.k8s import K8sConfigMap logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) -def create_config_synchronizer(spec, namespace): +UPDATE_EVERY_SECOND_PROPERTY = 'update-every-seconds' + +def create_git_config_synchronizer(spec, namespace): if 'git-url' not in spec.keys(): raise kopf.HandlerFatalError(f"git-url must be set.") if 'config-map' not in spec.keys(): @@ -20,7 +22,7 @@ def create_config_synchronizer(spec, namespace): logger.info(f'config-map = {config_map}') _kwargs = {} - for k in {'git-branch', 'git-username', 'git-token', 'update-every-seconds'}: + for k in {'git-branch', 'git-username', 'git-token', UPDATE_EVERY_SECOND_PROPERTY}: if k in spec: logger.info(f'{k} = {spec[k]}') _kwargs[k.replace('-', '_')] = spec[k] @@ -38,24 +40,25 @@ def create_config_synchronizer(spec, namespace): @kopf.on.create('sdap.apache.org', 'v1', 'gitbasedconfigs') def create_fn(body, spec, **kwargs): - logger.info(f'sdap config operator creation') + logger.info(f'sdap git config operator creation') namespace = body['metadata']['namespace'] msg = create_config_synchronizer(spec, namespace) - logger.info(f'sdap config operator created {msg}') + logger.info(f'sdap git config operator created {msg}') return {'message': msg} + @kopf.on.update('sdap.apache.org', 'v1', 'gitbasedconfigs') def update_fn(spec, status, namespace, **kwargs): - logger.info(f'sdap config operator update') + logger.info(f'sdap git config operator update') msg = create_config_synchronizer(spec, namespace) - logger.info(f'sdap config operator updated {msg}') + logger.info(f'sdap local config operator updated {msg}') return {'message': msg}
