Skip to content

Commit ddbe303

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-255
2 parents aab8f66 + 71a2b23 commit ddbe303

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1849
-1590
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/pull_request.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
env:
99
DOCKER_FILE_PATH: Dockerfile
10-
GOLANG_VERSION: 1.17
10+
GOLANG_VERSION: 1.20.2
1111
KUBERNETES_VERSION: "1.18.0"
1212
KIND_VERSION: "0.10.0"
1313
REGISTRY: ghcr.io
@@ -40,7 +40,7 @@ jobs:
4040
- name: Run golangci-lint
4141
uses: golangci/golangci-lint-action@v3
4242
with:
43-
version: v1.50.1
43+
version: v1.51.1
4444
only-new-issues: false
4545
args: --timeout 10m
4646

.github/workflows/push.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
env:
99
DOCKER_FILE_PATH: Dockerfile
10-
GOLANG_VERSION: 1.17.7
10+
GOLANG_VERSION: 1.20.2
1111
KUBERNETES_VERSION: "1.18.0"
1212
KIND_VERSION: "0.10.0"
1313
HELM_REGISTRY_URL: "https://stakater.github.io/stakater-charts"
@@ -43,10 +43,10 @@ jobs:
4343
- name: Run golangci-lint
4444
uses: golangci/golangci-lint-action@v3
4545
with:
46-
version: v1.50.1
46+
version: v1.51.1
4747
only-new-issues: false
4848
args: --timeout 10m
49-
49+
5050
- name: Install kubectl
5151
run: |
5252
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"
@@ -138,7 +138,7 @@ jobs:
138138
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
139139
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
140140
org.opencontainers.image.revision=${{ github.sha }}
141-
141+
142142
##############################
143143
## Add steps to generate required artifacts for a release here(helm chart, operator manifest etc.)
144144
##############################
@@ -162,7 +162,7 @@ jobs:
162162
- name: Helm Template
163163
run: |
164164
helm template reloader deployments/kubernetes/chart/reloader/ > deployments/kubernetes/reloader.yaml
165-
helm template reloader deployments/kubernetes/chart/reloader/ --output-dir deployments/kubernetes/manifests/ && mv deployments/kubernetes/manifests/reloader/templates/* deployments/kubernetes/manifests/ && rm -r deployments/kubernetes/manifests/reloader
165+
helm template reloader deployments/kubernetes/chart/reloader/ --output-dir deployments/kubernetes/manifests && mv deployments/kubernetes/manifests/reloader/templates/* deployments/kubernetes/manifests/ && rm -r deployments/kubernetes/manifests/reloader
166166
167167
# Publish helm chart
168168
- name: Publish Helm chart
@@ -178,16 +178,16 @@ jobs:
178178
linting: on
179179
commit_username: stakater-user
180180
commit_email: stakater@gmail.com
181-
181+
182182
# Commit back changes
183183
- name: Commit files
184184
run: |
185185
git config --local user.email "stakater@gmail.com"
186186
git config --local user.name "stakater-user"
187-
git status
187+
git status
188188
git add .
189189
git commit -m "[skip-ci] Update artifacts" -a
190-
190+
191191
- name: Push changes
192192
uses: ad-m/github-push-action@master
193193
with:

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- "v*"
77

88
env:
9-
GOLANG_VERSION: 1.17.7
9+
GOLANG_VERSION: 1.20.2
1010

1111
jobs:
1212
build:
@@ -15,12 +15,12 @@ jobs:
1515

1616
steps:
1717
- name: Check out code
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919
with:
2020
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/
2121

2222
- name: Set up Go 1.x
23-
uses: actions/setup-go@v2
23+
uses: actions/setup-go@v3
2424
with:
2525
go-version: ${{ env.GOLANG_VERSION }}
2626
id: go

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ARG BUILDER_IMAGE
22
ARG BASE_IMAGE
33

44
# Build the manager binary
5-
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE:-golang:1.17.7} as builder
5+
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE:-golang:1.20.2} as builder
66

77
ARG TARGETOS
88
ARG TARGETARCH

README.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ metadata:
3131
annotations:
3232
reloader.stakater.com/auto: "true"
3333
spec:
34-
template: metadata:
34+
template:
35+
metadata:
3536
```
3637
3738
This will discover deploymentconfigs/deployments/daemonsets/statefulset/rollouts automatically where `foo-configmap` or `foo-secret` is being used either via environment variable or from volume mount. And it will perform rolling upgrade on related pods when `foo-configmap` or `foo-secret`are updated.
@@ -86,7 +87,8 @@ metadata:
8687
annotations:
8788
configmap.reloader.stakater.com/reload: "foo-configmap"
8889
spec:
89-
template: metadata:
90+
template:
91+
metadata:
9092
```
9193

9294
Use comma separated list to define multiple configmaps.
@@ -141,6 +143,7 @@ spec:
141143
- you may override the configmap annotation with the `--configmap-annotation` flag
142144
- you may override the secret annotation with the `--secret-annotation` flag
143145
- you may want to prevent watching certain namespaces with the `--namespaces-to-ignore` flag
146+
- you may want to watch only a set of namespaces with certain labels by using the `--namespace-selector` flag
144147
- you may want to prevent watching certain resources with the `--resources-to-ignore` flag
145148
- you can configure logging in JSON format with the `--log-format=json` option
146149
- you can configure the "reload strategy" with the `--reload-strategy=<strategy-name>` option (details below)
@@ -180,6 +183,25 @@ Reloader can be configured to ignore the resources `secrets` and `configmaps` by
180183

181184
`Note`: At one time only one of these resource can be ignored, trying to do it will cause error in Reloader. Workaround for ignoring both resources is by scaling down the reloader pods to `0`.
182185

186+
Reloader can be configured to watch only namespaces labeled with (one or more) labels of your choosing by using the `--namespace-selector` parameter, for example:
187+
```
188+
--namespace-selector=reloder:enabled,test:true
189+
```
190+
191+
Only namespaces labeled like the following namespace YAML will be watched:
192+
```yaml
193+
kind: Namespace
194+
apiVersion: v1
195+
metadata:
196+
...
197+
labels:
198+
reloder: enabled
199+
test: true
200+
...
201+
```
202+
If you want to select namespace only by the key of the label use ```*``` as the value.
203+
For example, for ```--namespace-selector=select-this:*``` all namespaces with label-key "select-this" will be selected regardless of the labels value
204+
183205
### Vanilla kustomize
184206

185207
You can also apply the vanilla manifests by running the following command
@@ -231,17 +253,32 @@ Reloader can be configured to ignore the resources `secrets` and `configmaps` by
231253

232254
`Note`: At one time only one of these resource can be ignored, trying to do it will cause error in helm template compilation.
233255

256+
Reloader can be configured to watch only namespaces labeled with (one or more) labels of your choosing by using the `namespaceSelector` parameter
257+
258+
| Parameter | Description | Type |
259+
| ---------------- | -------------------------------------------------------------- | ------- |
260+
| namespaceSelector | list of comma separated key:value namespace | string |
261+
234262
You can also set the log format of Reloader to json by setting `logFormat` to `json` in values.yaml and apply the chart
235263

236264
You can enable to scrape Reloader's Prometheus metrics by setting `serviceMonitor.enabled` or `podMonitor.enabled` to `true` in values.yaml file. Service monitor will be removed in future releases of reloader in favour of Pod monitor.
237265

238266
**Note:** Reloading of OpenShift (DeploymentConfig) and/or Argo Rollouts has to be enabled explicitly because it might not be always possible to use it on a cluster with restricted permissions. This can be done by changing the following parameters:
239267

240-
| Parameter | Description | Type |
241-
| ---------------- |------------------------------------------------------------------------------| ------- |
242-
| isOpenshift | Enable OpenShift DeploymentConfigs. Valid value are either `true` or `false` | boolean |
243-
| isArgoRollouts | Enable Argo Rollouts. Valid value are either `true` or `false` | boolean |
244-
| reloadOnCreate | Enable reload on create events. Valid value are either `true` or `false` | boolean |
268+
| Parameter | Description | Type |
269+
|------------------|------------------------------------------------------------------------------------------------------------------------------------------| ------- |
270+
| isOpenshift | Enable OpenShift DeploymentConfigs. Valid value are either `true` or `false` | boolean |
271+
| isArgoRollouts | Enable Argo Rollouts. Valid value are either `true` or `false` | boolean |
272+
| reloadOnCreate | Enable reload on create events. Valid value are either `true` or `false` | boolean |
273+
| syncAfterRestart | Enable sync after reloader restarts for **Add** events, works only when reloadOnCreate is `true`. Valid value are either `true` or `false` | boolean |
274+
275+
**ReloadOnCreate** reloadOnCreate controls how Reloader handles secrets being added to the cache for the first time. If reloadOnCreate is set to true:
276+
* Configmaps/secrets being added to the cache will cause Reloader to perform a rolling update of the associated workload.
277+
* When applications are deployed for the first time, Reloader will perform a rolling update of the associated workload.
278+
* If you are running Reloader in HA mode all workloads will have a rolling update performed when a new leader is elected.
279+
280+
If ReloadOnCreate is set to false:
281+
* Updates to configMaps/Secrets that occur while there is no leader will not be picked up by the new leader until a subsequent update of the configmap/secret occurs. In the worst case the window in which there can be no leader is 15s as this is the LeaseDuration.
245282

246283
## Help
247284

@@ -251,7 +288,7 @@ You can find more documentation [here](docs)
251288

252289
### Have a question?
253290

254-
File a GitHub [issue](https://github.com/stakater/Reloader/issues), or send us an [email](mailto:stakater@gmail.com).
291+
File a GitHub [issue](https://github.com/stakater/Reloader/issues), or send us an [email](mailto:hello@stakater.com).
255292

256293
### Talk to us on Slack
257294

deployments/kubernetes/chart/reloader/Chart.yaml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
apiVersion: v1
44
name: reloader
55
description: Reloader chart that runs on kubernetes
6-
version: v0.0.114
7-
appVersion: v0.0.114
6+
version: v1.0.20
7+
appVersion: v1.0.20
88
keywords:
99
- Reloader
1010
- kubernetes
@@ -16,16 +16,6 @@ maintainers:
1616
- name: Stakater
1717
email: hello@stakater.com
1818
- name: rasheedamir
19-
email: rasheed@aurorasolutions.io
20-
- name: waseem-h
21-
email: waseemhassan@stakater.com
19+
email: rasheed@stakater.com
2220
- name: faizanahmad055
2321
email: faizan.ahmad55@outlook.com
24-
- name: kahootali
25-
email: ali.kahoot@aurorasolutions.io
26-
- name: ahmadiq
27-
email: ahmad@aurorasolutions.io
28-
- name: ahsan-storm
29-
email: ahsanmuhammad1@outlook.com
30-
- name: ahmedwaleedmalik
31-
email: waleed@stakater.com

deployments/kubernetes/chart/reloader/templates/_helpers.tpl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ heritage: {{ .Release.Service | quote }}
2828
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
2929
{{- end -}}
3030

31+
{{/*
32+
Create pod anti affinity labels
33+
*/}}
34+
{{- define "reloader-podAntiAffinity" -}}
35+
podAntiAffinity:
36+
preferredDuringSchedulingIgnoredDuringExecution:
37+
- weight: 100
38+
podAffinityTerm:
39+
labelSelector:
40+
matchExpressions:
41+
- key: app
42+
operator: In
43+
values:
44+
- {{ template "reloader-fullname" . }}
45+
topologyKey: "kubernetes.io/hostname"
46+
{{- end -}}
47+
3148
{{/*
3249
Create the name of the service account to use
3350
*/}}
@@ -45,4 +62,4 @@ Create the annotations to support helm3
4562
{{- define "reloader-helm3.annotations" -}}
4663
meta.helm.sh/release-namespace: {{ .Release.Namespace | quote }}
4764
meta.helm.sh/release-name: {{ .Release.Name | quote }}
48-
{{- end -}}
65+
{{- end -}}

deployments/kubernetes/chart/reloader/templates/clusterrole.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ metadata:
1717
{{ toYaml .Values.reloader.matchLabels | indent 4 }}
1818
{{- end }}
1919
name: {{ template "reloader-fullname" . }}-role
20-
namespace: {{ .Release.Namespace }}
2120
rules:
2221
- apiGroups:
2322
- ""
@@ -32,6 +31,14 @@ rules:
3231
- list
3332
- get
3433
- watch
34+
{{- if .Values.reloader.namespaceSelector }}
35+
- apiGroups:
36+
- ""
37+
resources:
38+
- namespaces
39+
verbs:
40+
- get
41+
{{- end }}
3542
{{- if and (.Capabilities.APIVersions.Has "apps.openshift.io/v1") (.Values.reloader.isOpenshift) }}
3643
- apiGroups:
3744
- "apps.openshift.io"
@@ -77,4 +84,21 @@ rules:
7784
- get
7885
- update
7986
- patch
87+
{{- if .Values.reloader.enableHA }}
88+
- apiGroups:
89+
- "coordination.k8s.io"
90+
resources:
91+
- leases
92+
verbs:
93+
- create
94+
- get
95+
- update
96+
{{- end}}
97+
- apiGroups:
98+
- ""
99+
resources:
100+
- events
101+
verbs:
102+
- create
103+
- patch
80104
{{- end }}

deployments/kubernetes/chart/reloader/templates/clusterrolebinding.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ metadata:
1717
{{ toYaml .Values.reloader.matchLabels | indent 4 }}
1818
{{- end }}
1919
name: {{ template "reloader-fullname" . }}-role-binding
20-
namespace: {{ .Release.Namespace }}
2120
roleRef:
2221
apiGroup: rbac.authorization.k8s.io
2322
kind: ClusterRole
2423
name: {{ template "reloader-fullname" . }}-role
2524
subjects:
2625
- kind: ServiceAccount
2726
name: {{ template "reloader-serviceAccountName" . }}
28-
namespace: {{ .Release.Namespace }}
27+
namespace: {{ .Values.namespace | default .Release.Namespace }}
2928
{{- end }}

0 commit comments

Comments
 (0)