Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust the resources and remove default limits #101

Merged
merged 4 commits into from
Apr 16, 2024
Merged
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
70 changes: 37 additions & 33 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ The following providers are used by this module:

- [[provider_random]] <<provider_random,random>> (>= 3)

- [[provider_argocd]] <<provider_argocd,argocd>> (>= 5)

- [[provider_utils]] <<provider_utils,utils>> (>= 1.6)

- [[provider_argocd]] <<provider_argocd,argocd>> (>= 5)

=== Resources

The following resources are used by this module:
Expand Down Expand Up @@ -310,7 +310,7 @@ Description: Override of target revision of the application chart.

Type: `string`

Default: `"v4.3.0"`
Default: `"v4.4.0"`

==== [[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>

Expand Down Expand Up @@ -362,12 +362,14 @@ Default: `{}`

==== [[input_resources]] <<input_resources,resources>>

Description: Resource limits and requests for the Argo CD components. Follow the style on https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/[official documentation] to understand the format of the values.
Description: Resource limits and requests for Argo CD's components. Follow the style on https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/[official documentation] to understand the format of the values.

NOTE: The `repo_server` requests and limits will be applied to all the extra containers that are deployed with the `argocd-repo-server` component (each container has the same requests and limits as the main container, **so it is cumulative**).

NOTE: If you enable the HA mode using the `high_availability` variable, the values for Redis will be applied to the Redis HA chart instead of the default one.

IMPORTANT: These are not production values. You should always adjust them to your needs.

Type:
[source,hcl]
----
Expand All @@ -379,8 +381,8 @@ object({
memory = optional(string, "128Mi")
}), {})
limits = optional(object({
cpu = optional(string, "100m")
memory = optional(string, "128Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand All @@ -390,8 +392,8 @@ object({
memory = optional(string, "512Mi")
}), {})
limits = optional(object({
cpu = optional(string, "1")
memory = optional(string, "2Gi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand All @@ -401,8 +403,8 @@ object({
memory = optional(string, "128Mi")
}), {})
limits = optional(object({
cpu = optional(string, "200m")
memory = optional(string, "256Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand All @@ -412,8 +414,8 @@ object({
memory = optional(string, "128Mi")
}), {})
limits = optional(object({
cpu = optional(string, "400m")
memory = optional(string, "256Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand All @@ -423,19 +425,19 @@ object({
memory = optional(string, "128Mi")
}), {})
limits = optional(object({
cpu = optional(string, "100m")
memory = optional(string, "256Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

redis = optional(object({
requests = optional(object({
cpu = optional(string, "200m")
memory = optional(string, "64Mi")
memory = optional(string, "256Mi")
}), {})
limits = optional(object({
cpu = optional(string, "300m")
memory = optional(string, "128Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand Down Expand Up @@ -668,12 +670,12 @@ Description: Map of extra accounts that were created and their tokens.
[cols="a,a",options="header,autowidth"]
|===
|Name |Version
|[[provider_null]] <<provider_null,null>> |>= 3
|[[provider_jwt]] <<provider_jwt,jwt>> |>= 1.1
|[[provider_time]] <<provider_time,time>> |>= 0.9
|[[provider_random]] <<provider_random,random>> |>= 3
|[[provider_utils]] <<provider_utils,utils>> |>= 1.6
|[[provider_argocd]] <<provider_argocd,argocd>> |>= 5
|[[provider_null]] <<provider_null,null>> |>= 3
|===

= Resources
Expand Down Expand Up @@ -729,7 +731,7 @@ Description: Map of extra accounts that were created and their tokens.
|[[input_target_revision]] <<input_target_revision,target_revision>>
|Override of target revision of the application chart.
|`string`
|`"v4.3.0"`
|`"v4.4.0"`
|no

|[[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>
Expand Down Expand Up @@ -777,12 +779,14 @@ object({
|no

|[[input_resources]] <<input_resources,resources>>
|Resource limits and requests for the Argo CD components. Follow the style on https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/[official documentation] to understand the format of the values.
|Resource limits and requests for Argo CD's components. Follow the style on https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/[official documentation] to understand the format of the values.

NOTE: The `repo_server` requests and limits will be applied to all the extra containers that are deployed with the `argocd-repo-server` component (each container has the same requests and limits as the main container, **so it is cumulative**).

NOTE: If you enable the HA mode using the `high_availability` variable, the values for Redis will be applied to the Redis HA chart instead of the default one.

IMPORTANT: These are not production values. You should always adjust them to your needs.

|

[source]
Expand All @@ -795,8 +799,8 @@ object({
memory = optional(string, "128Mi")
}), {})
limits = optional(object({
cpu = optional(string, "100m")
memory = optional(string, "128Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand All @@ -806,8 +810,8 @@ object({
memory = optional(string, "512Mi")
}), {})
limits = optional(object({
cpu = optional(string, "1")
memory = optional(string, "2Gi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand All @@ -817,8 +821,8 @@ object({
memory = optional(string, "128Mi")
}), {})
limits = optional(object({
cpu = optional(string, "200m")
memory = optional(string, "256Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand All @@ -828,8 +832,8 @@ object({
memory = optional(string, "128Mi")
}), {})
limits = optional(object({
cpu = optional(string, "400m")
memory = optional(string, "256Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand All @@ -839,19 +843,19 @@ object({
memory = optional(string, "128Mi")
}), {})
limits = optional(object({
cpu = optional(string, "100m")
memory = optional(string, "256Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

redis = optional(object({
requests = optional(object({
cpu = optional(string, "200m")
memory = optional(string, "64Mi")
memory = optional(string, "256Mi")
}), {})
limits = optional(object({
cpu = optional(string, "300m")
memory = optional(string, "128Mi")
cpu = optional(string)
memory = optional(string)
}), {})
}), {})

Expand Down
52 changes: 38 additions & 14 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ locals {
]
# The extra containers of the repo_server pod must have resource requests/limits in order to allow this component
# to autoscale properly.
resources = var.resources.repo_server # TODO Maybe this resources should be different from the repo_server one.
resources = { # TODO Maybe these resources should be different from the repo_server one.
requests = { for k, v in var.resources.repo_server.requests : k => v if v != null }
limits = { for k, v in var.resources.repo_server.limits : k => v if v != null }
}
},
{
name = "helmfile-cmp"
Expand Down Expand Up @@ -108,7 +111,10 @@ locals {
]
# The extra containers of the repo_server pod must have resource requests/limits in order to allow this component
# to autoscale properly.
resources = var.resources.repo_server # TODO Maybe this resources should be different from the repo_server one.
resources = { # TODO Maybe these resources should be different from the repo_server one.
requests = { for k, v in var.resources.repo_server.requests : k => v if v != null }
limits = { for k, v in var.resources.repo_server.limits : k => v if v != null }
}
}
]

Expand All @@ -134,8 +140,6 @@ locals {
var.repo_server_azure_workload_identity_clientid != null ? { "azure.workload.identity/client-id" = var.repo_server_azure_workload_identity_clientid } : {}
)

repo_server_service_account_labels = var.repo_server_azure_workload_identity_clientid != null ? { "azure.workload.identity/use" : "true" } : {}

repo_server_pod_labels = merge(
var.repo_server_azure_workload_identity_clientid != null ? { "azure.workload.identity/use" : "true" } : {},
var.repo_server_aadpodidbinding != null ? { "aadpodidbinding" : var.repo_server_aadpodidbinding } : {}
Expand Down Expand Up @@ -163,12 +167,18 @@ locals {
}
})
applicationSet = {
replicas = var.high_availability.enabled ? var.high_availability.application_set.replicas : null
resources = var.resources.application_set
replicas = var.high_availability.enabled ? var.high_availability.application_set.replicas : null
resources = {
requests = { for k, v in var.resources.application_set.requests : k => v if v != null }
limits = { for k, v in var.resources.application_set.limits : k => v if v != null }
}
}
controller = {
replicas = var.high_availability.enabled ? var.high_availability.controller.replicas : null
resources = var.resources.controller
replicas = var.high_availability.enabled ? var.high_availability.controller.replicas : null
resources = {
requests = { for k, v in var.resources.controller.requests : k => v if v != null }
limits = { for k, v in var.resources.controller.limits : k => v if v != null }
}
metrics = {
enabled = true
serviceMonitor = {
Expand All @@ -186,7 +196,10 @@ locals {
minReplicas = var.high_availability.repo_server.autoscaling.min_replicas
maxReplicas = var.high_availability.repo_server.autoscaling.max_replicas
} : null
resources = var.resources.repo_server
resources = {
requests = { for k, v in var.resources.repo_server.requests : k => v if v != null }
limits = { for k, v in var.resources.repo_server.limits : k => v if v != null }
}
metrics = {
enabled = true
serviceMonitor = {
Expand All @@ -198,7 +211,6 @@ locals {
podLabels = local.repo_server_pod_labels
serviceAccount = {
annotations = local.repo_server_service_account_annotations
labels = local.repo_server_service_account_labels
}
}
extraObjects = local.extra_objects
Expand All @@ -209,7 +221,10 @@ locals {
minReplicas = var.high_availability.server.autoscaling.min_replicas
maxReplicas = var.high_availability.server.autoscaling.max_replicas
} : null
resources = var.resources.server
resources = {
requests = { for k, v in var.resources.server.requests : k => v if v != null }
limits = { for k, v in var.resources.server.limits : k => v if v != null }
}
extraArgs = [
"--insecure",
]
Expand Down Expand Up @@ -273,16 +288,25 @@ locals {
}
}
notifications = {
resources = var.resources.notifications
resources = {
requests = { for k, v in var.resources.notifications.requests : k => v if v != null }
limits = { for k, v in var.resources.notifications.limits : k => v if v != null }
}
}
# When the Redis HA is enabled, the default Redis chart is not used, so we change the value to null.
redis = !var.high_availability.enabled ? {
resources = var.resources.redis
resources = {
requests = { for k, v in var.resources.redis.requests : k => v if v != null }
limits = { for k, v in var.resources.redis.limits : k => v if v != null }
}
} : null
redis-ha = var.high_availability.enabled ? {
enabled = true
redis = {
resources = var.resources.redis
resources = {
requests = { for k, v in var.resources.redis.requests : k => v if v != null }
limits = { for k, v in var.resources.redis.limits : k => v if v != null }
}
}
} : {
enabled = false
Expand Down
Loading