Repository: kubeclipper/kubeclipper
Pull request #456 (2022-11-30 06:13:11)

[master] update k8s cluster service and pod cidr
This is an automated cherry-pick of #453

```release-note
None
```

kubeclipper-bot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubeclipper/kubeclipper/pull/456#" title="Author self-approved">kubeclipper-bot</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **x893675** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @x893675` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubeclipper%2Fkubeclipper).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubeclipper/kubeclipper/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["x893675"]} -->
codecov-commenter: # [Codecov](https://codecov.io/gh/kubeclipper/kubeclipper/pull/456?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubeclipper) Report
> Merging [#456](https://codecov.io/gh/kubeclipper/kubeclipper/pull/456?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubeclipper) (6d037c2) into [master](https://codecov.io/gh/kubeclipper/kubeclipper/commit/dc73c974d26c6360cc9556fd2ad216784a54c4cb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubeclipper) (dc73c97) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/kubeclipper/kubeclipper/pull/456/graphs/tree.svg?width=650&height=150&src=pr&token=3PWFG2MHTE&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubeclipper)](https://codecov.io/gh/kubeclipper/kubeclipper/pull/456?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubeclipper)

```diff
@@           Coverage Diff           @@
##           master     #456   +/-   ##
=======================================
  Coverage   11.56%   11.56%           
=======================================
  Files         115      115           
  Lines       18593    18593           
=======================================
  Hits         2151     2151           
  Misses      16191    16191           
  Partials      251      251           
```



x893675: /lgtm
/approve
kubeclipper-bot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubeclipper/kubeclipper/pull/456#" title="Author self-approved">kubeclipper-bot</a>*, *<a href="https://github.com/kubeclipper/kubeclipper/pull/456#issuecomment-1331702494" title="Approved">x893675</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubeclipper%2Fkubeclipper).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubeclipper/kubeclipper/blob/master/OWNERS)~~ [x893675]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
kubeclipper-bot: LGTM label has been added.  <details>Git tree hash: 1bc651aeaf9aecf31c153ccf2a37f744a410c089</details>

Patch:
diff --git a/pkg/cli/create/create_cluster.go b/pkg/cli/create/create_cluster.go
index 0598a21..0c87b5d 100644
--- a/pkg/cli/create/create_cluster.go
+++ b/pkg/cli/create/create_cluster.go
@@ -23,6 +23,7 @@ import (
 	"encoding/base64"
 	"errors"
 	"fmt"
+	"github.com/kubeclipper/kubeclipper/pkg/constatns"
 	"net"
 	"os"
 	"strings"
@@ -343,8 +344,8 @@ func (l *CreateClusterOptions) newCluster() *v1.Cluster {
 		ContainerRuntime:  v1.ContainerRuntime{},
 		Networking: v1.Networking{
 			IPFamily:      v1.IPFamilyIPv4,
-			Services:      v1.NetworkRanges{CIDRBlocks: []string{"10.96.0.0/16"}},
-			Pods:          v1.NetworkRanges{CIDRBlocks: []string{"172.25.0.0/24"}},
+			Services:      v1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterServiceSubnet}},
+			Pods:          v1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterPodSubnet}},
 			DNSDomain:     "cluster.local",
 			ProxyMode:     "ipvs",
 			WorkerNodeVip: "169.254.169.100",
diff --git a/pkg/constatns/constats.go b/pkg/constatns/constats.go
index d8e72ab..c1597f0 100644
--- a/pkg/constatns/constats.go
+++ b/pkg/constatns/constats.go
@@ -13,3 +13,8 @@ const (
 	KcEtcdCertsConfigMapName = "kc-etcd"
 	KcNatsCertsConfigMapName = "kc-nats"
 )
+
+const (
+	ClusterServiceSubnet = "10.96.0.0/12"
+	ClusterPodSubnet     = "172.25.0.0/16"
+)


Test patch:
diff --git a/pkg/apis/core/v1/schema_test.go b/pkg/apis/core/v1/schema_test.go
index ae11b2f..c17596e 100644
--- a/pkg/apis/core/v1/schema_test.go
+++ b/pkg/apis/core/v1/schema_test.go
@@ -20,6 +20,7 @@ package v1
 
 import (
 	"fmt"
+	"github.com/kubeclipper/kubeclipper/pkg/constatns"
 	"reflect"
 	"testing"
 
@@ -82,8 +83,8 @@ var (
 		},
 		Networking: v1.Networking{
 			IPFamily:      v1.IPFamilyIPv4,
-			Services:      v1.NetworkRanges{CIDRBlocks: []string{"10.96.0.0/16"}},
-			Pods:          v1.NetworkRanges{CIDRBlocks: []string{"172.25.0.0/24"}},
+			Services:      v1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterServiceSubnet}},
+			Pods:          v1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterPodSubnet}},
 			DNSDomain:     "cluster.local",
 			ProxyMode:     "ipvs",
 			WorkerNodeVip: "169.254.169.100",
diff --git a/pkg/apis/core/v1/utils_test.go b/pkg/apis/core/v1/utils_test.go
index 478336c..8b801d1 100644
--- a/pkg/apis/core/v1/utils_test.go
+++ b/pkg/apis/core/v1/utils_test.go
@@ -21,6 +21,7 @@ package v1
 import (
 	"context"
 	"encoding/json"
+	"github.com/kubeclipper/kubeclipper/pkg/constatns"
 	"testing"
 
 	"github.com/golang/mock/gomock"
@@ -77,8 +78,8 @@ var (
 		},
 		Networking: v1.Networking{
 			IPFamily:      v1.IPFamilyIPv4,
-			Services:      v1.NetworkRanges{CIDRBlocks: []string{"10.96.0.0/16"}},
-			Pods:          v1.NetworkRanges{CIDRBlocks: []string{"172.25.0.0/24"}},
+			Services:      v1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterServiceSubnet}},
+			Pods:          v1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterPodSubnet}},
 			DNSDomain:     "cluster.local",
 			ProxyMode:     "ipvs",
 			WorkerNodeVip: "169.254.169.100",
diff --git a/pkg/scheme/core/v1/cni/calico_test.go b/pkg/scheme/core/v1/cni/calico_test.go
index 06024c3..a861e4a 100644
--- a/pkg/scheme/core/v1/cni/calico_test.go
+++ b/pkg/scheme/core/v1/cni/calico_test.go
@@ -4,6 +4,7 @@ import (
 	"bytes"
 	"testing"
 
+	"github.com/kubeclipper/kubeclipper/pkg/constatns"
 	v1 "github.com/kubeclipper/kubeclipper/pkg/scheme/core/v1"
 )
 
@@ -19,7 +20,7 @@ func TestCNI_renderCalicoTo(t *testing.T) {
 			stepper: CalicoRunnable{
 				BaseCni{
 					DualStack:   false,
-					PodIPv4CIDR: "172.25.0.0/24",
+					PodIPv4CIDR: constatns.ClusterPodSubnet,
 					PodIPv6CIDR: "aaa:bbb",
 					CNI: v1.CNI{
 						LocalRegistry: "172.0.0.1:5000",
diff --git a/pkg/scheme/core/v1/k8s/kubeadm_test.go b/pkg/scheme/core/v1/k8s/kubeadm_test.go
index 5a0fe22..3ca8a74 100644
--- a/pkg/scheme/core/v1/k8s/kubeadm_test.go
+++ b/pkg/scheme/core/v1/k8s/kubeadm_test.go
@@ -22,6 +22,7 @@ import (
 	"bytes"
 	"testing"
 
+	"github.com/kubeclipper/kubeclipper/pkg/constatns"
 	v1 "github.com/kubeclipper/kubeclipper/pkg/scheme/core/v1"
 )
 
@@ -65,8 +66,8 @@ func TestKubeadmConfig_renderTo(t *testing.T) {
 				Etcd:                    v1.Etcd{DataDir: "/var/lib/etcd"},
 				Networking: v1.Networking{
 					IPFamily:      v1.IPFamilyIPv4,
-					Services:      v1.NetworkRanges{CIDRBlocks: []string{"10.96.0.0/16"}},
-					Pods:          v1.NetworkRanges{CIDRBlocks: []string{"172.25.0.0/24"}},
+					Services:      v1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterServiceSubnet}},
+					Pods:          v1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterPodSubnet}},
 					DNSDomain:     "cluster.local",
 					ProxyMode:     "ipvs",
 					WorkerNodeVip: "8.8.8.8",
diff --git a/test/e2e/cluster/utils.go b/test/e2e/cluster/utils.go
index 3549c5d..5eadafb 100644
--- a/test/e2e/cluster/utils.go
+++ b/test/e2e/cluster/utils.go
@@ -23,9 +23,7 @@ import (
 	"fmt"
 	"time"
 
-	"github.com/onsi/ginkgo"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
+	"github.com/kubeclipper/kubeclipper/pkg/constatns"
 	apierror "github.com/kubeclipper/kubeclipper/pkg/errors"
 	"github.com/kubeclipper/kubeclipper/pkg/query"
 	"github.com/kubeclipper/kubeclipper/pkg/scheme/common"
@@ -33,6 +31,8 @@ import (
 	"github.com/kubeclipper/kubeclipper/pkg/simple/client/kc"
 	"github.com/kubeclipper/kubeclipper/test/framework"
 	"github.com/kubeclipper/kubeclipper/test/framework/cluster"
+	"github.com/onsi/ginkgo"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
 type Setter func(cluster *corev1.Cluster)
@@ -138,8 +138,8 @@ func initCluster() *corev1.Cluster {
 		},
 		Networking: corev1.Networking{
 			IPFamily:      corev1.IPFamilyIPv4,
-			Services:      corev1.NetworkRanges{CIDRBlocks: []string{"10.96.0.0/16"}},
-			Pods:          corev1.NetworkRanges{CIDRBlocks: []string{"172.25.0.0/24"}},
+			Services:      corev1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterServiceSubnet}},
+			Pods:          corev1.NetworkRanges{CIDRBlocks: []string{constatns.ClusterPodSubnet}},
 			DNSDomain:     "cluster.local",
 			ProxyMode:     "ipvs",
 			WorkerNodeVip: "169.254.169.100",
diff --git a/test/framework/test_context.go b/test/framework/test_context.go
index e7a35a1..a0334f6 100644
--- a/test/framework/test_context.go
+++ b/test/framework/test_context.go
@@ -20,14 +20,15 @@ package framework
 
 import (
 	"flag"
+	"github.com/kubeclipper/kubeclipper/pkg/constatns"
 
 	"github.com/onsi/ginkgo/config"
 )
 
 const (
 	defaultHost          = "http://127.0.0.1:8080"
-	defaultServiceSubnet = "10.96.0.0/16"
-	defaultPodSubnet     = "172.25.0.0/24"
+	defaultServiceSubnet = constatns.ClusterServiceSubnet
+	defaultPodSubnet     = constatns.ClusterPodSubnet
 	defaultLocalRegistry = "127.0.0.1:5000"
 	defaultWorkerNodeVip = "169.254.169.100"
 )
@@ -61,9 +62,9 @@ func RegisterCommonFlags(flags *flag.FlagSet) {
 	flag.StringVar(&TestContext.Host, "server-address", defaultHost,
 		"Ki Server API Server IP/DNS, default 127.0.0.1:8080")
 	flag.StringVar(&TestContext.ServiceSubnet, "svc-subnet", defaultServiceSubnet,
-		"cluster svc sub net, default 10.96.0.0/16")
+		"cluster svc sub net, default 10.96.0.0/12")
 	flag.StringVar(&TestContext.PodSubnet, "pod-subnet", defaultPodSubnet,
-		"cluster pod sub net, default 172.25.0.0/24")
+		"cluster pod sub net, default 172.25.0.0/16")
 	flag.StringVar(&TestContext.LocalRegistry, "registry", defaultLocalRegistry,
 		"cri image registry addr, default 127.0.0.1:5000")
 	flag.StringVar(&TestContext.WorkerNodeVip, "vip", defaultWorkerNodeVip,