Skip to content

Commit

Permalink
Merge pull request kiwigrid#4 from eloo/feature/use-namespace
Browse files Browse the repository at this point in the history
Use NAMESPACE env variable to search on a specific namespace
  • Loading branch information
pulledtim authored Aug 1, 2018
2 parents 9505bcb + bc4c402 commit 92aa169
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ Example for a simple deployment can be found in `example.yaml`. Depending on the
- required: true
- type: string

- `NAMESPACE`
- description: If specified, the sidecar will search for config-maps inside this namespace
- required: false
- type: string

- `REQ_URL`
- description: URL to which send a request after a configmap got reloaded
- required: false
Expand All @@ -51,5 +56,3 @@ Example for a simple deployment can be found in `example.yaml`. Depending on the
- description: If you use POST you can also provide json payload
- required: false
- type: json


8 changes: 7 additions & 1 deletion sidecar/sidecar.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ def removeFile(folder, filename):
def watchForChanges(label, targetFolder, url, method, payload):
v1 = client.CoreV1Api()
w = watch.Watch()
for event in w.stream(v1.list_config_map_for_all_namespaces):
stream = None
namespace = os.getenv("NAMESPACE")
if namespace is None:
stream = w.stream(v1.list_config_map_for_all_namespaces)
else:
stream = w.stream(v1.list_namespaced_config_map, namespace=namespace)
for event in stream:
metadata = event['object'].metadata
if metadata.labels is None:
continue
Expand Down

0 comments on commit 92aa169

Please sign in to comment.