Skip to content

Commit fd98ba8

Browse files
authored
Set deploymentUpdateStrategy when agent mode is deployment (#220)
1 parent dc36f1f commit fd98ba8

3 files changed

Lines changed: 68 additions & 7 deletions

File tree

charts/amazon-cloudwatch-observability/crds/cloudwatch.aws.amazon.com_amazoncloudwatchagents.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,6 +2595,59 @@ spec:
25952595
- name
25962596
type: object
25972597
type: array
2598+
deploymentUpdateStrategy:
2599+
description: |-
2600+
UpdateStrategy represents the strategy the operator will take replacing existing Deployment pods with new pods
2601+
https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/deployment-v1/#DeploymentSpec
2602+
This is only applicable to Deployment mode.
2603+
properties:
2604+
rollingUpdate:
2605+
description: |-
2606+
Rolling update config params. Present only if DeploymentStrategyType =
2607+
RollingUpdate.
2608+
---
2609+
TODO: Update this to follow our convention for oneOf, whatever we decide it
2610+
to be.
2611+
properties:
2612+
maxSurge:
2613+
anyOf:
2614+
- type: integer
2615+
- type: string
2616+
description: |-
2617+
The maximum number of pods that can be scheduled above the desired number of
2618+
pods.
2619+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
2620+
This can not be 0 if MaxUnavailable is 0.
2621+
Absolute number is calculated from percentage by rounding up.
2622+
Defaults to 25%.
2623+
Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when
2624+
the rolling update starts, such that the total number of old and new pods do not exceed
2625+
130% of desired pods. Once old pods have been killed,
2626+
new ReplicaSet can be scaled up further, ensuring that total number of pods running
2627+
at any time during the update is at most 130% of desired pods.
2628+
x-kubernetes-int-or-string: true
2629+
maxUnavailable:
2630+
anyOf:
2631+
- type: integer
2632+
- type: string
2633+
description: |-
2634+
The maximum number of pods that can be unavailable during the update.
2635+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
2636+
Absolute number is calculated from percentage by rounding down.
2637+
This can not be 0 if MaxSurge is 0.
2638+
Defaults to 25%.
2639+
Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods
2640+
immediately when the rolling update starts. Once new pods are ready, old ReplicaSet
2641+
can be scaled down further, followed by scaling up the new ReplicaSet, ensuring
2642+
that the total number of pods available at all times during the update is at
2643+
least 70% of desired pods.
2644+
x-kubernetes-int-or-string: true
2645+
type: object
2646+
type:
2647+
description: Type of deployment. Can be "Recreate" or "RollingUpdate".
2648+
Default is RollingUpdate.
2649+
type: string
2650+
type: object
25982651
env:
25992652
description: |-
26002653
ENV vars to set on the OpenTelemetry Collector's Pods. These can then in certain cases be

charts/amazon-cloudwatch-observability/templates/_helpers.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ Helper function to modify cloudwatch-agent YAML config
8787
{{- end -}}
8888
{{- end -}}
8989

90+
{{- define "cloudwatch-agent.updateStrategy" -}}
91+
{{- if eq .mode "deployment" -}}
92+
deploymentUpdateStrategy
93+
{{- else -}}
94+
updateStrategy
95+
{{- end -}}
96+
{{- end -}}
97+
9098
{{- define "cloudwatch-agent.rolloutStrategyMaxSurge" -}}
9199
{{- if eq .mode "daemonset" -}}
92100
0

charts/amazon-cloudwatch-observability/templates/linux/cloudwatch-agent-custom-resource.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ metadata:
7171
name: {{ $agent.name | default (include "cloudwatch-agent.name" $) }}
7272
namespace: {{ $.Release.Namespace }}
7373
spec:
74-
updateStrategy:
75-
type: {{ $agent.updateStrategy.type }}
76-
{{- if eq $agent.updateStrategy.type "RollingUpdate" }}
77-
rollingUpdate:
78-
maxUnavailable: {{ $agent.updateStrategy.rollingUpdate.maxUnavailable | default (include "cloudwatch-agent.rolloutStrategyMaxUnavailable" (dict "mode" $agent.mode)) }}
79-
maxSurge: {{ $agent.updateStrategy.rollingUpdate.maxSurge | default (include "cloudwatch-agent.rolloutStrategyMaxSurge" (dict "mode" $agent.mode)) }}
80-
{{- end }}
74+
{{ template "cloudwatch-agent.updateStrategy" (dict "mode" $agent.mode) }}:
75+
type: {{ $agent.updateStrategy.type }}
76+
{{- if eq $agent.updateStrategy.type "RollingUpdate" }}
77+
rollingUpdate:
78+
maxUnavailable: {{ $agent.updateStrategy.rollingUpdate.maxUnavailable | default (include "cloudwatch-agent.rolloutStrategyMaxUnavailable" (dict "mode" $agent.mode)) }}
79+
maxSurge: {{ $agent.updateStrategy.rollingUpdate.maxSurge | default (include "cloudwatch-agent.rolloutStrategyMaxSurge" (dict "mode" $agent.mode)) }}
80+
{{- end }}
8181
image: {{ template "cloudwatch-agent.image" (merge $agent.image (dict "region" $.Values.region)) }}
8282
mode: {{ $agent.mode }}
8383
replicas: {{ $agent.replicas }}

0 commit comments

Comments
 (0)