Compare commits

...

72 Commits

Author SHA1 Message Date
stakater-user
9d1733200a [skip-ci] Update artifacts 2022-05-26 15:33:56 +00:00
Faizan Ahmad
841db3c829 Merge pull request #310 from stakater/remove-docker-lint
Remove docker linting from Pull request
2022-05-26 17:11:18 +02:00
stakater-user
1155c981d6 [skip-ci] Update artifacts 2022-05-26 14:18:53 +00:00
faizanahmad055
d29c99ffef Remove docker linting from Pull request
Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
2022-05-26 14:57:51 +02:00
Abdul Haseeb
3e5b1d09b8 Merge pull request #308 from stakater/update-golang-cli-version
Update golang-cli package versions
2022-05-26 17:47:59 +05:00
faizanahmad055
61b7a88462 Update golang-cli package versions
Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
2022-05-26 14:46:32 +02:00
Faizan Ahmad
d9d986f1f2 Merge pull request #297 from karl-johan-grahn/doc-qa
feat(qa): add qa checks for dockerfile and documentation
2022-04-04 21:06:56 +02:00
stakater-user
42a25bfe64 [skip-ci] Update artifacts 2022-03-25 12:04:59 +00:00
Faizan Ahmad
df667b9c15 Merge pull request #296 from stefan-work/master
feat(kubernetes/chart): explicitly mount service-account-token in dep…
2022-03-25 12:57:47 +01:00
Stefan Klein
f1c71731d9 feat(kubernetes/chart): explicitly mount service-account-token in deployment 2022-03-25 12:09:10 +01:00
Karl-Johan Grahn
e2b14ab7b5 fix(qa): update dockerfile path 2022-03-21 21:32:49 +01:00
Karl-Johan Grahn
4592bd4331 feat(qa): add qa checks for dockerfile and documentation 2022-03-21 21:03:39 +01:00
stakater-user
e380fbaf03 [skip-ci] Update artifacts 2022-03-02 20:49:44 +00:00
Faizan Ahmad
2bce1352a3 Merge pull request #292 from alin-taranu/upgrade-go-version-to-1.17.7
Update go version to fix critical vulnerabilities
2022-03-02 21:42:39 +01:00
Alin Taranu
5b3b617f06 Update go version to fix critical vulnerabilites
The following CVEs should be fix by upgrading go version:
* CVE-2022-23806
* CVE-2022-23772
* CVE-2021-44717
* CVE-2022-23773
* CVE-2021-44716
* CVE-2021-41771
* CVE-2021-41772
2022-03-02 13:41:07 +01:00
stakater-user
5040a4236a [skip-ci] Update artifacts 2022-02-27 18:58:50 +00:00
Faizan Ahmad
f6cbc005fc Merge pull request #281 from ruinshe/add-container-sc-support
Add container security context support for Helm chart
2022-02-27 19:50:15 +01:00
stakater-user
91774c941f [skip-ci] Update artifacts 2022-02-27 18:40:03 +00:00
Faizan Ahmad
db0e127563 Merge pull request #282 from AyoyAB/feature/enable-internal-build
Enable internal builds without direct Internet access
2022-02-27 19:31:29 +01:00
John Allberg
3671d33447 Enable setting GOPROXY and GOPRIVATE during build. 2022-02-27 10:16:42 +01:00
John Allberg
e85176b5a7 Make build command more readable. 2022-02-27 10:16:42 +01:00
John Allberg
7941de60ac Enable setting builder and base image during build. 2022-02-27 10:16:38 +01:00
stakater-user
565612e421 [skip-ci] Update artifacts 2022-02-26 22:43:34 +00:00
Faizan Ahmad
31e247e3ae Merge pull request #291 from stakater/fix-reloading-on-create
Make reload on create optional
2022-02-26 23:22:54 +01:00
faizanahmad055
1e79b86f72 Update readme
Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
2022-02-20 00:00:04 +01:00
faizanahmad055
b5b684c67b Fix reload on create flag
Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
2022-02-19 23:23:33 +01:00
faizanahmad055
bbc6bd2dea Update go version
Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
2022-02-14 10:33:55 +01:00
faizanahmad055
61ce150d7c Make reload on create optional
Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
2022-02-13 19:53:49 +01:00
stakater-user
56e83ecde9 [skip-ci] Update artifacts 2022-02-13 12:16:49 +00:00
Faizan Ahmad
c33876508c Merge pull request #290 from ctschubel/master
add replicas config to helm-chart
2022-02-13 13:07:37 +01:00
ctschubel
55ea2e430e add replicas to values.yaml.tmpl 2022-02-10 19:33:29 +01:00
ctschubel
4beefc3f43 fix replica config value name in helm-chart 2022-02-10 16:05:03 +01:00
ctschubel
3b1d30141c add replicas config to helm-chart 2022-02-10 15:21:16 +01:00
Ruins He
fa75df8e96 feat(kubernetes/chart): add container security context configuration into values.yaml.tpl
Signed-off-by: Ruins He <lyhypacm@gmail.com>
2022-01-03 18:22:43 +08:00
Ruins He
21087aaddc feat(kubernetes/chart): add container security context support for Helm chart
Signed-off-by: Ruins He <lyhypacm@gmail.com>
2022-01-03 18:00:15 +08:00
stakater-user
766bc24241 [skip-ci] Update artifacts 2022-01-02 13:43:49 +00:00
Faizan Ahmad
8e3aad3b0e Merge pull request #280 from jsoref/issue-278
Add .Release.Namespace
2022-01-02 14:35:19 +01:00
Josh Soref
ce2866bf6a Add .Release.Namespace
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-01-02 01:46:17 -05:00
stakater-user
bcbaad8495 [skip-ci] Update artifacts 2021-11-08 21:27:34 +00:00
Faizan Ahmad
3346319082 Merge pull request #271 from stakater/fix-deployment-pipeline
Fix yaml error in deployment manifest
2021-11-08 22:17:38 +01:00
faizanahmad055
139aa43c1c Fix yaml error in deployment manifest
Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
2021-11-08 22:02:06 +01:00
Faizan Ahmad
11fdd40e41 Merge pull request #263 from Aenima4six2/aenima4six2/176
Issue 176 - Use pod templates annotations
2021-11-08 16:47:29 +01:00
aenima4six2
c4ce86cb0b 176 - Update helm chart with reloadStrategy support 2021-11-06 18:14:46 -04:00
aenima4six2
dfe7e9b3ca 176 - Add reload strategies to support pod annotation templates 2021-10-17 19:09:50 -04:00
stakater-user
1c29bfc084 [skip-ci] Update artifacts 2021-10-12 07:03:12 +00:00
Faizan Ahmad
c48e2bb8bb Merge pull request #269 from stakater/fix-reloader
Fix update path of reloader
2021-10-12 08:45:48 +02:00
hanzala1234
df40b5d02e Delete reloader.yam 2021-10-11 19:58:59 +05:00
hanzala1234
aa26a2222b Fix update path of reloader 2021-10-11 19:58:13 +05:00
stakater-user
f9d1a967c7 [skip-ci] Update artifacts 2021-10-11 14:43:27 +00:00
Faizan Ahmad
b2e1d3f0dd Merge pull request #268 from stakater/fix-pipeline
Generate manifest in separate file
2021-10-11 16:28:20 +02:00
hanzala
24478a9dd4 Update jumbo manifest in pipeline 2021-10-11 19:12:39 +05:00
hanzala
160525bd1f Fix command 2021-10-11 18:38:13 +05:00
hanzala
d9158ab602 Fix helm template command 2021-10-08 17:36:54 +05:00
hanzala
2b4cc64026 Generate manifest in separate file 2021-10-08 17:34:44 +05:00
stakater-user
ccd7dcb867 [skip-ci] Update artifacts 2021-09-30 08:29:26 +00:00
Faizan Ahmad
5c5c555a7f Merge pull request #264 from jamesgoodhouse/update_helm_notes
Update NOTES for Helm chart to be dynamic
2021-09-30 10:13:30 +02:00
James J. Goodhouse
273e4768f3 update helm chart NOTES to be dynamic 2021-09-28 09:16:49 -07:00
Ahmed Waleed Malik
69e359e9fc Merge pull request #259 from iamNoah1/better-readability
[skip-ci] better readiblity for example templates
2021-08-30 09:41:23 +05:00
Noah Ispas (iamNoah1)
e5352df348 better readiblity for example templates 2021-08-28 20:34:30 +02:00
stakater-user
f2b4e8e6c6 [skip-ci] Update artifacts 2021-07-30 06:35:22 +00:00
Ahmed Waleed Malik
99a38bff8e Merge pull request #254 from stakater/handle-resource-redeploy
fix: Reload pods after redeploy secrets or configmap
2021-07-30 11:20:35 +05:00
Ahmed Waleed Malik
d0aa627715 Merge pull request #253 from stakater/remove-unused-files
[skip-ci] Remove unused files
2021-07-30 10:56:58 +05:00
Waleed Malik
953cbe9d28 Reload resource if secret/configmap is re-created 2021-07-30 10:24:50 +05:00
Waleed Malik
f7873aba7b Update dependencies 2021-07-29 15:24:41 +05:00
Waleed Malik
f9728ecfff Add run target in Makefile 2021-07-29 15:24:30 +05:00
Waleed Malik
96a44153de Non-root user should be specified in numeric form in Dockerfile 2021-07-29 15:24:09 +05:00
Waleed Malik
cafbcbd2cb Update build image targetC 2021-07-29 14:56:43 +05:00
Waleed Malik
6397a35e32 Remove unused files 2021-07-29 14:33:04 +05:00
Waleed Malik
aea8592880 Update golangci-lint step in workflows 2021-07-29 14:32:56 +05:00
stakater-user
2aa514a34c [skip-ci] Update artifacts 2021-07-28 10:36:56 +00:00
Faizan Ahmad
ac39bc4eba Merge pull request #251 from aslafy-z/patch-1
docs(helm): podmonitor does not need service
2021-07-28 12:20:07 +02:00
Zadkiel
284d21686e docs(helm): podmonitor does not need service 2021-07-20 17:42:59 +02:00
35 changed files with 3288 additions and 480 deletions

View File

@@ -7,9 +7,9 @@ on:
env:
DOCKER_FILE_PATH: Dockerfile
GOLANG_VERSION: 1.15.2
GOLANG_VERSION: 1.17.7
KUBERNETES_VERSION: "1.18.0"
KIND_VERSION: "0.7.0"
KIND_VERSION: "0.10.0"
jobs:
build:
@@ -36,16 +36,29 @@ jobs:
run: |
make install
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0
golangci-lint run --timeout=10m ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2.3.0
with:
version: v1.45.2
only-new-issues: false
args: --timeout 10m
- name: Helm Lint
run: |
cd deployments/kubernetes/chart/reloader
helm lint
- name: Link check
uses: gaurav-nelson/github-action-markdown-link-check@v1
- name: Spell check
uses: errata-ai/vale-action@v1.5.0
with:
styles: https://github.com/errata-ai/write-good/releases/latest/download/write-good.zip
files: docs
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install kubectl
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"

View File

@@ -7,9 +7,9 @@ on:
env:
DOCKER_FILE_PATH: Dockerfile
GOLANG_VERSION: 1.15.2
GOLANG_VERSION: 1.17.7
KUBERNETES_VERSION: "1.18.0"
KIND_VERSION: "0.7.0"
KIND_VERSION: "0.10.0"
HELM_REGISTRY_URL: "https://stakater.github.io/stakater-charts"
jobs:
@@ -39,11 +39,13 @@ jobs:
run: |
make install
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0
golangci-lint run --timeout=10m ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2.3.0
with:
version: v1.45.2
only-new-issues: false
args: --timeout 10m
- name: Install kubectl
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"
@@ -68,7 +70,7 @@ jobs:
- name: Generate Tag
id: generate_tag
uses: anothrNick/github-tag-action@1.26.0
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }}
WITH_V: true
@@ -114,7 +116,7 @@ jobs:
# Generate tag for operator without "v"
- name: Generate Operator Tag
id: generate_operator_tag
uses: anothrNick/github-tag-action@1.26.0
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }}
WITH_V: false
@@ -129,7 +131,8 @@ jobs:
- name: Helm Template
run: |
helm template stakater deployments/kubernetes/chart/reloader/ > deployments/kubernetes/reloader.yaml
helm template reloader deployments/kubernetes/chart/reloader/ > deployments/kubernetes/reloader.yaml
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
# Publish helm chart
- name: Publish Helm chart
@@ -162,7 +165,7 @@ jobs:
branch: ${{ github.ref }}
- name: Push Latest Tag
uses: anothrNick/github-tag-action@1.26.0
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }}
WITH_V: true

View File

@@ -6,7 +6,7 @@ on:
- "v*"
env:
GOLANG_VERSION: 1.15.2
GOLANG_VERSION: 1.17.7
jobs:
build:

3
.gitignore vendored
View File

@@ -8,4 +8,5 @@ _gopath/
.DS_Store
.vscode
vendor
dist
dist
Reloader

7
.vale.ini Normal file
View File

@@ -0,0 +1,7 @@
StylesPath = spellingstyles
MinAlertLevel = warning
# Only check MarkDown files
[*.md]
BasedOnStyles = Vale

View File

@@ -1,8 +1,13 @@
ARG BUILDER_IMAGE
ARG BASE_IMAGE
# Build the manager binary
FROM --platform=${BUILDPLATFORM} golang:1.15.2 as builder
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE:-golang:1.17.7} as builder
ARG TARGETOS
ARG TARGETARCH
ARG GOPROXY
ARG GOPRIVATE
WORKDIR /workspace
@@ -19,14 +24,20 @@ COPY internal/ internal/
COPY pkg/ pkg/
# Build
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on go build -mod=mod -a -o manager main.go
RUN CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
GOPROXY=${GOPROXY} \
GOPRIVATE=${GOPRIVATE} \
GO111MODULE=on \
go build -mod=mod -a -o manager main.go
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
FROM ${BASE_IMAGE:-gcr.io/distroless/static:nonroot}
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot
USER 65532:65532
# Port for metrics and probes
EXPOSE 9090

View File

@@ -1,48 +1,57 @@
# note: call scripts from /scripts
.PHONY: default build builder-image binary-image test stop clean-images clean push apply deploy release release-all manifest push clean-image
.PHONY: default build build-image test stop push apply deploy release release-all manifest push
OS ?= linux
ARCH ?= ???
ALL_ARCH ?= arm64 arm amd64
BUILDER ?= reloader-builder-${ARCH}
BUILDER_IMAGE ?=
BASE_IMAGE ?=
BINARY ?= Reloader
DOCKER_IMAGE ?= stakater/reloader
# Default value "dev"
TAG ?= v0.0.75.0
REPOSITORY_GENERIC = ${DOCKER_IMAGE}:${TAG}
REPOSITORY_ARCH = ${DOCKER_IMAGE}:${TAG}-${ARCH}
# Default value "dev"
VERSION ?= 0.0.1
REPOSITORY_GENERIC = ${DOCKER_IMAGE}:${VERSION}
REPOSITORY_ARCH = ${DOCKER_IMAGE}:v${VERSION}-${ARCH}
BUILD=
GOCMD = go
GOFLAGS ?= $(GOFLAGS:)
LDFLAGS =
GOPROXY ?=
GOPRIVATE ?=
default: build test
install:
"$(GOCMD)" mod download
run:
go run ./main.go
build:
"$(GOCMD)" build ${GOFLAGS} ${LDFLAGS} -o "${BINARY}"
builder-image:
docker buildx build --platform ${OS}/${ARCH} --build-arg GOARCH=$(ARCH) -t "${BUILDER}" --load -f build/package/Dockerfile.build .
reloader-${ARCH}.tar:
docker buildx build --platform ${OS}/${ARCH} --build-arg GOARCH=$(ARCH) -t "${BUILDER}" --load -f build/package/Dockerfile.build .
docker run --platform ${OS}/${ARCH} --rm "${BUILDER}" > reloader-${ARCH}.tar
binary-image: builder-image
cat reloader-${ARCH}.tar | docker buildx build --platform ${OS}/${ARCH} -t "${REPOSITORY_ARCH}" --load -f Dockerfile.run -
build-image:
docker buildx build \
--platform ${OS}/${ARCH} \
--build-arg GOARCH=$(ARCH) \
--build-arg BUILDER_IMAGE=$(BUILDER_IMAGE) \
--build-arg BASE_IMAGE=${BASE_IMAGE} \
--build-arg GOPROXY=${GOPROXY} \
--build-arg GOPRIVATE=${GOPRIVATE} \
-t "${REPOSITORY_ARCH}" \
--load \
-f Dockerfile \
.
push:
docker push ${REPOSITORY_ARCH}
release: binary-image push manifest
release: build-image push manifest
release-all:
-rm -rf ~/.docker/manifests/*
@@ -66,23 +75,6 @@ test:
stop:
@docker stop "${BINARY}"
clean-images: stop
-docker rmi "${BINARY}"
@for arch in $(ALL_ARCH) ; do \
echo Clean image: $$arch ; \
make clean-image ARCH=$$arch ; \
done
-docker rmi "${REPOSITORY_GENERIC}"
clean-image:
-docker rmi "${BUILDER}"
-docker rmi "${REPOSITORY_ARCH}"
-rm -rf ~/.docker/manifests/*
clean:
"$(GOCMD)" clean -i
-rm -rf reloader-*.tar
apply:
kubectl apply -f deployments/manifests/ -n temp-reloader

View File

@@ -99,7 +99,8 @@ metadata:
annotations:
configmap.reloader.stakater.com/reload: "foo-configmap,bar-configmap,baz-configmap"
spec:
template: metadata:
template:
metadata:
```
### Secret
@@ -114,7 +115,8 @@ metadata:
annotations:
secret.reloader.stakater.com/reload: "foo-secret"
spec:
template: metadata:
template:
metadata:
```
Use comma separated list to define multiple secrets.
@@ -125,7 +127,8 @@ metadata:
annotations:
secret.reloader.stakater.com/reload: "foo-secret,bar-secret,baz-secret"
spec:
template: metadata:
template:
metadata:
```
### NOTES
@@ -142,6 +145,19 @@ spec:
- you may want to prevent watching certain namespaces with the `--namespaces-to-ignore` flag
- you may want to prevent watching certain resources with the `--resources-to-ignore` flag
- you can configure logging in JSON format with the `--log-format=json` option
- you can configure the "reload strategy" with the `--reload-strategy=<strategy-name>` option (details below)
## Reload Strategies
Reloader supports multiple "reload" strategies for performing rolling upgrades to resources. The following list describes them:
- **env-vars**: When a tracked `configMap`/`secret` is updated, this strategy attaches a Reloader specific environment variable to any containers
referencing the changed `configMap` or `secret` on the owning resource (e.g., `Deployment`, `StatefulSet`, etc.).
This strategy can be specified with the `--reload-strategy=env-vars` argument. Note: This is the default reload strategy.
- **annotations**: When a tracked `configMap`/`secret` is updated, this strategy attaches a `reloader.stakater.com/last-reloaded-from` pod template annotation
on the owning resource (e.g., `Deployment`, `StatefulSet`, etc.). This strategy is useful when using resource syncing tools like ArgoCD, since it will not cause these tools
to detect configuration drift after a resource is reloaded. Note: Since the attached pod template annotation only tracks the last reload source, this strategy will reload any tracked resource should its
`configMap` or `secret` be deleted and recreated.
This strategy can be specified with the `--reload-strategy=annotations` argument.
## Deploying to Kubernetes
@@ -224,9 +240,10 @@ You can enable to scrape Reloader's Prometheus metrics by setting `serviceMonito
**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:
| Parameter | Description | Type |
| ---------------- | ---------------------------------------------------------------------------- | ------- |
| ---------------- |------------------------------------------------------------------------------| ------- |
| isOpenshift | Enable OpenShift DeploymentConfigs. Valid value are either `true` or `false` | boolean |
| isArgoRollouts | Enable Argo Rollouts. Valid value are either `true` or `false` | boolean |
| reloadOnCreate | Enable reload on create events. Valid value are either `true` or `false` | boolean |
## Help

View File

@@ -1,26 +0,0 @@
FROM golang:1.15.2-alpine
LABEL maintainer "Stakater Team"
ARG GOARCH=amd64
RUN apk -v --update \
--no-cache \
add git build-base
WORKDIR "$GOPATH/src/github.com/stakater/Reloader"
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ENV CGO_ENABLED=0 GOOS=linux GOARCH=$GOARCH
RUN go build -a --installsuffix cgo --ldflags="-s" -o /Reloader
COPY build/package/Dockerfile.run /
# Running this image produces a tarball suitable to be piped into another
# Docker build command.
CMD tar -cf - -C / Dockerfile.run Reloader

View File

@@ -1,14 +0,0 @@
FROM alpine:3.11
LABEL maintainer "Stakater Team"
RUN apk add --update --no-cache ca-certificates
COPY Reloader /bin/Reloader
# On alpine 'nobody' has uid 65534
USER 65534
# Port for metrics and probes
EXPOSE 9090
ENTRYPOINT ["/bin/Reloader"]

View File

@@ -3,8 +3,8 @@
apiVersion: v1
name: reloader
description: Reloader chart that runs on kubernetes
version: v0.0.97
appVersion: v0.0.97
version: v0.0.112
appVersion: v0.0.112
keywords:
- Reloader
- kubernetes

View File

@@ -1,7 +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"
{{ .Values.reloader.custom_annotations.configmap | default "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"
- For a `Deployment` called `foo` have a `Secret` called `foo-secret`. Then add this annotation to main metadata of your `Deployment`
{{ .Values.reloader.custom_annotations.secret | default "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.

View File

@@ -15,8 +15,9 @@ metadata:
{{ toYaml .Values.reloader.matchLabels | indent 4 }}
{{- end }}
name: {{ template "reloader-fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
replicas: 1
replicas: {{ .Values.reloader.deployment.replicas }}
revisionHistoryLimit: 2
selector:
matchLabels:
@@ -113,12 +114,16 @@ spec:
periodSeconds: {{ .Values.reloader.deployment.readinessProbe.periodSeconds | default "10" }}
successThreshold: {{ .Values.reloader.deployment.readinessProbe.successThreshold | default "1" }}
{{- with .Values.reloader.deployment.containerSecurityContext }}
securityContext: {{ toYaml . | nindent 10 }}
{{- end }}
{{- if eq .Values.reloader.readOnlyRootFileSystem true }}
volumeMounts:
- mountPath: /tmp/
name: tmp-volume
{{- end }}
{{- if or (.Values.reloader.logFormat) (.Values.reloader.ignoreSecrets) (.Values.reloader.ignoreNamespaces) (.Values.reloader.ignoreConfigMaps) (.Values.reloader.custom_annotations) (eq .Values.reloader.isArgoRollouts true) }}
{{- if or (.Values.reloader.logFormat) (.Values.reloader.ignoreSecrets) (.Values.reloader.ignoreNamespaces) (.Values.reloader.ignoreConfigMaps) (.Values.reloader.custom_annotations) (eq .Values.reloader.isArgoRollouts true) (eq .Values.reloader.reloadOnCreate true) (ne .Values.reloader.reloadStrategy "default")}}
args:
{{- if .Values.reloader.logFormat }}
- "--log-format={{ .Values.reloader.logFormat }}"
@@ -158,6 +163,12 @@ spec:
{{- if eq .Values.reloader.isArgoRollouts true }}
- "--is-Argo-Rollouts={{ .Values.reloader.isArgoRollouts }}"
{{- end }}
{{- if eq .Values.reloader.reloadOnCreate true }}
- "--reload-on-create={{ .Values.reloader.reloadOnCreate }}"
{{- end }}
{{- if ne .Values.reloader.reloadStrategy "default" }}
- "--reload-strategy={{ .Values.reloader.reloadStrategy }}"
{{- end }}
{{- end }}
{{- if .Values.reloader.deployment.resources }}
resources:
@@ -167,6 +178,9 @@ spec:
securityContext: {{ toYaml .Values.reloader.deployment.securityContext | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "reloader-serviceAccountName" . }}
{{- if hasKey .Values.reloader.deployment "automountServiceAccountToken" }}
automountServiceAccountToken: {{ .Values.reloader.deployment.automountServiceAccountToken }}
{{- end }}
{{- if eq .Values.reloader.readOnlyRootFileSystem true }}
volumes:
- emptyDir: {}

View File

@@ -4,6 +4,9 @@ kind: ServiceAccount
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.global.imagePullSecrets | nindent 2 }}
{{- end }}
{{- if hasKey .Values.reloader.serviceAccount "automountServiceAccountToken" }}
automountServiceAccountToken: {{ .Values.reloader.serviceAccount.automountServiceAccountToken }}
{{- end }}
metadata:
annotations:
{{ include "reloader-helm3.annotations" . | indent 4 }}
@@ -19,4 +22,5 @@ metadata:
{{ toYaml .Values.reloader.matchLabels | indent 4 }}
{{- end }}
name: {{ template "reloader-serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}

View File

@@ -0,0 +1,19 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"reloader": {
"type": "object",
"properties": {
"reloadStrategy": {
"type": "string",
"enum": [
"default",
"env-vars",
"annotations"
]
}
}
}
}
}

View File

@@ -13,6 +13,8 @@ reloader:
isOpenshift: false
ignoreSecrets: false
ignoreConfigMaps: false
reloadOnCreate: false
reloadStrategy: default # Set to default, env-vars or annotations
ignoreNamespaces: "" # Comma separated list of namespaces to ignore
logFormat: "" #json
watchGlobally: true
@@ -22,6 +24,7 @@ reloader:
rbac: false
matchLabels: {}
deployment:
replicas: 1
nodeSelector:
# cloud.google.com/gke-nodepool: default-pool
@@ -40,6 +43,13 @@ reloader:
runAsNonRoot: true
runAsUser: 65534
containerSecurityContext: {}
# capabilities:
# drop:
# - ALL
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# A list of tolerations to be applied to the Deployment.
# Example:
# tolerations:
@@ -52,10 +62,10 @@ reloader:
labels:
provider: stakater
group: com.stakater.platform
version: v0.0.97
version: v0.0.112
image:
name: stakater/reloader
tag: v0.0.97
tag: v0.0.112
pullPolicy: IfNotPresent
# Support for extra environment variables.
env:
@@ -108,15 +118,17 @@ reloader:
annotations: {}
# The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template
name:
name:
# Optional flags to pass to the Reloader entrypoint
# Example:
# custom_annotations:
# configmap: "my.company.com/configmap"
# secret: "my.company.com/secret"
custom_annotations: {}
serviceMonitor:
# enabling this requires service to be enabled as well, or no endpoints will be found
# Deprecated: Service monitor will be removed in future releases of reloader in favour of Pod monitor
# Enabling this requires service to be enabled as well, or no endpoints will be found
enabled: false
# Set the namespace the ServiceMonitor should be deployed
# namespace: monitoring
@@ -128,7 +140,6 @@ reloader:
# timeout: 10s
podMonitor:
# enabling this requires service to be enabled as well, or no endpoints will be found
enabled: false
# Set the namespace the podMonitor should be deployed
# namespace: monitoring

View File

@@ -1,7 +1,7 @@
---
# Source: reloader/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
annotations:
@@ -9,10 +9,10 @@ metadata:
meta.helm.sh/release-name: "reloader"
labels:
app: reloader-reloader
chart: "reloader-v0.0.77"
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Tiller"
app.kubernetes.io/managed-by: "Tiller"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
name: reloader-reloader-role
namespace: default
rules:
@@ -46,4 +46,3 @@ rules:
- get
- update
- patch

View File

@@ -1,7 +1,7 @@
---
# Source: reloader/templates/clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
annotations:
@@ -9,10 +9,10 @@ metadata:
meta.helm.sh/release-name: "reloader"
labels:
app: reloader-reloader
chart: "reloader-v0.0.77"
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Tiller"
app.kubernetes.io/managed-by: "Tiller"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
name: reloader-reloader-role-binding
namespace: default
roleRef:
@@ -23,4 +23,3 @@ subjects:
- kind: ServiceAccount
name: reloader-reloader
namespace: default

View File

@@ -8,15 +8,15 @@ metadata:
meta.helm.sh/release-name: "reloader"
labels:
app: reloader-reloader
chart: "reloader-v0.0.77"
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Tiller"
app.kubernetes.io/managed-by: "Tiller"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
group: com.stakater.platform
provider: stakater
version: v0.0.77
version: v0.0.112
name: reloader-reloader
namespace: default
spec:
replicas: 1
revisionHistoryLimit: 2
@@ -28,17 +28,16 @@ spec:
metadata:
labels:
app: reloader-reloader
chart: "reloader-v0.0.77"
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Tiller"
app.kubernetes.io/managed-by: "Tiller"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
group: com.stakater.platform
provider: stakater
version: v0.0.77
version: v0.0.112
spec:
containers:
- image: "stakater/reloader:v0.0.77"
- image: "stakater/reloader:v0.0.112"
imagePullPolicy: IfNotPresent
name: reloader-reloader
@@ -49,13 +48,19 @@ spec:
httpGet:
path: /metrics
port: http
timeoutSeconds: 5
failureThreshold: 5
periodSeconds: 10
successThreshold: 1
readinessProbe:
httpGet:
path: /metrics
port: http
timeoutSeconds: 5
failureThreshold: 5
periodSeconds: 10
successThreshold: 1
securityContext:
runAsNonRoot: true
runAsUser: 65534
serviceAccountName: reloader-reloader

View File

@@ -1,6 +1,5 @@
---
# Source: reloader/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
@@ -9,9 +8,9 @@ metadata:
meta.helm.sh/release-name: "reloader"
labels:
app: reloader-reloader
chart: "reloader-v0.0.77"
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Tiller"
app.kubernetes.io/managed-by: "Tiller"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
name: reloader-reloader
namespace: default

View File

@@ -5,14 +5,15 @@ kind: ServiceAccount
metadata:
annotations:
meta.helm.sh/release-namespace: "default"
meta.helm.sh/release-name: "stakater"
meta.helm.sh/release-name: "reloader"
labels:
app: stakater-reloader
chart: "reloader-v0.0.97"
release: "stakater"
app: reloader-reloader
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
name: stakater-reloader
name: reloader-reloader
namespace: default
---
# Source: reloader/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
@@ -21,14 +22,14 @@ kind: ClusterRole
metadata:
annotations:
meta.helm.sh/release-namespace: "default"
meta.helm.sh/release-name: "stakater"
meta.helm.sh/release-name: "reloader"
labels:
app: stakater-reloader
chart: "reloader-v0.0.97"
release: "stakater"
app: reloader-reloader
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
name: stakater-reloader-role
name: reloader-reloader-role
namespace: default
rules:
- apiGroups:
@@ -69,22 +70,22 @@ kind: ClusterRoleBinding
metadata:
annotations:
meta.helm.sh/release-namespace: "default"
meta.helm.sh/release-name: "stakater"
meta.helm.sh/release-name: "reloader"
labels:
app: stakater-reloader
chart: "reloader-v0.0.97"
release: "stakater"
app: reloader-reloader
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
name: stakater-reloader-role-binding
name: reloader-reloader-role-binding
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: stakater-reloader-role
name: reloader-reloader-role
subjects:
- kind: ServiceAccount
name: stakater-reloader
name: reloader-reloader
namespace: default
---
# Source: reloader/templates/deployment.yaml
@@ -93,40 +94,41 @@ kind: Deployment
metadata:
annotations:
meta.helm.sh/release-namespace: "default"
meta.helm.sh/release-name: "stakater"
meta.helm.sh/release-name: "reloader"
labels:
app: stakater-reloader
chart: "reloader-v0.0.97"
release: "stakater"
app: reloader-reloader
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
group: com.stakater.platform
provider: stakater
version: v0.0.97
name: stakater-reloader
version: v0.0.112
name: reloader-reloader
namespace: default
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: stakater-reloader
release: "stakater"
app: reloader-reloader
release: "reloader"
template:
metadata:
labels:
app: stakater-reloader
chart: "reloader-v0.0.97"
release: "stakater"
app: reloader-reloader
chart: "reloader-v0.0.112"
release: "reloader"
heritage: "Helm"
app.kubernetes.io/managed-by: "Helm"
group: com.stakater.platform
provider: stakater
version: v0.0.97
version: v0.0.112
spec:
containers:
- image: "stakater/reloader:v0.0.97"
- image: "stakater/reloader:v0.0.112"
imagePullPolicy: IfNotPresent
name: stakater-reloader
name: reloader-reloader
ports:
- name: http
@@ -150,4 +152,4 @@ spec:
securityContext:
runAsNonRoot: true
runAsUser: 65534
serviceAccountName: stakater-reloader
serviceAccountName: reloader-reloader

View File

@@ -13,6 +13,8 @@ reloader:
isOpenshift: false
ignoreSecrets: false
ignoreConfigMaps: false
reloadOnCreate: false
reloadStrategy: default # Set to default, env-vars or annotations
ignoreNamespaces: "" # Comma separated list of namespaces to ignore
logFormat: "" #json
watchGlobally: true
@@ -22,6 +24,7 @@ reloader:
rbac: false
matchLabels: {}
deployment:
replicas: 1
nodeSelector:
# cloud.google.com/gke-nodepool: default-pool
@@ -40,6 +43,13 @@ reloader:
runAsNonRoot: true
runAsUser: 65534
containerSecurityContext: {}
# capabilities:
# drop:
# - ALL
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# A list of tolerations to be applied to the Deployment.
# Example:
# tolerations:

67
go.mod
View File

@@ -1,22 +1,73 @@
module github.com/stakater/Reloader
go 1.15
go 1.17
require (
github.com/argoproj/argo-rollouts v1.0.1
github.com/onsi/ginkgo v1.15.1 // indirect
github.com/onsi/gomega v1.11.0 // indirect
github.com/argoproj/argo-rollouts v1.0.2
github.com/openshift/api v0.0.0-20210527122704-efd9d5958e01
github.com/openshift/client-go v0.0.0-20210521082421-73d9475a9142
github.com/prometheus/client_golang v1.10.0
github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.1.3
k8s.io/api v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/client-go v0.21.1
k8s.io/api v0.21.2
k8s.io/apimachinery v0.21.2
k8s.io/client-go v0.21.2
)
require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/evanphx/json-patch v4.9.0+incompatible // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/go-openapi/jsonpointer v0.19.3 // indirect
github.com/go-openapi/jsonreference v0.19.3 // indirect
github.com/go-openapi/spec v0.19.3 // indirect
github.com/go-openapi/swag v0.19.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/go-cmp v0.5.4 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gnostic v0.4.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/onsi/ginkgo v1.15.1 // indirect
github.com/onsi/gomega v1.11.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.21.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect
golang.org/x/text v0.3.4 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.8.0 // indirect
k8s.io/kube-openapi v0.0.0-20210216185858-15cd8face8d6 // indirect
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.0.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
// Replacements for argo-rollouts
replace (
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.16.0
k8s.io/api => k8s.io/api v0.20.4
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.20.4
k8s.io/apimachinery => k8s.io/apimachinery v0.21.0-alpha.0
@@ -41,4 +92,6 @@ replace (
k8s.io/metrics => k8s.io/metrics v0.20.4
k8s.io/mount-utils => k8s.io/mount-utils v0.20.5-rc.0
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.20.4
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.20.4
k8s.io/sample-controller => k8s.io/sample-controller v0.20.4
)

12
go.sum
View File

@@ -135,8 +135,8 @@ github.com/apex/log v1.9.0/go.mod h1:m82fZlWIuiWzWP04XCTXmnX0xRkYYbCdYn8jbJeLBEA
github.com/apex/logs v1.0.0/go.mod h1:XzxuLZ5myVHDy9SAmYpamKKRNApGj54PfYLcFrXqDwo=
github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE=
github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys=
github.com/argoproj/argo-rollouts v1.0.1 h1:oMOi6uIfaO5k8e+KsRX5/cRA9ETjStdaYDzQRcfDUIA=
github.com/argoproj/argo-rollouts v1.0.1/go.mod h1:BCm4diDqurBn7sRfeCnYFf4Eu7+RynEjnhNBJomMJBA=
github.com/argoproj/argo-rollouts v1.0.2 h1:QC+5BsHVDnLMnKNhCLoR/E1AT0DpiWIczW5xseEBqDM=
github.com/argoproj/argo-rollouts v1.0.2/go.mod h1:lSK1l0H/67x3fnBt8GtfQUPJx8DoD9PhchzmDC6nWMI=
github.com/argoproj/pkg v0.9.0/go.mod h1:ra+bQPmbVAoEL+gYSKesuigt4m49i3Qa3mE/xQcjCiA=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
@@ -528,9 +528,6 @@ github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:Fecb
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
@@ -885,7 +882,6 @@ github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uY
github.com/rivo/tview v0.0.0-20200219210816-cd38d7432498/go.mod h1:6lkG1x+13OShEf0EaOCaTQYyB7d5nSbb181KtjlS+84=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/robfig/cron v1.1.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
@@ -1128,7 +1124,6 @@ golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1146,7 +1141,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -1489,7 +1483,6 @@ gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/kyokomi/emoji.v1 v1.5.1/go.mod h1:N9AZ6hi1jHOPn34PsbpufQZUcKftSD7WgS2pgpmH4Lg=
gopkg.in/mcuadros/go-syslog.v2 v2.2.1/go.mod h1:l5LPIyOOyIdQquNg+oU6Z3524YwrcqEm0aKH+5zpt2U=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/src-d/go-billy.v4 v4.2.1/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
gopkg.in/src-d/go-git-fixtures.v3 v3.1.1/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
@@ -1498,7 +1491,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.1/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@@ -52,6 +52,15 @@ func GetDeploymentItems(clients kube.Clients, namespace string) []interface{} {
if err != nil {
logrus.Errorf("Failed to list deployments %v", err)
}
// Ensure we always have pod annotations to add to
for i, v := range deployments.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
annotations := make(map[string]string)
deployments.Items[i].Spec.Template.ObjectMeta.Annotations = annotations
}
}
return util.InterfaceSlice(deployments.Items)
}
@@ -61,6 +70,14 @@ func GetDaemonSetItems(clients kube.Clients, namespace string) []interface{} {
if err != nil {
logrus.Errorf("Failed to list daemonSets %v", err)
}
// Ensure we always have pod annotations to add to
for i, v := range daemonSets.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
daemonSets.Items[i].Spec.Template.ObjectMeta.Annotations = make(map[string]string)
}
}
return util.InterfaceSlice(daemonSets.Items)
}
@@ -70,6 +87,14 @@ func GetStatefulSetItems(clients kube.Clients, namespace string) []interface{} {
if err != nil {
logrus.Errorf("Failed to list statefulSets %v", err)
}
// Ensure we always have pod annotations to add to
for i, v := range statefulSets.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
statefulSets.Items[i].Spec.Template.ObjectMeta.Annotations = make(map[string]string)
}
}
return util.InterfaceSlice(statefulSets.Items)
}
@@ -79,6 +104,14 @@ func GetDeploymentConfigItems(clients kube.Clients, namespace string) []interfac
if err != nil {
logrus.Errorf("Failed to list deploymentConfigs %v", err)
}
// Ensure we always have pod annotations to add to
for i, v := range deploymentConfigs.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
deploymentConfigs.Items[i].Spec.Template.ObjectMeta.Annotations = make(map[string]string)
}
}
return util.InterfaceSlice(deploymentConfigs.Items)
}
@@ -88,6 +121,14 @@ func GetRolloutItems(clients kube.Clients, namespace string) []interface{} {
if err != nil {
logrus.Errorf("Failed to list Rollouts %v", err)
}
// Ensure we always have pod annotations to add to
for i, v := range rollouts.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
rollouts.Items[i].Spec.Template.ObjectMeta.Annotations = make(map[string]string)
}
}
return util.InterfaceSlice(rollouts.Items)
}

View File

@@ -3,7 +3,9 @@ package cmd
import (
"errors"
"fmt"
"github.com/stakater/Reloader/internal/pkg/constants"
"os"
"strings"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -18,9 +20,10 @@ import (
// NewReloaderCommand starts the reloader controller
func NewReloaderCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "reloader",
Short: "A watcher for your Kubernetes cluster",
Run: startReloader,
Use: "reloader",
Short: "A watcher for your Kubernetes cluster",
PreRunE: validateFlags,
Run: startReloader,
}
// options
@@ -33,9 +36,25 @@ func NewReloaderCommand() *cobra.Command {
cmd.PersistentFlags().StringSlice("resources-to-ignore", []string{}, "list of resources to ignore (valid options 'configMaps' or 'secrets')")
cmd.PersistentFlags().StringSlice("namespaces-to-ignore", []string{}, "list of namespaces to ignore")
cmd.PersistentFlags().StringVar(&options.IsArgoRollouts, "is-Argo-Rollouts", "false", "Add support for argo rollouts")
cmd.PersistentFlags().StringVar(&options.ReloadStrategy, constants.ReloadStrategyFlag, constants.EnvVarsReloadStrategy, "Specifies the desired reload strategy")
cmd.PersistentFlags().StringVar(&options.ReloadOnCreate, "reload-on-create", "false", "Add support to watch create events")
return cmd
}
func validateFlags(*cobra.Command, []string) error {
// Ensure the reload strategy is one of the following...
valid := []string{constants.EnvVarsReloadStrategy, constants.AnnotationsReloadStrategy}
for _, s := range valid {
if s == options.ReloadStrategy {
return nil
}
}
err := fmt.Sprintf("%s must be one of: %s", constants.ReloadStrategyFlag, strings.Join(valid, ", "))
return errors.New(err)
}
func configureLogging(logFormat string) error {
switch logFormat {
case "json":

View File

@@ -7,4 +7,16 @@ const (
SecretEnvVarPostfix = "SECRET"
// EnvVarPrefix is a Prefix for environment variable
EnvVarPrefix = "STAKATER_"
// ReloaderAnnotationPrefix is a Prefix for all reloader annotations
ReloaderAnnotationPrefix = "reloader.stakater.com"
// LastReloadedFromAnnotation is an annotation used to describe the last resource that triggered a reload
LastReloadedFromAnnotation = "last-reloaded-from"
// ReloadStrategyFlag The reload strategy flag name
ReloadStrategyFlag = "reload-strategy"
// EnvVarsReloadStrategy instructs Reloader to add container environment variables to facilitate a restart
EnvVarsReloadStrategy = "env-vars"
// AnnotationsReloadStrategy instructs Reloader to add pod template annotations to facilitate a restart
AnnotationsReloadStrategy = "annotations"
)

View File

@@ -2,6 +2,7 @@ package controller
import (
"fmt"
"github.com/stakater/Reloader/internal/pkg/options"
"time"
"github.com/sirupsen/logrus"
@@ -30,6 +31,9 @@ type Controller struct {
collectors metrics.Collectors
}
// controllerInitialized flag determines whether controlled is being initialized
var controllerInitialized bool = false
// NewController for initializing a Controller
func NewController(
client kubernetes.Interface, resource string, namespace string, ignoredNamespaces []string, collectors metrics.Collectors) (*Controller, error) {
@@ -57,8 +61,14 @@ func NewController(
// Add function to add a new object to the queue in case of creating a resource
func (c *Controller) Add(obj interface{}) {
// Not required as reloader should update the resource in the event of any change and not in the event of any resource creation.
// This causes the issue where reloader reloads the pods when reloader itself gets restarted as it's queue is filled with all the k8s objects as new resources.
if options.ReloadOnCreate == "true" {
if !c.resourceInIgnoredNamespace(obj) && controllerInitialized {
c.queue.Add(handler.ResourceCreatedHandler{
Resource: obj,
Collectors: c.collectors,
})
}
}
}
func (c *Controller) resourceInIgnoredNamespace(raw interface{}) bool {
@@ -111,6 +121,9 @@ func (c *Controller) Run(threadiness int, stopCh chan struct{}) {
}
func (c *Controller) runWorker() {
// At this point the controller is fully initialized and we can start processing the resources
controllerInitialized = true
for c.processNextItem() {
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
package handler
import (
"strconv"
"strings"
"encoding/json"
"errors"
"fmt"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"github.com/stakater/Reloader/internal/pkg/callbacks"
@@ -13,6 +13,8 @@ import (
"github.com/stakater/Reloader/internal/pkg/util"
"github.com/stakater/Reloader/pkg/kube"
v1 "k8s.io/api/core/v1"
"strconv"
"strings"
)
// GetDeploymentRollingUpgradeFuncs returns all callback funcs for a deployment
@@ -146,7 +148,7 @@ func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFunc
result := constants.NotUpdated
reloaderEnabled, err := strconv.ParseBool(reloaderEnabledValue)
if err == nil && reloaderEnabled {
result = updateContainers(upgradeFuncs, i, config, true)
result = invokeReloadStrategy(upgradeFuncs, i, config, true)
}
if result != constants.Updated && annotationValue != "" {
@@ -154,7 +156,7 @@ func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFunc
for _, value := range values {
value = strings.Trim(value, " ")
if value == config.ResourceName {
result = updateContainers(upgradeFuncs, i, config, false)
result = invokeReloadStrategy(upgradeFuncs, i, config, false)
if result == constants.Updated {
break
}
@@ -165,7 +167,7 @@ func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFunc
if result != constants.Updated && searchAnnotationValue == "true" {
matchAnnotationValue := config.ResourceAnnotations[options.SearchMatchAnnotation]
if matchAnnotationValue == "true" {
result = updateContainers(upgradeFuncs, i, config, true)
result = invokeReloadStrategy(upgradeFuncs, i, config, true)
}
}
@@ -257,7 +259,7 @@ func getContainerWithEnvReference(containers []v1.Container, resourceName string
return nil
}
func getContainerToUpdate(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface{}, config util.Config, autoReload bool) *v1.Container {
func getContainerUsingResource(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface{}, config util.Config, autoReload bool) *v1.Container {
volumes := upgradeFuncs.VolumesFunc(item)
containers := upgradeFuncs.ContainersFunc(item)
initContainers := upgradeFuncs.InitContainersFunc(item)
@@ -296,10 +298,70 @@ func getContainerToUpdate(upgradeFuncs callbacks.RollingUpgradeFuncs, item inter
return container
}
func updateContainers(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface{}, config util.Config, autoReload bool) constants.Result {
func invokeReloadStrategy(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface{}, config util.Config, autoReload bool) constants.Result {
if options.ReloadStrategy == constants.AnnotationsReloadStrategy {
return updatePodAnnotations(upgradeFuncs, item, config, autoReload)
}
return updateContainerEnvVars(upgradeFuncs, item, config, autoReload)
}
func updatePodAnnotations(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface{}, config util.Config, autoReload bool) constants.Result {
container := getContainerUsingResource(upgradeFuncs, item, config, autoReload)
if container == nil {
return constants.NoContainerFound
}
// Generate reloaded annotations. Attaching this to the item's annotation will trigger a rollout
// Note: the data on this struct is purely informational and is not used for future updates
reloadSource := util.NewReloadSourceFromConfig(config, []string{container.Name})
annotations, err := createReloadedAnnotations(&reloadSource)
if err != nil {
logrus.Errorf("Failed to create reloaded annotations for %s! error = %v", config.ResourceName, err)
return constants.NotUpdated
}
// Copy the all annotations to the item's annotations
pa := upgradeFuncs.PodAnnotationsFunc(item)
if pa == nil {
return constants.NotUpdated
}
for k, v := range annotations {
pa[k] = v
}
return constants.Updated
}
func createReloadedAnnotations(target *util.ReloadSource) (map[string]string, error) {
if target == nil {
return nil, errors.New("target is required")
}
// Create a single "last-invokeReloadStrategy-from" annotation that stores metadata about the
// resource that caused the last invokeReloadStrategy.
// Intentionally only storing the last item in order to keep
// the generated annotations as small as possible.
annotations := make(map[string]string)
lastReloadedResourceName := fmt.Sprintf("%s/%s",
constants.ReloaderAnnotationPrefix,
constants.LastReloadedFromAnnotation,
)
lastReloadedResource, err := json.Marshal(target)
if err != nil {
return nil, err
}
annotations[lastReloadedResourceName] = string(lastReloadedResource)
return annotations, nil
}
func updateContainerEnvVars(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface{}, config util.Config, autoReload bool) constants.Result {
var result constants.Result
envVar := constants.EnvVarPrefix + util.ConvertToEnvVarName(config.ResourceName) + "_" + config.Type
container := getContainerToUpdate(upgradeFuncs, item, config, autoReload)
container := getContainerUsingResource(upgradeFuncs, item, config, autoReload)
if container == nil {
return constants.NoContainerFound

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,7 @@
package options
import "github.com/stakater/Reloader/internal/pkg/constants"
var (
// ConfigmapUpdateOnChangeAnnotation is an annotation to detect changes in
// configmaps specified by name
@@ -17,6 +19,10 @@ var (
SearchMatchAnnotation = "reloader.stakater.com/match"
// LogFormat is the log format to use (json, or empty string for default)
LogFormat = ""
// Adds support for argo rollouts
// IsArgoRollouts Adds support for argo rollouts
IsArgoRollouts = "false"
// ReloadStrategy Specify the update strategy
ReloadStrategy = constants.EnvVarsReloadStrategy
// ReloadOnCreate Adds support to watch create events
ReloadOnCreate = "false"
)

View File

@@ -2,6 +2,8 @@ package testutil
import (
"context"
"encoding/json"
"fmt"
"math/rand"
"sort"
"strconv"
@@ -563,8 +565,8 @@ func GetSecretWithUpdatedLabel(namespace string, secretName string, label string
}
}
// GetResourceSHA returns the SHA value of given environment variable
func GetResourceSHA(containers []v1.Container, envVar string) string {
// GetResourceSHAFromEnvVar returns the SHA value of given environment variable
func GetResourceSHAFromEnvVar(containers []v1.Container, envVar string) string {
for i := range containers {
envs := containers[i].Env
for j := range envs {
@@ -576,6 +578,28 @@ func GetResourceSHA(containers []v1.Container, envVar string) string {
return ""
}
// GetResourceSHAFromAnnotation returns the SHA value of given environment variable
func GetResourceSHAFromAnnotation(podAnnotations map[string]string) string {
lastReloadedResourceName := fmt.Sprintf("%s/%s",
constants.ReloaderAnnotationPrefix,
constants.LastReloadedFromAnnotation,
)
annotationJson, ok := podAnnotations[lastReloadedResourceName]
if !ok {
return ""
}
var last util.ReloadSource
bytes := []byte(annotationJson)
err := json.Unmarshal(bytes, &last)
if err != nil {
return ""
}
return last.Hash
}
//ConvertResourceToSHA generates SHA from secret or configmap data
func ConvertResourceToSHA(resourceType string, namespace string, resourceName string, data string) string {
values := []string{}
@@ -806,8 +830,8 @@ func RandSeq(n int) string {
return string(b)
}
// VerifyResourceUpdate verifies whether the rolling upgrade happened or not
func VerifyResourceUpdate(clients kube.Clients, config util.Config, envVarPostfix string, upgradeFuncs callbacks.RollingUpgradeFuncs) bool {
// VerifyResourceEnvVarUpdate verifies whether the rolling upgrade happened or not
func VerifyResourceEnvVarUpdate(clients kube.Clients, config util.Config, envVarPostfix string, upgradeFuncs callbacks.RollingUpgradeFuncs) bool {
items := upgradeFuncs.ItemsFunc(clients, config.Namespace)
for _, i := range items {
containers := upgradeFuncs.ContainersFunc(i)
@@ -836,7 +860,45 @@ func VerifyResourceUpdate(clients kube.Clients, config util.Config, envVarPostfi
if matches {
envName := constants.EnvVarPrefix + util.ConvertToEnvVarName(config.ResourceName) + "_" + envVarPostfix
updated := GetResourceSHA(containers, envName)
updated := GetResourceSHAFromEnvVar(containers, envName)
if updated == config.SHAValue {
return true
}
}
}
return false
}
// VerifyResourceAnnotationUpdate verifies whether the rolling upgrade happened or not
func VerifyResourceAnnotationUpdate(clients kube.Clients, config util.Config, upgradeFuncs callbacks.RollingUpgradeFuncs) bool {
items := upgradeFuncs.ItemsFunc(clients, config.Namespace)
for _, i := range items {
podAnnotations := upgradeFuncs.PodAnnotationsFunc(i)
// match statefulsets with the correct annotation
annotationValue := util.ToObjectMeta(i).Annotations[config.Annotation]
searchAnnotationValue := util.ToObjectMeta(i).Annotations[options.AutoSearchAnnotation]
reloaderEnabledValue := util.ToObjectMeta(i).Annotations[options.ReloaderAutoAnnotation]
reloaderEnabled, err := strconv.ParseBool(reloaderEnabledValue)
matches := false
if err == nil && reloaderEnabled {
matches = true
} else if annotationValue != "" {
values := strings.Split(annotationValue, ",")
for _, value := range values {
value = strings.Trim(value, " ")
if value == config.ResourceName {
matches = true
break
}
}
} else if searchAnnotationValue == "true" {
if config.ResourceAnnotations[options.SearchMatchAnnotation] == "true" {
matches = true
}
}
if matches {
updated := GetResourceSHAFromAnnotation(podAnnotations)
if updated == config.SHAValue {
return true
}

View File

@@ -0,0 +1,39 @@
package util
import "time"
type ReloadSource struct {
Type string `json:"type"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Hash string `json:"hash"`
ContainerRefs []string `json:"containerRefs"`
ObservedAt int64 `json:"observedAt"`
}
func NewReloadSource(
resourceName string,
resourceNamespace string,
resourceType string,
resourceHash string,
containerRefs []string,
) ReloadSource {
return ReloadSource{
ObservedAt: time.Now().Unix(),
Name: resourceName,
Namespace: resourceNamespace,
Type: resourceType,
Hash: resourceHash,
ContainerRefs: containerRefs,
}
}
func NewReloadSourceFromConfig(config Config, containerRefs []string) ReloadSource {
return NewReloadSource(
config.ResourceName,
config.Namespace,
config.Type,
config.SHAValue,
containerRefs,
)
}

View File

@@ -1,4 +0,0 @@
issues:
kind: 1
url: https://aurorasolutions.atlassian.net
project: STK