runtime: resource limits (kubernetes implementation) (#1931)
* runtime: add resource limit CreateOptions * util/kubernetes/client: implement support for resource limits * runtime/kubernetes: set resource limits for k8s deployments * util/kubernetes: remove template check for ints * util/kubernetes: fix incorrect yaml syntax * runtime/kubernetes: fix incorrect units * runtime: update create options to use Resources struct
This commit is contained in:
@@ -90,8 +90,8 @@ spec:
|
||||
{{- range . }}
|
||||
- containerPort: {{ .ContainerPort }}
|
||||
name: {{ .Name }}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .ReadinessProbe }}
|
||||
{{- with .ReadinessProbe }}
|
||||
readinessProbe:
|
||||
@@ -106,6 +106,39 @@ spec:
|
||||
periodSeconds: {{ .PeriodSeconds }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Resources }}
|
||||
{{- with .Resources }}
|
||||
resources:
|
||||
{{- if .Limits }}
|
||||
{{- with .Limits }}
|
||||
limits:
|
||||
{{- if .Memory }}
|
||||
memory: {{ .Memory }}
|
||||
{{- end }}
|
||||
{{- if .CPU }}
|
||||
cpu: {{ .CPU }}
|
||||
{{- end }}
|
||||
{{- if .EphemeralStorage }}
|
||||
ephemeral-storage: {{ .EphemeralStorage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Requests }}
|
||||
{{- with .Requests }}
|
||||
requests:
|
||||
{{- if .Memory }}
|
||||
memory: {{ .Memory }}
|
||||
{{- end }}
|
||||
{{- if .CPU }}
|
||||
cpu: {{ .CPU }}
|
||||
{{- end }}
|
||||
{{- if .EphemeralStorage }}
|
||||
ephemeral-storage: {{ .EphemeralStorage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
`
|
||||
|
@@ -35,13 +35,14 @@ type Condition struct {
|
||||
|
||||
// Container defined container runtime values
|
||||
type Container struct {
|
||||
Name string `json:"name"`
|
||||
Image string `json:"image"`
|
||||
Env []EnvVar `json:"env,omitempty"`
|
||||
Command []string `json:"command,omitempty"`
|
||||
Args []string `json:"args,omitempty"`
|
||||
Ports []ContainerPort `json:"ports,omitempty"`
|
||||
ReadinessProbe *Probe `json:"readinessProbe,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Image string `json:"image"`
|
||||
Env []EnvVar `json:"env,omitempty"`
|
||||
Command []string `json:"command,omitempty"`
|
||||
Args []string `json:"args,omitempty"`
|
||||
Ports []ContainerPort `json:"ports,omitempty"`
|
||||
ReadinessProbe *Probe `json:"readinessProbe,omitempty"`
|
||||
Resources *ResourceRequirements `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
// DeploymentSpec defines micro deployment spec
|
||||
@@ -234,3 +235,16 @@ type TCPSocketAction struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
Port int `json:"port,omitempty"`
|
||||
}
|
||||
|
||||
// ResourceRequirements describes the compute resource requirements.
|
||||
type ResourceRequirements struct {
|
||||
Limits *ResourceLimits `json:"limits,omitempty"`
|
||||
Requests *ResourceLimits `json:"requests,omitempty"`
|
||||
}
|
||||
|
||||
// ResourceLimits describes the limits for a service
|
||||
type ResourceLimits struct {
|
||||
Memory string `json:"memory,omitempty"`
|
||||
CPU string `json:"cpu,omitempty"`
|
||||
EphemeralStorage string `json:"ephemeral-storage,omitempty"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user