From aa8b415fd4f72f3395ffcbf7d0f71950478420b8 Mon Sep 17 00:00:00 2001 From: Faizan Ahmad Date: Wed, 1 Aug 2018 14:41:11 +0500 Subject: [PATCH] [STK-322] Update readme to resolve any confusions (#9) * Update readme to resolve any confusions * Add new heading * Remove unnecessary deployment commands from readme * Set watch globally to true for jumbo manifest * Update chart version to resolve conflicts * Update readme with deploy with helm --- README.md | 38 ++++++++++++------- .../kubernetes/chart/reloader/values.yaml | 2 +- deployments/kubernetes/manifests/rbac.yaml | 6 +-- deployments/kubernetes/reloader.yaml | 10 ++--- .../templates/chart/values.yaml.tmpl | 2 +- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index d792714a..ef78b22d 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ## Problem -We would like to watch if some change happens in `ConfigMap` and `Secret` objects and then perform certain upgrade on relevant `Deployment`, `Deamonset` and `Statefulset` +We would like to watch if some change happens in `ConfigMap` and `Secret` objects and then perform rolling upgrade on relevant `Deployment`, `Deamonset` and `Statefulset` ## Solution -Reloader can watch any changes in `ConfigMap` and `Secret` objects and update or recreate Pods for their associated `Deployments`, `Deamonsets` and `Statefulsets`. In this way Pods can get the latest changes in `ConfigMap` or `Secret` objects. +Reloader can watch changes in `ConfigMap` and `Secret` and do rolling upgrades on Pods with their associated `Deployments`, `Deamonsets` and `Statefulsets`. **NOTE:** This controller has been inspired from [configmapController](https://github.com/fabric8io/configmapcontroller) @@ -30,11 +30,19 @@ metadata: secret.reloader.stakater.com/reload: "foo" ``` +## How Reloader works + Then, providing `Reloader` is running, whenever you edit the `ConfigMap` or `Secret` called `foo` the Reloader will update the `Deployment` by adding the environment variable: ``` -STAKATER_FOO_REVISION=${reloaderRevision} +STAKATER_FOO_CONFIGMAP=${reloaderRevisionHash} ``` +Or if the change is detected in secret +``` +STAKATER_FOO_SECRET=${reloaderRevisionHash} +``` + +`reloaderRevisionHash` is the change in secret or configmap that is converted into SHA1. This value gets updated every time when reloader detects any change. This then triggers a rolling upgrade of your deployment's pods to use the new configuration. @@ -42,27 +50,31 @@ Same procedure can be followed to perform rolling upgrade on `Deamonsets` and `S ## Deploying to Kubernetes -You can deploy Reloader by running the following kubectl commands: - -```bash -kubectl apply -f rbac.yaml -n -kubectl apply -f deployment.yaml -n -``` +You can deploy Reloader by following methods: ### Vanilla Manifests You can apply vanilla manifests by running the following command ```bash -kubecl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml +kubectl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml ``` ### Helm Charts -Or alternatively if you configured `helm` on your cluster, you can deploy Reloader via helm chart located under `deployments/kubernetes/chart/reloader` folder. +Alternatively if you have configured helm on your cluster, you can add reloader to helm from our public chart repository and deploy it via helm using below mentioned commands -### Monitor All namespaces -You can monitor all namespaces in cluster by setting the `watchGlobally` flag to `true` in manifest file. + ```bash +helm repo add stakater https://stakater.github.io/stakater-charts + +helm repo update + +helm install stakater/reloader +``` + +## Monitor All namespaces + +By default Reloader gets deployed in `default` namespace and watches changes `secrets` and `configmaps` in all namespaces. ## Help diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index 310d780e..cbdfe012 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -12,4 +12,4 @@ reloader: name: stakater/reloader tag: "0.0.6" pullPolicy: IfNotPresent - watchGlobally: false \ No newline at end of file + watchGlobally: true \ No newline at end of file diff --git a/deployments/kubernetes/manifests/rbac.yaml b/deployments/kubernetes/manifests/rbac.yaml index 04ed4516..91d6adc1 100644 --- a/deployments/kubernetes/manifests/rbac.yaml +++ b/deployments/kubernetes/manifests/rbac.yaml @@ -14,7 +14,7 @@ metadata: name: reloader --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: Role +kind: ClusterRole metadata: labels: app: reloader @@ -51,7 +51,7 @@ rules: - patch --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: RoleBinding +kind: ClusterRoleBinding metadata: labels: app: reloader @@ -65,7 +65,7 @@ metadata: namespace: default roleRef: apiGroup: rbac.authorization.k8s.io - kind: Role + kind: ClusterRole name: reloader-role subjects: - kind: ServiceAccount diff --git a/deployments/kubernetes/reloader.yaml b/deployments/kubernetes/reloader.yaml index b6876ea8..66906915 100644 --- a/deployments/kubernetes/reloader.yaml +++ b/deployments/kubernetes/reloader.yaml @@ -29,10 +29,6 @@ spec: spec: containers: - env: - - name: KUBERNETES_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace image: "stakater/reloader:0.0.6" imagePullPolicy: IfNotPresent name: reloader @@ -54,7 +50,7 @@ metadata: name: reloader --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: Role +kind: ClusterRole metadata: labels: app: reloader @@ -91,7 +87,7 @@ rules: - patch --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: RoleBinding +kind: ClusterRoleBinding metadata: labels: app: reloader @@ -105,7 +101,7 @@ metadata: namespace: default roleRef: apiGroup: rbac.authorization.k8s.io - kind: Role + kind: ClusterRole name: reloader-role subjects: - kind: ServiceAccount diff --git a/deployments/kubernetes/templates/chart/values.yaml.tmpl b/deployments/kubernetes/templates/chart/values.yaml.tmpl index 13e5e09b..f267fe85 100644 --- a/deployments/kubernetes/templates/chart/values.yaml.tmpl +++ b/deployments/kubernetes/templates/chart/values.yaml.tmpl @@ -12,4 +12,4 @@ reloader: name: {{ getenv "DOCKER_IMAGE" }} tag: "{{ getenv "VERSION" }}" pullPolicy: IfNotPresent - watchGlobally: false \ No newline at end of file + watchGlobally: true \ No newline at end of file