Skip to content

Commit

Permalink
svc port forward
Browse files Browse the repository at this point in the history
  • Loading branch information
weibaohui committed Nov 9, 2023
1 parent 111b5b4 commit 056a11f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
25 changes: 22 additions & 3 deletions src/frontend/components/service/SvcConnectView.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
<script setup lang="ts">
import { V1Service } from '@backend/k8s/model/V1Service'
import type { V1ServicePort } from '@backend/k8s/model/V1ServicePort'
import { K8sService } from '@frontend/service/k8s/K8sService'
import { ColorHelper } from '@frontend/service/page/ColorHelper'
import { NSpace, NTable, NTag } from 'naive-ui'
import * as _ from 'lodash'
import { NButton, NSpace, NTable, NTag, useMessage } from 'naive-ui'
const props = defineProps({
svc: V1Service,
})
const message = useMessage()
async function forward(svc: V1Service, p: V1ServicePort) {
const randomInt = _.random(30000, 60000)
await K8sService.playService.shellControllerForwardService({
ns: svc.metadata.namespace,
localPort: randomInt,
svcPort: `${p.port}`,
svcName: svc.metadata.name,
})
message.success('转发成功')
}
</script>

<template>
Expand Down Expand Up @@ -52,9 +68,12 @@ const props = defineProps({
Ports
</td>
<td>
<div v-for="port in props.svc.spec.ports" :key="port">
<p v-for="port in props.svc.spec.ports" :key="port">
{{ port.port }}:{{ port.nodePort ? port.nodePort : port.targetPort }}/{{ port.protocol }}
</div>
<NButton type="success" @click="forward(props.svc, port)">
Forward
</NButton>
</p>
</td>
</tr>
</tbody>
Expand Down
15 changes: 7 additions & 8 deletions src/frontend/components/service/SvcView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ const props = defineProps({
<template>
<NMessageProvider>
<SvcActionView :is-dropdown="false" :svc="props.svc" />
<TitleBar title="Basic info" :show-title="true" />
<SvcBasicInfoView :svc="props.svc" />
<TitleBar title="Connect Info" />
<SvcConnectView :svc="props.svc" />
<TitleBar title="Endpoints" />
<SvcEndpointListView :svc="props.svc" />
<InvolvedEventView :item="props.svc.metadata" :show-title="true" />
</NMessageProvider>
<TitleBar title="Basic info" :show-title="true" />
<SvcBasicInfoView :svc="props.svc" />
<TitleBar title="Connect Info" />
<SvcConnectView :svc="props.svc" />
<TitleBar title="Endpoints" />
<SvcEndpointListView :svc="props.svc" />

<InvolvedEventView :item="props.svc.metadata" :show-title="true" />
</template>

<style scoped>
Expand Down

0 comments on commit 056a11f

Please sign in to comment.