mirror of
				https://github.com/1Panel-dev/KubePi.git
				synced 2025-10-31 10:36:27 +08:00 
			
		
		
		
	fix(deployment): 去掉withoutLabel参数
This commit is contained in:
		| @@ -1,7 +1,6 @@ | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"embed" | ||||
| 	"github.com/KubeOperator/ekko/internal/route" | ||||
| 	"github.com/KubeOperator/ekko/internal/server" | ||||
| 	"github.com/spf13/cobra" | ||||
| @@ -13,12 +12,6 @@ var ( | ||||
| 	serverBindPort int | ||||
| ) | ||||
|  | ||||
| //go:embed web/terminal | ||||
| var embedWebTerminal embed.FS | ||||
|  | ||||
| //go:embed web/dashboard | ||||
| var embedWebDashboard embed.FS | ||||
|  | ||||
| func init() { | ||||
| 	RootCmd.Flags().StringVar(&serverBindHost, "server-bind-host", "", "ekko bind address") | ||||
| 	RootCmd.Flags().IntVar(&serverBindPort, "server-bind-port", 0, "ekko bind port") | ||||
| @@ -29,8 +22,8 @@ var RootCmd = &cobra.Command{ | ||||
| 	Use:   "ekko", | ||||
| 	Short: "A dashboard for kubernetes", | ||||
| 	RunE: func(cmd *cobra.Command, args []string) error { | ||||
| 		server.EmbedWebDashboard = embedWebDashboard | ||||
| 		server.EmbedWebTerminal = embedWebTerminal | ||||
| 		// server.EmbedWebDashboard = embedWebDashboard | ||||
| 		// server.EmbedWebTerminal = embedWebTerminal | ||||
| 		return server.Listen(route.InitRoute) | ||||
| 	}, | ||||
| } | ||||
|   | ||||
							
								
								
									
										148
									
								
								web/dashboard/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										148
									
								
								web/dashboard/package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1974,6 +1974,80 @@ | ||||
|         "webpack-chain": "^6.4.0", | ||||
|         "webpack-dev-server": "^3.11.0", | ||||
|         "webpack-merge": "^4.2.2" | ||||
|       }, | ||||
|       "dependencies": { | ||||
|         "ansi-styles": { | ||||
|           "version": "4.3.0", | ||||
|           "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", | ||||
|           "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "color-convert": "^2.0.1" | ||||
|           } | ||||
|         }, | ||||
|         "chalk": { | ||||
|           "version": "4.1.1", | ||||
|           "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", | ||||
|           "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "ansi-styles": "^4.1.0", | ||||
|             "supports-color": "^7.1.0" | ||||
|           } | ||||
|         }, | ||||
|         "color-convert": { | ||||
|           "version": "2.0.1", | ||||
|           "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", | ||||
|           "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "color-name": "~1.1.4" | ||||
|           } | ||||
|         }, | ||||
|         "has-flag": { | ||||
|           "version": "4.0.0", | ||||
|           "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", | ||||
|           "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", | ||||
|           "dev": true, | ||||
|           "optional": true | ||||
|         }, | ||||
|         "loader-utils": { | ||||
|           "version": "2.0.0", | ||||
|           "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", | ||||
|           "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "big.js": "^5.2.2", | ||||
|             "emojis-list": "^3.0.0", | ||||
|             "json5": "^2.1.2" | ||||
|           } | ||||
|         }, | ||||
|         "supports-color": { | ||||
|           "version": "7.2.0", | ||||
|           "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", | ||||
|           "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "has-flag": "^4.0.0" | ||||
|           } | ||||
|         }, | ||||
|         "vue-loader-v16": { | ||||
|           "version": "npm:vue-loader@16.3.0", | ||||
|           "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.3.0.tgz", | ||||
|           "integrity": "sha512-UDgni/tUVSdwHuQo+vuBmEgamWx88SuSlEb5fgdvHrlJSPB9qMBRF6W7bfPWSqDns425Gt1wxAUif+f+h/rWjg==", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "chalk": "^4.1.0", | ||||
|             "hash-sum": "^2.0.0", | ||||
|             "loader-utils": "^2.0.0" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "@vue/cli-shared-utils": { | ||||
| @@ -13554,80 +13628,6 @@ | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "vue-loader-v16": { | ||||
|       "version": "npm:vue-loader@16.3.0", | ||||
|       "resolved": "https://registry.nlark.com/vue-loader/download/vue-loader-16.3.0.tgz", | ||||
|       "integrity": "sha1-LxleS6D7DiY1ltaDDfF9Gjbok2w=", | ||||
|       "dev": true, | ||||
|       "optional": true, | ||||
|       "requires": { | ||||
|         "chalk": "^4.1.0", | ||||
|         "hash-sum": "^2.0.0", | ||||
|         "loader-utils": "^2.0.0" | ||||
|       }, | ||||
|       "dependencies": { | ||||
|         "ansi-styles": { | ||||
|           "version": "4.3.0", | ||||
|           "resolved": "https://registry.nlark.com/ansi-styles/download/ansi-styles-4.3.0.tgz", | ||||
|           "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "color-convert": "^2.0.1" | ||||
|           } | ||||
|         }, | ||||
|         "chalk": { | ||||
|           "version": "4.1.1", | ||||
|           "resolved": "https://registry.nlark.com/chalk/download/chalk-4.1.1.tgz", | ||||
|           "integrity": "sha1-yAs/qyi/Y3HmhjMl7uZ+YYt35q0=", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "ansi-styles": "^4.1.0", | ||||
|             "supports-color": "^7.1.0" | ||||
|           } | ||||
|         }, | ||||
|         "color-convert": { | ||||
|           "version": "2.0.1", | ||||
|           "resolved": "https://registry.npm.taobao.org/color-convert/download/color-convert-2.0.1.tgz", | ||||
|           "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "color-name": "~1.1.4" | ||||
|           } | ||||
|         }, | ||||
|         "has-flag": { | ||||
|           "version": "4.0.0", | ||||
|           "resolved": "https://registry.npm.taobao.org/has-flag/download/has-flag-4.0.0.tgz?cache=0&sync_timestamp=1618559744568&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhas-flag%2Fdownload%2Fhas-flag-4.0.0.tgz", | ||||
|           "integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=", | ||||
|           "dev": true, | ||||
|           "optional": true | ||||
|         }, | ||||
|         "loader-utils": { | ||||
|           "version": "2.0.0", | ||||
|           "resolved": "https://registry.npm.taobao.org/loader-utils/download/loader-utils-2.0.0.tgz", | ||||
|           "integrity": "sha1-5MrOW4FtQloWa18JfhDNErNgZLA=", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "big.js": "^5.2.2", | ||||
|             "emojis-list": "^3.0.0", | ||||
|             "json5": "^2.1.2" | ||||
|           } | ||||
|         }, | ||||
|         "supports-color": { | ||||
|           "version": "7.2.0", | ||||
|           "resolved": "https://registry.nlark.com/supports-color/download/supports-color-7.2.0.tgz", | ||||
|           "integrity": "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=", | ||||
|           "dev": true, | ||||
|           "optional": true, | ||||
|           "requires": { | ||||
|             "has-flag": "^4.0.0" | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "vue-router": { | ||||
|       "version": "3.5.1", | ||||
|       "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz", | ||||
|   | ||||
| @@ -24,6 +24,10 @@ export function listConfigMaps (cluster_name, limit, continueToken, search) { | ||||
|   return get(url, param) | ||||
| } | ||||
|  | ||||
| export function listConfigMapsWithNs (cluster_name, namespace) { | ||||
|   return get(`${namespaceMapUrl(cluster_name, namespace)}`); | ||||
| } | ||||
|  | ||||
| export function getConfigMap (cluster_name, namespace, name) { | ||||
|   return get(`${namespaceMapUrl(cluster_name, namespace)}/${name}`) | ||||
| } | ||||
|   | ||||
| @@ -85,14 +85,11 @@ import KoAnnotations from "@/components/ko-workloads/ko-annotations" | ||||
| import KoSecretData from "@/components/ko-configuration/ko-secret-data" | ||||
| import YamlEditor from "@/components/yaml-editor" | ||||
| import {createSecret} from "@/api/secrets" | ||||
| import KoSecretDockerData from "@/components/ko-configuration/ko-secret-docker-data" | ||||
| import KoSecretKeys from "@/components/ko-configuration/ko-secret-keys" | ||||
| import KoSecretAuthentication from "@/components/ko-configuration/ko-secret-authentication" | ||||
| import KoSecretCertificate from "@/components/ko-configuration/ko-secret-certificate" | ||||
| // import KoSecretDockerData from "@/components/ko-configuration/ko-secret-docker-data" | ||||
|  | ||||
| export default { | ||||
|   name: "SecretCreate", | ||||
|   components: { KoSecretCertificate, KoSecretAuthentication, KoSecretKeys, KoSecretDockerData, YamlEditor, KoSecretData, LayoutContent, KoAnnotations, KoLabels }, | ||||
|   components: { YamlEditor, KoSecretData, LayoutContent, KoAnnotations, KoLabels }, | ||||
|   props: {}, | ||||
|   data () { | ||||
|     return { | ||||
|   | ||||
| @@ -5,17 +5,17 @@ | ||||
|       <el-form label-position="top" ref="form" :model="form"> | ||||
|         <el-row :gutter="20"> | ||||
|           <el-col :span="5"> | ||||
|             <el-form-item label="Namespace" prop="metadata.namespace"> | ||||
|               <ko-form-item itemType="select" :selections="namespace_list" v-model="form.metadata.namespace" /> | ||||
|             <el-form-item :label="$t('business.namespace.namespace')" prop="metadata.namespace"> | ||||
|               <ko-form-item @change="changeNs" itemType="select2" :selections="namespace_list" v-model="form.metadata.namespace" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="7"> | ||||
|             <el-form-item label="Name" prop="metadata.name" :rules="requiredRules"> | ||||
|             <el-form-item :label="$t('commons.table.name')" prop="metadata.name" :rules="requiredRules"> | ||||
|               <ko-form-item itemType="input" v-model="form.metadata.name" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="Replicas" prop="spec.replicas" :rules="numberRules"> | ||||
|             <el-form-item :label="$t('business.workload.replicas')" prop="spec.replicas" :rules="numberRules"> | ||||
|               <ko-form-item placeholder="Any text you want that better describes this resource" clearable itemType="number" v-model="form.spec.replicas" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
| @@ -24,8 +24,8 @@ | ||||
|           <el-col :span="12"> | ||||
|             <el-row> | ||||
|               <el-col :span="20"> | ||||
|                 <el-form-item label="Container"> | ||||
|                   <ko-form-item @change="selectContainer" itemType="select" v-model="currentIndex" :selections="container_lists" /> | ||||
|                 <el-form-item :label="$t('business.workload.container')"> | ||||
|                   <ko-form-item @change="selectContainer" itemType="select" v-model="currentContainerIndex" :selections="container_lists" /> | ||||
|                 </el-form-item> | ||||
|               </el-col> | ||||
|               <el-col :span="2"> | ||||
| @@ -46,9 +46,9 @@ | ||||
|       <el-tabs style="margin-top: 30px;background-color: #141418;" type="border-card" v-model="activeName"> | ||||
|         <el-tab-pane label="General" name="General"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-container ref="ko_container" :containerParentObj="form.spec.template.spec.containers[currentContainerIndex]" /> | ||||
|             <ko-container ref="ko_container" :containerParentObj="form.spec.template.spec.containers[currentContainerIndex]" :secretList="secret_list_of_ns"/> | ||||
|             <ko-ports ref="ko_ports" :portParentObj="form.spec.template.spec.containers[currentContainerIndex]" /> | ||||
|             <ko-command ref="ko_command" :commandParentObj="form.spec.template.spec.containers[currentContainerIndex]" :namespace="form.metadata.namespace"/> | ||||
|             <ko-command ref="ko_command" :commandParentObj="form.spec.template.spec.containers[currentContainerIndex]" :currentNamespace="form.metadata.namespace" :configMapList="config_map_list_of_ns" :secretList="secret_list_of_ns" /> | ||||
|           </div> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Resources" name="Resources"> | ||||
| @@ -56,9 +56,9 @@ | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Health Check" name="Health Check"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-health-check ref="ko_health_readiness_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Readiness Check" health_check_helper="Containers will be removed from service endpoints when this check is failing. Recommended." /> | ||||
|             <ko-health-check ref="ko_health_liveness_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Liveness Check" health_check_helper="Containers will be restarted when this check is failing. Not recommended for most uses." /> | ||||
|             <ko-health-check ref="ko_health_startup_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Startup Check" health_check_helper="Containers will wait until this check succeeds before attempting other health checks." /> | ||||
|             <ko-health-check ref="ko_health_readiness_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Readiness Check" /> | ||||
|             <ko-health-check ref="ko_health_liveness_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Liveness Check" /> | ||||
|             <ko-health-check ref="ko_health_startup_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Startup Check" /> | ||||
|           </div> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Security Context" name="Security Context"> | ||||
| @@ -69,8 +69,8 @@ | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Scheduling" name="Scheduling"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-pod-scheduling ref="ko_pod_scheduling" :podSchedulingParentObj="form.spec.template.spec" /> | ||||
|             <ko-node-scheduling ref="ko_node_scheduling" :nodeSchedulingParentObj="form.spec.template.spec" /> | ||||
|             <ko-pod-scheduling ref="ko_pod_scheduling" :podSchedulingParentObj="form.spec.template.spec" :namespaceList="namespace_list" /> | ||||
|             <ko-node-scheduling ref="ko_node_scheduling" :nodeSchedulingParentObj="form.spec.template.spec" :nodeList="node_list" /> | ||||
|             <ko-tolerations ref="ko_toleration" :tolerationsParentObj="form.spec.template.spec" /> | ||||
|           </div> | ||||
|         </el-tab-pane> | ||||
| @@ -79,12 +79,14 @@ | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Labels/Annotations" name="Labels/Annotations"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-labels ref="ko_labels" :labelParentObj="form.spec.template.metadata" /> | ||||
|             <ko-annotations ref="ko_annotations" :annotationsParentObj="form.spec.template.metadata" /> | ||||
|             <ko-labels ref="ko_labels" :labelParentObj="form.metadata" labelTitle="Labels" /> | ||||
|             <ko-annotations ref="ko_annotations" :annotationsParentObj="form.metadata" annotationsTitle="Annotations" /> | ||||
|             <ko-labels ref="ko_labels" :labelParentObj="form.spec.template.metadata" labelTitle="Pod Labels" /> | ||||
|             <ko-annotations ref="ko_annotations" :annotationsParentObj="form.spec.template.metadata" annotationsTitle="Pod Annotations" /> | ||||
|           </div> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Storage" name="Storage"> | ||||
|           <ko-storage ref="ko_storage" :storageParentObj="form.spec.template.spec" :containerIndex="currentIndex" /> | ||||
|           <ko-storage ref="ko_storage" :storageParentObj="form.spec.template.spec" :currentContainerIndex="currentContainerIndex" :configMapList="config_map_list_of_ns" :secretList="secret_list_of_ns" /> | ||||
|         </el-tab-pane> | ||||
|       </el-tabs> | ||||
|     </div> | ||||
| @@ -96,7 +98,7 @@ | ||||
|         <el-button @click="onCancel()">{{ $t("commons.button.cancel") }}</el-button> | ||||
|         <el-button v-if="!showYaml" @click="onEditYaml()">{{ $t("commons.button.edit_yaml") }}</el-button> | ||||
|         <el-button v-if="showYaml" @click="backToForm()">{{ $t("commons.button.back_form") }}</el-button> | ||||
|         <el-button v-loading="loading" @click="onSubmit()" type="primary"> | ||||
|         <el-button v-loading="operationLoading" @click="onSubmit()" type="primary"> | ||||
|           {{ $t("commons.button.create") }} | ||||
|         </el-button> | ||||
|       </div> | ||||
| @@ -123,8 +125,12 @@ import KoAnnotations from "@/components/ko-workloads/ko-annotations.vue" | ||||
| import KoStorage from "@/components/ko-workloads/ko-storage.vue" | ||||
|  | ||||
| import YamlEditor from "@/components/yaml-editor" | ||||
|  | ||||
| import { createDeployment } from "@/api/workloads" | ||||
| import { listNamespace } from "@/api/namespaces" | ||||
| import { listNodes } from "@/api/nodes" | ||||
| import { listSecrets } from "@/api/secrets" | ||||
| import { listConfigMaps } from "@/api/configmaps" | ||||
| import Rule from "@/utils/rules" | ||||
|  | ||||
| export default { | ||||
| @@ -135,18 +141,15 @@ export default { | ||||
|       showYaml: false, | ||||
|       yaml: {}, | ||||
|       isRefresh: false, | ||||
|       operation: "", | ||||
|       loading: false, | ||||
|       namespace_list: [], | ||||
|       image_pull_policy_list: [ | ||||
|         { label: "Always", value: "Always" }, | ||||
|         { label: "ifNotPresent", value: "ifNotPresent" }, | ||||
|         { label: "Never", value: "Never" }, | ||||
|       ], | ||||
|       secret_list: [], | ||||
|       secret_list_of_ns: [], | ||||
|       config_map_list: [], | ||||
|       config_map_list_of_ns: [], | ||||
|       node_list: [], | ||||
|       container_lists: [{ label: "Container-0", value: 0 }], | ||||
|       activeName: "General", | ||||
|       description: "", | ||||
|       currentIndex: 0, | ||||
|       currentContainerIndex: 0, | ||||
|       isValid: true, | ||||
|       unValidInfo: "", | ||||
| @@ -175,26 +178,69 @@ export default { | ||||
|         }, | ||||
|         type: "apps.deployment", | ||||
|       }, | ||||
|       clusterName: "", | ||||
|       operationLoading: false, | ||||
|       numberRules: [Rule.NumberRule], | ||||
|       requiredRules: [Rule.RequiredRule], | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     loadNamespace() { | ||||
|       listNamespace(this.$route.params.cluster).then((res) => { | ||||
|       this.namespace_list = [] | ||||
|       listNamespace(this.clusterName).then((res) => { | ||||
|         for (const ns of res.items) { | ||||
|           this.namespace_list.push({ label: ns.metadata.name, value: ns.metadata.name }) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     loadSecrets() { | ||||
|       this.secret_list = [] | ||||
|       listSecrets(this.clusterName).then((res) => { | ||||
|         this.secret_list = res.items | ||||
|         this.loadSecretsWithNs() | ||||
|       }) | ||||
|     }, | ||||
|     loadSecretsWithNs() { | ||||
|       this.secret_list_of_ns = [] | ||||
|       for (const s of this.secret_list) { | ||||
|         if (s.metadata.namespace === this.form.metadata.namespace) { | ||||
|           this.secret_list_of_ns.push(s) | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     loadConfigMaps() { | ||||
|       this.config_map_list = [] | ||||
|       listConfigMaps(this.clusterName).then((res) => { | ||||
|         this.config_map_list = res.items | ||||
|         this.loadConfigMapsWithNs() | ||||
|       }) | ||||
|     }, | ||||
|     loadConfigMapsWithNs() { | ||||
|       this.config_map_list_of_ns = [] | ||||
|       for (const c of this.config_map_list) { | ||||
|         if (c.metadata.namespace === this.form.metadata.namespace) { | ||||
|           this.config_map_list_of_ns.push(c) | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     changeNs() { | ||||
|       this.loadSecretsWithNs() | ||||
|       this.loadConfigMapsWithNs() | ||||
|     }, | ||||
|     loadNodes() { | ||||
|       this.node_list = [] | ||||
|       listNodes(this.clusterName).then((res) => { | ||||
|         this.node_list = res.items | ||||
|       }) | ||||
|     }, | ||||
|  | ||||
|     selectContainer() { | ||||
|       this.form = this.gatherFormData() | ||||
|       this.gatherFormValid() | ||||
|       if (!this.isValid) { | ||||
|         this.$notify({ title: "提示", message: this.unValidInfo }) | ||||
|         this.$notify({ title: this.$t("commons.message_box.prompt"), message: this.unValidInfo }) | ||||
|         return | ||||
|       } | ||||
|       this.currentContainerIndex = this.currentIndex | ||||
|       this.form = this.gatherFormData() | ||||
|       this.isRefresh = !this.isRefresh | ||||
|     }, | ||||
|     handleAddContainer() { | ||||
| @@ -213,6 +259,11 @@ export default { | ||||
|       } | ||||
|     }, | ||||
|     gatherFormValid() { | ||||
|       this.$refs["form"].validate((valid) => { | ||||
|         if (!valid) { | ||||
|           return | ||||
|         } | ||||
|       }) | ||||
|       if (!this.$refs.ko_container.checkIsValid()) { | ||||
|         this.isValid = false | ||||
|         this.unValidInfo = "ko_container 参数不完整" | ||||
| @@ -220,33 +271,21 @@ export default { | ||||
|       } | ||||
|     }, | ||||
|     gatherFormData() { | ||||
|       // general | ||||
|       this.$refs.ko_container.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // ports | ||||
|       this.$refs.ko_ports.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // command | ||||
|       this.$refs.ko_command.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // resource | ||||
|       this.$refs.ko_resource.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // health_check | ||||
|       this.$refs.ko_health_readiness_check.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       this.$refs.ko_health_liveness_check.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       this.$refs.ko_health_startup_check.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // security context | ||||
|       this.$refs.ko_security_context.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // networking | ||||
|       this.$refs.ko_networking.transformation(this.form.spec.template.spec) | ||||
|       // scheduling | ||||
|       this.$refs.ko_node_scheduling.transformation(this.form.spec.template.spec) | ||||
|       this.$refs.ko_pod_scheduling.transformation(this.form.spec.template.spec) | ||||
|       this.$refs.ko_toleration.transformation(this.form.spec.template.spec) | ||||
|       // upgrade policy | ||||
|       this.$refs.ko_upgrade_policy.transformation(this.form.spec) | ||||
|       // labels | ||||
|       this.$refs.ko_labels.transformation(this.form.spec.template.metadata) | ||||
|       // annotations | ||||
|       this.$refs.ko_annotations.transformation(this.form.spec.template.metadata) | ||||
|       // storage | ||||
|       this.$refs.ko_storage.transformation(this.form.spec.template.spec) | ||||
|       return this.form | ||||
|     }, | ||||
| @@ -257,7 +296,7 @@ export default { | ||||
|       let data = {} | ||||
|       this.gatherFormValid() | ||||
|       if (!this.isValid) { | ||||
|         this.$notify({ title: "提示", message: this.unValidInfo }) | ||||
|         this.$notify({ title: this.$t("commons.message_box.prompt"), message: this.unValidInfo }) | ||||
|         return | ||||
|       } | ||||
|       if (this.showYaml) { | ||||
| @@ -287,10 +326,13 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.currentIndex = 0 | ||||
|     this.currentContainerIndex = 0 | ||||
|     this.showYaml = this.$route.params.showYaml | ||||
|     this.clusterName = this.$route.query.cluster | ||||
|     this.loadNamespace() | ||||
|     this.loadSecrets() | ||||
|     this.loadConfigMaps() | ||||
|     this.loadNodes() | ||||
|   }, | ||||
| } | ||||
| </script> | ||||
|   | ||||
| @@ -45,18 +45,6 @@ | ||||
|           </table> | ||||
|         </el-card> | ||||
|       </el-col> | ||||
|       <el-col :span="24"> | ||||
|         <br> | ||||
|         <el-card> | ||||
|           <div class="card_title"> | ||||
|             <h3>{{ $t("business.configuration.data") }}</h3> | ||||
|           </div> | ||||
|           <div> | ||||
|             <json-editor :value="form"> | ||||
|             </json-editor> | ||||
|           </div> | ||||
|         </el-card> | ||||
|       </el-col> | ||||
|     </el-row> | ||||
|   </layout-content> | ||||
| </template> | ||||
| @@ -64,29 +52,30 @@ | ||||
| <script> | ||||
| import LayoutContent from "@/components/layout/LayoutContent" | ||||
| import { getDeploymentByName } from "@/api/workloads" | ||||
| import JsonEditor from "@/components/json-editor" | ||||
|  | ||||
| export default { | ||||
|   name: "DeploymentDetail", | ||||
|   components: { JsonEditor, LayoutContent }, | ||||
|   components: { LayoutContent }, | ||||
|   data() { | ||||
|     return { | ||||
|       form: { | ||||
|         metadata: {}, | ||||
|       }, | ||||
|       loading: false, | ||||
|       clusterName: "", | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     getDetail() { | ||||
|       this.loading = true | ||||
|       getDeploymentByName(this.$route.params.cluster, this.$route.params.namespace, this.$route.params.name).then((res) => { | ||||
|       getDeploymentByName(this.clusterName, this.$route.params.namespace, this.$route.params.name).then((res) => { | ||||
|         this.form = res | ||||
|         this.loading = false | ||||
|       }) | ||||
|     }, | ||||
|   }, | ||||
|   created() { | ||||
|     this.clusterName = this.$route.query.cluster | ||||
|     this.getDetail() | ||||
|   }, | ||||
| } | ||||
|   | ||||
| @@ -5,17 +5,17 @@ | ||||
|       <el-form label-position="top" ref="form" :model="form"> | ||||
|         <el-row :gutter="20"> | ||||
|           <el-col :span="5"> | ||||
|             <el-form-item label="Namespace" prop="metadata.namespace"> | ||||
|               <ko-form-item itemType="select" :selections="namespace_list" v-model="form.metadata.namespace" /> | ||||
|             <el-form-item :label="$t('business.namespace.namespace')" prop="metadata.namespace"> | ||||
|               <ko-form-item @change="changeNs" itemType="select2" :selections="namespace_list" v-model="form.metadata.namespace" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="7"> | ||||
|             <el-form-item label="Name" prop="metadata.name" :rules="requiredRules"> | ||||
|             <el-form-item :label="$t('commons.table.name')" prop="metadata.name" :rules="requiredRules"> | ||||
|               <ko-form-item itemType="input" v-model="form.metadata.name" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="Replicas" prop="spec.replicas" :rules="numberRules"> | ||||
|             <el-form-item :label="$t('business.workload.replicas')" prop="spec.replicas" :rules="numberRules"> | ||||
|               <ko-form-item placeholder="Any text you want that better describes this resource" clearable itemType="number" v-model="form.spec.replicas" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
| @@ -24,8 +24,8 @@ | ||||
|           <el-col :span="12"> | ||||
|             <el-row> | ||||
|               <el-col :span="20"> | ||||
|                 <el-form-item label="Container"> | ||||
|                   <ko-form-item @change="selectContainer" itemType="select" v-model="currentIndex" :selections="container_lists" /> | ||||
|                 <el-form-item :label="$t('business.workload.container')"> | ||||
|                   <ko-form-item @change="selectContainer" itemType="select" v-model="currentContainerIndex" :selections="container_lists" /> | ||||
|                 </el-form-item> | ||||
|               </el-col> | ||||
|               <el-col :span="2"> | ||||
| @@ -46,45 +46,47 @@ | ||||
|       <el-tabs style="margin-top: 30px;background-color: #141418;" type="border-card" v-model="activeName"> | ||||
|         <el-tab-pane label="General" name="General"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-container ref="ko_general" :containerParentObj="form.spec.template.spec.containers[currentContainerIndex]" /> | ||||
|             <ko-container ref="ko_container" :containerParentObj="form.spec.template.spec.containers[currentContainerIndex]" :secretList="secret_list_of_ns" /> | ||||
|             <ko-ports ref="ko_ports" :portParentObj="form.spec.template.spec.containers[currentContainerIndex]" /> | ||||
|             <ko-command ref="ko_command" :commandParentObj="form.spec.template.spec.containers[currentContainerIndex]" :namespace="form.metadata.namespace" /> | ||||
|             <ko-command ref="ko_command" :commandParentObj="form.spec.template.spec.containers[currentContainerIndex]" :currentNamespace="form.metadata.namespace" :configMapList="config_map_list_of_ns" :secretList="secret_list_of_ns" /> | ||||
|           </div> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Resources" name="Resources"> | ||||
|           <ko-resources ref="ko_resource" :key="isRefresh" :resourceParentObj="form.spec.template.spec.containers[currentContainerIndex]" /> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Health Check" name="Health Check"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-health-check ref="ko_health_readiness_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Readiness Check" health_check_helper="Containers will be removed from service endpoints when this check is failing. Recommended." /> | ||||
|             <ko-health-check ref="ko_health_liveness_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Liveness Check" health_check_helper="Containers will be restarted when this check is failing. Not recommended for most uses." /> | ||||
|             <ko-health-check ref="ko_health_startup_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Startup Check" health_check_helper="Containers will wait until this check succeeds before attempting other health checks." /> | ||||
|             <ko-health-check ref="ko_health_readiness_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Readiness Check" /> | ||||
|             <ko-health-check ref="ko_health_liveness_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Liveness Check" /> | ||||
|             <ko-health-check ref="ko_health_startup_check" :healthCheckParentObj="form.spec.template.spec.containers[currentContainerIndex]" style="margin-top=30px" health_check_type="Startup Check" /> | ||||
|           </div> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Security Context" name="Security Context"> | ||||
|           <ko-security-context ref="ko_security_context" :securityContextParentObj="form.spec.template.spec.containers[currentContainerIndex]" /> | ||||
|         <el-tab-pane label="Labels/Annotations" name="Labels/Annotations"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-labels ref="ko_labels" :labelParentObj="form.metadata" labelTitle="Labels" /> | ||||
|             <ko-annotations ref="ko_annotations" :annotationsParentObj="form.metadata" annotationsTitle="Annotations" /> | ||||
|             <ko-labels ref="ko_labels" :labelParentObj="form.spec.template.metadata" labelTitle="Pod Labels" /> | ||||
|             <ko-annotations ref="ko_annotations" :annotationsParentObj="form.spec.template.metadata" annotationsTitle="Pod Annotations" /> | ||||
|           </div> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Networking" name="Networking"> | ||||
|           <ko-networking ref="ko_networking" :key="isRefresh" :networkingParentObj="form.spec.template.spec" /> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Scheduling" name="Scheduling"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-pod-scheduling ref="ko_pod_scheduling" :podSchedulingParentObj="form.spec.template.spec" /> | ||||
|             <ko-node-scheduling ref="ko_node_scheduling" :podSchedulingParentObj="form.spec.template.spec" /> | ||||
|             <ko-tolerations ref="ko_tolerations" :tolerationsParentObj="form.spec.template.spec" /> | ||||
|             <ko-pod-scheduling ref="ko_pod_scheduling" :podSchedulingParentObj="form.spec.template.spec" :namespaceList="namespace_list" /> | ||||
|             <ko-node-scheduling ref="ko_node_scheduling" :nodeSchedulingParentObj="form.spec.template.spec" :nodeList="node_list" /> | ||||
|             <ko-tolerations ref="ko_toleration" :tolerationsParentObj="form.spec.template.spec" /> | ||||
|           </div> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Resources" name="Resources"> | ||||
|           <ko-resources ref="ko_resource" :key="isRefresh" :resourceParentObj="form.spec.template.spec.containers[currentContainerIndex]" /> | ||||
|         </el-tab-pane> | ||||
|          <el-tab-pane label="Scaling/Upgrade Policy" name="Scaling/Upgrade Policy"> | ||||
|           <ko-upgrade-policy ref="ko_upgrade_policy" :key="isRefresh" :upgradePolicyParentObj="form.spec" /> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Labels/Annotations" name="Labels/Annotations"> | ||||
|           <div :key="isRefresh"> | ||||
|             <ko-labels ref="ko_labels" :labelParentObj="form.spec.template.metadata" /> | ||||
|             <ko-annotations ref="ko_annotations" :annotationsParentObj="form.spec.template.metadata" /> | ||||
|           </div> | ||||
|         <el-tab-pane label="Security Context" name="Security Context"> | ||||
|           <ko-security-context ref="ko_security_context" :key="isRefresh" :securityContextParentObj="form.spec.template.spec.containers[currentContainerIndex]" /> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="Storage" name="Storage"> | ||||
|           <ko-storage ref="ko_storage" :storageParentObj="form.spec.template.spec" :containerIndex="currentContainerIndex" /> | ||||
|           <ko-storage :key="isRefresh" ref="ko_storage" :storageParentObj="form.spec.template.spec" :currentContainerIndex="currentContainerIndex" :configMapList="config_map_list_of_ns" :secretList="secret_list_of_ns" /> | ||||
|         </el-tab-pane> | ||||
|       </el-tabs> | ||||
|     </div> | ||||
| @@ -121,11 +123,16 @@ import KoAnnotations from "@/components/ko-workloads/ko-annotations.vue" | ||||
| import KoStorage from "@/components/ko-workloads/ko-storage.vue" | ||||
|  | ||||
| import YamlEditor from "@/components/yaml-editor" | ||||
|  | ||||
| import { getDeploymentByName, createDeployment } from "@/api/workloads" | ||||
| import { listNamespace } from "@/api/namespaces" | ||||
| import { listNodes } from "@/api/nodes" | ||||
| import { listSecrets } from "@/api/secrets" | ||||
| import { listConfigMaps } from "@/api/configmaps" | ||||
| import Rule from "@/utils/rules" | ||||
|  | ||||
| export default { | ||||
|   name: "DeploymentForm", | ||||
|   name: "DeploymentEdit", | ||||
|   components: { LayoutContent, KoFormItem, KoContainer, KoPorts, KoCommand, KoResources, KoHealthCheck, KoSecurityContext, KoNetworking, KoPodScheduling, KoNodeScheduling, KoTolerations, KoUpgradePolicy, KoLabels, KoAnnotations, KoStorage, YamlEditor }, | ||||
|   data() { | ||||
|     return { | ||||
| @@ -134,28 +141,24 @@ export default { | ||||
|       isRefresh: false, | ||||
|       operation: "", | ||||
|       loading: false, | ||||
|       namespace_list: [ | ||||
|         { label: "kube-system", value: "kube-system" }, | ||||
|         { label: "kube-public", value: "kube-public" }, | ||||
|         { label: "kube-operator", value: "kube-operator" }, | ||||
|         { label: "default", value: "default" }, | ||||
|       ], | ||||
|       image_pull_policy_list: [ | ||||
|         { label: "Always", value: "Always" }, | ||||
|         { label: "ifNotPresent", value: "ifNotPresent" }, | ||||
|         { label: "Never", value: "Never" }, | ||||
|       ], | ||||
|       container_lists: [{ label: "Container-0", value: 0 }], | ||||
|       namespace_list: [], | ||||
|       secret_list: [], | ||||
|       secret_list_of_ns: [], | ||||
|       config_map_list: [], | ||||
|       config_map_list_of_ns: [], | ||||
|       node_list: [], | ||||
|       container_lists: [], | ||||
|       activeName: "General", | ||||
|       description: "", | ||||
|       currentIndex: 0, | ||||
|       currentContainerIndex: 0, | ||||
|       currentIndex: 0, // select框值 | ||||
|       currentContainerIndex: 0, // 实际当前值 | ||||
|       isValid: true, | ||||
|       unValidInfo: "", | ||||
|       form: { | ||||
|         apiVersion: "apps/v1", | ||||
|         kind: "Deployment", | ||||
|         metadata: { | ||||
|           name: "my-test-deployment", | ||||
|           namespace: "kube-operator", | ||||
|           namespace: "", | ||||
|         }, | ||||
|         spec: { | ||||
|           replicas: 1, | ||||
| @@ -175,6 +178,7 @@ export default { | ||||
|         }, | ||||
|         type: "apps.deployment", | ||||
|       }, | ||||
|       clusterName: "", | ||||
|       operationLoading: false, | ||||
|       numberRules: [Rule.NumberRule], | ||||
|       requiredRules: [Rule.RequiredRule], | ||||
| @@ -182,13 +186,75 @@ export default { | ||||
|   }, | ||||
|   methods: { | ||||
|     search() { | ||||
|       getDeploymentByName(this.$route.params.cluster, this.$route.params.namespace, this.$route.params.name).then((res) => { | ||||
|       getDeploymentByName(this.clusterName, this.$route.params.namespace, this.$route.params.name).then((res) => { | ||||
|         this.form = res | ||||
|         this.container_lists = [] | ||||
|         if (this.form.spec.template.spec.containers) { | ||||
|           for (let i = 0; i < this.form.spec.template.spec.containers.length; i++) { | ||||
|             this.container_lists.push({ label: this.form.spec.template.spec.containers[i].name, value: i }) | ||||
|           } | ||||
|         } else { | ||||
|           this.container_lists = [{ label: "Container-0", value: 0 }] | ||||
|         } | ||||
|         this.isRefresh = !this.isRefresh | ||||
|       }) | ||||
|     }, | ||||
|     loadNamespace() { | ||||
|       this.namespace_list = [] | ||||
|       listNamespace(this.clusterName).then((res) => { | ||||
|         for (const ns of res.items) { | ||||
|           this.namespace_list.push(ns.metadata.name) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     loadSecrets() { | ||||
|       this.secret_list = [] | ||||
|       listSecrets(this.clusterName).then((res) => { | ||||
|         this.secret_list = res.items | ||||
|         this.loadSecretsWithNs() | ||||
|       }) | ||||
|     }, | ||||
|     loadSecretsWithNs() { | ||||
|       this.secret_list_of_ns = [] | ||||
|       for (const s of this.secret_list) { | ||||
|         if (s.metadata.namespace === this.form.metadata.namespace) { | ||||
|           this.secret_list_of_ns.push(s) | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     loadConfigMaps() { | ||||
|       this.config_map_list = [] | ||||
|       listConfigMaps(this.clusterName).then((res) => { | ||||
|         this.config_map_list = res.items | ||||
|         this.loadConfigMapsWithNs() | ||||
|       }) | ||||
|     }, | ||||
|     loadConfigMapsWithNs() { | ||||
|       this.config_map_list_of_ns = [] | ||||
|       for (const c of this.config_map_list) { | ||||
|         if (c.metadata.namespace === this.form.metadata.namespace) { | ||||
|           this.config_map_list_of_ns.push(c) | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     changeNs() { | ||||
|       this.loadSecretsWithNs() | ||||
|       this.loadConfigMapsWithNs() | ||||
|     }, | ||||
|     loadNodes() { | ||||
|       this.node_list = [] | ||||
|       listNodes(this.clusterName).then((res) => { | ||||
|         this.node_list = res.items | ||||
|       }) | ||||
|     }, | ||||
|  | ||||
|     selectContainer() { | ||||
|       this.form = this.transformYaml() | ||||
|       this.gatherFormValid() | ||||
|       if (!this.isValid) { | ||||
|         this.$notify({ title: this.$t("commons.message_box.prompt"), message: this.unValidInfo }) | ||||
|         return | ||||
|       } | ||||
|       this.form = this.gatherFormData() | ||||
|       this.currentContainerIndex = this.currentIndex | ||||
|       this.isRefresh = !this.isRefresh | ||||
|     }, | ||||
| @@ -207,32 +273,32 @@ export default { | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     transformYaml() { | ||||
|       // general | ||||
|       this.$refs.ko_general.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // ports | ||||
|     gatherFormValid() { | ||||
|       if (!this.$refs.ko_container.checkIsValid()) { | ||||
|         this.isValid = false | ||||
|         this.unValidInfo = "ko_container 参数不完整" | ||||
|         return | ||||
|       } | ||||
|       if (!this.$refs.ko_storage.checkIsValid()) { | ||||
|         this.isValid = false | ||||
|         this.unValidInfo = "ko_storage 参数不完整" | ||||
|         return | ||||
|       } | ||||
|     }, | ||||
|     gatherFormData() { | ||||
|       this.$refs.ko_container.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       this.$refs.ko_ports.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // command | ||||
|       this.$refs.ko_command.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // resource | ||||
|       this.$refs.ko_resource.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // health_check | ||||
|       this.$refs.ko_health_readiness_check.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       this.$refs.ko_health_liveness_check.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       this.$refs.ko_health_startup_check.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // security context | ||||
|       this.$refs.ko_security_context.transformation(this.form.spec.template.spec.containers[this.currentContainerIndex]) | ||||
|       // networking | ||||
|       this.$refs.ko_networking.transformation(this.form.spec.template.spec) | ||||
|       // node scheduling | ||||
|       this.$refs.ko_pod_scheduling.transformation(this.form.spec.template.spec) | ||||
|       // upgrade policy | ||||
|       this.$refs.ko_upgrade_policy.transformation(this.form.spec) | ||||
|       // labels | ||||
|       this.$refs.ko_labels.transformation(this.form.spec.template.metadata) | ||||
|       // annotations | ||||
|       this.$refs.ko_annotations.transformation(this.form.spec.template.metadata) | ||||
|       // storage | ||||
|       this.$refs.ko_storage.transformation(this.form.spec.template.spec) | ||||
|       return this.form | ||||
|     }, | ||||
| @@ -241,10 +307,15 @@ export default { | ||||
|     }, | ||||
|     onSubmit() { | ||||
|       let data = {} | ||||
|       this.gatherFormValid() | ||||
|       if (!this.isValid) { | ||||
|         this.$notify({ title: this.$t("commons.message_box.prompt"), message: this.unValidInfo }) | ||||
|         return | ||||
|       } | ||||
|       if (this.showYaml) { | ||||
|         data = this.$refs.yaml_editor.getValue() | ||||
|       } else { | ||||
|         data = this.transformYaml() | ||||
|         data = this.gatherFormData() | ||||
|       } | ||||
|       this.loading = true | ||||
|       createDeployment(this.clusterName, data) | ||||
| @@ -260,7 +331,7 @@ export default { | ||||
|         }) | ||||
|     }, | ||||
|     onEditYaml() { | ||||
|       this.yaml = this.transformYaml() | ||||
|       this.yaml = this.gatherFormData() | ||||
|       this.showYaml = true | ||||
|     }, | ||||
|     backToForm() { | ||||
| @@ -270,9 +341,14 @@ export default { | ||||
|   mounted() { | ||||
|     this.currentIndex = 0 | ||||
|     this.currentContainerIndex = 0 | ||||
|     this.clusterName = this.$route.query.cluster | ||||
|     if (this.$route.params.name) { | ||||
|       this.search() | ||||
|     } | ||||
|     this.loadNamespace() | ||||
|     this.loadSecrets() | ||||
|     this.loadConfigMaps() | ||||
|     this.loadNodes() | ||||
|   }, | ||||
| } | ||||
| </script> | ||||
|   | ||||
| @@ -12,12 +12,12 @@ | ||||
|         </el-button-group> | ||||
|       </template> | ||||
|       <el-table-column type="selection" fix></el-table-column> | ||||
|       <el-table-column sortable label="Name" prop="name"> | ||||
|       <el-table-column sortable :label="$t('commons.table.name')" prop="name"> | ||||
|         <template v-slot:default="{row}"> | ||||
|           <el-link @click="openDetail(row)">{{ row.name }}</el-link> | ||||
|         </template> | ||||
|       </el-table-column> | ||||
|       <el-table-column sortable label="Status" prop="status"> | ||||
|       <el-table-column sortable :label="$t('commons.table.status')" prop="status"> | ||||
|         <template v-slot:default="{row}"> | ||||
|           <el-button v-if="row.status ==='Active'" type="success" size="mini" plain round> | ||||
|             {{row.status}} | ||||
| @@ -27,7 +27,7 @@ | ||||
|           </el-button> | ||||
|         </template> | ||||
|       </el-table-column> | ||||
|       <el-table-column sortable label="Namespace" prop="namespace" /> | ||||
|       <el-table-column sortable :label="$t('business.namespace.namespace')" prop="namespace" /> | ||||
|       <el-table-column :label="$t('commons.table.created_time')" prop="metadata.creationTimestamp" fix> | ||||
|         <template v-slot:default="{row}"> | ||||
|           {{ row.created_time | datetimeFormat }} | ||||
| @@ -55,14 +55,14 @@ export default { | ||||
|           label: this.$t("commons.button.edit"), | ||||
|           icon: "el-icon-edit", | ||||
|           click: (row) => { | ||||
|             this.$router.push({ name: "DeploymentEdit", params: { cluster: "songliucs", namespace: row.namespace, name: row.name, yamlShow: false } }) | ||||
|             this.$router.push({ name: "DeploymentEdit", params: { namespace: row.namespace, name: row.name }, query: { yamlShow: false } }) | ||||
|           }, | ||||
|         }, | ||||
|         { | ||||
|           label: this.$t("commons.button.edit_yaml"), | ||||
|           icon: "el-icon-edit", | ||||
|           click: (row) => { | ||||
|             this.$router.push({ name: "DeploymentEdit", params: { cluster: "songliucs", namespace: row.namespace, name: row.name, yamlShow: true } }) | ||||
|             this.$router.push({ name: "DeploymentEdit", params: { namespace: row.namespace, name: row.name }, query: { yamlShow: true } }) | ||||
|           }, | ||||
|         }, | ||||
|         { | ||||
| @@ -87,14 +87,15 @@ export default { | ||||
|         nextToken: "", | ||||
|       }, | ||||
|       selects: [], | ||||
|       clusterName: "", | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     onCreate() { | ||||
|       this.$router.push({ name: "DeploymentCreate", params: { cluster: "songliucs", yamlShow: false } }) | ||||
|       this.$router.push({ name: "DeploymentCreate", query: { yamlShow: false } }) | ||||
|     }, | ||||
|     openDetail(row) { | ||||
|       this.$router.push({ name: "DeploymentDetail", params: { cluster: "songliucs", namespace: row.namespace, name: row.name } }) | ||||
|       this.$router.push({ name: "DeploymentDetail", params: { namespace: row.namespace, name: row.name } }) | ||||
|     }, | ||||
|     onDelete(row) { | ||||
|       this.$confirm(this.$t("commons.confirm_message.delete"), this.$t("commons.message_box.prompt"), { | ||||
| @@ -136,7 +137,7 @@ export default { | ||||
|           nextToken: "", | ||||
|         } | ||||
|       } | ||||
|       listDeployments("songliucs") | ||||
|       listDeployments(this.clusterName) | ||||
|         .then((res) => { | ||||
|           for (const item of res.items) { | ||||
|             this.data.push({ | ||||
| @@ -157,6 +158,7 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.clusterName = this.$route.query.cluster | ||||
|     this.search() | ||||
|   }, | ||||
| } | ||||
|   | ||||
| @@ -4,6 +4,10 @@ | ||||
|       <el-option v-for="(item, index) in selections" :key="index" :label="item.label" :value="item.value"/> | ||||
|     </el-select> | ||||
|  | ||||
|     <el-select v-if="itemType==='select2'" filterable clearable style="width: 100%;" v-bind="$attrs" v-on="$listeners"> | ||||
|       <el-option v-for="(item, index) in selections" :key="index" :label="item" :value="item" /> | ||||
|     </el-select> | ||||
|  | ||||
|     <el-input v-if="itemType==='input'" clearable v-bind="$attrs" v-on="$listeners"> | ||||
|       <template v-if="deviderName" slot="append">{{ deviderName }}</template> | ||||
|     </el-input> | ||||
| @@ -42,7 +46,6 @@ export default { | ||||
|   name: "KoFormItem", | ||||
|   props: { | ||||
|     itemType: String, // input, select, radio | ||||
|     labelName: String, | ||||
|     selections: Array, // 如果是 select | ||||
|     deviderName: String, // 如果需要加上单位 | ||||
|     radios: Array, // 如果是 radio | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| <template> | ||||
|   <div style="margin-top: 20px"> | ||||
|     <ko-card title="Annotations"> | ||||
|     <ko-card :title="annotationsTitle"> | ||||
|       <table style="width: 98%" class="tab-table"> | ||||
|         <tr> | ||||
|           <th scope="col" width="48%" align="left"> | ||||
| @@ -13,10 +13,10 @@ | ||||
|         </tr> | ||||
|         <tr v-for="(row, index) in annotations" v-bind:key="index"> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" placeholder="e.g. foo" itemType="input" v-model="row.key" /> | ||||
|             <ko-form-item placeholder="e.g. foo" itemType="input" v-model="row.key" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" placeholder="e.g. bar" itemType="input" v-model="row.value" /> | ||||
|             <ko-form-item placeholder="e.g. bar" itemType="textarea" v-model="row.value" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <el-button type="text" style="font-size: 10px" @click="handleDelete(index)"> | ||||
| @@ -43,6 +43,7 @@ export default { | ||||
|   components: { KoFormItem, KoCard }, | ||||
|   props: { | ||||
|     annotationsParentObj: Object, | ||||
|     annotationsTitle: String, | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| <template> | ||||
|   <div style="margin-top: 20px"> | ||||
|     <ko-card title="Command"> | ||||
|     <ko-card :key="reFresh" title="Command"> | ||||
|       <el-form label-position="top" ref="form" :model="form"> | ||||
|         <el-row :gutter="20"> | ||||
|           <el-col :span="12"> | ||||
| @@ -10,7 +10,7 @@ | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="Arguments" prop="args"> | ||||
|               <ko-form-item placeholder="e.g. /usr/sbin/httpd -f httpd.conf" itemType="input" v-model="form.args" /> | ||||
|               <ko-form-item placeholder="e.g. /usr/sbin/httpd -f httpd.conf" itemType="textarea" v-model="form.args" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|         </el-row> | ||||
| @@ -44,24 +44,24 @@ | ||||
|         </tr> | ||||
|         <tr v-for="(row, index) in form.envResource" v-bind:key="index"> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="select" v-model="row.type" :selections="type_list" /> | ||||
|             <ko-form-item itemType="select2" v-model="row.type" :selections="type_list" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="input" v-model="row.prefix_or_alias" /> | ||||
|             <ko-form-item itemType="input" v-model="row.prefix_or_alias" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item v-if="row.type === 'Key/Value Pair' || row.type === 'Pod Field'" :withoutLabel="true" itemType="input" disabled placeholder="N/A" /> | ||||
|             <ko-form-item v-if="row.type === 'Resource' || row.type === 'Field'" :withoutLabel="true" itemType="input" v-model="row.source" /> | ||||
|             <ko-form-item v-if="row.type === 'ConfigMap key'" :withoutLabel="true" itemType="select" v-model="row.source" @change="changeConfigMap(row.source)" :selections="config_map_name_list" /> | ||||
|             <ko-form-item v-if="row.type === 'ConfigMap'" :withoutLabel="true" itemType="select" v-model="row.source" :selections="config_map_name_list" /> | ||||
|             <ko-form-item v-if="row.type === 'Secret' || row.type === 'Secret key'" :withoutLabel="true" itemType="select" v-model="row.source" :selections="secret_list" /> | ||||
|             <ko-form-item v-if="row.type === 'Key/Value Pair' || row.type === 'Pod Field'" itemType="input" disabled placeholder="N/A" /> | ||||
|             <ko-form-item v-if="row.type === 'Resource' || row.type === 'Field'" itemType="input" v-model="row.source" /> | ||||
|             <ko-form-item v-if="row.type === 'ConfigMap key'" itemType="select2" v-model="row.source" @change="changeConfigMap(row.source)" :selections="config_map_name_list" /> | ||||
|             <ko-form-item v-if="row.type === 'ConfigMap'" itemType="select2" v-model="row.source" :selections="config_map_name_list" /> | ||||
|             <ko-form-item v-if="row.type === 'Secret' || row.type === 'Secret key'" itemType="select2" v-model="row.source" :selections="secret_list" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" v-if="row.type ==='Key/Value Pair' || row.type === 'Pod Field'" itemType="input" v-model="row.value" /> | ||||
|             <ko-form-item :withoutLabel="true" v-if="row.type ==='Resource'" itemType="select" v-model="row.value" :selections="resource_value_list" /> | ||||
|             <ko-form-item :withoutLabel="true" v-if="row.type ==='ConfigMap key'" itemType="select" v-model="row.value" :selections="config_map_value_list" /> | ||||
|             <ko-form-item :withoutLabel="true" v-if="row.type ==='Secret key'" itemType="select" v-model="row.value" :selections="secret_value_list" /> | ||||
|             <ko-form-item :withoutLabel="true" v-if="row.type === 'Secret' || row.type === 'ConfigMap'" disabled itemType="input" v-model="row.key" placeholder="N/A" /> | ||||
|             <ko-form-item v-if="row.type ==='Key/Value Pair' || row.type === 'Pod Field'" itemType="textarea" v-model="row.value" /> | ||||
|             <ko-form-item v-if="row.type ==='Resource'" itemType="select2" v-model="row.value" :selections="resource_value_list" /> | ||||
|             <ko-form-item v-if="row.type ==='ConfigMap key'" itemType="select2" v-model="row.value" :selections="config_map_value_list" /> | ||||
|             <ko-form-item v-if="row.type ==='Secret key'" itemType="select2" v-model="row.value" :selections="secret_value_list" /> | ||||
|             <ko-form-item v-if="row.type === 'Secret' || row.type === 'ConfigMap'" disabled itemType="input" v-model="row.key" placeholder="N/A" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <el-button type="text" style="font-size: 10px" @click="handleDelete(index)"> | ||||
| @@ -82,23 +82,45 @@ | ||||
| <script> | ||||
| import KoFormItem from "@/components/ko-form-item/index" | ||||
| import KoCard from "@/components/ko-card/index" | ||||
| import { listSecrets } from "@/api/secrets" | ||||
| import { listConfigMaps } from "@/api/configmaps" | ||||
|  | ||||
| export default { | ||||
|   name: "KoCommand", | ||||
|   components: { KoFormItem, KoCard }, | ||||
|   props: { | ||||
|     commandParentObj: Object, | ||||
|     namespace: String, | ||||
|     currentNamespace: String, | ||||
|     configMapList: Array, | ||||
|     secretList: Array, | ||||
|   }, | ||||
|   watch: { | ||||
|     namespace: { | ||||
|     currentNamespace: { | ||||
|       handler(newName) { | ||||
|         this.namespace = newName | ||||
|       }, | ||||
|       immediate: true, | ||||
|     }, | ||||
|     configMapList: { | ||||
|       handler(newName) { | ||||
|         this.config_map_name_list = [] | ||||
|         this.config_map_list = [] | ||||
|         for (const cm of newName) { | ||||
|           this.config_map_name_list.push(cm.metadata.name) | ||||
|           this.config_map_list.push(cm) | ||||
|         } | ||||
|       }, | ||||
|       immediate: true, | ||||
|       deep: true, | ||||
|     }, | ||||
|     secretList: { | ||||
|       handler(newName) { | ||||
|         this.secret_list = [] | ||||
|         for (const s of newName) { | ||||
|           this.secret_list.push(s.metadata.name) | ||||
|         } | ||||
|       }, | ||||
|       immediate: true, | ||||
|       deep: true, | ||||
|     }, | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
| @@ -106,36 +128,19 @@ export default { | ||||
|         args: "", | ||||
|         command: "", | ||||
|         workingDir: "", | ||||
|         stdin: "", | ||||
|         stdin: "No", | ||||
|         tty: false, | ||||
|         envResource: [], | ||||
|       }, | ||||
|       reFresh: false, | ||||
|       namespace: "", | ||||
|       config_map_name_list: [], | ||||
|       config_map_list: [], | ||||
|       config_map_value_list: [], | ||||
|       secret_list: [], | ||||
|       resource_value_list: [ | ||||
|         { label: "limits.cpu", value: "limits.cpu" }, | ||||
|         { label: "limits.ephemeral-storage", value: "limits.ephemeral-storage" }, | ||||
|         { label: "limits.memory", value: "limits.memory" }, | ||||
|         { label: "requests.cpu", value: "requests.cpu" }, | ||||
|         { label: "requests.ephemeral-storage", value: "requests.ephemeral-storage" }, | ||||
|         { label: "requests.memory", value: "requests.memory" }, | ||||
|       ], | ||||
|       secret_value_list: [ | ||||
|         { label: "ca.crt", value: "ca.crt" }, | ||||
|         { label: "namespace", value: "namespace" }, | ||||
|         { label: "token", value: "token" }, | ||||
|       ], | ||||
|       type_list: [ | ||||
|         { label: "Key/Value Pair", value: "Key/Value Pair" }, | ||||
|         { label: "Pod Field", value: "Pod Field" }, | ||||
|         { label: "Resource", value: "Resource" }, | ||||
|         { label: "ConfigMap key", value: "ConfigMap key" }, | ||||
|         { label: "Secret key", value: "Secret key" }, | ||||
|         { label: "Secret", value: "Secret" }, | ||||
|         { label: "ConfigMap", value: "ConfigMap" }, | ||||
|       ], | ||||
|       resource_value_list: ["limits.cpu", "limits.ephemeral-storage", "limits.memory", "requests.cpu", "requests.ephemeral-storage", "requests.memory"], | ||||
|       secret_value_list: ["ca.crt", "namespace", "token"], | ||||
|       type_list: ["Key/Value Pair", "Pod Field", "Resource", "ConfigMap key", "Secret key", "Secret", "ConfigMap"], | ||||
|       stdin_list: [ | ||||
|         { label: "No", value: "No" }, | ||||
|         { label: "Ones", value: "Ones" }, | ||||
| @@ -144,30 +149,12 @@ export default { | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     loadSecrets() { | ||||
|       listSecrets(this.$route.params.cluster).then((res) => { | ||||
|         this.secret_list = [] | ||||
|         for (const secret of res.items) { | ||||
|           this.secret_list.push({ label: secret.metadata.name, value: secret.metadata.name }) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     loadConfigMaps() { | ||||
|       listConfigMaps(this.$route.params.cluster).then((res) => { | ||||
|         this.config_map_name_list = [] | ||||
|         for (const cm of res.items) { | ||||
|           this.config_map_name_list.push({ label: cm.metadata.name, value: cm.metadata.name }) | ||||
|           this.config_map_list.push(cm) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     changeConfigMap(comfigmap) { | ||||
|       console.log(this.namespace) | ||||
|       this.config_map_value_list = [] | ||||
|       for (const cm of this.config_map_list) { | ||||
|         if (comfigmap === cm.metadata.name && cm.metadata.namespace === this.namespace) { | ||||
|           for (const item of Object.keys(cm.data)) { | ||||
|             this.config_map_value_list.push({ label: item, value: item }) | ||||
|             this.config_map_value_list.push(item) | ||||
|           } | ||||
|         } | ||||
|       } | ||||
| @@ -282,7 +269,7 @@ export default { | ||||
|                 prefix: en.prefix_or_alias, | ||||
|                 configMapRef: { | ||||
|                   name: en.source, | ||||
|                   optional: false, // 这个false是什么意思不知道 | ||||
|                   optional: false,  | ||||
|                 }, | ||||
|               }) | ||||
|               break | ||||
| @@ -298,8 +285,6 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.loadSecrets() | ||||
|     this.loadConfigMaps() | ||||
|     if (this.commandParentObj) { | ||||
|       if (this.commandParentObj.command) { | ||||
|         this.form.command = this.commandParentObj.command.join(",") | ||||
|   | ||||
| @@ -23,7 +23,7 @@ | ||||
|         </el-row> | ||||
|         <el-row> | ||||
|           <el-form-item label="Pull Secrets" prop="imagePullSecrets"> | ||||
|             <ko-form-item itemType="select" multiple v-model="form.imagePullSecrets" :selections="secret_list" /> | ||||
|             <ko-form-item itemType="select2" multiple v-model="form.imagePullSecrets" :selections="secret_list" /> | ||||
|           </el-form-item> | ||||
|         </el-row> | ||||
|       </el-form> | ||||
| @@ -35,13 +35,25 @@ | ||||
| import KoFormItem from "@/components/ko-form-item/index" | ||||
| import KoCard from "@/components/ko-card/index" | ||||
| import Rule from "@/utils/rules" | ||||
| import { listSecrets } from "@/api/secrets" | ||||
|  | ||||
| export default { | ||||
|   name: "KoContainer", | ||||
|   components: { KoFormItem, KoCard }, | ||||
|   props: { | ||||
|     containerParentObj: Object, | ||||
|     secretList: Array, | ||||
|   }, | ||||
|   watch: { | ||||
|     secretList: { | ||||
|       handler(newName) { | ||||
|         this.secret_list = [] | ||||
|         for (const s of newName) { | ||||
|           this.secret_list.push(s.metadata.name) | ||||
|         } | ||||
|       }, | ||||
|       immediate: true, | ||||
|       deep: true, | ||||
|     }, | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
| @@ -62,14 +74,6 @@ export default { | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     loadSecrets() { | ||||
|       listSecrets(this.$route.params.cluster).then((res) => { | ||||
|         this.secret_list = [] | ||||
|         for (const secret of res.items) { | ||||
|           this.secret_list.push({ label: secret.metadata.name, value: secret.metadata.name }) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     checkIsValid() { | ||||
|       let isValid = true | ||||
|       this.$refs["form"].validate((valid) => { | ||||
| @@ -90,7 +94,6 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.loadSecrets() | ||||
|     if (this.containerParentObj) { | ||||
|       if (this.containerParentObj.name) { | ||||
|         this.form.name = this.containerParentObj.name | ||||
|   | ||||
| @@ -13,10 +13,10 @@ | ||||
|         </tr> | ||||
|         <tr v-for="label in data" v-bind:key="label.index"> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" placeholder="e.g. foo" clearable itemType="input" v-model="label.key"/> | ||||
|             <ko-form-item placeholder="e.g. foo" clearable itemType="input" v-model="label.key"/> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" placeholder="e.g. bar" clearable itemType="textarea" v-model="label.value"/> | ||||
|             <ko-form-item placeholder="e.g. bar" clearable itemType="textarea" v-model="label.value"/> | ||||
|           </td> | ||||
|           <td> | ||||
|             <el-button type="text" style="font-size: 10px" @click="handleDelete(label)"> | ||||
|   | ||||
| @@ -72,10 +72,10 @@ | ||||
|                 </tr> | ||||
|                 <tr v-for="(row, index) in form.httpHeaders" v-bind:key="index"> | ||||
|                   <td> | ||||
|                     <ko-form-item :withoutLabel="true" placeholder="e.g. foo" itemType="input" v-model="row.key" /> | ||||
|                     <ko-form-item placeholder="e.g. foo" itemType="input" v-model="row.key" /> | ||||
|                   </td> | ||||
|                   <td> | ||||
|                     <ko-form-item :withoutLabel="true" placeholder="e.g. bar" itemType="input" v-model="row.value" /> | ||||
|                     <ko-form-item placeholder="e.g. bar" itemType="input" v-model="row.value" /> | ||||
|                   </td> | ||||
|                   <td> | ||||
|                     <el-button type="text" style="font-size: 10px" @click="handleDelete(index)"> | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| <template> | ||||
|   <div style="margin-top: 20px"> | ||||
|     <ko-card title="Labels"> | ||||
|     <ko-card :title="labelTitle"> | ||||
|       <table style="width: 98%" class="tab-table"> | ||||
|         <tr> | ||||
|           <th scope="col" width="48%" align="left"> | ||||
| @@ -13,10 +13,10 @@ | ||||
|         </tr> | ||||
|         <tr v-for="(row, index) in labels" v-bind:key="index"> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" placeholder="e.g. foo" itemType="input" v-model="row.key" /> | ||||
|             <ko-form-item placeholder="e.g. foo" itemType="input" v-model="row.key" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" placeholder="e.g. bar" itemType="input" v-model="row.value" /> | ||||
|             <ko-form-item placeholder="e.g. bar" itemType="textarea"  v-model="row.value" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <el-button type="text" style="font-size: 10px" @click="handleDelete(index)"> | ||||
| @@ -43,6 +43,7 @@ export default { | ||||
|   components: { KoFormItem,KoCard }, | ||||
|   props: { | ||||
|     labelParentObj: Object, | ||||
|     labelTitle: String, | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|   | ||||
| @@ -5,12 +5,12 @@ | ||||
|         <el-row :gutter="20"> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="Network Mode" prop="hostNetwork"> | ||||
|               <ko-form-item itemType="select" v-model="form.hostNetwork" :selections="network_mode_list" /> | ||||
|               <ko-form-item itemType="radio" v-model="form.hostNetwork" :radios="network_mode_list" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="DNS Policy" prop="dnsPolicy"> | ||||
|               <ko-form-item itemType="select" v-model="form.dnsPolicy" :selections="dns_policy_list" /> | ||||
|               <ko-form-item itemType="radio" v-model="form.dnsPolicy" :radios="dns_policy_list" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|         </el-row> | ||||
| @@ -39,7 +39,7 @@ | ||||
|             </tr> | ||||
|             <tr v-for="row in form.dnsConfig.nameservers" v-bind:key="row.index"> | ||||
|               <td> | ||||
|                 <ko-form-item :withoutLabel="true" placeholder="e.g. 1.1.1.1" itemType="input" v-model="row.value" /> | ||||
|                 <ko-form-item placeholder="e.g. 1.1.1.1" itemType="input" v-model="row.value" /> | ||||
|               </td> | ||||
|               <td> | ||||
|                 <el-button type="text" style="font-size: 10px" @click="handleNameserversDelete(row.index)"> | ||||
| @@ -62,7 +62,7 @@ | ||||
|             </tr> | ||||
|             <tr v-for="row in form.dnsConfig.searches" v-bind:key="row.index"> | ||||
|               <td> | ||||
|                 <ko-form-item :withoutLabel="true" placeholder="e.g. mycompany.com" itemType="input" v-model="row.value" /> | ||||
|                 <ko-form-item placeholder="e.g. mycompany.com" itemType="input" v-model="row.value" /> | ||||
|               </td> | ||||
|               <td> | ||||
|                 <el-button type="text" style="font-size: 10px" @click="handleSearchesDelete(row.index)"> | ||||
| @@ -93,10 +93,10 @@ | ||||
|           </tr> | ||||
|           <tr v-for="row in form.dnsConfig.options" v-bind:key="row.index"> | ||||
|             <td> | ||||
|               <ko-form-item :withoutLabel="true" placeholder="e.g. foo" itemType="input" v-model="row.name" /> | ||||
|               <ko-form-item placeholder="e.g. foo" itemType="input" v-model="row.name" /> | ||||
|             </td> | ||||
|             <td> | ||||
|               <ko-form-item :withoutLabel="true" placeholder="e.g. bar" itemType="input" v-model="row.value" /> | ||||
|               <ko-form-item placeholder="e.g. bar" itemType="input" v-model="row.value" /> | ||||
|             </td> | ||||
|             <td> | ||||
|               <el-button type="text" style="font-size: 10px" @click="handleOptionsDelete(row.index)"> | ||||
| @@ -126,10 +126,10 @@ | ||||
|           </tr> | ||||
|           <tr v-for="(row, index) in form.hostAliases" v-bind:key="index"> | ||||
|             <td> | ||||
|               <ko-form-item :withoutLabel="true" placeholder="e.g. 1.1.1.1" itemType="input" v-model="row.ip" /> | ||||
|               <ko-form-item placeholder="e.g. 1.1.1.1" itemType="input" v-model="row.ip" /> | ||||
|             </td> | ||||
|             <td> | ||||
|               <ko-form-item :withoutLabel="true" placeholder="e.g. foo.com,bar.com" itemType="input" v-model="row.hostnames" /> | ||||
|               <ko-form-item placeholder="e.g. foo.com,bar.com" itemType="input" v-model="row.hostnames" /> | ||||
|             </td> | ||||
|             <td> | ||||
|               <el-button type="text" style="font-size: 10px" @click="handleAliasDelete(index)"> | ||||
| @@ -173,7 +173,7 @@ export default { | ||||
|         subdomain: "", | ||||
|         dnsPolicy: "", | ||||
|         hostname: "", | ||||
|         hostNetwork: "", | ||||
|         hostNetwork: false, | ||||
|         hostAliases: [], | ||||
|         dnsConfig: { | ||||
|           nameservers: [], | ||||
|   | ||||
| @@ -12,7 +12,7 @@ | ||||
|         <el-row v-if="scheduling_type === 'specific_node'"> | ||||
|           <el-col :span="24"> | ||||
|             <el-form-item label="Node Name"> | ||||
|               <ko-form-item itemType="select" v-model="nodeName" :selections="node_list" /> | ||||
|               <ko-form-item itemType="select2" v-model="nodeName" :selections="node_list" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|         </el-row> | ||||
| @@ -50,14 +50,14 @@ | ||||
|                 </tr> | ||||
|                 <tr v-for="(row, index) in item.rules" v-bind:key="index"> | ||||
|                   <td> | ||||
|                     <ko-form-item :withoutLabel="true" itemType="input" v-model="row.key" /> | ||||
|                     <ko-form-item itemType="input" v-model="row.key" /> | ||||
|                   </td> | ||||
|                   <td> | ||||
|                     <ko-form-item :withoutLabel="true" itemType="select" v-model="row.operator" :selections="operator_list" /> | ||||
|                     <ko-form-item itemType="select" v-model="row.operator" :selections="operator_list" /> | ||||
|                   </td> | ||||
|                   <td> | ||||
|                     <ko-form-item :withoutLabel="true" v-if="row.operator === 'Exists' || row.operator === 'DoesNotExist'" disabled itemType="input" value="N/A" /> | ||||
|                     <ko-form-item :withoutLabel="true" v-else itemType="input" v-model="row.value" /> | ||||
|                     <ko-form-item v-if="row.operator === 'Exists' || row.operator === 'DoesNotExist'" disabled itemType="input" value="N/A" /> | ||||
|                     <ko-form-item v-else itemType="input" v-model="row.value" /> | ||||
|                   </td> | ||||
|                   <td> | ||||
|                     <el-button type="text" style="font-size: 10px" @click="handleMatchDelete(item, index)"> | ||||
| @@ -83,13 +83,25 @@ | ||||
| <script> | ||||
| import KoFormItem from "@/components/ko-form-item/index" | ||||
| import KoCard from "@/components/ko-card/index" | ||||
| import { listNodes } from "@/api/nodes" | ||||
|  | ||||
| export default { | ||||
|   name: "KoNodeScheduling", | ||||
|   components: { KoFormItem, KoCard }, | ||||
|   props: { | ||||
|     nodeSchedulingParentObj: Object, | ||||
|     nodeList: Array, | ||||
|   }, | ||||
|   watch: { | ||||
|     nodeList: { | ||||
|       handler(newName) { | ||||
|         this.node_list = [] | ||||
|         for (const node of newName) { | ||||
|           this.node_list.push(node.metadata.name) | ||||
|         } | ||||
|       }, | ||||
|       immediate: true, | ||||
|       deep: true, | ||||
|     }, | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
| @@ -117,14 +129,6 @@ export default { | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     loadNodes() { | ||||
|       listNodes(this.$route.params.cluster).then((res) => { | ||||
|         this.node_list = [] | ||||
|         for (const node of res.items) { | ||||
|           this.node_list.push({ label: node.metadata.name, value: node.metadata.name }) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     handleNodeRulesAdd() { | ||||
|       var item = { | ||||
|         priority: "Preferred", | ||||
| @@ -212,7 +216,6 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.loadNodes() | ||||
|     this.nodeSchedulings = [] | ||||
|     if (this.nodeSchedulingParentObj) { | ||||
|       if (this.nodeSchedulingParentObj.affinity) { | ||||
|   | ||||
| @@ -27,7 +27,7 @@ | ||||
|               </el-col> | ||||
|               <el-col :span="12" v-if="item.namespaceOperation === 'selectNamespace'"> | ||||
|                 <el-form-item label="Namespace"> | ||||
|                   <ko-form-item itemType="select" v-model="item.namespaces" multiple :selections="namespace_list" /> | ||||
|                   <ko-form-item itemType="select2" v-model="item.namespaces" multiple :selections="namespace_list" /> | ||||
|                 </el-form-item> | ||||
|               </el-col> | ||||
|             </el-row> | ||||
| @@ -47,14 +47,14 @@ | ||||
|               </tr> | ||||
|               <tr v-for="(row, index) in item.rules" v-bind:key="index"> | ||||
|                 <td> | ||||
|                   <ko-form-item :withoutLabel="true" itemType="input" v-model="row.key" /> | ||||
|                   <ko-form-item itemType="input" v-model="row.key" /> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                   <ko-form-item :withoutLabel="true" itemType="select" v-model="row.operator" :selections="operator_list" /> | ||||
|                   <ko-form-item itemType="select" v-model="row.operator" :selections="operator_list" /> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                   <ko-form-item :withoutLabel="true" v-if="row.operator === 'Exists' || row.operator === 'DoesNotExist'" disabled itemType="input" value="N/A" /> | ||||
|                   <ko-form-item :withoutLabel="true" v-else itemType="input" v-model="row.value" /> | ||||
|                   <ko-form-item v-if="row.operator === 'Exists' || row.operator === 'DoesNotExist'" disabled itemType="input" value="N/A" /> | ||||
|                   <ko-form-item v-else itemType="input" v-model="row.value" /> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                   <el-button type="text" style="font-size: 10px" @click="handleMatchDelete(item, index)"> | ||||
| @@ -91,7 +91,16 @@ export default { | ||||
|   name: "KoPodScheduling", | ||||
|   components: { KoFormItem, KoCard }, | ||||
|   props: { | ||||
|     podScheduling: Object, | ||||
|     podSchedulingParentObj: Object, | ||||
|     namespaceList: Array, | ||||
|   }, | ||||
|   watch: { | ||||
|     namespaceList: { | ||||
|       handler(newName) { | ||||
|         this.namespace_list = newName | ||||
|       }, | ||||
|       immediate: true, | ||||
|     }, | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
| @@ -115,12 +124,7 @@ export default { | ||||
|         { label: "=", value: "In" }, | ||||
|         { label: "!=", value: "NotIn" }, | ||||
|       ], | ||||
|       namespace_list: [ | ||||
|         { label: "kube-system", value: "kube-system" }, | ||||
|         { label: "kube-public", value: "kube-public" }, | ||||
|         { label: "kube-operator", value: "kube-operator" }, | ||||
|         { label: "default", value: "default" }, | ||||
|       ], | ||||
|       namespace_list: [], | ||||
|       podSchedulings: [], | ||||
|     } | ||||
|   }, | ||||
| @@ -264,18 +268,19 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.namespace_list = this.namespaceList | ||||
|     this.podSchedulings = [] | ||||
|     if (this.podScheduling) { | ||||
|       if (this.podScheduling.affinity) { | ||||
|         if (this.podScheduling.affinity.podAffinity) { | ||||
|           if (this.podScheduling.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution) { | ||||
|             const schedulings = this.podScheduling.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution | ||||
|     if (this.podSchedulingParentObj) { | ||||
|       if (this.podSchedulingParentObj.affinity) { | ||||
|         if (this.podSchedulingParentObj.affinity.podAffinity) { | ||||
|           if (this.podSchedulingParentObj.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution) { | ||||
|             const schedulings = this.podSchedulingParentObj.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution | ||||
|             for (const s of schedulings) { | ||||
|               this.valueTrans("Affinity", "Required", s) | ||||
|             } | ||||
|           } | ||||
|           if (this.podScheduling.affinity.podAffinity.preferredDuringSchedulingIgnoredDuringExecution) { | ||||
|             const schedulings = this.podScheduling.affinity.podAffinity.preferredDuringSchedulingIgnoredDuringExecution | ||||
|           if (this.podSchedulingParentObj.affinity.podAffinity.preferredDuringSchedulingIgnoredDuringExecution) { | ||||
|             const schedulings = this.podSchedulingParentObj.affinity.podAffinity.preferredDuringSchedulingIgnoredDuringExecution | ||||
|             for (const s of schedulings) { | ||||
|               if (s.podAffinityTerm) { | ||||
|                 this.valueTrans("Affinity", "Preferred", s.podAffinityTerm) | ||||
| @@ -283,15 +288,15 @@ export default { | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|         if (this.podScheduling.affinity.podAntiAffinity) { | ||||
|           if (this.podScheduling.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution) { | ||||
|             const schedulings = this.podScheduling.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution | ||||
|         if (this.podSchedulingParentObj.affinity.podAntiAffinity) { | ||||
|           if (this.podSchedulingParentObj.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution) { | ||||
|             const schedulings = this.podSchedulingParentObj.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution | ||||
|             for (const s of schedulings) { | ||||
|               this.valueTrans("Anti-Affinity", "Required", s) | ||||
|             } | ||||
|           } | ||||
|           if (this.podScheduling.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution) { | ||||
|             const schedulings = this.podScheduling.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution | ||||
|           if (this.podSchedulingParentObj.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution) { | ||||
|             const schedulings = this.podSchedulingParentObj.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution | ||||
|             for (const s of schedulings) { | ||||
|               if (s.podAffinityTerm) { | ||||
|                 this.valueTrans("Anti-Affinity", "Preferred", s.podAffinityTerm) | ||||
|   | ||||
| @@ -15,28 +15,28 @@ | ||||
|         </tr> | ||||
|         <tr v-for="(row, index) in ports" v-bind:key="index"> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="select" v-model="row._serviceType" :selections="service_type_list" /> | ||||
|             <ko-form-item itemType="select" v-model="row._serviceType" :selections="service_type_list" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="input" v-model="row.name" /> | ||||
|             <ko-form-item itemType="input" v-model="row.name" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" placeholder="e.g. 8080" itemType="number" v-model.number="row.containerPort" /> | ||||
|             <ko-form-item placeholder="e.g. 8080" itemType="number" v-model.number="row.containerPort" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="select" v-model="row.protocol" :selections="protocol_list" /> | ||||
|             <ko-form-item itemType="select" v-model="row.protocol" :selections="protocol_list" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <el-switch v-model="row.expose" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :disabled="row._serviceType === 'NodePort' || row._serviceType === 'LoadBalancer' || !row.expose" :withoutLabel="true" placeholder="e.g. 80" itemType="number" v-model.number="row.hostPort" /> | ||||
|             <ko-form-item :disabled="row._serviceType === 'NodePort' || row._serviceType === 'LoadBalancer' || !row.expose" placeholder="e.g. 80" itemType="number" v-model.number="row.hostPort" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :disabled="row._serviceType === 'ClusterIP' || row._serviceType === '' || !row.expose" :withoutLabel="true" placeholder="e.g. 80" itemType="number" v-model.number="row._listeningPort" /> | ||||
|             <ko-form-item :disabled="row._serviceType === 'ClusterIP' || row._serviceType === '' || !row.expose" placeholder="e.g. 80" itemType="number" v-model.number="row._listeningPort" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :disabled="row._serviceType === 'NodePort' || row._serviceType === 'LoadBalancer' || !row.expose" :withoutLabel="true" placeholder="e.g. 1.1.1.1" itemType="input" v-model="row.hostIP" /> | ||||
|             <ko-form-item :disabled="row._serviceType === 'NodePort' || row._serviceType === 'LoadBalancer' || !row.expose" placeholder="e.g. 1.1.1.1" itemType="input" v-model="row.hostIP" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <el-button type="text" style="font-size: 10px" @click="handleDelete(index)"> | ||||
| @@ -72,7 +72,7 @@ export default { | ||||
|         { label: "UDP", value: "UDP" }, | ||||
|       ], | ||||
|       service_type_list: [ | ||||
|         { label: "Do not create a service", value: "" }, | ||||
|         { label: "Not create a service", value: "" }, | ||||
|         { label: "Cluster IP", value: "ClusterIP" }, | ||||
|         { label: "Node Port", value: "NodePort" }, | ||||
|         { label: "Load Balancer", value: "LoadBalancer" }, | ||||
| @@ -134,9 +134,9 @@ export default { | ||||
|           itemPo.expose = po.expose | ||||
|           itemPo.protocol = po.protocol | ||||
|           itemPo.containerPort = po.containerPort | ||||
|           itemPo._serviceType = po._serviceType | ||||
|           itemPo._serviceType = po._serviceType ? po._serviceType : "" | ||||
|           if (po.expose) { | ||||
|             switch (po._listeningPort) { | ||||
|             switch (po._serviceType) { | ||||
|               case "": | ||||
|               case "ClusterIP": | ||||
|                 itemPo.hostPort = po.hostPort | ||||
|   | ||||
| @@ -36,12 +36,12 @@ | ||||
|         <el-row :gutter="20"> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="Add Capabilities" prop="capabilities.add"> | ||||
|               <ko-form-item multiple itemType="select" v-model="form.capabilities.add" :selections="capability_list" /> | ||||
|               <ko-form-item multiple itemType="select2" v-model="form.capabilities.add" :selections="capability_list" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="Drop Capabilities" prop="capabilities.drop"> | ||||
|               <ko-form-item multiple itemType="select" v-model="form.capabilities.drop" :selections="capability_list" /> | ||||
|               <ko-form-item multiple itemType="select2" v-model="form.capabilities.drop" :selections="capability_list" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|         </el-row> | ||||
| @@ -78,16 +78,11 @@ export default { | ||||
|         { label: "No", value: false }, | ||||
|         { label: "Yes: container has a read-only root filesystem", value: true }, | ||||
|       ], | ||||
|       capability_list: [ | ||||
|         { label: "ALL", value: "ALL" }, | ||||
|         { label: "AUDIT_CONTROL", value: "AUDIT_CONTROL" }, | ||||
|         { label: "AUDIT_WRITE", value: "AUDIT_WRITE" }, | ||||
|         { label: "BLOCK_SUSPEND", value: "BLOCK_SUSPEND" }, | ||||
|       ], | ||||
|       capability_list: ["CHOWN", "DAC_OVERRIDE", "DAC_READ_SEARCH", "FOWNER", "FSETID", "KILL", "SETGID", "SETUID", "SETPCAP", "LINUX_IMMUTABLE", "NET_BIND_SERVICE", "NET_BROADCAST", "NET_ADMIN", "NET_RAW", "IPC_LOCK", "IPC_OWNER", "SYS_MODULE", "SYS_RAWIO", "SYS_CHROOT", "SYS_PTRACE", "SYS_PACCT", "SYS_ADMIN", "SYS_BOOT", "SYS_NICE", "SYS_RESOURCE", "SYS_TIME", "SYS_TTY_CONFIG", "MKNOD", "LEASE", "AUDIT_WRITE", "AUDIT_CONTROL", "SETFCAP", "MAC_OVERRIDE", "MAC_ADMIN", "SYSLOG", "WAKE_ALARM", "BLOCK_SUSPEND", "AUDIT_READ", "PERFMON", "BPF", "CHECKPOINT_RESTORE"], | ||||
|       form: { | ||||
|         privileged: "", | ||||
|         allowPrivilegeEscalation: "", | ||||
|         runAsNonRoot: "", | ||||
|         privileged: false, | ||||
|         allowPrivilegeEscalation: true, | ||||
|         runAsNonRoot: false, | ||||
|         readOnlyRootFilesystem: false, | ||||
|         runAsUser: "", | ||||
|         capabilities: { | ||||
|   | ||||
| @@ -7,17 +7,17 @@ | ||||
|             <span>{{item._type}}</span> | ||||
|             <el-button style="float: right; padding: 3px 0" type="text" @click="handleVolumeDelete(index)">删 除</el-button> | ||||
|           </div> | ||||
|           <el-form label-position="top" ref="form"> | ||||
|           <el-form label-position="top"> | ||||
|             <div v-if="item._type === 'persistentVolumeClaim'"> | ||||
|               <el-row :gutter="20"> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="Volume Name"> | ||||
|                     <ko-form-item itemType="input" v-model="item.name" /> | ||||
|                   <el-form-item label="Volume Name" required> | ||||
|                     <ko-form-item itemType="input" v-model="item.metadata.name" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="Persistent Volume Claim"> | ||||
|                     <ko-form-item itemType="select" v-model="item.weight" :selections="pvc_list" /> | ||||
|                     <ko-form-item itemType="select2" v-model="item.metadata.weight" :selections="pvc_list" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|               </el-row> | ||||
| @@ -26,7 +26,7 @@ | ||||
|               <el-row :gutter="20"> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="Volume Name"> | ||||
|                     <ko-form-item itemType="input" v-model="item.name" /> | ||||
|                     <ko-form-item itemType="input" v-model="item.metadata.name" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|                 <el-col :span="12"> | ||||
| @@ -38,12 +38,12 @@ | ||||
|               <el-row :gutter="20"> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="ConfigMap"> | ||||
|                     <ko-form-item itemType="select" v-model="item.configMap.name" :selections="config_map_name_list" /> | ||||
|                     <ko-form-item itemType="select2" v-model="item.metadata.configMap.name" :selections="config_map_name_list" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="Optional"> | ||||
|                     <ko-form-item itemType="radio" v-model="item.configMap.optional" :radios="optional_list" /> | ||||
|                     <ko-form-item itemType="radio" v-model="item.metadata.configMap.optional" :radios="optional_list" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|               </el-row> | ||||
| @@ -52,24 +52,24 @@ | ||||
|               <el-row :gutter="20"> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="Volume Name"> | ||||
|                     <ko-form-item itemType="input" v-model="item.name" /> | ||||
|                     <ko-form-item itemType="input" v-model="item.metadata.name" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="Default Mode"> | ||||
|                     <ko-form-item itemType="input" v-model.number="item.defaultMode" /> | ||||
|                     <ko-form-item itemType="input" v-model="item.defaultMode" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|               </el-row> | ||||
|               <el-row :gutter="20"> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="Secret"> | ||||
|                     <ko-form-item itemType="select" v-model="item.secret.name" :selections="secret_list" /> | ||||
|                     <ko-form-item itemType="select2" v-model="item.metadata.secret.name" :selections="secret_list" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|                 <el-col :span="12"> | ||||
|                   <el-form-item label="Optional"> | ||||
|                     <ko-form-item itemType="radio" v-model="item.secret.optional" :radios="optional_list" /> | ||||
|                     <ko-form-item itemType="radio" v-model="item.metadata.secret.optional" :radios="optional_list" /> | ||||
|                   </el-form-item> | ||||
|                 </el-col> | ||||
|               </el-row> | ||||
| @@ -83,25 +83,25 @@ | ||||
|               <th scope="col" width="8%" align="left"><label>read only</label></th> | ||||
|               <th align="left"></th> | ||||
|             </tr> | ||||
|             <tr v-for="(row, index) in volumeMounts" v-bind:key="index"> | ||||
|             <tr v-for="(row, index) in item.volumeMounts" v-bind:key="index"> | ||||
|               <td> | ||||
|                 <ko-form-item :withoutLabel="true" itemType="input" v-model="row.mountPath" /> | ||||
|                 <ko-form-item itemType="input" v-model="row.mountPath" /> | ||||
|               </td> | ||||
|               <td> | ||||
|                 <ko-form-item :withoutLabel="true" itemType="input" v-model="row.subPath" /> | ||||
|                 <ko-form-item itemType="input" v-model="row.subPath" /> | ||||
|               </td> | ||||
|               <td> | ||||
|                 <el-checkbox v-model="row.readOnly" /> | ||||
|               </td> | ||||
|               <td> | ||||
|                 <el-button type="text" style="font-size: 10px" @click="handleMountDelete(index)"> | ||||
|                 <el-button type="text" style="font-size: 10px" @click="handleMountDelete(item, index)"> | ||||
|                   {{ $t("commons.button.delete") }} | ||||
|                 </el-button> | ||||
|               </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|               <td align="left"> | ||||
|                 <el-button @click="handleMountAdd()">Add Mount</el-button> | ||||
|                 <el-button @click="handleMountAdd(item)">Add Mount</el-button> | ||||
|               </td> | ||||
|             </tr> | ||||
|           </table> | ||||
| @@ -124,21 +124,50 @@ | ||||
| <script> | ||||
| import KoFormItem from "@/components/ko-form-item/index" | ||||
| import KoCard from "@/components/ko-card/index" | ||||
| import { listSecrets } from "@/api/secrets" | ||||
| import { listConfigMaps } from "@/api/configmaps" | ||||
|  | ||||
| export default { | ||||
|   name: "KoStorage", | ||||
|   components: { KoFormItem, KoCard }, | ||||
|   props: { | ||||
|     storageParentObj: Object, | ||||
|     containerIndex: Number, | ||||
|     currentContainerIndex: Number, | ||||
|     configMapList: Array, | ||||
|     secretList: Array, | ||||
|   }, | ||||
|   watch: { | ||||
|     currentContainerIndex: { | ||||
|       handler(newName) { | ||||
|         this.containerIndex = newName | ||||
|       }, | ||||
|       immediate: true, | ||||
|     }, | ||||
|     configMapList: { | ||||
|       handler(newName) { | ||||
|         this.config_map_name_list = [] | ||||
|         for (const cm of newName) { | ||||
|           this.config_map_name_list.push(cm.metadata.name) | ||||
|         } | ||||
|       }, | ||||
|       immediate: true, | ||||
|       deep: true, | ||||
|     }, | ||||
|     secretList: { | ||||
|       handler(newName) { | ||||
|         this.secret_list = [] | ||||
|         for (const s of newName) { | ||||
|           this.secret_list.push(s.metadata.name) | ||||
|         } | ||||
|       }, | ||||
|       immediate: true, | ||||
|       deep: true, | ||||
|     }, | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       containerIndex: 0, | ||||
|       volumes: [], | ||||
|       volumeAdd: [], | ||||
|       pvc_list: [], | ||||
|       volumeMounts: [], | ||||
|       secret_list: [], | ||||
|       config_map_name_list: [], | ||||
|       volume_type_list: [ | ||||
| @@ -153,91 +182,145 @@ export default { | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     loadSecrets() { | ||||
|       listSecrets(this.$route.params.cluster).then((res) => { | ||||
|         this.secret_list = [] | ||||
|         for (const secret of res.items) { | ||||
|           this.secret_list.push({ label: secret.metadata.name, value: secret.metadata.name }) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     loadConfigMaps() { | ||||
|       listConfigMaps(this.$route.params.cluster).then((res) => { | ||||
|         this.config_map_name_list = [] | ||||
|         for (const cm of res.items) { | ||||
|           this.config_map_name_list.push({ label: cm.metadata.name, value: cm.metadata.name }) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     handleVolumeAdd(type) { | ||||
|       let item = {} | ||||
|       item._type = type | ||||
|       item.volumeMounts = [] | ||||
|       item.defaultMode = 644 | ||||
|       switch (type) { | ||||
|         case "configMap": | ||||
|           this.volumes.push({ | ||||
|             _type: type, | ||||
|           item.metadata = { | ||||
|             name: "", | ||||
|             configMap: { | ||||
|               name: "", | ||||
|               defaultMode: "", | ||||
|               defaultMode: 644, | ||||
|               optional: true, | ||||
|             }, | ||||
|           }) | ||||
|           } | ||||
|           break | ||||
|         case "secret": | ||||
|           this.volumes.push({ | ||||
|             _type: type, | ||||
|           item.metadata = { | ||||
|             name: "", | ||||
|             secret: { | ||||
|               name: "", | ||||
|               defaultMode: "", | ||||
|               defaultMode: 644, | ||||
|               optional: true, | ||||
|             }, | ||||
|           }) | ||||
|           } | ||||
|           break | ||||
|         case "persistentVolumeClaim": | ||||
|           this.volumes.push({ | ||||
|             _type: type, | ||||
|           item.metadata = { | ||||
|             name: "", | ||||
|             persistentVolumeClaim: { | ||||
|               claimName: "", | ||||
|               readOnly: false, | ||||
|             }, | ||||
|           }) | ||||
|           } | ||||
|           break | ||||
|       } | ||||
|       this.volumes.push(item) | ||||
|       this.volumeAdd.push(item) | ||||
|     }, | ||||
|     handleVolumeDelete(index) { | ||||
|       for (const vo of this.volumes) { | ||||
|         for (let i = 0; i < this.volumeAdd; i++) { | ||||
|           if (vo.metadata.name == this.volumeAdd[i].metadata.name) { | ||||
|             this.volumeAdd.splice(i, 1) | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       this.volumes.splice(index, 1) | ||||
|     }, | ||||
|  | ||||
|     handleMountAdd() { | ||||
|       var item = { | ||||
|     handleMountAdd(item) { | ||||
|       item.volumeMounts.push({ | ||||
|         mountPath: "", | ||||
|         subPath: "", | ||||
|         readOnly: false, | ||||
|       } | ||||
|       this.volumeMounts.push(item) | ||||
|       }) | ||||
|     }, | ||||
|     handleMountDelete(index) { | ||||
|       this.volumeMounts.splice(index, 1) | ||||
|     handleMountDelete(item, index) { | ||||
|       item.volumeMounts.splice(index, 1) | ||||
|     }, | ||||
|  | ||||
|     checkIsValid() { | ||||
|       for (const vo of this.volumes) { | ||||
|         if (vo.metadata.name == "") { | ||||
|           return false | ||||
|         } | ||||
|         for (const mo of vo.volumeMounts) { | ||||
|           if (mo.mountPath != "") { | ||||
|             return false | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     transformation(parentFrom) { | ||||
|       parentFrom.volume = this.volumes | ||||
|       parentFrom.containers[this.containerIndex].volumeMounts = this.volumeMounts | ||||
|       if (!parentFrom.volumes) { | ||||
|         parentFrom.volumes = [] | ||||
|       } | ||||
|       parentFrom.containers[this.containerIndex].volumeMounts = [] | ||||
|       for (const volume of this.volumeAdd) { | ||||
|         switch (volume._type) { | ||||
|           case "configMap": | ||||
|             if (volume.defaultMode) { | ||||
|               volume.configMap.defaultMode = parseInt(volume.defaultMode) | ||||
|             } | ||||
|             break | ||||
|           case "secret": | ||||
|             if (volume.defaultMode) { | ||||
|               volume.secret.defaultMode = parseInt(volume.defaultMode) | ||||
|             } | ||||
|             break | ||||
|         } | ||||
|         parentFrom.volumes.push(volume.metadata) | ||||
|       } | ||||
|       for (const volume of this.volumes) { | ||||
|         if (volume.volumeMounts.length !== 0) { | ||||
|           for (const mount of volume.volumeMounts) { | ||||
|             parentFrom.containers[this.containerIndex].volumeMounts.push({ mountPath: mount.mountPath, subPath: mount.subPath, readOnly: mount.readOnly }) | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.loadSecrets() | ||||
|     this.loadConfigMaps() | ||||
|     this.volumes = [] | ||||
|     this.volumeMounts = [] | ||||
|     let volumeMounts = [] | ||||
|     if (this.storageParentObj.containers.length - 1 >= this.containerIndex) { | ||||
|       if (this.storageParentObj.containers[this.containerIndex].volumeMounts) { | ||||
|         this.volumeMounts = this.storageParentObj.containers[this.containerIndex].volumeMounts | ||||
|         volumeMounts = this.storageParentObj.containers[this.containerIndex].volumeMounts | ||||
|       } | ||||
|     } | ||||
|     if (this.storageParentObj.volumes) { | ||||
|       this.volumes = this.storageParentObj.volumes | ||||
|       for (const volume of this.storageParentObj.volumes) { | ||||
|         for (const mount of volumeMounts) { | ||||
|           if (mount.name === volume.name) { | ||||
|             let item = {} | ||||
|             item.volumeMounts = [] | ||||
|             item.metadata = volume | ||||
|             item.volumeMounts.push(mount) | ||||
|             if (volume.configMap) { | ||||
|               if (volume.configMap.defaultMode) { | ||||
|                 item.defaultMode = volume.configMap.defaultMode.toString(8) | ||||
|               } | ||||
|               item._type = "configMap" | ||||
|               this.volumes.push(item) | ||||
|             } | ||||
|             if (volume.secret) { | ||||
|               if (volume.secret.defaultMode) { | ||||
|                 item.defaultMode = volume.secret.defaultMode.toString(8) | ||||
|               } | ||||
|               item._type = "secret" | ||||
|               this.volumes.push(item) | ||||
|             } | ||||
|             if (volume.persistentVolumeClaim) { | ||||
|               item._type = "persistentVolumeClaim" | ||||
|               this.volumes.push(item) | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
| } | ||||
|   | ||||
| @@ -22,19 +22,20 @@ | ||||
|         </tr> | ||||
|         <tr v-for="(row, index) in tolerations" v-bind:key="index"> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="input" v-model="row.key" /> | ||||
|             <ko-form-item itemType="input" v-model="row.key" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="select" v-model="row.operator" :selections="operator_list" /> | ||||
|             <ko-form-item itemType="select" v-model="row.operator" :selections="operator_list" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="input" v-model="row.value" /> | ||||
|             <ko-form-item v-if="row.operator === 'Exists'" disabled placeholder="N/A" itemType="input" v-model="row.value" /> | ||||
|             <ko-form-item v-if="row.operator !== 'Exists'" itemType="input" v-model="row.value" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" itemType="select" v-model="row.effect" :selections="effect_list" /> | ||||
|             <ko-form-item itemType="select" v-model="row.effect" :selections="effect_list" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <ko-form-item :withoutLabel="true" :disabled="row.effect !== 'NoExecute'" itemType="number" v-model.number="row.tolerationSeconds" /> | ||||
|             <ko-form-item :disabled="row.effect !== 'NoExecute'" itemType="number" deviderName="Seconds" v-model.number="row.tolerationSeconds" /> | ||||
|           </td> | ||||
|           <td> | ||||
|             <el-button type="text" style="font-size: 10px" @click="handleTolerationsDelete(index)"> | ||||
|   | ||||
| @@ -139,7 +139,9 @@ const message = { | ||||
|       description: "描述" | ||||
|     }, | ||||
|     workload: { | ||||
|       workload: "工作量" | ||||
|       workload: "工作量", | ||||
|       replicas: "副本数", | ||||
|       container: "容器", | ||||
|     }, | ||||
|     network: { | ||||
|       network: "网络" | ||||
|   | ||||
| @@ -27,7 +27,7 @@ const Workloads = { | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       path: "/deployments/detail/:cluster/:namespace/:name", | ||||
|       path: "/deployments/detail/:namespace/:name", | ||||
|       name: "DeploymentDetail", | ||||
|       hidden: true, | ||||
|       component: () => import("@/business/workloads/deployments/detail"), | ||||
| @@ -36,7 +36,7 @@ const Workloads = { | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       path: "/deployments/create/:cluster/:yamlShow", | ||||
|       path: "/deployments/create", | ||||
|       name: "DeploymentCreate", | ||||
|       hidden: true, | ||||
|       component: () => import("@/business/workloads/deployments/create"), | ||||
| @@ -45,7 +45,7 @@ const Workloads = { | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       path: "/deployments/edit/:cluster/:namespace/:name/:yamlShow", | ||||
|       path: "/deployments/edit/:namespace/:name", | ||||
|       name: "DeploymentEdit", | ||||
|       hidden: true, | ||||
|       component: () => import("@/business/workloads/deployments/edit"), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ssongliu
					ssongliu