From 158a7c314c3da1fbf915c9eeb14989ad99af4f35 Mon Sep 17 00:00:00 2001 From: sbezverk Date: Mon, 12 Dec 2016 08:43:06 -0500 Subject: [PATCH] PoC DaemonSet configmap monitor --- README.md | 4 ++- configmap-monitor.yaml | 82 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 configmap-monitor.yaml diff --git a/README.md b/README.md index 9481beb..4737121 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# configmap-monitor \ No newline at end of file +# configmap-monitor + +PoC DaemonSet restart on configmap change diff --git a/configmap-monitor.yaml b/configmap-monitor.yaml new file mode 100644 index 0000000..b46cccd --- /dev/null +++ b/configmap-monitor.yaml @@ -0,0 +1,82 @@ +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: configmap-updater + namespace: default +spec: + template: + metadata: + labels: + component: configmap-monitor + system: kube + annotations: + pod.alpha.kubernetes.io/initialized: "true" + pod.alpha.kubernetes.io/init-containers: '[ + { + "name": "copy-config", + "image": "docker.io/port/centos-binary-kolla-kube-toolbox:3.0.1", + "command": [ + "/bin/sh", + "-c", + "cp -a /tmp/main-process-configmap/..data/* /tmp/pod-main-config/; + kubectl get configmap main-process-configmap -o json | jq -r ''.metadata.resourceVersion '' > /tmp/configmap-monitor/configmap-version.txt; " + ], + "volumeMounts": [ + { + "name": "pod-main-config", + "mountPath": "/tmp/pod-main-config" + }, + { + "name": "configmap-monitor", + "mountPath": "/tmp/configmap-monitor" + }, + { + "name": "main-process-configmap", + "mountPath": "/tmp/main-process-configmap" + } + ] + } + ]' + spec: + containers: + - image: docker.io/port/centos-binary-kolla-kube-toolbox:3.0.1 + name: main + livenessProbe: + exec: + command: + - /bin/bash + - -c + - | + original_version=$(