Skip to content

Commit

Permalink
Reuse control plane's resource partial template in 'partials' chart
Browse files Browse the repository at this point in the history
Signed-off-by: ihcsim <ihcsim@gmail.com>
  • Loading branch information
ihcsim committed Jul 26, 2019
1 parent 739aff8 commit 1006ea9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 51 deletions.
16 changes: 8 additions & 8 deletions charts/linkerd/templates/_resources.tpl
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{{/* Specify resource requests and limits for workloads */}}
{{- define "linkerd.resources" -}}
resources:
{{- if or .CPU.Request .Memory.Request }}
requests:
{{- with .CPU.Request }}
{{- if or .CPU.Limit .Memory.Limit }}
limits:
{{- with .CPU.Limit }}
cpu: {{.}}
{{- end }}
{{- with .Memory.Request }}
{{- with .Memory.Limit }}
memory: {{.}}
{{- end }}
{{- end }}
{{- if or .CPU.Limit .Memory.Limit }}
limits:
{{- with .CPU.Limit }}
{{- if or .CPU.Request .Memory.Request }}
requests:
{{- with .CPU.Request }}
cpu: {{.}}
{{- end }}
{{- with .Memory.Limit }}
{{- with .Memory.Request }}
memory: {{.}}
{{- end }}
{{- end }}
Expand Down
28 changes: 14 additions & 14 deletions charts/linkerd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ Proxy:
UID: &proxy_uid 2102

# use this to override the default resource requirements in HA mode
#ResourceRequirements:
#limits:
#cpu: "1"
#memory: 250Mi
#requests:
#cpu: 100m
#memory: 20Mi
ResourceRequirements:
CPU:
Limit: "1"
Request: 100m
Memory:
Limit: 250Mi
Request: 20Mi

# proxy-init configuration
ProxyInit:
Expand All @@ -82,13 +82,13 @@ ProxyInit:
UID: *proxy_uid

# use this to override the default resource requirements in HA mode
#ResourceRequirements:
#limits:
#cpu: "100m"
#memory: 50Mi
#requests:
#cpu: 10m
#memory: 10Mi
ResourceRequirements:
CPU:
Limit: 100m
Request: 10m
Memory:
Limit: 50Mi
Request: 10Mi

# annotations
CreatedByAnnotation: linkerd.io/created-by
Expand Down
7 changes: 1 addition & 6 deletions charts/partials/templates/_proxy-init.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
image: {{.Image.Name}}:{{.Image.Version}}
imagePullPolicy: {{.Image.PullPolicy}}
name: linkerd-init
resources:
{{- if .ResourceRequirements -}}
{{- toYaml .ResourceRequirements | trim | nindent 4 -}}
{{- else -}}
{{- include "partials.proxy-init.resource" .Proxy | nindent 4 -}}
{{- end }}
{{- include "partials.resource" .ResourceRequirements | nindent 2 }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
7 changes: 1 addition & 6 deletions charts/partials/templates/_proxy.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@
port: {{.Port.Admin}}
initialDelaySeconds: 2
{{- if eq .HighAvailability true -}}
resources:
{{- if .ResourceRequirements -}}
{{- toYaml .ResourceRequirements | trim | nindent 4 -}}
{{- else -}}
{{- include "partials.proxy.resource" .Proxy | nindent 4 -}}
{{- end }}
{{- include "partials.resource" .ResourceRequirements | nindent 2 -}}
{{- end }}
securityContext:
allowPrivilegeEscalation: false
Expand Down
38 changes: 21 additions & 17 deletions charts/partials/templates/_resource.tpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{{- define "partials.proxy.resource" -}}
limits:
cpu: "1"
memory: 250Mi
requests:
cpu: 100m
memory: 20Mi
{{- end -}}

{{- define "partials.proxy-init.resource" -}}
limits:
cpu: 100m
memory: 50Mi
requests:
cpu: 10m
memory: 10Mi
{{- end -}}
{{- define "partials.resource" -}}
resources:
{{- if or .CPU.Limit .Memory.Limit }}
limits:
{{- with .CPU.Limit }}
cpu: {{.}}
{{- end }}
{{- with .Memory.Limit }}
memory: {{.}}
{{- end }}
{{- end }}
{{- if or .CPU.Request .Memory.Request }}
requests:
{{- with .CPU.Request }}
cpu: {{.}}
{{- end }}
{{- with .Memory.Request }}
memory: {{.}}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit 1006ea9

Please sign in to comment.