diff --git a/stable/reloader/.helmignore b/stable/reloader/.helmignore new file mode 100644 index 0000000000..9e1690881f --- /dev/null +++ b/stable/reloader/.helmignore @@ -0,0 +1,2 @@ +# OWNERS file for Kubernetes +OWNERS diff --git a/stable/reloader/Chart.yaml b/stable/reloader/Chart.yaml new file mode 100644 index 0000000000..c0126458e9 --- /dev/null +++ b/stable/reloader/Chart.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +name: reloader +description: Reloader chart that runs on kubernetes +version: 1.0.0 +appVersion: 0.0.18 +keywords: + - Reloader + - kubernetes +home: https://github.com/stakater/Reloader +sources: +- https://github.com/stakater/Reloader +icon: https://raw.githubusercontent.com/stakater/Reloader/master/assets/web/reloader-round-100px.png +maintainers: +- name: rasheedamir + email: rasheed@aurorasolutions.io +- name: waseem-h + email: waseemhassan@stakater.com +- name: faizanahmad055 + email: faizan.ahmad55@outlook.com +- name: kahootali + email: ali.kahoot@aurorasolutions.io +- name: ahmadiq + email: ahmad@aurorasolutions.io +- name: ahsan-storm + email: ahsanmuhammad1@outlook.com diff --git a/stable/reloader/OWNERS b/stable/reloader/OWNERS new file mode 100644 index 0000000000..31ea124be1 --- /dev/null +++ b/stable/reloader/OWNERS @@ -0,0 +1,14 @@ +approvers: +- faizanahmad055 +- kahootali +- ahmadiq +- waseem-h +- rasheedamir +- ahsan-storm +reviewers: +- faizanahmad055 +- kahootali +- ahmadiq +- waseem-h +- rasheedamir +- ahsan-storm diff --git a/stable/reloader/README.md b/stable/reloader/README.md new file mode 100644 index 0000000000..fb5375e5e3 --- /dev/null +++ b/stable/reloader/README.md @@ -0,0 +1,163 @@ +# ![](https://raw.githubusercontent.com/stakater/Reloader/master/assets/web/reloader-round-100px.png) RELOADER + +A Kubernetes controller to watch changes in ConfigMap and Secrets and then restart pods for Deployment, StatefulSet and DaemonSet + +[![Get started with Stakater](https://stakater.github.io/README/stakater-github-banner.png)](http://stakater.com/?utm_source=Reloader&utm_medium=github) + +## Problem + +We would like to watch if some change happens in `ConfigMap` and/or `Secret`; then perform a rolling upgrade on relevant `Deployment`, `Deamonset` and `Statefulset` + +## Solution + +Reloader can watch changes in `ConfigMap` and `Secret` and do rolling upgrades on Pods with their associated `Deployments`, `Deamonsets` and `Statefulsets`. + +## How to use Reloader + +### Configmap + +For a `Deployment` called `foo` have a `ConfigMap` called `foo-configmap`. Then add this annotation to main metadata of your `Deployment` + +```yaml +kind: Deployment +metadata: + annotations: + configmap.reloader.stakater.com/reload: "foo-configmap" +spec: + template: + metadata: +``` + +Use comma separated list to define multiple configmaps. + +```yaml +kind: Deployment +metadata: + annotations: + configmap.reloader.stakater.com/reload: "foo-configmap,bar-configmap,baz-configmap" +spec: + template: + metadata: +``` + +### Secret + +For a `Deployment` called `foo` have a `Secret` called `foo-secret`. Then add this annotation to main metadata of your `Deployment` + +```yaml +kind: Deployment +metadata: + annotations: + secret.reloader.stakater.com/reload: "foo-secret" +spec: + template: + metadata: +``` + +Use comma separated list to define multiple secrets. + +```yaml +kind: Deployment +metadata: + annotations: + secret.reloader.stakater.com/reload: "foo-secret,bar-secret,baz-secret" +spec: + template: + metadata: +``` + +## Usage + +The following quickstart let's you set up Reloader quickly: + +Update the `values.yaml` and set the following properties + +| Key | Description | Example | Default Value | +|---------------|---------------------------------------------------------------------------|------------------------------------|------------------------------------| +| watchGlobally | Option to watch configmap and secrets in all namespaces | `true` | `true` | +| matchLabels | Additional match Labels for selector | `{}` | `{}` | +| deployment.annotations | Annotations for deployment | `{}` | `{}` | +| deployment.labels | Labels for deployment | `provider` | `provider` | +| deployment.image.name | Image name for reloader | `stakater/reloader` | `stakater/reloader` | +| deployment.image.tag | Image tag for reloader | `0.0.18` | `0.0.18` | +| deployment.image.pullPolicy | Image pull policy for reloader | `IfNotPresent` | `IfNotPresent` | +| deployment.env.open | Additional key value pair as environment variables | `STORAGE: local` | `` | +| deployment.env.secret | Additional Key value pair as environment variables. It gets the values based on keys from default reloader secret if any | `BASIC_AUTH_USER: test` | `` | +| deployment.env.field | Additional environment variables to expose pod information to containers. | `POD_IP: status.podIP` | `` | +| rbac.enabled | Option to create rbac | `true` | `true` | +| rbac.labels | Additional labels for rbac | `{}` | `{}` | +| serviceAccount.create | Option to create serviceAccount | `true` | `true` | +| serviceAccount.name | Name of serviceAccount | `reloader` | `reloader` | + +## Deploying to Kubernetes + +You can deploy Reloader by following methods: + +### Helm Charts + +if you have configured helm on your cluster, you can add reloader to helm from public chart repository and deploy it via helm using below mentioned commands + + ```bash +helm repo add stable https://kubernetes-charts.storage.googleapis.com/ + +helm repo update + +helm install stable/reloader +``` + +**Note:** By default reloader watches in all namespaces. To watch in single namespace, please run following command. It will install reloader in `test` namespace which will only watch `Deployments`, `Deamonsets` and `Statefulsets` in `test` namespace. + +```bash +helm install stable/reloader --set reloader.watchGlobally=false --namespace test +``` + +## Help + +### Documentation +You can find more documentation [here](https://github.com/stakater/Reloader/tree/master/docs) + +### Have a question? +File a GitHub [issue](https://github.com/stakater/Reloader/issues), or send us an [email](mailto:stakater@gmail.com). + +### Talk to us on Slack + +Join and talk to us on Slack for discussing Reloader + +[![Join Slack](https://stakater.github.io/README/stakater-join-slack-btn.png)](https://stakater-slack.herokuapp.com/) +[![Chat](https://stakater.github.io/README/stakater-chat-btn.png)](https://stakater.slack.com/messages/CC5S05S12) + +## Contributing + +### Bug Reports & Feature Requests + +Please use the [issue tracker](https://github.com/stakater/Reloader/issues) to report any bugs or file feature requests. + +### Developing + +PRs are welcome. In general, we follow the "fork-and-pull" Git workflow. + + 1. **Fork** the repo on GitHub + 2. **Clone** the project to your own machine + 3. **Commit** changes to your own branch + 4. **Push** your work back up to your fork + 5. Submit a **Pull request** so that we can review your changes + +NOTE: Be sure to merge the latest from "upstream" before making a pull request! + +## Changelog + +View our closed [Pull Requests](https://github.com/stakater/Reloader/pulls?q=is%3Apr+is%3Aclosed). + +## License + +Apache2 © [Stakater](http://stakater.com) + +## About + +[Reloader](https://github.com/stakater/Reloader) is maintained by [Stakater][website]. Like it? Please let us know at + +See [our other projects][community] +or contact us in case of professional services and queries on + + [website]: http://stakater.com/ + [community]: https://github.com/stakater/ diff --git a/stable/reloader/templates/NOTES.txt b/stable/reloader/templates/NOTES.txt new file mode 100644 index 0000000000..f2a38752a4 --- /dev/null +++ b/stable/reloader/templates/NOTES.txt @@ -0,0 +1,7 @@ +- For a `Deployment` called `foo` have a `ConfigMap` called `foo-configmap`. Then add this annotation to main metadata of your `Deployment` + configmap.reloader.stakater.com/reload: "foo-configmap" + +- For a `Deployment` called `foo` have a `Secret` called `foo-secret`. Then add this annotation to main metadata of your `Deployment` + secret.reloader.stakater.com/reload: "foo-secret" + +- After successful installation, your pods will get rolling updates when a change in data of configmap or secret will happen. diff --git a/stable/reloader/templates/_helpers.tpl b/stable/reloader/templates/_helpers.tpl new file mode 100644 index 0000000000..a149b1cf0d --- /dev/null +++ b/stable/reloader/templates/_helpers.tpl @@ -0,0 +1,37 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "reloader-name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" | lower -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "reloader-fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "reloader-labels.selector" -}} +app: {{ template "reloader-name" . }} +release: {{ .Release.Name | quote }} +{{- end -}} + +{{- define "reloader-labels.chart" -}} +chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" +heritage: {{ .Release.Service | quote }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "serviceAccountName" -}} +{{- if .Values.reloader.serviceAccount.create -}} + {{ default (include "reloader-fullname" .) .Values.reloader.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.reloader.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/stable/reloader/templates/clusterrole.yaml b/stable/reloader/templates/clusterrole.yaml new file mode 100644 index 0000000000..08d85aaf95 --- /dev/null +++ b/stable/reloader/templates/clusterrole.yaml @@ -0,0 +1,39 @@ +--- +{{- if and .Values.reloader.watchGlobally (.Values.reloader.rbac.enabled) }} +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + labels: +{{ include "reloader-labels.chart" . | indent 4 }} +{{ include "reloader-labels.selector" . | indent 4 }} +{{- if .Values.reloader.rbac.labels }} +{{ toYaml .Values.reloader.rbac.labels | indent 4 }} +{{- end }} +{{- if .Values.reloader.matchLabels }} +{{ toYaml .Values.reloader.matchLabels | indent 4 }} +{{- end }} + name: {{ template "reloader-name" . }}-role + namespace: {{ .Release.Namespace }} +rules: + - apiGroups: + - "" + resources: + - secrets + - configmaps + verbs: + - list + - get + - watch + - apiGroups: + - "extensions" + - "apps" + resources: + - deployments + - daemonsets + - statefulsets + verbs: + - list + - get + - update + - patch +{{- end }} diff --git a/stable/reloader/templates/clusterrolebinding.yaml b/stable/reloader/templates/clusterrolebinding.yaml new file mode 100644 index 0000000000..01d909448c --- /dev/null +++ b/stable/reloader/templates/clusterrolebinding.yaml @@ -0,0 +1,25 @@ +{{- if and .Values.reloader.watchGlobally (.Values.reloader.rbac.enabled) }} +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + labels: +{{ include "reloader-labels.chart" . | indent 4 }} +{{ include "reloader-labels.selector" . | indent 4 }} +{{- if .Values.reloader.rbac.labels }} +{{ toYaml .Values.reloader.rbac.labels | indent 4 }} +{{- end }} +{{- if .Values.reloader.matchLabels }} +{{ toYaml .Values.reloader.matchLabels | indent 4 }} +{{- end }} + name: {{ template "reloader-name" . }}-role-binding + namespace: {{ .Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "reloader-name" . }}-role +subjects: + - kind: ServiceAccount + name: {{ template "serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/stable/reloader/templates/deployment.yaml b/stable/reloader/templates/deployment.yaml new file mode 100644 index 0000000000..d1baaf920e --- /dev/null +++ b/stable/reloader/templates/deployment.yaml @@ -0,0 +1,74 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: +{{- if .Values.reloader.deployment.annotations }} + annotations: +{{ toYaml .Values.reloader.deployment.annotations | indent 4 }} +{{- end }} + labels: +{{ include "reloader-labels.chart" . | indent 4 }} +{{ include "reloader-labels.selector" . | indent 4 }} +{{- if .Values.reloader.deployment.labels }} +{{ toYaml .Values.reloader.deployment.labels | indent 4 }} +{{- end }} +{{- if .Values.reloader.matchLabels }} +{{ toYaml .Values.reloader.matchLabels | indent 4 }} +{{- end }} + name: {{ template "reloader-name" . }} +spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: +{{ include "reloader-labels.selector" . | indent 6 }} +{{- if .Values.reloader.matchLabels }} +{{ toYaml .Values.reloader.matchLabels | indent 6 }} +{{- end }} + template: + metadata: + labels: +{{ include "reloader-labels.selector" . | indent 8 }} +{{ include "reloader-labels.chart" . | indent 8 }} +{{- if .Values.reloader.deployment.labels }} +{{ toYaml .Values.reloader.deployment.labels | indent 8 }} +{{- end }} +{{- if .Values.reloader.matchLabels }} +{{ toYaml .Values.reloader.matchLabels | indent 8 }} +{{- end }} + spec: + containers: + - env: + {{- range $name, $value := .Values.reloader.deployment.env.open }} + {{- if not (empty $value) }} + - name: {{ $name | quote }} + value: {{ $value | quote }} + {{- end }} + {{- end }} + {{- $secret_name := include "reloader-fullname" . }} + {{- range $name, $value := .Values.reloader.deployment.env.secret }} + {{- if not ( empty $value) }} + - name: {{ $name | quote }} + valueFrom: + secretKeyRef: + name: {{ $secret_name }} + key: {{ $name | quote }} + {{- end }} + {{- end }} + {{- range $name, $value := .Values.reloader.deployment.env.field }} + {{- if not ( empty $value) }} + - name: {{ $name | quote }} + valueFrom: + fieldRef: + fieldPath: {{ $value | quote}} + {{- end }} + {{- end }} + {{- if eq .Values.reloader.watchGlobally false }} + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + {{- end }} + image: "{{ .Values.reloader.deployment.image.name }}:{{ .Values.reloader.deployment.image.tag }}" + imagePullPolicy: {{ .Values.reloader.deployment.image.pullPolicy }} + name: {{ template "reloader-name" . }} + serviceAccountName: {{ template "serviceAccountName" . }} diff --git a/stable/reloader/templates/role.yaml b/stable/reloader/templates/role.yaml new file mode 100644 index 0000000000..cff7e69e44 --- /dev/null +++ b/stable/reloader/templates/role.yaml @@ -0,0 +1,38 @@ +{{- if and (not (.Values.reloader.watchGlobally)) (.Values.reloader.rbac.enabled) }} +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: Role +metadata: + labels: +{{ include "reloader-labels.chart" . | indent 4 }} +{{ include "reloader-labels.selector" . | indent 4 }} +{{- if .Values.reloader.rbac.labels }} +{{ toYaml .Values.reloader.rbac.labels | indent 4 }} +{{- end }} +{{- if .Values.reloader.matchLabels }} +{{ toYaml .Values.reloader.matchLabels | indent 4 }} +{{- end }} + name: {{ template "reloader-name" . }}-role + namespace: {{ .Release.Namespace }} +rules: + - apiGroups: + - "" + resources: + - secrets + - configmaps + verbs: + - list + - get + - watch + - apiGroups: + - "extensions" + - "apps" + resources: + - deployments + - daemonsets + - statefulsets + verbs: + - list + - get + - update + - patch +{{- end }} diff --git a/stable/reloader/templates/rolebinding.yaml b/stable/reloader/templates/rolebinding.yaml new file mode 100644 index 0000000000..8db19274e0 --- /dev/null +++ b/stable/reloader/templates/rolebinding.yaml @@ -0,0 +1,25 @@ +{{- if and (not (.Values.reloader.watchGlobally)) (.Values.reloader.rbac.enabled) }} +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: RoleBinding +metadata: + labels: +{{ include "reloader-labels.chart" . | indent 4 }} +{{ include "reloader-labels.selector" . | indent 4 }} +{{- if .Values.reloader.rbac.labels }} +{{ toYaml .Values.reloader.rbac.labels | indent 4 }} +{{- end }} +{{- if .Values.reloader.matchLabels }} +{{ toYaml .Values.reloader.matchLabels | indent 4 }} +{{- end }} + name: {{ template "reloader-name" . }}-role-binding + namespace: {{ .Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ template "reloader-name" . }}-role +subjects: + - kind: ServiceAccount + name: {{ template "serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/stable/reloader/templates/serviceaccount.yaml b/stable/reloader/templates/serviceaccount.yaml new file mode 100644 index 0000000000..461dd527e0 --- /dev/null +++ b/stable/reloader/templates/serviceaccount.yaml @@ -0,0 +1,15 @@ +{{- if .Values.reloader.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: +{{ include "reloader-labels.chart" . | indent 4 }} +{{ include "reloader-labels.selector" . | indent 4 }} +{{- if .Values.reloader.serviceAccount.labels }} +{{ toYaml .Values.reloader.serviceAccount.labels | indent 4 }} +{{- end }} +{{- if .Values.reloader.matchLabels }} +{{ toYaml .Values.reloader.matchLabels | indent 4 }} +{{- end }} + name: {{ template "serviceAccountName" . }} +{{- end }} diff --git a/stable/reloader/values.yaml b/stable/reloader/values.yaml new file mode 100644 index 0000000000..04199f44fc --- /dev/null +++ b/stable/reloader/values.yaml @@ -0,0 +1,32 @@ +reloader: + watchGlobally: true + matchLabels: {} + deployment: + annotations: {} + labels: + provider: stakater + group: com.stakater.platform + image: + name: stakater/reloader + tag: "0.0.18" + pullPolicy: IfNotPresent + # Support for extra environment variables. + env: + # Open supports Key value pair as environment variables. + open: + # secret supports Key value pair as environment variables. It gets the values based on keys from default reloader secret if any. + secret: + # field supports Key value pair as environment variables. It gets the values from other fields of pod. + field: + + rbac: + enabled: true + labels: {} + # Service account config for the agent pods + serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + labels: {} + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: reloader