1
1
<template >
2
2
<div class =" tab-pane" id =" tabs-hpa" >
3
- <div class =" mb-3" >
4
- <label class =" form-label" >HPA Name</label >
5
- <input type =" text" class =" form-control w-33" name =" example-text-input" v-model =" hpaFormData.hpaName" placeholder =" name" />
6
- </div >
7
- <div class =" mb-3" >
8
- <label class =" form-label" >Namespace</label >
9
- <input type =" text" class =" form-control w-33" name =" example-text-input" v-model =" hpaFormData.namespace" placeholder =" namespace" />
10
- </div >
11
- <div class =" mb-3" >
12
- <label class =" form-label" >Labels</label >
13
- <div class =" generate-form" v-for =" (item, idx) in hpaLabels" :key =" idx" >
14
- <input type =" text" class =" form-control w-33" name =" example-password-input" v-model =" item.key" placeholder =" key" />
15
- <input type =" text" class =" form-control w-33" name =" example-password-input" v-model =" item.value" placeholder =" value" />
16
- <div class =" btn-list" >
17
- <button class =" btn btn-primary" @click =" addLabel" style =" text-align : center !important ;" >
18
- <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-plus" style =" margin : 0 !important ;" >
19
- <path stroke =" none" d =" M0 0h24v24H0z" fill =" none" />
20
- <path d =" M12 5l0 14" />
21
- <path d =" M5 12l14 0" />
22
- </svg >
23
- </button >
24
- <button class =" btn btn-primary" @click =" removeLabel(idx)" >
25
- <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-minus" style =" margin : 0 !important ;" >
26
- <path stroke =" none" d =" M0 0h24v24H0z" fill =" none" />
27
- <path d =" M5 12l14 0" />
28
- </svg >
29
- </button >
3
+ <div class =" card" >
4
+ <div class =" card-header" >
5
+ <h3 class =" card-title" >Metadata 영역</h3 >
6
+ </div >
7
+ <div class =" card-body" >
8
+ <div class =" mb-3" >
9
+ <label class =" form-label required" >HPA Name</label >
10
+ <input type =" text" class =" form-control w-33" name =" example-text-input" v-model =" metadata.name" placeholder =" name" />
11
+ </div >
12
+ <div class =" mb-3" >
13
+ <label class =" form-label required" >Namespace</label >
14
+ <input type =" text" class =" form-control w-33" name =" example-text-input" v-model =" metadata.namespace" placeholder =" namespace" />
15
+ </div >
16
+ <div class =" mb-3" >
17
+ <label class =" form-label required" >Labels</label >
18
+ <div class =" generate-form" v-for =" (item, idx) in hpaLabels" :key =" idx" >
19
+ <input type =" text" class =" form-control w-33" name =" example-password-input" v-model =" item.key" placeholder =" key" />
20
+ <input type =" text" class =" form-control w-33" name =" example-password-input" v-model =" item.value" placeholder =" value" />
21
+ <div class =" btn-list" >
22
+ <button class =" btn btn-primary" @click =" addLabel" style =" text-align : center !important ;" >
23
+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-plus" style =" margin : 0 !important ;" >
24
+ <path stroke =" none" d =" M0 0h24v24H0z" fill =" none" />
25
+ <path d =" M12 5l0 14" />
26
+ <path d =" M5 12l14 0" />
27
+ </svg >
28
+ </button >
29
+ <button class =" btn btn-primary" @click =" removeLabel(idx)" >
30
+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-minus" style =" margin : 0 !important ;" >
31
+ <path stroke =" none" d =" M0 0h24v24H0z" fill =" none" />
32
+ <path d =" M5 12l14 0" />
33
+ </svg >
34
+ </button >
35
+ </div >
36
+ </div >
30
37
</div >
31
38
</div >
32
39
</div >
33
- <div class =" mb-3" >
34
- <label class =" form-label" >Target</label >
35
- <div class =" generate-form" >
36
- <select class =" form-select" v-model =" target.kind" style =" width :33% !important " >
37
- <option value =" deployment" >Deployment</option >
38
- </select >
39
- <input type =" text" class =" form-control w-33" name =" example-password-input" v-model =" target.name" placeholder =" name" />
40
+
41
+ <div class =" card mt-4" >
42
+ <div class =" card-header" >
43
+ <h3 class =" card-title" >Spec 영역</h3 >
40
44
</div >
41
- </div >
42
- <div class =" mb-3" >
43
- <label class =" form-label" >Min Replicas</label >
44
- <input type =" number" class =" form-control w-33" name =" example-text-input" v-model =" hpaFormData.minReplicas" placeholder =" image" />
45
- </div >
46
- <div class =" mb-3" >
47
- <label class =" form-label" >Max Replicas</label >
48
- <input type =" number" class =" form-control w-33" name =" example-text-input" v-model =" hpaFormData.maxReplicas" placeholder =" image" />
49
- </div >
50
- <div class =" mb-3" >
51
- <label class =" form-label" >Metric</label >
52
- <div class =" generate-form" >
53
- <select class =" form-select" v-model =" metric.type" style =" width :33% !important " >
54
- <option value =" cpu" >CPU</option >
55
- <option value =" memory" >MEMORY</option >
56
- </select >
57
- <input type =" number" class =" form-control w-33" name =" example-password-input" v-model =" metric.targetAverageUtilization" placeholder =" value" max =" 100" />
45
+ <div class =" card-body" >
46
+ <div class =" mb-3" >
47
+ <label class =" form-label" >Scale Target</label >
48
+ </div >
49
+ <div class =" row" style =" width :68% !important " >
50
+ <div class =" col" >
51
+ <label class =" form-label required" >Api Version</label >
52
+ <input type =" text" class =" form-control" v-model =" scaleTargetRef.apiVersion" />
53
+ </div >
54
+ <div class =" col" >
55
+ <label class =" form-label required" >Kind</label >
56
+ <input type =" text" class =" form-control" v-model =" scaleTargetRef.kind" />
57
+ </div >
58
+ </div >
59
+ <div class =" row" style =" width :68% !important " >
60
+ <div class =" col" >
61
+ <label class =" form-label required" >Name</label >
62
+ <input type =" text" class =" form-control" v-model =" scaleTargetRef.name" />
63
+ </div >
64
+ </div >
65
+ <div class =" row" style =" width :68% !important " >
66
+ <div class =" col" >
67
+ <label class =" form-label required" >Min Replicas</label >
68
+ <input type =" text" class =" form-control" v-model =" spec.minReplicas" />
69
+ </div >
70
+ </div >
71
+ <div class =" row" style =" width :68% !important " >
72
+ <div class =" col" >
73
+ <label class =" form-label required" >Max Replicas</label >
74
+ <input type =" text" class =" form-control" v-model =" spec.maxReplicas" />
75
+ </div >
76
+ </div >
77
+ <div class =" row" style =" width :68% !important " >
78
+ <div class =" col" >
79
+ <label class =" form-label required" >CPU Percentage</label >
80
+ <input type =" text" class =" form-control" v-model =" spec.targetCPUUtilizationPercentage" />
81
+ </div >
82
+ </div >
83
+
58
84
</div >
59
85
</div >
60
86
61
- <div class =" btn-list justify-content-end" >
62
- <a class =" btn btn-primary" @click =" onClickHpa" data-bs-toggle =' modal' data-bs-target =' #modal-hpa ' >GENERATE</a >
87
+ <div class =" btn-list justify-content-end mt-4 " >
88
+ <a class =" btn btn-primary" @click =" onClickHpa" data-bs-toggle =' modal' data-bs-target =' #modal-yaml ' >GENERATE</a >
63
89
</div >
64
- <hpaModal />
90
+ <yamlModal :yaml-data = " yamlData " :title = " title " />
65
91
</div >
66
92
67
93
@@ -75,45 +101,60 @@ import { ref } from 'vue';
75
101
import { onMounted } from ' vue' ;
76
102
import { useToast } from ' vue-toastification' ;
77
103
import { generateYamlHpa } from ' @/api/yaml.ts' ;
78
- import hpaModal from ' ./hpaModal.vue' ;
79
- import { bootstrap } from " bootstrap"
104
+ import yamlModal from ' ./yamlModal.vue' ;
80
105
81
106
const toast = useToast ()
82
107
/**
83
108
* @Title formData
84
109
* @Desc pod 데이터
85
110
*/
111
+ const title = ref (" " as string )
86
112
const hpaFormData = ref ({} as Hpa )
87
- const hpaLabels = ref ([{}])
88
- const target = ref ({})
89
- const metric = ref ({})
113
+ const metadata = ref ({} as any )
114
+ const hpaLabels = ref ([] as any )
115
+ const spec = ref ({} as any )
116
+ const scaleTargetRef = ref ({} as any )
117
+ const yamlData = ref (" " as string )
90
118
91
119
onMounted (async () => {
92
120
await setInit ();
93
121
})
94
122
95
123
const setInit = () => {
124
+ title .value = " HPA"
125
+ metadata .value = {
126
+ name: " " ,
127
+ namespace: " " ,
128
+ labels: {}
129
+ }
96
130
hpaLabels .value .push ({key: " " , value:" " })
97
- target .value = {kind: " deployment" , name: " " }
98
- metric .value = {type: " cpu" , targetAverageUtilization: 0 }
99
- hpaFormData .value .hpaName = " "
100
- hpaFormData .value .namespace = " "
101
- hpaFormData .value .minReplicas = 0
102
- hpaFormData .value .maxReplicas = 0
131
+ spec .value = {
132
+ scaleTargetRef: {},
133
+ minReplicas: " " ,
134
+ maxReplicas: " " ,
135
+ targetCPUUtilizationPercentage: " "
136
+ }
137
+ scaleTargetRef .value = {
138
+ apiVersion: " " ,
139
+ kind: " " ,
140
+ name: " "
141
+ }
103
142
}
104
143
105
144
const onClickHpa = async () => {
106
- hpaFormData .value .target = target .value
107
- hpaFormData .value .metric = metric .value
108
145
109
- const transformedObject = hpaLabels .value .reduce ((acc , item ) => {
146
+ const transformedObject = hpaLabels .value .reduce ((acc : { [ x : string ] : any ; } , item : { key : string | number ; value : any ; } ) => {
110
147
acc [item .key ] = item .value ;
111
148
return acc ;
112
149
}, {});
113
150
114
- hpaFormData .value .labels = transformedObject ;
115
- const { data } = await generateYamlHpa (hpaFormData .value );
151
+ metadata .value .labels = transformedObject ;
152
+ spec .value .scaleTargetRef = scaleTargetRef .value ;
153
+ hpaFormData .value .metadata = metadata .value
154
+ hpaFormData .value .spec = spec .value ;
116
155
156
+ const { data } = await generateYamlHpa (hpaFormData .value );
157
+ yamlData .value = data ;
117
158
}
118
159
119
160
const addLabel = () => {
0 commit comments