Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/apps/v1alpha1/kubernetes/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/apps/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ See the reference for components utilized in this service:
| `nodeGroups` | Worker nodes configuration map. | `map[string]object` | `{...}` |
| `nodeGroups[name].minReplicas` | Minimum number of replicas. | `int` | `0` |
| `nodeGroups[name].maxReplicas` | Maximum number of replicas. | `int` | `10` |
| `nodeGroups[name].maxUnhealthy` | Max unhealthy nodes (integer or percentage) tolerated before the MachineHealthCheck stops auto-remediation. | `string` | `100%` |
| `nodeGroups[name].instanceType` | Virtual machine instance type. | `string` | `u1.medium` |
| `nodeGroups[name].diskSize` | Persistent disk size for kubelet and containerd data. | `quantity` | `20Gi` |
| `nodeGroups[name].storageClass` | StorageClass for worker node persistent disks. When empty, uses the management cluster default StorageClass (the one annotated storageclass.kubernetes.io/is-default-class: true). NOTE: deliberately not marked immutable — the field is optional and undefaulted, so a strict `self == oldSelf` rule would block any future attempt to set it on an existing node group. | `string` | `""` |
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/kubernetes/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ metadata:
namespace: {{ $.Release.Namespace }}
spec:
clusterName: {{ $.Release.Name }}
maxUnhealthy: 0
maxUnhealthy: {{ $group.maxUnhealthy | default "100%" | quote }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the default function in Helm/Go templates treats falsy values like 0 (integer) as empty, which causes them to be overridden by the default value ("100%"). Since 0 is a valid value for maxUnhealthy (used to explicitly disable auto-remediation), this will prevent users from setting maxUnhealthy: 0 as an integer in their values.

Using hasKey allows us to check if the key is explicitly defined in the node group map, preserving 0 or any other falsy values.

  maxUnhealthy: {{ if hasKey $group "maxUnhealthy" }}{{ $group.maxUnhealthy | quote }}{{ else }}"100%"{{ end }}

nodeStartupTimeout: 10m
selector:
matchLabels:
Expand Down
6 changes: 6 additions & 0 deletions packages/apps/kubernetes/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"instanceType": "u1.medium",
"kubelet": {},
"maxReplicas": 10,
"maxUnhealthy": "100%",
"minReplicas": 0,
"resources": {},
"roles": [
Expand Down Expand Up @@ -122,6 +123,11 @@
"type": "integer",
"default": 10
},
"maxUnhealthy": {
"description": "Max unhealthy nodes (integer or percentage) tolerated before the MachineHealthCheck stops auto-remediation.",
"type": "string",
"default": "100%"
},
"minReplicas": {
"description": "Minimum number of replicas.",
"type": "integer",
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/kubernetes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ storageClass: replicated
## @typedef {struct} NodeGroup - Worker node group configuration.
## @field {int} minReplicas=0 - Minimum number of replicas.
## @field {int} maxReplicas=10 - Maximum number of replicas.
## @field {string} [maxUnhealthy]="100%" - Max unhealthy nodes (integer or percentage) tolerated before the MachineHealthCheck stops auto-remediation.
## @field {string} instanceType="u1.medium" - Virtual machine instance type.
## @x-cozystack-options {source: instancetype}
## @field {quantity} diskSize="20Gi" - Persistent disk size for kubelet and containerd data.
Expand All @@ -94,6 +95,7 @@ nodeGroups:
md0:
minReplicas: 0
maxReplicas: 10
maxUnhealthy: "100%"
instanceType: "u1.medium"
diskSize: 20Gi
storageClass: ""
Expand Down
Loading
Loading