Add resources in containers and values
This commit is contained in:
@@ -153,6 +153,9 @@ func (d *Deployment) AddContainer(service types.ServiceConfig) {
|
|||||||
Ports: ports,
|
Ports: ports,
|
||||||
Name: service.Name,
|
Name: service.Name,
|
||||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
ImagePullPolicy: corev1.PullIfNotPresent,
|
||||||
|
Resources: corev1.ResourceRequirements{
|
||||||
|
Requests: corev1.ResourceList{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
if _, ok := d.chart.Values[service.Name]; !ok {
|
if _, ok := d.chart.Values[service.Name]; !ok {
|
||||||
d.chart.Values[service.Name] = NewValue(service, d.isMainApp)
|
d.chart.Values[service.Name] = NewValue(service, d.isMainApp)
|
||||||
@@ -584,6 +587,16 @@ func (d *Deployment) Yaml() ([]byte, error) {
|
|||||||
line = pre + "\n" + line + "\n" + post
|
line = pre + "\n" + line + "\n" + post
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(line, "resources: {}") {
|
||||||
|
spaces = strings.Repeat(" ", utils.CountStartingSpaces(line))
|
||||||
|
pre := spaces + `{{- if .Values.` + serviceName + `.resources }}`
|
||||||
|
post := spaces + "{{- end }}"
|
||||||
|
|
||||||
|
line = strings.ReplaceAll(line, "resources: {}", "resources:")
|
||||||
|
line += "\n" + spaces + " {{ .Values." + serviceName + ".resources | toYaml | nindent __indent__ }}"
|
||||||
|
line = pre + "\n" + line + "\n" + post
|
||||||
|
}
|
||||||
|
|
||||||
content[i] = line
|
content[i] = line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,6 +59,7 @@ type Value struct {
|
|||||||
CronJob *CronJobValue `yaml:"cronjob,omitempty"`
|
CronJob *CronJobValue `yaml:"cronjob,omitempty"`
|
||||||
NodeSelector map[string]string `yaml:"nodeSelector"`
|
NodeSelector map[string]string `yaml:"nodeSelector"`
|
||||||
ServiceAccount string `yaml:"serviceAccount"`
|
ServiceAccount string `yaml:"serviceAccount"`
|
||||||
|
Resources map[string]any `yaml:"resources"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CronJobValue is a cronjob configuration that will be saved in values.yaml.
|
// CronJobValue is a cronjob configuration that will be saved in values.yaml.
|
||||||
|
Reference in New Issue
Block a user