-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impl/app image pull #145
Impl/app image pull #145
Changes from all commits
04c491a
83df995
ce163de
a14b49f
076b87c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ const defaultApp: AppIn = { | |
{ | ||
image: '', | ||
name: 'container-1', | ||
env: [], | ||
}, | ||
], | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,7 @@ const SettingCompute = () => { | |
/> | ||
{values.autoscaling ? ( | ||
<div className="flex flex-col gap-3xl"> | ||
<div className="flex flex-col gap-md p-2xl rounded border border-border-default"> | ||
<div className="flex flex-col gap-md p-2xl rounded border border-border-default bg-surface-basic-default"> | ||
<div className="flex flex-row gap-lg items-center"> | ||
<div className="bodyMd-medium text-text-default"> | ||
Select min and max replicas | ||
|
@@ -125,55 +125,56 @@ const SettingCompute = () => { | |
max={10} | ||
value={[values.minReplicas, values.maxReplicas]} | ||
onChange={(value) => { | ||
console.log(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): Removal of the console.log statement is a good practice for production code to avoid exposing potentially sensitive information and to keep the console clean. Ensure that all necessary debugging has been completed. |
||
if (Array.isArray(value)) { | ||
handleChange('minReplicas')(dummyEvent(value[0])); | ||
handleChange('maxReplicas')(dummyEvent(value[1])); | ||
} | ||
}} | ||
/> | ||
</div> | ||
<div className="flex flex-col gap-md p-2xl rounded border border-border-default"> | ||
<div className="flex flex-row gap-lg items-center"> | ||
<div className="bodyMd-medium text-text-default"> | ||
Select CPU | ||
<div className="flex flex-row justify-between gap-3xl"> | ||
<div className="flex flex-col gap-md p-2xl rounded border border-border-default bg-surface-basic-default w-full"> | ||
<div className="flex flex-row gap-lg items-center"> | ||
<div className="bodyMd-medium text-text-default"> | ||
Select CPU | ||
</div> | ||
<code className="bodyMd text-text-soft flex-1 text-end"> | ||
{values.cpuThreshold || 75}% CPU | ||
</code> | ||
</div> | ||
<code className="bodyMd text-text-soft flex-1 text-end"> | ||
{values.cpuThreshold || 75}% CPU | ||
</code> | ||
<Slider | ||
step={1} | ||
min={50} | ||
max={95} | ||
value={values.cpuThreshold} | ||
onChange={(value) => { | ||
handleChange('cpuThreshold')(dummyEvent(value)); | ||
}} | ||
/> | ||
</div> | ||
<Slider | ||
step={1} | ||
min={50} | ||
max={95} | ||
value={values.cpuThreshold} | ||
onChange={(value) => { | ||
handleChange('cpuThreshold')(dummyEvent(value)); | ||
}} | ||
/> | ||
</div> | ||
<div className="flex flex-col gap-md p-2xl rounded border border-border-default"> | ||
<div className="flex flex-row gap-lg items-center"> | ||
<div className="bodyMd-medium text-text-default"> | ||
Select Memory | ||
<div className="flex flex-col gap-md p-2xl rounded border border-border-default bg-surface-basic-default w-full"> | ||
<div className="flex flex-row gap-lg items-center"> | ||
<div className="bodyMd-medium text-text-default"> | ||
Select Memory | ||
</div> | ||
<code className="bodyMd text-text-soft flex-1 text-end"> | ||
{values.memoryThreshold || 75}% Memory | ||
</code> | ||
</div> | ||
<code className="bodyMd text-text-soft flex-1 text-end"> | ||
{values.memoryThreshold || 75}% Memory | ||
</code> | ||
<Slider | ||
step={1} | ||
min={50} | ||
max={95} | ||
value={values.memoryThreshold} | ||
onChange={(value) => { | ||
handleChange('memoryThreshold')(dummyEvent(value)); | ||
}} | ||
/> | ||
</div> | ||
<Slider | ||
step={1} | ||
min={50} | ||
max={95} | ||
value={values.memoryThreshold} | ||
onChange={(value) => { | ||
handleChange('memoryThreshold')(dummyEvent(value)); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
) : ( | ||
<div className="flex flex-col gap-md p-2xl rounded border border-border-default"> | ||
<div className="flex flex-col gap-md p-2xl rounded border border-border-default bg-surface-basic-default"> | ||
<div className="flex flex-row gap-lg items-center"> | ||
<div className="bodyMd-medium text-text-default"> | ||
Select replicas | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import { registryHost } from '~/lib/configs/base-url.cjs'; | |
import { BottomNavigation } from '~/console/components/commons'; | ||
import { useOutletContext } from '@remix-run/react'; | ||
import { useLog } from '~/root/lib/client/hooks/use-log'; | ||
import { Checkbox } from '~/components/atoms/checkbox'; | ||
import { plans } from './datas'; | ||
import { IProjectContext } from '../../_layout'; | ||
|
||
|
@@ -81,9 +82,17 @@ const AppCompute = () => { | |
const { values, errors, handleChange, isLoading, submit } = useForm({ | ||
initialValues: { | ||
imageUrl: app.spec.containers[activeContIndex]?.image || '', | ||
imagePullPolicy: | ||
app.spec.containers[activeContIndex]?.imagePullPolicy || 'IfNotPresent', | ||
pullSecret: 'TODO', | ||
cpuMode: app.metadata?.annotations?.[keyconstants.cpuMode] || 'shared', | ||
memPerCpu: app.metadata?.annotations?.[keyconstants.memPerCpu] || '1', | ||
autoscaling: app.spec.hpa?.enabled || false, | ||
minReplicas: app.spec.hpa?.minReplicas || 1, | ||
maxReplicas: app.spec.hpa?.maxReplicas || 3, | ||
cpuThreshold: app.spec.hpa?.thresholdCpu || 75, | ||
memoryThreshold: app.spec.hpa?.thresholdMemory || 75, | ||
replicas: app.spec.replicas || 1, | ||
|
||
cpu: parseValue( | ||
app.spec.containers[activeContIndex]?.resourceCpu?.max, | ||
|
@@ -159,7 +168,7 @@ const AppCompute = () => { | |
? `${values.repoName}:${values.repoImageTag}` | ||
: `${registryHost}/${values.repoAccountName}/${values.repoName}:${values.repoImageTag}`, | ||
name: 'container-0', | ||
imagePullPolicy: 'Always', | ||
imagePullPolicy: val.imagePullPolicy, | ||
resourceCpu: | ||
val.selectionMode === 'quick' | ||
? { | ||
|
@@ -184,6 +193,14 @@ const AppCompute = () => { | |
}, | ||
}, | ||
], | ||
hpa: { | ||
enabled: val.autoscaling, | ||
maxReplicas: val.maxReplicas, | ||
minReplicas: val.minReplicas, | ||
thresholdCpu: val.cpuThreshold, | ||
thresholdMemory: val.memoryThreshold, | ||
}, | ||
replicas: val.replicas, | ||
}, | ||
})); | ||
}, | ||
|
@@ -301,6 +318,16 @@ const AppCompute = () => { | |
} | ||
loading={digestLoading} | ||
/> | ||
|
||
<Checkbox | ||
label="Image Pull Policy" | ||
checked={values.imagePullPolicy === 'Always'} | ||
onChange={(val) => { | ||
const imagePullPolicy = val ? 'Always' : 'IfNotPresent'; | ||
console.log(imagePullPolicy); | ||
handleChange('imagePullPolicy')(dummyEvent(imagePullPolicy)); | ||
}} | ||
Comment on lines
+323
to
+329
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_clarification): The implementation of the 'Image Pull Policy' checkbox is a good addition for user flexibility. However, ensure that the UI clearly communicates the implications of changing this setting to the user, as it can affect the deployment's behavior regarding image updates. |
||
/> | ||
</div> | ||
|
||
<div className="flex flex-col"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,7 +230,7 @@ export const EnvironmentVariables = () => { | |
submit, | ||
resetValues: resetAppValue, | ||
} = useForm({ | ||
initialValues: getContainer().env || [], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (edge_case_not_handled): This change simplifies the initialization of environment variables by assuming that |
||
initialValues: getContainer().env, | ||
validationSchema: Yup.array(entry), | ||
onSubmit: (val) => { | ||
setContainer((c) => ({ | ||
|
@@ -252,15 +252,16 @@ export const EnvironmentVariables = () => { | |
}, [hasChanges]); | ||
|
||
const addEntry = (val: IEnvVariable) => { | ||
const tempVal = val || []; | ||
setValues((v = []) => { | ||
const data = { | ||
key: val.key, | ||
type: val.type, | ||
refName: val.refName || '', | ||
refKey: val.refKey || '', | ||
value: val.value || '', | ||
key: tempVal.key, | ||
type: tempVal.type, | ||
refName: tempVal.refName || '', | ||
refKey: tempVal.refKey || '', | ||
value: tempVal.value || '', | ||
}; | ||
return [...v, data]; | ||
return [...(v || []), data]; | ||
}); | ||
}; | ||
|
||
|
@@ -312,8 +313,6 @@ export const EnvironmentVariables = () => { | |
}), | ||
}), | ||
onSubmit: () => { | ||
console.log(eValues); | ||
|
||
if (eValues.textInputValue) { | ||
const ev: IEnvVariable = { | ||
key: eValues.key, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code_refinement): Consistency in the UI is key for a good user experience. The addition of the 'Image Pull Policy' checkbox here, similar to its addition in the new-app compute settings, helps maintain that consistency. Just ensure that the default state and any state changes are correctly managed across different components and routes.