Compare commits

..

15 Commits

Author SHA1 Message Date
Muneeb Aijaz
ca09e243a3 Merge pull request #799 from stakater/chart-rel-1.2.0
Update helm chart - 1.2.0
2024-11-20 13:22:19 +05:00
MuneebAijaz
22f6c3e461 separate out workflows 2024-11-20 12:31:26 +05:00
MuneebAijaz
d784b552ee separate out workflows 2024-11-20 12:30:49 +05:00
MuneebAijaz
33710457ef separate out workflows 2024-11-20 12:27:53 +05:00
MuneebAijaz
f3bf76bb9d Update helm chart - 1.2.0 2024-11-20 12:07:35 +05:00
Muneeb Aijaz
e9811bf166 Merge pull request #788 from stakater/helm-chart-rel
Add workflow for helm chart push
2024-11-19 10:59:10 +05:00
Muneeb Aijaz
93e7aca146 Update push-helm-chart.yaml 2024-11-19 10:43:04 +05:00
Muneeb Aijaz
ff7c5c0f74 Merge pull request #784 from tom1299/master
fix: Remove obsolete permissions for apiGroup `extensions` from helm templates
2024-11-18 17:07:33 +05:00
Muneeb Aijaz
1ffef1a1d4 Merge pull request #792 from stakater/remove-bump-chart
Remove chart bump from init release since its not relevant
2024-11-18 16:32:32 +05:00
MuneebAijaz
c9b919f2f4 Remove chart bump from init release since its not relevant 2024-11-18 16:18:29 +05:00
Muneeb Aijaz
b4cc5420ac Merge pull request #789 from stakater/MuneebAijaz-patch-1
Pin version for checkout action
2024-11-18 15:06:23 +05:00
Muneeb Aijaz
865a985bcd Pin version for checkout action 2024-11-18 15:04:39 +05:00
MuneebAijaz
2cd4f2397a Add workflow for helm chart push 2024-11-18 11:11:34 +05:00
lochan_2112
53b650ac80 Provide annotations to exclude reloading resources (#764)
* Provide annotations to exclude reloading resources

* update test case

* undo commented tests

* remove sleep
2024-11-16 20:36:27 +01:00
tom1299
394707a7f8 Remove obsolete permissions for apiGroup extensions 2024-11-10 07:21:13 +01:00
12 changed files with 544 additions and 182 deletions

View File

@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
@@ -48,7 +48,6 @@ jobs:
run: |
set -ue
VERSION=${{ inputs.TARGET_VERSION }} make update-manifests-version
VERSION=${{ inputs.TARGET_VERSION }} make bump-chart
git diff
- name: Generate new set of manifests

View File

@@ -0,0 +1,72 @@
name: Pull Request Workflow for Helm Chart changes
on:
pull_request:
branches:
- master
paths:
- 'deployments/kubernetes/chart/reloader/**'
env:
DOCKER_FILE_PATH: Dockerfile
DOCKER_UBI_FILE_PATH: Dockerfile.ubi
KUBERNETES_VERSION: "1.30.0"
KIND_VERSION: "0.23.0"
REGISTRY: ghcr.io
jobs:
helm-validation:
permissions:
contents: read
runs-on: ubuntu-latest
name: Helm Chart Validation
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0
# Setting up helm binary
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.11.3
- name: Helm chart unit tests
uses: d3adb5/helm-unittest-action@v2
with:
charts: deployments/kubernetes/chart/reloader
- name: Add Stakater Helm Repo
run: |
helm repo add stakater https://stakater.github.io/stakater-charts
- name: Get version for chart from helm repo
id: chart_eval
run: |
current_chart_version=$(helm search repo stakater/reloader | tail -n 1 | awk '{print $2}')
echo "CURRENT_CHART_VERSION=$(echo ${current_chart_version})" >> $GITHUB_OUTPUT
- name: Get Updated Chart version from Chart.yaml
uses: mikefarah/yq@master
id: new_chart_version
with:
cmd: yq e '.version' deployments/kubernetes/chart/reloader/Chart.yaml
- name: Check Version
uses: aleoyakas/check-semver-increased-action@v1
id: check-version
with:
current-version: ${{ steps.new_chart_version.outputs.result }}
previous-version: ${{ steps.chart_eval.outputs.CURRENT_CHART_VERSION }}
- name: Fail if Helm Chart version isnt updated
if: steps.check-version.outputs.is-version-increased != 'true'
run: |
echo "Helm Chart Version wasnt updated"
exit 1

View File

@@ -1,4 +1,4 @@
name: Pull Request
name: Pull Request Workflow for Code changes
on:
pull_request:
@@ -14,6 +14,7 @@ on:
- '!docs/**'
- '!theme_common'
- '!theme_override'
- '!deployments/kubernetes/chart/reloader/**'
env:
DOCKER_FILE_PATH: Dockerfile
@@ -162,72 +163,3 @@ jobs:
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Check if Helm validation needs to run
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
chart:
- 'deployments/kubernetes/chart/reloader/**'
outputs:
helm_chart_changed: ${{ steps.filter.outputs.chart }}
helm-validation:
permissions:
contents: read
runs-on: ubuntu-latest
name: Helm Chart Validation
needs:
- build
if: ${{ needs.build.outputs.helm_chart_changed }} == "true"
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0
# Setting up helm binary
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.11.3
- name: Helm chart unit tests
uses: d3adb5/helm-unittest-action@v2
with:
charts: deployments/kubernetes/chart/reloader
- name: Add Stakater Helm Repo
run: |
helm repo add stakater https://stakater.github.io/stakater-charts
- name: Get version for chart from helm repo
id: chart_eval
run: |
current_chart_version=$(helm search repo stakater/reloader | tail -n 1 | awk '{print $2}')
echo "CURRENT_CHART_VERSION=$(echo ${current_chart_version})" >> $GITHUB_OUTPUT
- name: Get Updated Chart version from Chart.yaml
uses: mikefarah/yq@master
id: new_chart_version
with:
cmd: yq e '.version' deployments/kubernetes/chart/reloader/Chart.yaml
- name: Check Version
uses: aleoyakas/check-semver-increased-action@v1
id: check-version
with:
current-version: ${{ steps.new_chart_version.outputs.result }}
previous-version: ${{ steps.chart_eval.outputs.CURRENT_CHART_VERSION }}
- name: Fail if Helm Chart version isnt updated
if: steps.check-version.outputs.is-version-increased != 'true'
run: |
echo "Helm Chart Version wasnt updated"
exit 1

105
.github/workflows/push-helm-chart.yaml vendored Normal file
View File

@@ -0,0 +1,105 @@
name: Push Helm Chart
on:
pull_request:
types:
- closed
branches:
- master
paths:
- 'deployments/kubernetes/chart/reloader/**'
env:
HELM_REGISTRY_URL: "https://stakater.github.io/stakater-charts"
REGISTRY: ghcr.io
jobs:
build:
permissions:
contents: read
packages: write # to push artifacts to `ghcr.io`
name: Build
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
token: ${{ secrets.PUBLISH_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
submodules: recursive
# Setting up helm binary
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.11.3
- name: Add Stakater Helm Repo
run: |
helm repo add stakater https://stakater.github.io/stakater-charts
- name: Get version for chart from helm repo
id: chart_eval
run: |
current_chart_version=$(helm search repo stakater/reloader | tail -n 1 | awk '{print $2}')
echo "CURRENT_CHART_VERSION=$(echo ${current_chart_version})" >> $GITHUB_OUTPUT
- name: Get Updated Chart version from Chart.yaml
uses: mikefarah/yq@master
id: new_chart_version
with:
cmd: yq e '.version' deployments/kubernetes/chart/reloader/Chart.yaml
- name: Check Version
uses: aleoyakas/check-semver-increased-action@v1
id: check-version
with:
current-version: ${{ steps.new_chart_version.outputs.result }}
previous-version: ${{ steps.chart_eval.outputs.CURRENT_CHART_VERSION }}
- name: Fail if Helm Chart version isnt updated
if: steps.check-version.outputs.is-version-increased != 'true'
run: |
echo "Helm Chart Version wasnt updated"
exit 1
- name: Login to GHCR Registry
uses: docker/login-action@v2
with:
registry: ghcr.io/stakater
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Publish Helm chart to ghcr.io
run: |
helm package ./deployments/kubernetes/chart/reloader --destination ./packaged-chart
helm push ./packaged-chart/*.tgz oci://ghcr.io/stakater/charts
rm -rf ./packaged-chart
- name: Publish Helm chart to gh-pages
uses: stefanprodan/helm-gh-pages@master
with:
branch: master
repository: stakater-charts
target_dir: docs
token: ${{ secrets.PUBLISH_TOKEN }}
charts_dir: deployments/kubernetes/chart/
charts_url: ${{ env.HELM_REGISTRY_URL }}
owner: stakater
linting: on
commit_username: stakater-user
commit_email: stakater@gmail.com
- name: Notify Slack
uses: 8398a7/action-slack@v3
if: always() # Pick up events even if the job fails or is canceled.
with:
status: ${{ job.status }}
fields: repo,author,action,eventName,ref,workflow
env:
GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.STAKATER_DELIVERY_SLACK_WEBHOOK }}

View File

@@ -155,7 +155,7 @@ k8s-manifests: $(KUSTOMIZE) ## Generate k8s manifests using Kustomize from 'mani
.PHONY: update-manifests-version
update-manifests-version: ## Generate k8s manifests using Kustomize from 'manifests' folder
sed -i 's/image: "ghcr.io\/stakater\/reloader:latest"/image: \"ghcr.io\/stakater\/reloader:v$(VERSION)"/g' deployments/kubernetes/manifests/deployment.yaml
sed -i 's/image:.*/image: \"ghcr.io\/stakater\/reloader:v$(VERSION)"/g' deployments/kubernetes/manifests/deployment.yaml
# Bump Chart
bump-chart:

View File

@@ -3,8 +3,8 @@
apiVersion: v1
name: reloader
description: Reloader chart that runs on kubernetes
version: 1.1.1
appVersion: v1.1.0
version: 1.2.0
appVersion: v1.2.0
keywords:
- Reloader
- kubernetes

View File

@@ -76,16 +76,6 @@ rules:
- get
- update
- patch
- apiGroups:
- "extensions"
resources:
- deployments
- daemonsets
verbs:
- list
- get
- update
- patch
- apiGroups:
- "batch"
resources:

View File

@@ -94,11 +94,11 @@ reloader:
labels:
provider: stakater
group: com.stakater.platform
version: v1.1.0
version: v1.2.0
image:
name: ghcr.io/stakater/reloader
base: stakater/reloader
tag: v1.1.0
tag: v1.2.0
pullPolicy: IfNotPresent
# Support for extra environment variables.
env:

View File

@@ -199,6 +199,9 @@ func PerformAction(clients kube.Clients, config util.Config, upgradeFuncs callba
searchAnnotationValue, foundSearchAnn := annotations[options.AutoSearchAnnotation]
reloaderEnabledValue, foundAuto := annotations[options.ReloaderAutoAnnotation]
typedAutoAnnotationEnabledValue, foundTypedAuto := annotations[config.TypedAutoAnnotation]
excludeConfigmapAnnotationValue, foundExcludeConfigmap := annotations[options.ConfigmapExcludeReloaderAnnotation]
excludeSecretAnnotationValue, foundExcludeSecret := annotations[options.SecretExcludeReloaderAnnotation]
if !found && !foundAuto && !foundTypedAuto && !foundSearchAnn {
annotations = upgradeFuncs.PodAnnotationsFunc(i)
annotationValue = annotations[config.Annotation]
@@ -206,6 +209,24 @@ func PerformAction(clients kube.Clients, config util.Config, upgradeFuncs callba
reloaderEnabledValue = annotations[options.ReloaderAutoAnnotation]
typedAutoAnnotationEnabledValue = annotations[config.TypedAutoAnnotation]
}
isResourceExcluded := false
switch config.Type {
case constants.ConfigmapEnvVarPostfix:
if foundExcludeConfigmap {
isResourceExcluded = checkIfResourceIsExcluded(config.ResourceName, excludeConfigmapAnnotationValue)
}
case constants.SecretEnvVarPostfix:
if foundExcludeSecret {
isResourceExcluded = checkIfResourceIsExcluded(config.ResourceName, excludeSecretAnnotationValue)
}
}
if isResourceExcluded {
continue
}
result := constants.NotUpdated
reloaderEnabled, _ := strconv.ParseBool(reloaderEnabledValue)
typedAutoAnnotationEnabled, _ := strconv.ParseBool(typedAutoAnnotationEnabledValue)
@@ -275,6 +296,21 @@ func PerformAction(clients kube.Clients, config util.Config, upgradeFuncs callba
return nil
}
func checkIfResourceIsExcluded(resourceName, excludedResources string) bool {
if excludedResources == "" {
return false
}
excludedResourcesList := strings.Split(excludedResources, ",")
for _, excludedResource := range excludedResourcesList {
if strings.TrimSpace(excludedResource) == resourceName {
return true
}
}
return false
}
func getVolumeMountName(volumes []v1.Volume, mountType string, volumeName string) string {
for i := range volumes {
if mountType == constants.ConfigmapEnvVarPostfix {

View File

@@ -26,48 +26,52 @@ import (
var (
clients = kube.Clients{KubernetesClient: testclient.NewSimpleClientset()}
arsNamespace = "test-handler-" + testutil.RandSeq(5)
arsConfigmapName = "testconfigmap-handler-" + testutil.RandSeq(5)
arsSecretName = "testsecret-handler-" + testutil.RandSeq(5)
arsProjectedConfigMapName = "testprojectedconfigmap-handler-" + testutil.RandSeq(5)
arsProjectedSecretName = "testprojectedsecret-handler-" + testutil.RandSeq(5)
arsConfigmapWithInitContainer = "testconfigmapInitContainerhandler-" + testutil.RandSeq(5)
arsSecretWithInitContainer = "testsecretWithInitContainer-handler-" + testutil.RandSeq(5)
arsProjectedConfigMapWithInitContainer = "testProjectedConfigMapWithInitContainer-handler" + testutil.RandSeq(5)
arsProjectedSecretWithInitContainer = "testProjectedSecretWithInitContainer-handler" + testutil.RandSeq(5)
arsConfigmapWithInitEnv = "configmapWithInitEnv-" + testutil.RandSeq(5)
arsSecretWithInitEnv = "secretWithInitEnv-handler-" + testutil.RandSeq(5)
arsConfigmapWithEnvName = "testconfigmapWithEnv-handler-" + testutil.RandSeq(5)
arsConfigmapWithEnvFromName = "testconfigmapWithEnvFrom-handler-" + testutil.RandSeq(5)
arsSecretWithEnvName = "testsecretWithEnv-handler-" + testutil.RandSeq(5)
arsSecretWithEnvFromName = "testsecretWithEnvFrom-handler-" + testutil.RandSeq(5)
arsConfigmapWithPodAnnotations = "testconfigmapPodAnnotations-handler-" + testutil.RandSeq(5)
arsConfigmapWithBothAnnotations = "testconfigmapBothAnnotations-handler-" + testutil.RandSeq(5)
arsConfigmapAnnotated = "testconfigmapAnnotated-handler-" + testutil.RandSeq(5)
arsConfigMapWithNonAnnotatedDeployment = "testconfigmapNonAnnotatedDeployment-handler-" + testutil.RandSeq(5)
arsSecretWithSecretAutoAnnotation = "testsecretwithsecretautoannotationdeployment-handler-" + testutil.RandSeq(5)
arsConfigmapWithConfigMapAutoAnnotation = "testconfigmapwithconfigmapautoannotationdeployment-handler-" + testutil.RandSeq(5)
arsNamespace = "test-handler-" + testutil.RandSeq(5)
arsConfigmapName = "testconfigmap-handler-" + testutil.RandSeq(5)
arsSecretName = "testsecret-handler-" + testutil.RandSeq(5)
arsProjectedConfigMapName = "testprojectedconfigmap-handler-" + testutil.RandSeq(5)
arsProjectedSecretName = "testprojectedsecret-handler-" + testutil.RandSeq(5)
arsConfigmapWithInitContainer = "testconfigmapInitContainerhandler-" + testutil.RandSeq(5)
arsSecretWithInitContainer = "testsecretWithInitContainer-handler-" + testutil.RandSeq(5)
arsProjectedConfigMapWithInitContainer = "testProjectedConfigMapWithInitContainer-handler" + testutil.RandSeq(5)
arsProjectedSecretWithInitContainer = "testProjectedSecretWithInitContainer-handler" + testutil.RandSeq(5)
arsConfigmapWithInitEnv = "configmapWithInitEnv-" + testutil.RandSeq(5)
arsSecretWithInitEnv = "secretWithInitEnv-handler-" + testutil.RandSeq(5)
arsConfigmapWithEnvName = "testconfigmapWithEnv-handler-" + testutil.RandSeq(5)
arsConfigmapWithEnvFromName = "testconfigmapWithEnvFrom-handler-" + testutil.RandSeq(5)
arsSecretWithEnvName = "testsecretWithEnv-handler-" + testutil.RandSeq(5)
arsSecretWithEnvFromName = "testsecretWithEnvFrom-handler-" + testutil.RandSeq(5)
arsConfigmapWithPodAnnotations = "testconfigmapPodAnnotations-handler-" + testutil.RandSeq(5)
arsConfigmapWithBothAnnotations = "testconfigmapBothAnnotations-handler-" + testutil.RandSeq(5)
arsConfigmapAnnotated = "testconfigmapAnnotated-handler-" + testutil.RandSeq(5)
arsConfigMapWithNonAnnotatedDeployment = "testconfigmapNonAnnotatedDeployment-handler-" + testutil.RandSeq(5)
arsSecretWithSecretAutoAnnotation = "testsecretwithsecretautoannotationdeployment-handler-" + testutil.RandSeq(5)
arsConfigmapWithConfigMapAutoAnnotation = "testconfigmapwithconfigmapautoannotationdeployment-handler-" + testutil.RandSeq(5)
arsSecretWithExcludeSecretAnnotation = "testsecretwithsecretexcludeannotationdeployment-handler-" + testutil.RandSeq(5)
arsConfigmapWithExcludeConfigMapAnnotation = "testconfigmapwithconfigmapexcludeannotationdeployment-handler-" + testutil.RandSeq(5)
ersNamespace = "test-handler-" + testutil.RandSeq(5)
ersConfigmapName = "testconfigmap-handler-" + testutil.RandSeq(5)
ersSecretName = "testsecret-handler-" + testutil.RandSeq(5)
ersProjectedConfigMapName = "testprojectedconfigmap-handler-" + testutil.RandSeq(5)
ersProjectedSecretName = "testprojectedsecret-handler-" + testutil.RandSeq(5)
ersConfigmapWithInitContainer = "testconfigmapInitContainerhandler-" + testutil.RandSeq(5)
ersSecretWithInitContainer = "testsecretWithInitContainer-handler-" + testutil.RandSeq(5)
ersProjectedConfigMapWithInitContainer = "testProjectedConfigMapWithInitContainer-handler" + testutil.RandSeq(5)
ersProjectedSecretWithInitContainer = "testProjectedSecretWithInitContainer-handler" + testutil.RandSeq(5)
ersConfigmapWithInitEnv = "configmapWithInitEnv-" + testutil.RandSeq(5)
ersSecretWithInitEnv = "secretWithInitEnv-handler-" + testutil.RandSeq(5)
ersConfigmapWithEnvName = "testconfigmapWithEnv-handler-" + testutil.RandSeq(5)
ersConfigmapWithEnvFromName = "testconfigmapWithEnvFrom-handler-" + testutil.RandSeq(5)
ersSecretWithEnvName = "testsecretWithEnv-handler-" + testutil.RandSeq(5)
ersSecretWithEnvFromName = "testsecretWithEnvFrom-handler-" + testutil.RandSeq(5)
ersConfigmapWithPodAnnotations = "testconfigmapPodAnnotations-handler-" + testutil.RandSeq(5)
ersConfigmapWithBothAnnotations = "testconfigmapBothAnnotations-handler-" + testutil.RandSeq(5)
ersConfigmapAnnotated = "testconfigmapAnnotated-handler-" + testutil.RandSeq(5)
ersSecretWithSecretAutoAnnotation = "testsecretwithsecretautoannotationdeployment-handler-" + testutil.RandSeq(5)
ersConfigmapWithConfigMapAutoAnnotation = "testconfigmapwithconfigmapautoannotationdeployment-handler-" + testutil.RandSeq(5)
ersNamespace = "test-handler-" + testutil.RandSeq(5)
ersConfigmapName = "testconfigmap-handler-" + testutil.RandSeq(5)
ersSecretName = "testsecret-handler-" + testutil.RandSeq(5)
ersProjectedConfigMapName = "testprojectedconfigmap-handler-" + testutil.RandSeq(5)
ersProjectedSecretName = "testprojectedsecret-handler-" + testutil.RandSeq(5)
ersConfigmapWithInitContainer = "testconfigmapInitContainerhandler-" + testutil.RandSeq(5)
ersSecretWithInitContainer = "testsecretWithInitContainer-handler-" + testutil.RandSeq(5)
ersProjectedConfigMapWithInitContainer = "testProjectedConfigMapWithInitContainer-handler" + testutil.RandSeq(5)
ersProjectedSecretWithInitContainer = "testProjectedSecretWithInitContainer-handler" + testutil.RandSeq(5)
ersConfigmapWithInitEnv = "configmapWithInitEnv-" + testutil.RandSeq(5)
ersSecretWithInitEnv = "secretWithInitEnv-handler-" + testutil.RandSeq(5)
ersConfigmapWithEnvName = "testconfigmapWithEnv-handler-" + testutil.RandSeq(5)
ersConfigmapWithEnvFromName = "testconfigmapWithEnvFrom-handler-" + testutil.RandSeq(5)
ersSecretWithEnvName = "testsecretWithEnv-handler-" + testutil.RandSeq(5)
ersSecretWithEnvFromName = "testsecretWithEnvFrom-handler-" + testutil.RandSeq(5)
ersConfigmapWithPodAnnotations = "testconfigmapPodAnnotations-handler-" + testutil.RandSeq(5)
ersConfigmapWithBothAnnotations = "testconfigmapBothAnnotations-handler-" + testutil.RandSeq(5)
ersConfigmapAnnotated = "testconfigmapAnnotated-handler-" + testutil.RandSeq(5)
ersSecretWithSecretAutoAnnotation = "testsecretwithsecretautoannotationdeployment-handler-" + testutil.RandSeq(5)
ersConfigmapWithConfigMapAutoAnnotation = "testconfigmapwithconfigmapautoannotationdeployment-handler-" + testutil.RandSeq(5)
ersSecretWithSecretExcludeAnnotation = "testsecretwithsecretexcludeannotationdeployment-handler-" + testutil.RandSeq(5)
ersConfigmapWithConfigMapExcludeAnnotation = "testconfigmapwithconfigmapexcludeannotationdeployment-handler-" + testutil.RandSeq(5)
)
func TestMain(m *testing.M) {
@@ -196,6 +200,18 @@ func setupArs() {
logrus.Errorf("Error in configmap creation: %v", err)
}
// Creating secret used with secret auto annotation
_, err = testutil.CreateSecret(clients.KubernetesClient, arsNamespace, arsSecretWithExcludeSecretAnnotation, data)
if err != nil {
logrus.Errorf("Error in secret creation: %v", err)
}
// Creating configmap used with configmap auto annotation
_, err = testutil.CreateConfigMap(clients.KubernetesClient, arsNamespace, arsConfigmapWithExcludeConfigMapAnnotation, "www.google.com")
if err != nil {
logrus.Errorf("Error in configmap creation: %v", err)
}
// Creating Deployment with configmap
_, err = testutil.CreateDeployment(clients.KubernetesClient, arsConfigmapName, arsNamespace, true)
if err != nil {
@@ -309,6 +325,18 @@ func setupArs() {
logrus.Errorf("Error in Deployment with configmap and with configmap auto annotation: %v", err)
}
// Creating Deployment with secret and exclude secret annotation
_, err = testutil.CreateDeploymentWithExcludeAnnotation(clients.KubernetesClient, arsSecretWithExcludeSecretAnnotation, arsNamespace, testutil.SecretResourceType)
if err != nil {
logrus.Errorf("Error in Deployment with secret and with secret exclude annotation: %v", err)
}
// Creating Deployment with secret and exclude configmap annotation
_, err = testutil.CreateDeploymentWithExcludeAnnotation(clients.KubernetesClient, arsConfigmapWithExcludeConfigMapAnnotation, arsNamespace, testutil.ConfigmapResourceType)
if err != nil {
logrus.Errorf("Error in Deployment with configmap and with configmap exclude annotation: %v", err)
}
// Creating DaemonSet with configmap
_, err = testutil.CreateDaemonSet(clients.KubernetesClient, arsConfigmapName, arsNamespace, true)
if err != nil {
@@ -510,6 +538,18 @@ func teardownArs() {
logrus.Errorf("Error while deleting deployment with configmap auto annotation %v", deploymentError)
}
// Deleting Deployment with secret and exclude secret annotation
deploymentError = testutil.DeleteDeployment(clients.KubernetesClient, arsNamespace, arsSecretWithExcludeSecretAnnotation)
if deploymentError != nil {
logrus.Errorf("Error while deleting deployment with secret auto annotation %v", deploymentError)
}
// Deleting Deployment with configmap and exclude configmap annotation
deploymentError = testutil.DeleteDeployment(clients.KubernetesClient, arsNamespace, arsConfigmapWithExcludeConfigMapAnnotation)
if deploymentError != nil {
logrus.Errorf("Error while deleting deployment with configmap auto annotation %v", deploymentError)
}
// Deleting DaemonSet with configmap
daemonSetError := testutil.DeleteDaemonSet(clients.KubernetesClient, arsNamespace, arsConfigmapName)
if daemonSetError != nil {
@@ -683,6 +723,18 @@ func teardownArs() {
logrus.Errorf("Error while deleting the configmap used with configmap auto annotations: %v", err)
}
// Deleting Secret used with exclude secret annotation
err = testutil.DeleteSecret(clients.KubernetesClient, arsNamespace, arsSecretWithExcludeSecretAnnotation)
if err != nil {
logrus.Errorf("Error while deleting the secret used with secret auto annotations: %v", err)
}
// Deleting ConfigMap used with exclude configmap annotation
err = testutil.DeleteConfigMap(clients.KubernetesClient, arsNamespace, arsConfigmapWithExcludeConfigMapAnnotation)
if err != nil {
logrus.Errorf("Error while deleting the configmap used with configmap auto annotations: %v", err)
}
// Deleting namespace
testutil.DeleteNamespace(arsNamespace, clients.KubernetesClient)
@@ -787,6 +839,18 @@ func setupErs() {
logrus.Errorf("Error in configmap creation: %v", err)
}
// Creating secret used with secret exclude annotation
_, err = testutil.CreateSecret(clients.KubernetesClient, ersNamespace, ersSecretWithSecretExcludeAnnotation, data)
if err != nil {
logrus.Errorf("Error in secret creation: %v", err)
}
// Creating configmap used with configmap exclude annotation
_, err = testutil.CreateConfigMap(clients.KubernetesClient, ersNamespace, ersConfigmapWithConfigMapExcludeAnnotation, "www.google.com")
if err != nil {
logrus.Errorf("Error in configmap creation: %v", err)
}
// Creating Deployment with configmap
_, err = testutil.CreateDeployment(clients.KubernetesClient, ersConfigmapName, ersNamespace, true)
if err != nil {
@@ -894,6 +958,18 @@ func setupErs() {
logrus.Errorf("Error in Deployment with configmap and with configmap auto annotation: %v", err)
}
// Creating Deployment with secret and with secret exclude annotation
_, err = testutil.CreateDeploymentWithExcludeAnnotation(clients.KubernetesClient, ersSecretWithSecretExcludeAnnotation, ersNamespace, testutil.SecretResourceType)
if err != nil {
logrus.Errorf("Error in Deployment with secret and with secret exclude annotation: %v", err)
}
// Creating Deployment with secret and with secret exclude annotation
_, err = testutil.CreateDeploymentWithExcludeAnnotation(clients.KubernetesClient, ersConfigmapWithConfigMapExcludeAnnotation, ersNamespace, testutil.ConfigmapResourceType)
if err != nil {
logrus.Errorf("Error in Deployment with configmap and with configmap exclude annotation: %v", err)
}
// Creating DaemonSet with configmap
_, err = testutil.CreateDaemonSet(clients.KubernetesClient, ersConfigmapName, ersNamespace, true)
if err != nil {
@@ -1094,6 +1170,18 @@ func teardownErs() {
logrus.Errorf("Error while deleting deployment with configmap auto annotation %v", deploymentError)
}
// Deleting Deployment with secret and secret exclude annotation
deploymentError = testutil.DeleteDeployment(clients.KubernetesClient, ersNamespace, ersSecretWithSecretExcludeAnnotation)
if deploymentError != nil {
logrus.Errorf("Error while deleting deployment with secret exclude annotation %v", deploymentError)
}
// Deleting Deployment with configmap and configmap exclude annotation
deploymentError = testutil.DeleteDeployment(clients.KubernetesClient, ersNamespace, ersConfigmapWithConfigMapExcludeAnnotation)
if deploymentError != nil {
logrus.Errorf("Error while deleting deployment with configmap exclude annotation %v", deploymentError)
}
// Deleting DaemonSet with configmap
daemonSetError := testutil.DeleteDaemonSet(clients.KubernetesClient, ersNamespace, ersConfigmapName)
if daemonSetError != nil {
@@ -1267,6 +1355,18 @@ func teardownErs() {
logrus.Errorf("Error while deleting the configmap used with configmap auto annotation: %v", err)
}
// Deleting Secret used with secret exclude annotation
err = testutil.DeleteSecret(clients.KubernetesClient, ersNamespace, ersSecretWithSecretExcludeAnnotation)
if err != nil {
logrus.Errorf("Error while deleting the secret used with secret exclude annotation: %v", err)
}
// Deleting ConfigMap used with configmap exclude annotation
err = testutil.DeleteConfigMap(clients.KubernetesClient, ersNamespace, ersConfigmapWithConfigMapExcludeAnnotation)
if err != nil {
logrus.Errorf("Error while deleting the configmap used with configmap exclude annotation: %v", err)
}
// Deleting namespace
testutil.DeleteNamespace(ersNamespace, clients.KubernetesClient)
@@ -1337,8 +1437,8 @@ func TestRollingUpgradeForDeploymentWithConfigmapUsingArs(t *testing.T) {
if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 {
t.Errorf("Counter was not increased")
}
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 {
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
@@ -1403,9 +1503,9 @@ func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationButWithA
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingArs(t *testing.T) {
@@ -1432,11 +1532,11 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingArs(t *te
t.Errorf("Counter was not increased")
}
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 {
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingArs(t *testing.T) {
@@ -1468,7 +1568,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingArs(t *
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUsingArs(t *testing.T) {
@@ -1575,7 +1675,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingArs(t *test
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerUsingArs(t *testing.T) {
@@ -1607,7 +1707,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerU
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingArs(t *testing.T) {
@@ -1639,7 +1739,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingArs(t *testing.T)
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingArs(t *testing.T) {
@@ -1670,8 +1770,8 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingArs
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingArs(t *testing.T) {
@@ -1703,7 +1803,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingArs(t *testing
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretUsingArs(t *testing.T) {
@@ -1735,7 +1835,7 @@ func TestRollingUpgradeForDeploymentWithSecretUsingArs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingArs(t *testing.T) {
@@ -1767,7 +1867,7 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingArs(t *testi
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingArs(t *testing.T) {
@@ -1799,7 +1899,7 @@ func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingArs(t *testing
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUsingArs(t *testing.T) {
@@ -1831,7 +1931,7 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUs
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingArs(t *testing.T) {
@@ -1863,7 +1963,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingArs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingArs(t *testing.T) {
@@ -1926,7 +2026,28 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingArs(t
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretExcludeAnnotationUsingArs(t *testing.T) {
options.ReloadStrategy = constants.AnnotationsReloadStrategy
envVarPostfix := constants.SecretEnvVarPostfix
shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretWithExcludeSecretAnnotation, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy")
config := getConfigWithAnnotations(envVarPostfix, arsSecretWithExcludeSecretAnnotation, shaData, "", options.SecretReloaderAutoAnnotation)
deploymentFuncs := GetDeploymentRollingUpgradeFuncs()
collectors := getCollectors()
err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy)
if err != nil {
t.Errorf("Rolling upgrade failed for Deployment with Secret")
}
logrus.Infof("Verifying deployment did not update")
updated := testutil.VerifyResourceAnnotationUpdate(clients, config, deploymentFuncs)
if updated {
t.Errorf("Deployment which had to be exluded was updated")
}
}
func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingArs(t *testing.T) {
@@ -1958,9 +2079,29 @@ func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingArs(t *testing.
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithExcludeConfigMapAnnotationUsingArs(t *testing.T) {
options.ReloadStrategy = constants.AnnotationsReloadStrategy
envVarPostfix := constants.ConfigmapEnvVarPostfix
shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapWithExcludeConfigMapAnnotation, "www.facebook.com")
config := getConfigWithAnnotations(envVarPostfix, arsConfigmapWithExcludeConfigMapAnnotation, shaData, "", options.ConfigmapReloaderAutoAnnotation)
deploymentFuncs := GetDeploymentRollingUpgradeFuncs()
collectors := getCollectors()
err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy)
if err != nil {
t.Errorf("Rolling upgrade failed for Deployment with exclude ConfigMap")
}
logrus.Infof("Verifying deployment did update")
updated := testutil.VerifyResourceAnnotationUpdate(clients, config, deploymentFuncs)
if updated {
t.Errorf("Deployment which had to be excluded was updated")
}
}
func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingArs(t *testing.T) {
options.ReloadStrategy = constants.AnnotationsReloadStrategy
envVarPostfix := constants.ConfigmapEnvVarPostfix
@@ -1990,7 +2131,7 @@ func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingArs(t *testi
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithConfigmapUsingArs(t *testing.T) {
@@ -2021,8 +2162,8 @@ func TestRollingUpgradeForDaemonSetWithConfigmapUsingArs(t *testing.T) {
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingArs(t *testing.T) {
@@ -2054,7 +2195,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingArs(t *tes
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingArs(t *testing.T) {
@@ -2118,7 +2259,7 @@ func TestRollingUpgradeForDaemonSetWithSecretUsingArs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingArs(t *testing.T) {
@@ -2150,7 +2291,7 @@ func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingArs(t *testin
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForStatefulSetWithConfigmapUsingArs(t *testing.T) {
@@ -2182,7 +2323,7 @@ func TestRollingUpgradeForStatefulSetWithConfigmapUsingArs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingArs(t *testing.T) {
@@ -2214,7 +2355,7 @@ func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingArs(t *t
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForStatefulSetWithSecretUsingArs(t *testing.T) {
@@ -2246,7 +2387,7 @@ func TestRollingUpgradeForStatefulSetWithSecretUsingArs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingArs(t *testing.T) {
@@ -2278,7 +2419,7 @@ func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingArs(t *test
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingArs(t *testing.T) {
@@ -2437,7 +2578,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingErs(t *te
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingErs(t *testing.T) {
@@ -2469,7 +2610,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingErs(t *
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUsingErs(t *testing.T) {
@@ -2576,7 +2717,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingErs(t *test
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerUsingErs(t *testing.T) {
@@ -2640,7 +2781,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingErs(t *testing.T)
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingErs(t *testing.T) {
@@ -2704,7 +2845,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingErs(t *testing
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretUsingErs(t *testing.T) {
@@ -2736,7 +2877,7 @@ func TestRollingUpgradeForDeploymentWithSecretUsingErs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingErs(t *testing.T) {
@@ -2800,7 +2941,7 @@ func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingErs(t *testing
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUsingErs(t *testing.T) {
@@ -2832,7 +2973,7 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUs
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingErs(t *testing.T) {
@@ -2864,7 +3005,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingErs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingErs(t *testing.T) {
@@ -2896,7 +3037,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingErs(t *testing.T)
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingErs(t *testing.T) {
@@ -2928,7 +3069,29 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingErs(t
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithSecretExcludeAnnotationUsingErs(t *testing.T) {
options.ReloadStrategy = constants.EnvVarsReloadStrategy
envVarPostfix := constants.SecretEnvVarPostfix
shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretWithSecretExcludeAnnotation, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy")
config := getConfigWithAnnotations(envVarPostfix, ersSecretWithSecretExcludeAnnotation, shaData, "", options.SecretReloaderAutoAnnotation)
deploymentFuncs := GetDeploymentRollingUpgradeFuncs()
collectors := getCollectors()
err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy)
time.Sleep(5 * time.Second)
if err != nil {
t.Errorf("Rolling upgrade failed for Deployment with exclude Secret")
}
logrus.Infof("Verifying deployment did not update")
updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs)
if updated {
t.Errorf("Deployment that had to be excluded was updated")
}
}
func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingErs(t *testing.T) {
@@ -2956,12 +3119,33 @@ func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingErs(t *testing.
t.Errorf("Counter was not increased")
}
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 {
if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithConfigMapExcludeAnnotationUsingErs(t *testing.T) {
options.ReloadStrategy = constants.EnvVarsReloadStrategy
envVarPostfix := constants.ConfigmapEnvVarPostfix
shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapWithConfigMapExcludeAnnotation, "www.facebook.com")
config := getConfigWithAnnotations(envVarPostfix, ersConfigmapWithConfigMapExcludeAnnotation, shaData, "", options.ConfigmapReloaderAutoAnnotation)
deploymentFuncs := GetDeploymentRollingUpgradeFuncs()
collectors := getCollectors()
err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy)
time.Sleep(5 * time.Second)
if err != nil {
t.Errorf("Rolling upgrade failed for Deployment with exclude ConfigMap")
}
logrus.Infof("Verifying deployment did not update")
updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs)
if updated {
t.Errorf("Deployment which had to be excluded was updated")
}
}
func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingErs(t *testing.T) {
@@ -2993,7 +3177,7 @@ func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingErs(t *testi
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithConfigmapUsingErs(t *testing.T) {
@@ -3025,7 +3209,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapUsingErs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingErs(t *testing.T) {
@@ -3057,7 +3241,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingErs(t *tes
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingErs(t *testing.T) {
@@ -3089,7 +3273,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingErs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithSecretUsingErs(t *testing.T) {
@@ -3121,7 +3305,7 @@ func TestRollingUpgradeForDaemonSetWithSecretUsingErs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingErs(t *testing.T) {
@@ -3153,7 +3337,7 @@ func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingErs(t *testin
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForStatefulSetWithConfigmapUsingErs(t *testing.T) {
@@ -3185,7 +3369,7 @@ func TestRollingUpgradeForStatefulSetWithConfigmapUsingErs(t *testing.T) {
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingErs(t *testing.T) {
@@ -3217,7 +3401,7 @@ func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingErs(t *t
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForStatefulSetWithSecretUsingErs(t *testing.T) {
@@ -3281,7 +3465,7 @@ func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingErs(t *test
t.Errorf("Counter by namespace was not increased")
}
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix)
}
func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingErs(t *testing.T) {

View File

@@ -17,6 +17,10 @@ var (
ConfigmapReloaderAutoAnnotation = "configmap.reloader.stakater.com/auto"
// SecretReloaderAutoAnnotation is an annotation to detect changes in secrets
SecretReloaderAutoAnnotation = "secret.reloader.stakater.com/auto"
// ConfigmapReloaderAutoAnnotation is a comma separated list of configmaps that excludes detecting changes on cms
ConfigmapExcludeReloaderAnnotation = "configmaps.exclude.reloader.stakater.com/reload"
// SecretExcludeReloaderAnnotation is a comma separated list of secrets that excludes detecting changes on secrets
SecretExcludeReloaderAnnotation = "secrets.exclude.reloader.stakater.com/reload"
// AutoSearchAnnotation is an annotation to detect changes in
// configmaps or triggers with the SearchMatchAnnotation
AutoSearchAnnotation = "reloader.stakater.com/search"

View File

@@ -503,6 +503,37 @@ func GetDeploymentWithTypedAutoAnnotation(namespace string, deploymentName strin
}
}
func GetDeploymentWithExcludeAnnotation(namespace string, deploymentName string, resourceType string) *appsv1.Deployment {
replicaset := int32(1)
annotation := map[string]string{}
if resourceType == SecretResourceType {
annotation[options.SecretExcludeReloaderAnnotation] = deploymentName
} else if resourceType == ConfigmapResourceType {
annotation[options.ConfigmapExcludeReloaderAnnotation] = deploymentName
}
return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: deploymentName,
Namespace: namespace,
Labels: map[string]string{"firstLabel": "temp"},
Annotations: annotation,
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"secondLabel": "temp"},
},
Replicas: &replicaset,
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType,
},
Template: getPodTemplateSpecWithVolumes(deploymentName),
},
}
}
// GetDaemonSet provides daemonset for testing
func GetDaemonSet(namespace string, daemonsetName string) *appsv1.DaemonSet {
return &appsv1.DaemonSet{
@@ -773,6 +804,15 @@ func CreateDeploymentWithTypedAutoAnnotation(client kubernetes.Interface, deploy
return deployment, err
}
// CreateDeploymentWithExcludeAnnotation creates a deployment in given namespace and returns the Deployment with typed auto annotation
func CreateDeploymentWithExcludeAnnotation(client kubernetes.Interface, deploymentName string, namespace string, resourceType string) (*appsv1.Deployment, error) {
logrus.Infof("Creating Deployment")
deploymentClient := client.AppsV1().Deployments(namespace)
deploymentObj := GetDeploymentWithExcludeAnnotation(namespace, deploymentName, resourceType)
deployment, err := deploymentClient.Create(context.TODO(), deploymentObj, metav1.CreateOptions{})
return deployment, err
}
// CreateDaemonSet creates a deployment in given namespace and returns the DaemonSet
func CreateDaemonSet(client kubernetes.Interface, daemonsetName string, namespace string, volumeMount bool) (*appsv1.DaemonSet, error) {
logrus.Infof("Creating DaemonSet")