Skip to content

Commit

Permalink
[chart] Add recreate strategy to deployments (#419)
Browse files Browse the repository at this point in the history
* Add recreate strategy to deployments

Co-authored-by: Roberto Santalla <[email protected]>

* fix tests

Co-authored-by: Roberto Santalla <[email protected]>
  • Loading branch information
kang-makes and roobre authored May 13, 2022
1 parent 5313cb2 commit 6ee6b4e
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 2 deletions.
3 changes: 2 additions & 1 deletion charts/newrelic-infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ integrations that you have configured.
| rbac.pspEnabled | bool | `false` | Whether the chart should create Pod Security Policy objects. |
| serviceAccount | object | See `values.yaml` | Settings controlling ServiceAccount creation. |
| serviceAccount.create | bool | `true` | Whether the chart should automatically create the ServiceAccount objects required to run. |
| strategy | object | `type: Recreate` | Update strategy for the deployed Deployments. |
| tolerations | list | `[]` | Sets pod's tolerations to node taints almost globally. (See [Affinities and tolerations](README.md#affinities-and-tolerations)) |
| updateStrategy | object | See `values.yaml` | Update strategy for the DaemonSets deployed. |
| updateStrategy | object | See `values.yaml` | Update strategy for the deployed DaemonSets. |
| verboseLog | bool | `false` | Sets the debug logs to this integration or all integrations if it is set globally. Can be configured also with `global.verboseLog` |

## Maintainers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ spec:
updateStrategy: {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- if eq .Values.controlPlane.kind "Deployment"}}
{{- with .Values.strategy }}
strategy: {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "newrelic.common.labels.selectorLabels" . | nindent 6 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/newrelic-infrastructure/templates/ksm/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ metadata:
annotations: {{ . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.strategy }}
strategy: {{ toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "newrelic.common.labels.selectorLabels" . | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
suite: test control plane strategy
templates:
- templates/controlplane/daemonset.yaml
- templates/controlplane/scraper-configmap.yaml
- templates/controlplane/agent-configmap.yaml
- templates/secret.yaml
tests:
- it: DaemonSet defaults to global updateStrategy
set:
licenseKey: test
cluster: test
asserts:
- equal:
path: spec.updateStrategy
value:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
template: templates/controlplane/daemonset.yaml

- it: DaemonSet updateStrategy can be overridden
set:
licenseKey: test
cluster: test
controlPlane:
kind: Deployment
asserts:
- equal:
path: spec.strategy
value:
type: Recreate
template: templates/controlplane/daemonset.yaml
- isNull:
path: spec.updateStrategy
template: templates/controlplane/daemonset.yaml

- it: Deployment defaults to recreate
set:
licenseKey: test
cluster: test
controlPlane:
kind: Deployment
asserts:
- equal:
path: spec.strategy
value:
type: Recreate
template: templates/controlplane/daemonset.yaml

- it: Deployment strategy can be overridden
set:
licenseKey: test
cluster: test
strategy:
type: Foobar
controlPlane:
kind: Deployment
asserts:
- equal:
path: spec.strategy
value:
type: Foobar
template: templates/controlplane/daemonset.yaml
- isNull:
path: spec.updateStrategy
template: templates/controlplane/daemonset.yaml

- it: Deployment strategy is not rendered on DaemonSet
set:
licenseKey: test
cluster: test
controlPlane:
strategy:
type: Foobar
asserts:
- isNull:
path: spec.strategy
template: templates/controlplane/daemonset.yaml

- it: DaemonSet strategy is not rendered on Deployment
set:
licenseKey: test
cluster: test
controlPlane:
kind: Deployment
updateStrategy:
type: Foobar
asserts:
- isNull:
path: spec.updateStrategy
template: templates/controlplane/daemonset.yaml
7 changes: 6 additions & 1 deletion charts/newrelic-infrastructure/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,18 @@ controlPlane:
# insecureSkipVerify: true
# auth: {}

# -- Update strategy for the DaemonSets deployed.
# -- Update strategy for the deployed DaemonSets.
# @default -- See `values.yaml`
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1

# -- Update strategy for the deployed Deployments.
# @default -- `type: Recreate`
strategy:
type: Recreate

# -- Adds extra attributes to the cluster and all the metrics emitted to the backend. Can be configured also with `global.customAttributes`
customAttributes: {}

Expand Down

0 comments on commit 6ee6b4e

Please sign in to comment.