mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-04 04:49:22 +08:00
feat: 容器创建增加 CPU 权重设置 (#1377)
This commit is contained in:
parent
20dbd6c181
commit
b7cda1d2f1
@ -36,6 +36,7 @@ type ContainerCreate struct {
|
|||||||
PublishAllPorts bool `json:"publishAllPorts"`
|
PublishAllPorts bool `json:"publishAllPorts"`
|
||||||
ExposedPorts []PortHelper `json:"exposedPorts"`
|
ExposedPorts []PortHelper `json:"exposedPorts"`
|
||||||
Cmd []string `json:"cmd"`
|
Cmd []string `json:"cmd"`
|
||||||
|
CPUShares int64 `josn:"cpuShares"`
|
||||||
NanoCPUs int64 `json:"nanoCPUs"`
|
NanoCPUs int64 `json:"nanoCPUs"`
|
||||||
Memory int64 `json:"memory"`
|
Memory int64 `json:"memory"`
|
||||||
AutoRemove bool `json:"autoRemove"`
|
AutoRemove bool `json:"autoRemove"`
|
||||||
|
@ -247,6 +247,9 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerCreate) error {
|
|||||||
if req.NanoCPUs != 0 {
|
if req.NanoCPUs != 0 {
|
||||||
hostConf.NanoCPUs = req.NanoCPUs * 1000000000
|
hostConf.NanoCPUs = req.NanoCPUs * 1000000000
|
||||||
}
|
}
|
||||||
|
if req.CPUShares != 0 {
|
||||||
|
hostConf.CPUShares = req.CPUShares
|
||||||
|
}
|
||||||
if req.Memory != 0 {
|
if req.Memory != 0 {
|
||||||
hostConf.Memory = req.Memory
|
hostConf.Memory = req.Memory
|
||||||
}
|
}
|
||||||
|
@ -483,6 +483,9 @@ const message = {
|
|||||||
cleanLog: 'Clean log',
|
cleanLog: 'Clean log',
|
||||||
newName: 'New name',
|
newName: 'New name',
|
||||||
source: 'Resource rate',
|
source: 'Resource rate',
|
||||||
|
cpuShare: 'CPU Share',
|
||||||
|
cpuShareHelper:
|
||||||
|
'The default CPU share for a container is 1024, which can be increased to give the container more CPU time.',
|
||||||
|
|
||||||
user: 'User',
|
user: 'User',
|
||||||
command: 'Command',
|
command: 'Command',
|
||||||
|
@ -490,6 +490,8 @@ const message = {
|
|||||||
cleanLog: '清空日志',
|
cleanLog: '清空日志',
|
||||||
newName: '新名称',
|
newName: '新名称',
|
||||||
source: '资源使用率',
|
source: '资源使用率',
|
||||||
|
cpuShare: 'CPU 权重',
|
||||||
|
cpuShareHelper: '容器默认份额为 1024 个 CPU,增大可使当前容器获得更多的 CPU 时间',
|
||||||
|
|
||||||
user: '用户',
|
user: '用户',
|
||||||
command: '命令',
|
command: '命令',
|
||||||
|
@ -81,6 +81,10 @@
|
|||||||
<el-form-item prop="autoRemove">
|
<el-form-item prop="autoRemove">
|
||||||
<el-checkbox v-model="form.autoRemove">{{ $t('container.autoRemove') }}</el-checkbox>
|
<el-checkbox v-model="form.autoRemove">{{ $t('container.autoRemove') }}</el-checkbox>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('container.cpuShare')" prop="cpuShares">
|
||||||
|
<el-input style="width: 40%" v-model.number="form.cpuShares" />
|
||||||
|
<span class="input-help">{{ $t('container.cpuShareHelper') }}</span>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="$t('container.cpuQuota')" prop="nanoCPUs">
|
<el-form-item :label="$t('container.cpuQuota')" prop="nanoCPUs">
|
||||||
<el-input type="number" style="width: 40%" v-model.number="form.nanoCPUs">
|
<el-input type="number" style="width: 40%" v-model.number="form.nanoCPUs">
|
||||||
<template #append>
|
<template #append>
|
||||||
@ -202,7 +206,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules, checkNumberRange } from '@/global/form-rules';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { ElForm } from 'element-plus';
|
import { ElForm } from 'element-plus';
|
||||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||||
@ -221,6 +225,7 @@ const form = reactive({
|
|||||||
cmd: [] as Array<string>,
|
cmd: [] as Array<string>,
|
||||||
publishAllPorts: false,
|
publishAllPorts: false,
|
||||||
exposedPorts: [] as Array<Container.Port>,
|
exposedPorts: [] as Array<Container.Port>,
|
||||||
|
cpuShares: 1024,
|
||||||
nanoCPUs: 0,
|
nanoCPUs: 0,
|
||||||
memory: 0,
|
memory: 0,
|
||||||
memoryItem: 0,
|
memoryItem: 0,
|
||||||
@ -251,6 +256,7 @@ const handlReset = () => {
|
|||||||
form.cmd = [];
|
form.cmd = [];
|
||||||
form.publishAllPorts = false;
|
form.publishAllPorts = false;
|
||||||
form.exposedPorts = [];
|
form.exposedPorts = [];
|
||||||
|
form.cpuShares = 1024;
|
||||||
form.nanoCPUs = 0;
|
form.nanoCPUs = 0;
|
||||||
form.memory = 0;
|
form.memory = 0;
|
||||||
form.memoryItem = 0;
|
form.memoryItem = 0;
|
||||||
@ -272,6 +278,7 @@ const handleClose = () => {
|
|||||||
const emit = defineEmits<{ (e: 'search'): void }>();
|
const emit = defineEmits<{ (e: 'search'): void }>();
|
||||||
|
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
|
cpuShares: [Rules.number, checkNumberRange(2, 262144)],
|
||||||
name: [Rules.requiredInput, Rules.name],
|
name: [Rules.requiredInput, Rules.name],
|
||||||
image: [Rules.requiredSelect],
|
image: [Rules.requiredSelect],
|
||||||
nanoCPUs: [Rules.number],
|
nanoCPUs: [Rules.number],
|
||||||
|
Loading…
Reference in New Issue
Block a user