feat: set shm-size volume/volumeMounts on kubernetes deployments
This commit is contained in:
@@ -113,6 +113,18 @@ type ProcessValues struct {
|
||||
Replicas int32 `yaml:"replicas"`
|
||||
Resources ProcessResourcesMap `yaml:"resources,omitempty"`
|
||||
Web ProcessWeb `yaml:"web,omitempty"`
|
||||
Volumes []ProcessVolume `yaml:"volumes,omitempty"`
|
||||
}
|
||||
|
||||
type ProcessVolume struct {
|
||||
Name string `yaml:"name"`
|
||||
MountPath string `yaml:"mount_path"`
|
||||
EmptyDir *ProcessVolumeEmptyDir `yaml:"empty_dir,omitempty"`
|
||||
}
|
||||
|
||||
type ProcessVolumeEmptyDir struct {
|
||||
Medium string `yaml:"medium"`
|
||||
SizeLimit string `yaml:"size_limit"`
|
||||
}
|
||||
|
||||
type ProcessAnnotations struct {
|
||||
|
||||
@@ -116,8 +116,30 @@ spec:
|
||||
{{- if $.Values.global.image.working_dir }}
|
||||
workingDir: {{ $.Values.global.image.working_dir }}
|
||||
{{- end }}
|
||||
{{- if $config.volumes }}
|
||||
volumeMounts:
|
||||
{{- range $volume := $config.volumes }}
|
||||
- name: {{ $volume.name }}
|
||||
mountPath: {{ $volume.mount_path }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $.Values.global.image.image_pull_secrets }}
|
||||
imagePullSecrets:
|
||||
- name: {{ $.Values.global.image.image_pull_secrets }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ $.Values.global.app_name }}
|
||||
{{- if $config.volumes }}
|
||||
volumes:
|
||||
{{- range $volume := $config.volumes }}
|
||||
- name: {{ $volume.name }}
|
||||
{{- if $volume.empty_dir }}
|
||||
emptyDir:
|
||||
{{- if $volume.empty_dir.medium }}
|
||||
medium: {{ $volume.empty_dir.medium }}
|
||||
{{- end }}
|
||||
{{- if $volume.empty_dir.size_limit }}
|
||||
sizeLimit: {{ $volume.empty_dir.size_limit }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -382,6 +382,18 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
||||
}
|
||||
}
|
||||
|
||||
processVolumes := []ProcessVolume{}
|
||||
if shmSize := getComputedShmSize(appName); shmSize != "" {
|
||||
processVolumes = append(processVolumes, ProcessVolume{
|
||||
Name: "shmem",
|
||||
MountPath: "/dev/shm",
|
||||
EmptyDir: &ProcessVolumeEmptyDir{
|
||||
Medium: "Memory",
|
||||
SizeLimit: shmSize,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
for processType, processCount := range processes {
|
||||
// todo: implement deployment annotations
|
||||
// todo: implement pod annotations
|
||||
@@ -439,6 +451,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
||||
ProcessType: ProcessType_Worker,
|
||||
Replicas: int32(processCount),
|
||||
Resources: processResources,
|
||||
Volumes: processVolumes,
|
||||
}
|
||||
|
||||
if processType == "web" {
|
||||
@@ -590,6 +603,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
||||
ProcessType: ProcessType_Cron,
|
||||
Replicas: 1,
|
||||
Resources: processResources,
|
||||
Volumes: processVolumes,
|
||||
}
|
||||
values.Processes[cronEntry.ID] = processValues
|
||||
|
||||
|
||||
@@ -179,12 +179,29 @@ teardown_() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku scheduler-k3s:set $TEST_APP shm-size 64Mi"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
assert_http_localhost_response "http" "$TEST_APP.dokku.me" "80" "" "python/http.server"
|
||||
|
||||
run /bin/bash -c "kubectl get deployment $TEST_APP-web -o json | jq -r '.spec.template.spec.volumes[0].emptyDir.sizeLimit'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "64Mi"
|
||||
|
||||
run /bin/bash -c "kubectl get deployment $TEST_APP-web -o json | jq -r '.spec.template.spec.volumes[0].emptyDir.medium'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "Memory"
|
||||
}
|
||||
|
||||
@test "(scheduler-k3s) deploy annotations" {
|
||||
|
||||
Reference in New Issue
Block a user