From bd28ba6f719dbc8119c1d9c9a06584a14c4bd1af Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Fri, 3 Oct 2025 09:38:31 +0800 Subject: [PATCH] feat: add network policy page (#536) * feat: add Network Policiies page Signed-off-by: Andy Lee * ci: add build Signed-off-by: Andy Lee * ci: ensure FROM and TO exist Signed-off-by: Andy Lee * ci: skip commitlint if FROM and TO emtpy Signed-off-by: Andy Lee * revert: unnecessary change * feat: add banner Signed-off-by: Andy Lee --------- Signed-off-by: Andy Lee --- .github/workflows/run-lint.yaml | 1 + pkg/harvester/config/doc-links.js | 1 + pkg/harvester/config/harvester-cluster.js | 17 ++++++++ .../edit/networking.k8s.io.networkpolicy.vue | 42 +++++++++++++++++++ pkg/harvester/l10n/en-us.yaml | 8 ++++ 5 files changed, 69 insertions(+) create mode 100644 pkg/harvester/edit/networking.k8s.io.networkpolicy.vue diff --git a/.github/workflows/run-lint.yaml b/.github/workflows/run-lint.yaml index 12df0252..8eecdadd 100644 --- a/.github/workflows/run-lint.yaml +++ b/.github/workflows/run-lint.yaml @@ -50,6 +50,7 @@ jobs: echo "FROM=$FROM" echo "TO=$TO" + npx commitlint --from "$FROM" --to "$TO" --verbose env: GITHUB_EVENT_NAME: ${{ github.event_name }} diff --git a/pkg/harvester/config/doc-links.js b/pkg/harvester/config/doc-links.js index c69f02f0..1542d906 100644 --- a/pkg/harvester/config/doc-links.js +++ b/pkg/harvester/config/doc-links.js @@ -8,4 +8,5 @@ export const DOC = { STORAGE_NETWORK_EXAMPLE: `/advanced/storagenetwork#configuration-example`, SUPPORT_BUNDLE_NAMESPACES: `/advanced/index/#support-bundle-namespaces`, VPC_CONFIGURATION_EXAMPLES: `/networking/kubeovn-vpc#vpc-peering-configuration-examples`, + NETWORK_POLICY: `/networking/kubeovn-vm-isolation/#network-policies`, }; diff --git a/pkg/harvester/config/harvester-cluster.js b/pkg/harvester/config/harvester-cluster.js index eb32c92d..3830fc50 100644 --- a/pkg/harvester/config/harvester-cluster.js +++ b/pkg/harvester/config/harvester-cluster.js @@ -10,6 +10,7 @@ import { LOGGING, STORAGE_CLASS, SECRET, + NETWORK_POLICY } from '@shell/config/types'; import { HCI, VOLUME_SNAPSHOT } from '../types'; import { @@ -425,6 +426,7 @@ export function init($plugin, store) { HCI.CLUSTER_NETWORK, HCI.NETWORK_ATTACHMENT, HCI.VPC, + NETWORK_POLICY, HCI.LB, HCI.IP_POOL, ], @@ -566,6 +568,21 @@ export function init($plugin, store) { ifHaveType: HCI.VPC, }); + configureType(NETWORK_POLICY, { hiddenNamespaceGroupButton: true, canYaml: false }); + + virtualType({ + labelKey: 'harvester.networkPolicy.label', + name: NETWORK_POLICY, + namespaced: true, + weight: 186, + route: { + name: `${ PRODUCT_NAME }-c-cluster-resource`, + params: { resource: NETWORK_POLICY } + }, + exact: false, + ifHaveType: NETWORK_POLICY, + }); + configureType(HCI.SNAPSHOT, { isCreatable: false, location: { diff --git a/pkg/harvester/edit/networking.k8s.io.networkpolicy.vue b/pkg/harvester/edit/networking.k8s.io.networkpolicy.vue new file mode 100644 index 00000000..08c7b6c8 --- /dev/null +++ b/pkg/harvester/edit/networking.k8s.io.networkpolicy.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/pkg/harvester/l10n/en-us.yaml b/pkg/harvester/l10n/en-us.yaml index 1ba85caf..eabbe8f5 100644 --- a/pkg/harvester/l10n/en-us.yaml +++ b/pkg/harvester/l10n/en-us.yaml @@ -1106,6 +1106,9 @@ harvester: remoteVpc: label: Remote VPC infoBanner: The static route destination CIDR must cover all subnets CIDR from remote VPC Peer. Read VPC Peering Configuration Examples for more information. + networkPolicy: + label: Network Policies + banner: The network policies must be used for VMs attached to overlay networks. Please read the harvester document how the network policy works. network: label: Virtual Machine Networks tabs: @@ -1832,6 +1835,11 @@ typeLabel: one { Virtual Private Cloud } other { Virtual Private Clouds } } + networking.k8s.io.networkpolicy: |- + {count, plural, + one { Network Policy } + other { Network Policies } + } harvesterhci.io.cloudtemplate: |- {count, plural, one { Cloud Configuration Template }