mirror of
https://github.com/stakater/Reloader.git
synced 2026-02-15 02:19:50 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea62b0036c | ||
|
|
decb9b06be | ||
|
|
94bd7bb694 | ||
|
|
67843f839a | ||
|
|
342395cd84 | ||
|
|
695c5b05d2 | ||
|
|
4d6da476ee | ||
|
|
d5ea5d810d | ||
|
|
0d10b35d3a | ||
|
|
807e0c0c1b | ||
|
|
052bbb23e5 | ||
|
|
28fb50598c | ||
|
|
a3e4c3a4d7 | ||
|
|
d3bae0d3bb |
15
README.md
15
README.md
@@ -42,6 +42,8 @@ You can apply vanilla manifests by running the following command
|
||||
kubectl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml
|
||||
```
|
||||
|
||||
By default Reloader gets deployed in `default` namespace and watches changes `secrets` and `configmaps` in all namespaces.
|
||||
|
||||
### Helm Charts
|
||||
|
||||
Alternatively if you have configured helm on your cluster, you can add reloader to helm from our public chart repository and deploy it via helm using below mentioned commands
|
||||
@@ -54,21 +56,20 @@ helm repo update
|
||||
helm install stakater/reloader
|
||||
```
|
||||
|
||||
## Monitor All namespaces
|
||||
|
||||
By default Reloader gets deployed in `default` namespace and watches changes `secrets` and `configmaps` in all namespaces.
|
||||
|
||||
## Help
|
||||
|
||||
**Got a question?**
|
||||
### Documentation
|
||||
You can find more documentation [here](docs/)
|
||||
|
||||
### Have a question?
|
||||
File a GitHub [issue](https://github.com/stakater/Reloader/issues), or send us an [email](mailto:stakater@gmail.com).
|
||||
|
||||
### Talk to us on Slack
|
||||
|
||||
Join and talk to us on the #tools-imc channel for discussing Reloader
|
||||
Join and talk to us on Slack for discussing Reloader
|
||||
|
||||
[](https://stakater-slack.herokuapp.com/)
|
||||
[](https://stakater.slack.com/messages/CAN960CTG/)
|
||||
[](https://stakater.slack.com/)
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
apiVersion: v1
|
||||
name: reloader
|
||||
description: Reloader chart that runs on kubernetes
|
||||
version: 0.0.8
|
||||
version: 0.0.14
|
||||
keywords:
|
||||
- Reloader
|
||||
- kubernetes
|
||||
|
||||
@@ -7,9 +7,9 @@ reloader:
|
||||
labels:
|
||||
provider: stakater
|
||||
group: com.stakater.platform
|
||||
version: 0.0.8
|
||||
version: 0.0.14
|
||||
image:
|
||||
name: stakater/reloader
|
||||
tag: "0.0.8"
|
||||
tag: "0.0.14"
|
||||
pullPolicy: IfNotPresent
|
||||
watchGlobally: true
|
||||
@@ -7,8 +7,8 @@ metadata:
|
||||
app: reloader
|
||||
group: com.stakater.platform
|
||||
provider: stakater
|
||||
version: 0.0.8
|
||||
chart: "reloader-0.0.8"
|
||||
version: 0.0.14
|
||||
chart: "reloader-0.0.14"
|
||||
release: "RELEASE-NAME"
|
||||
heritage: "Tiller"
|
||||
name: reloader
|
||||
@@ -29,7 +29,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
image: "stakater/reloader:0.0.8"
|
||||
image: "stakater/reloader:0.0.14"
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: reloader
|
||||
serviceAccountName: reloader
|
||||
|
||||
@@ -7,8 +7,8 @@ metadata:
|
||||
app: reloader
|
||||
group: com.stakater.platform
|
||||
provider: stakater
|
||||
version: 0.0.8
|
||||
chart: "reloader-0.0.8"
|
||||
version: 0.0.14
|
||||
chart: "reloader-0.0.14"
|
||||
release: "RELEASE-NAME"
|
||||
heritage: "Tiller"
|
||||
name: reloader
|
||||
@@ -20,8 +20,8 @@ metadata:
|
||||
app: reloader
|
||||
group: com.stakater.platform
|
||||
provider: stakater
|
||||
version: 0.0.8
|
||||
chart: "reloader-0.0.8"
|
||||
version: 0.0.14
|
||||
chart: "reloader-0.0.14"
|
||||
release: "RELEASE-NAME"
|
||||
heritage: "Tiller"
|
||||
name: reloader-role
|
||||
@@ -57,8 +57,8 @@ metadata:
|
||||
app: reloader
|
||||
group: com.stakater.platform
|
||||
provider: stakater
|
||||
version: 0.0.8
|
||||
chart: "reloader-0.0.8"
|
||||
version: 0.0.14
|
||||
chart: "reloader-0.0.14"
|
||||
release: "RELEASE-NAME"
|
||||
heritage: "Tiller"
|
||||
name: reloader-role-binding
|
||||
|
||||
@@ -7,8 +7,8 @@ metadata:
|
||||
app: reloader
|
||||
group: com.stakater.platform
|
||||
provider: stakater
|
||||
version: 0.0.8
|
||||
chart: "reloader-0.0.8"
|
||||
version: 0.0.14
|
||||
chart: "reloader-0.0.14"
|
||||
release: "RELEASE-NAME"
|
||||
heritage: "Tiller"
|
||||
name: reloader
|
||||
@@ -29,7 +29,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
image: "stakater/reloader:0.0.8"
|
||||
image: "stakater/reloader:0.0.14"
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: reloader
|
||||
serviceAccountName: reloader
|
||||
@@ -43,8 +43,8 @@ metadata:
|
||||
app: reloader
|
||||
group: com.stakater.platform
|
||||
provider: stakater
|
||||
version: 0.0.8
|
||||
chart: "reloader-0.0.8"
|
||||
version: 0.0.14
|
||||
chart: "reloader-0.0.14"
|
||||
release: "RELEASE-NAME"
|
||||
heritage: "Tiller"
|
||||
name: reloader
|
||||
@@ -56,8 +56,8 @@ metadata:
|
||||
app: reloader
|
||||
group: com.stakater.platform
|
||||
provider: stakater
|
||||
version: 0.0.8
|
||||
chart: "reloader-0.0.8"
|
||||
version: 0.0.14
|
||||
chart: "reloader-0.0.14"
|
||||
release: "RELEASE-NAME"
|
||||
heritage: "Tiller"
|
||||
name: reloader-role
|
||||
@@ -93,8 +93,8 @@ metadata:
|
||||
app: reloader
|
||||
group: com.stakater.platform
|
||||
provider: stakater
|
||||
version: 0.0.8
|
||||
chart: "reloader-0.0.8"
|
||||
version: 0.0.14
|
||||
chart: "reloader-0.0.14"
|
||||
release: "RELEASE-NAME"
|
||||
heritage: "Tiller"
|
||||
name: reloader-role-binding
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
|
||||
# Reloader vs ConfigmapController
|
||||
|
||||
Reloader is inspired from [configmapcontroller](https://github.com/fabric8io/configmapcontroller) but there are many ways in which it differs from configmapController. Below is the small comparison between these two controllers.
|
||||
Reloader is inspired from [Configmapcontroller](https://github.com/fabric8io/configmapcontroller) but there are many ways in which it differs from configmapController. Below is the small comparison between these two controllers.
|
||||
|
||||
| Configmap | Reloader |
|
||||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| ConfigmapController can only watch changes in `configmaps`. It cannot detect changes in other resources like `secrets`. | Reloader on the other hand can watch and detect changes in both `secrets` and `configmaps`. |
|
||||
| ConfigmapController can only perform rolling upgrades on `deployments`. It currently does not support rolling upgrades on `statefulsets` and `daemonsets` | Reloader on the other hand can perform rolling upgrades on `deployments` as well as on `statefulsets` and `daemonsets` |
|
||||
| Currently there are no unit test cases or end to end integration test cases in configmap controller. It add difficulties for any additional updates in configmap controller and one can not know for sure if new changes break any older functionality or not. | Reloader provides both unit test cases and end to end integration test cases for future updates. So one can make sure that new changes do not break any older functionality. |
|
||||
| Configmap controller uses `FABRICB_FOO_REVISION` environment variable to store any change in configmap controller. It does not encode it or convert it in suitable hash value to avoid data pollution in deployment. | Reloader uses SHA1 to encode the change in configmap or secret. It then saves the SHA1 value in `STAKATER_FOO_CONFIGMAP` or `STAKATER_FOO_SECRET` environment variable depending upon where the change has happened. The use of SHA1 provides a concise 40 characters encoded value that is also very less pron to collision. |
|
||||
| Reloader | Configmap |
|
||||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Reloader can watch both `secrets` and `configmaps`. | ConfigmapController can only watch changes in `configmaps`. It cannot detect changes in other resources like `secrets`. |
|
||||
| Reloader can perform rolling upgrades on `deployments` as well as on `statefulsets` and `daemonsets` | ConfigmapController can only perform rolling upgrades on `deployments`. It currently does not support rolling upgrades on `statefulsets` and `daemonsets` |
|
||||
| Reloader provides both unit test cases and end to end integration test cases for future updates. So one can make sure that new changes do not break any old functionality. | Currently there are not any unit test cases or end to end integration test cases in configmap controller. It add difficulties for any additional updates in configmap controller and one can not know for sure whether new changes breaks any old functionality or not. |
|
||||
| Reloader uses SHA1 to encode the change in configmap or secret. It then saves the SHA1 value in `STAKATER_FOO_CONFIGMAP` or `STAKATER_FOO_SECRET` environment variable depending upon where the change has happened. The use of SHA1 provides a concise 40 characters encoded value that is very less pron to collision. | Configmap controller uses `FABRICB_FOO_REVISION` environment variable to store any change in configmap controller. It does not encode it or convert it in suitable hash value to avoid data pollution in deployment. |
|
||||
7
docs/features.md
Normal file
7
docs/features.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Features
|
||||
|
||||
These are the key features of Reloader:
|
||||
|
||||
1. Restart pod in a depoloyment on change in linked/related configmap's or secret's
|
||||
2. Restart pod in a daemonset on change in linked/related configmap's or secret's
|
||||
3. Restart pod in a statefulset on change in linked/related configmap's or secret's
|
||||
@@ -2,9 +2,9 @@ package constants
|
||||
|
||||
const (
|
||||
// ConfigmapEnvVarPostfix is a postfix for configmap envVar
|
||||
ConfigmapEnvVarPostfix = "_CONFIGMAP"
|
||||
ConfigmapEnvVarPostfix = "CONFIGMAP"
|
||||
// SecretEnvVarPostfix is a postfix for secret envVar
|
||||
SecretEnvVarPostfix = "_SECRET"
|
||||
SecretEnvVarPostfix = "SECRET"
|
||||
// EnvVarPrefix is a Prefix for environment variable
|
||||
EnvVarPrefix = "STAKATER_"
|
||||
)
|
||||
|
||||
@@ -25,7 +25,6 @@ var (
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
||||
logrus.Infof("Creating namespace %s", namespace)
|
||||
testutil.CreateNamespace(namespace, client)
|
||||
|
||||
logrus.Infof("Creating controller")
|
||||
@@ -45,7 +44,6 @@ func TestMain(m *testing.M) {
|
||||
logrus.Infof("Running Testcases")
|
||||
retCode := m.Run()
|
||||
|
||||
logrus.Infof("Deleting namespace %q.\n", namespace)
|
||||
testutil.DeleteNamespace(namespace, client)
|
||||
|
||||
os.Exit(retCode)
|
||||
@@ -268,7 +266,6 @@ func TestControllerUpdatingSecretShouldCreateEnvInDeployment(t *testing.T) {
|
||||
if !updated {
|
||||
t.Errorf("Deployment was not updated")
|
||||
}
|
||||
//time.Sleep(5 * time.Second)
|
||||
|
||||
// Deleting Deployment
|
||||
err = testutil.DeleteDeployment(client, namespace, secretName)
|
||||
@@ -330,7 +327,6 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDeployment(t *testing.T) {
|
||||
if !updated {
|
||||
t.Errorf("Deployment was not updated")
|
||||
}
|
||||
//time.Sleep(5 * time.Second)
|
||||
|
||||
// Deleting Deployment
|
||||
err = testutil.DeleteDeployment(client, namespace, secretName)
|
||||
@@ -385,7 +381,6 @@ func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDeployment(t
|
||||
if updated {
|
||||
t.Errorf("Deployment should not be updated by changing label in secret")
|
||||
}
|
||||
//time.Sleep(5 * time.Second)
|
||||
|
||||
// Deleting Deployment
|
||||
err = testutil.DeleteDeployment(client, namespace, secretName)
|
||||
@@ -559,7 +554,6 @@ func TestControllerUpdatingSecretShouldCreateEnvInDaemonSet(t *testing.T) {
|
||||
if !updated {
|
||||
t.Errorf("DaemonSet was not updated")
|
||||
}
|
||||
//time.Sleep(5 * time.Second)
|
||||
|
||||
// Deleting DaemonSet
|
||||
err = testutil.DeleteDaemonSet(client, namespace, secretName)
|
||||
@@ -622,7 +616,6 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDaemonSet(t *testing.T) {
|
||||
if !updated {
|
||||
t.Errorf("DaemonSet was not updated")
|
||||
}
|
||||
//time.Sleep(5 * time.Second)
|
||||
|
||||
// Deleting DaemonSet
|
||||
err = testutil.DeleteDaemonSet(client, namespace, secretName)
|
||||
@@ -677,7 +670,6 @@ func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDaemonSet(t *
|
||||
if updated {
|
||||
t.Errorf("DaemonSet should not be updated by changing label in secret")
|
||||
}
|
||||
//time.Sleep(5 * time.Second)
|
||||
|
||||
// Deleting DaemonSet
|
||||
err = testutil.DeleteDaemonSet(client, namespace, secretName)
|
||||
@@ -851,7 +843,6 @@ func TestControllerUpdatingSecretShouldCreateEnvInStatefulSet(t *testing.T) {
|
||||
if !updated {
|
||||
t.Errorf("StatefulSet was not updated")
|
||||
}
|
||||
//time.Sleep(5 * time.Second)
|
||||
|
||||
// Deleting StatefulSet
|
||||
err = testutil.DeleteStatefulSet(client, namespace, secretName)
|
||||
@@ -913,7 +904,6 @@ func TestControllerUpdatingSecretShouldUpdateEnvInStatefulSet(t *testing.T) {
|
||||
if !updated {
|
||||
t.Errorf("StatefulSet was not updated")
|
||||
}
|
||||
//time.Sleep(5 * time.Second)
|
||||
|
||||
// Deleting StatefulSet
|
||||
err = testutil.DeleteStatefulSet(client, namespace, secretName)
|
||||
|
||||
@@ -2,7 +2,6 @@ package handler
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// ResourceCreatedHandler contains new objects
|
||||
@@ -13,17 +12,7 @@ type ResourceCreatedHandler struct {
|
||||
// Handle processes the newly created resource
|
||||
func (r ResourceCreatedHandler) Handle() error {
|
||||
if r.Resource == nil {
|
||||
logrus.Errorf("Error in Handler")
|
||||
} else {
|
||||
logrus.Infof("Detected changes in object %s", r.Resource)
|
||||
// process resource based on its type
|
||||
if _, ok := r.Resource.(*v1.ConfigMap); ok {
|
||||
logrus.Infof("A 'configmap' has been 'Added' but no implementation found to take action")
|
||||
} else if _, ok := r.Resource.(*v1.Secret); ok {
|
||||
logrus.Infof("A 'secret' has been 'Added' but no implementation found to take action")
|
||||
} else {
|
||||
logrus.Warnf("Invalid resource: Resource should be 'Secret' or 'Configmap' but found, %v", r.Resource)
|
||||
}
|
||||
logrus.Errorf("Resource creation handler received nil resource")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -23,47 +23,44 @@ type ResourceUpdatedHandler struct {
|
||||
// Handle processes the updated resource
|
||||
func (r ResourceUpdatedHandler) Handle() error {
|
||||
if r.Resource == nil || r.OldResource == nil {
|
||||
logrus.Errorf("Error in Handler")
|
||||
logrus.Errorf("Resource update handler received nil resource")
|
||||
} else {
|
||||
logrus.Infof("Detected changes in object %s", r.Resource)
|
||||
// process resource based on its type
|
||||
rollingUpgrade(r, callbacks.RollingUpgradeFuncs{
|
||||
ItemsFunc: callbacks.GetDeploymentItems,
|
||||
ContainersFunc: callbacks.GetDeploymentContainers,
|
||||
UpdateFunc: callbacks.UpdateDeployment,
|
||||
ResourceType: "Deployment",
|
||||
})
|
||||
rollingUpgrade(r, callbacks.RollingUpgradeFuncs{
|
||||
ItemsFunc: callbacks.GetDaemonSetItems,
|
||||
ContainersFunc: callbacks.GetDaemonSetContainers,
|
||||
UpdateFunc: callbacks.UpdateDaemonSet,
|
||||
ResourceType: "DaemonSet",
|
||||
})
|
||||
rollingUpgrade(r, callbacks.RollingUpgradeFuncs{
|
||||
ItemsFunc: callbacks.GetStatefulSetItems,
|
||||
ContainersFunc: callbacks.GetStatefulsetContainers,
|
||||
UpdateFunc: callbacks.UpdateStatefulset,
|
||||
ResourceType: "StatefulSet",
|
||||
})
|
||||
config, envVarPostfix, oldSHAData := getConfig(r)
|
||||
if config.SHAValue != oldSHAData {
|
||||
logrus.Infof("Changes detected in %s of type '%s' in namespace: %s", config.ResourceName, envVarPostfix, config.Namespace)
|
||||
// process resource based on its type
|
||||
rollingUpgrade(r, config, envVarPostfix, callbacks.RollingUpgradeFuncs{
|
||||
ItemsFunc: callbacks.GetDeploymentItems,
|
||||
ContainersFunc: callbacks.GetDeploymentContainers,
|
||||
UpdateFunc: callbacks.UpdateDeployment,
|
||||
ResourceType: "Deployment",
|
||||
})
|
||||
rollingUpgrade(r, config, envVarPostfix, callbacks.RollingUpgradeFuncs{
|
||||
ItemsFunc: callbacks.GetDaemonSetItems,
|
||||
ContainersFunc: callbacks.GetDaemonSetContainers,
|
||||
UpdateFunc: callbacks.UpdateDaemonSet,
|
||||
ResourceType: "DaemonSet",
|
||||
})
|
||||
rollingUpgrade(r, config, envVarPostfix, callbacks.RollingUpgradeFuncs{
|
||||
ItemsFunc: callbacks.GetStatefulSetItems,
|
||||
ContainersFunc: callbacks.GetStatefulsetContainers,
|
||||
UpdateFunc: callbacks.UpdateStatefulset,
|
||||
ResourceType: "StatefulSet",
|
||||
})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func rollingUpgrade(r ResourceUpdatedHandler, upgradeFuncs callbacks.RollingUpgradeFuncs) {
|
||||
func rollingUpgrade(r ResourceUpdatedHandler, config util.Config, envarPostfix string, upgradeFuncs callbacks.RollingUpgradeFuncs) {
|
||||
client, err := kube.GetClient()
|
||||
if err != nil {
|
||||
logrus.Fatalf("Unable to create Kubernetes client error = %v", err)
|
||||
}
|
||||
|
||||
config, envVarPostfix, oldSHAData := getConfig(r)
|
||||
|
||||
if config.SHAValue != oldSHAData {
|
||||
err = PerformRollingUpgrade(client, config, envVarPostfix, upgradeFuncs)
|
||||
if err != nil {
|
||||
logrus.Fatalf("Rolling upgrade failed with error = %v", err)
|
||||
}
|
||||
} else {
|
||||
logrus.Infof("Rolling upgrade will not happend because no actual change in data has been detected")
|
||||
err = PerformRollingUpgrade(client, config, envarPostfix, upgradeFuncs)
|
||||
if err != nil {
|
||||
logrus.Errorf("Rolling upgrade for %s failed with error = %v", config.ResourceName, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,12 +68,10 @@ func getConfig(r ResourceUpdatedHandler) (util.Config, string, string) {
|
||||
var oldSHAData, envVarPostfix string
|
||||
var config util.Config
|
||||
if _, ok := r.Resource.(*v1.ConfigMap); ok {
|
||||
logrus.Infof("Performing 'Updated' action for resource of type 'configmap'")
|
||||
oldSHAData = getSHAfromConfigmap(r.OldResource.(*v1.ConfigMap).Data)
|
||||
config = getConfigmapConfig(r)
|
||||
envVarPostfix = constants.ConfigmapEnvVarPostfix
|
||||
} else if _, ok := r.Resource.(*v1.Secret); ok {
|
||||
logrus.Infof("Performing 'Updated' action for resource of type 'secret'")
|
||||
oldSHAData = getSHAfromSecret(r.OldResource.(*v1.Secret).Data)
|
||||
config = getSecretConfig(r)
|
||||
envVarPostfix = constants.SecretEnvVarPostfix
|
||||
@@ -112,6 +107,7 @@ func PerformRollingUpgrade(client kubernetes.Interface, config util.Config, enva
|
||||
var err error
|
||||
for _, i := range items {
|
||||
containers := upgradeFuncs.ContainersFunc(i)
|
||||
resourceName := util.ToObjectMeta(i).Name
|
||||
// find correct annotation and update the resource
|
||||
annotationValue := util.ToObjectMeta(i).Annotations[config.Annotation]
|
||||
if annotationValue != "" {
|
||||
@@ -120,13 +116,13 @@ func PerformRollingUpgrade(client kubernetes.Interface, config util.Config, enva
|
||||
if value == config.ResourceName {
|
||||
updated := updateContainers(containers, value, config.SHAValue, envarPostfix)
|
||||
if !updated {
|
||||
logrus.Warnf("Rolling upgrade did not happen")
|
||||
logrus.Warnf("Rolling upgrade failed because no container found to add environment variable in %s of type %s in namespace: %s", resourceName, upgradeFuncs.ResourceType, config.Namespace)
|
||||
} else {
|
||||
err = upgradeFuncs.UpdateFunc(client, config.Namespace, i)
|
||||
if err != nil {
|
||||
logrus.Errorf("Update %s failed %v", upgradeFuncs.ResourceType, err)
|
||||
logrus.Errorf("Update for %s of type %s in namespace %s failed with error %v", resourceName, upgradeFuncs.ResourceType, config.Namespace, err)
|
||||
} else {
|
||||
logrus.Infof("Updated %s of type %s", config.ResourceName, upgradeFuncs.ResourceType)
|
||||
logrus.Infof("Updated %s of type %s in namespace: %s ", resourceName, upgradeFuncs.ResourceType, config.Namespace)
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -139,8 +135,7 @@ func PerformRollingUpgrade(client kubernetes.Interface, config util.Config, enva
|
||||
|
||||
func updateContainers(containers []v1.Container, annotationValue string, shaData string, envarPostfix string) bool {
|
||||
updated := false
|
||||
envar := constants.EnvVarPrefix + util.ConvertToEnvVarName(annotationValue) + envarPostfix
|
||||
logrus.Infof("Generated environment variable: %s", envar)
|
||||
envar := constants.EnvVarPrefix + util.ConvertToEnvVarName(annotationValue)+ "_" + envarPostfix
|
||||
for i := range containers {
|
||||
envs := containers[i].Env
|
||||
|
||||
@@ -155,7 +150,6 @@ func updateContainers(containers []v1.Container, annotationValue string, shaData
|
||||
}
|
||||
containers[i].Env = append(containers[i].Env, e)
|
||||
updated = true
|
||||
logrus.Infof("%s environment variable does not exist, creating a new envVar", envar)
|
||||
}
|
||||
}
|
||||
return updated
|
||||
@@ -164,9 +158,7 @@ func updateContainers(containers []v1.Container, annotationValue string, shaData
|
||||
func updateEnvVar(envs []v1.EnvVar, envar string, shaData string) bool {
|
||||
for j := range envs {
|
||||
if envs[j].Name == envar {
|
||||
logrus.Infof("%s environment variable found", envar)
|
||||
if envs[j].Value != shaData {
|
||||
logrus.Infof("Updating %s", envar)
|
||||
envs[j].Value = shaData
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ var (
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
||||
logrus.Infof("Creating namespace %s", namespace)
|
||||
// Creating namespace
|
||||
testutil.CreateNamespace(namespace, client)
|
||||
|
||||
logrus.Infof("Setting up the test resources")
|
||||
|
||||
@@ -236,7 +236,6 @@ func GetResourceSHA(containers []v1.Container, envar string) string {
|
||||
//ConvertResourceToSHA generates SHA from secret or configmap data
|
||||
func ConvertResourceToSHA(resourceType string, namespace string, resourceName string, data string) string {
|
||||
values := []string{}
|
||||
logrus.Infof("Generating SHA for secret data")
|
||||
if resourceType == SecretResourceType {
|
||||
secret := GetSecret(namespace, resourceName, data)
|
||||
for k, v := range secret.Data {
|
||||
@@ -391,7 +390,7 @@ func VerifyResourceUpdate(client kubernetes.Interface, config util.Config, envVa
|
||||
}
|
||||
}
|
||||
if matches {
|
||||
envName := constants.EnvVarPrefix + util.ConvertToEnvVarName(annotationValue) + envVarPostfix
|
||||
envName := constants.EnvVarPrefix + util.ConvertToEnvVarName(annotationValue) + "_" + envVarPostfix
|
||||
updated := GetResourceSHA(containers, envName)
|
||||
|
||||
if updated == config.SHAValue {
|
||||
|
||||
Reference in New Issue
Block a user