Skip to content

Commit

Permalink
spidercoordinator: fix auto fetch podCIDRType
Browse files Browse the repository at this point in the history
  • Loading branch information
cyclinder committed Oct 23, 2023
1 parent 5d69581 commit 9c31bab
Show file tree
Hide file tree
Showing 18 changed files with 416 additions and 179 deletions.
1 change: 1 addition & 0 deletions charts/spiderpool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ helm install spiderpool spiderpool/spiderpool --wait --namespace kube-system \
| `global.cniConfHostPath` | the host path of the cni config directory | `/etc/cni/net.d` |
| `global.ipamUNIXSocketHostPath` | the host path of unix domain socket for ipam plugin | `/var/run/spidernet/spiderpool.sock` |
| `global.configName` | the configmap name | `spiderpool-conf` |
| `global.ciliumConfigMap` | the cilium's configMap, default is kube-system/cilium-config | `kube-system/cilium-config` |

### ipam parameters

Expand Down
2 changes: 2 additions & 0 deletions charts/spiderpool/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ spec:
value: {{ .Values.multus.enableMultusConfig | quote }}
- name: SPIDERPOOL_CNI_CONFIG_DIR
value: {{ .Values.global.cniConfHostPath | quote }}
- name: SPIDERPOOL_CILIUM_CONFIGMAP_NAMESPACE_NAME
value: {{ .Values.global.ciliumConfigMap | quote }}
- name: SPIDERPOOL_POD_NAME
valueFrom:
fieldRef:
Expand Down
3 changes: 3 additions & 0 deletions charts/spiderpool/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ global:
## @param global.configName the configmap name
configName: "spiderpool-conf"

## @param global.ciliumConfigMap the cilium's configMap, default is kube-system/cilium-config
ciliumConfigMap: kube-system/cilium-config

## @section ipam parameters
##
ipam:
Expand Down
3 changes: 3 additions & 0 deletions cmd/spiderpool-controller/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var envInfo = []envConf{

{"SPIDERPOOL_MULTUS_CONFIG_ENABLED", "false", false, nil, &controllerContext.Cfg.EnableMultusConfig, nil},
{"SPIDERPOOL_MULTUS_CONFIG_INFORMER_RESYNC_PERIOD", "60", false, nil, nil, &controllerContext.Cfg.MultusConfigInformerResyncPeriod},
{"SPIDERPOOL_CILIUM_CONFIGMAP_NAMESPACE_NAME", "kube-system/cilium-config", false, &controllerContext.Cfg.CiliumConfigName, nil, nil},

{"SPIDERPOOL_IPPOOL_INFORMER_RESYNC_PERIOD", "300", false, nil, nil, &controllerContext.Cfg.IPPoolInformerResyncPeriod},
{"SPIDERPOOL_IPPOOL_INFORMER_WORKERS", "3", true, nil, nil, &controllerContext.Cfg.IPPoolInformerWorkers},
Expand Down Expand Up @@ -123,6 +124,8 @@ type Config struct {
GopsListenPort string
PyroscopeAddress string
DefaultCniConfDir string
// CiliumConfigName is formatted by namespace and name,default is kube-system/cilium-config
CiliumConfigName string

ControllerPodNamespace string
ControllerPodName string
Expand Down
1 change: 1 addition & 0 deletions cmd/spiderpool-controller/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ func setupInformers() {
LeaderRetryElectGap: time.Duration(controllerContext.Cfg.LeaseRetryGap) * time.Second,
ResyncPeriod: time.Duration(controllerContext.Cfg.CoordinatorInformerResyncPeriod) * time.Second,
DefaultCniConfDir: controllerContext.Cfg.DefaultCniConfDir,
CiliumConfigMap: controllerContext.Cfg.CiliumConfigName,
}).SetupInformer(controllerContext.InnerCtx, crdClient, k8sClient, controllerContext.Leader); err != nil {
logger.Fatal(err.Error())
}
Expand Down
27 changes: 16 additions & 11 deletions docs/reference/spiderpool-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,22 @@ Run the spiderpool controller daemon.

### ENV

| env | default | description |
|------------------------------------------|---------|------------------------------------------------------------------------------------|
| SPIDERPOOL_LOG_LEVEL | info | Log level, optional values are "debug", "info", "warn", "error", "fatal", "panic". |
| SPIDERPOOL_ENABLED_METRIC | false | Enable/disable metrics. |
| SPIDERPOOL_HEALTH_PORT | 5720 | Spiderpool-controller backend HTTP server port. |
| SPIDERPOOL_METRIC_HTTP_PORT | 5721 | Metric HTTP server port. |
| SPIDERPOOL_WEBHOOK_PORT | 5722 | Webhook HTTP server port. |
| SPIDERPOOL_CLI_PORT | 5723 | Spiderpool-CLI HTTP server port. |
| SPIDERPOOL_GOPS_LISTEN_PORT | 5724 | Port that gops is listening on. Disabled if empty. |
| SPIDERPOOL_GC_IP_ENABLED | true | Enable/disable IP GC. |
| SPIDERPOOL_GC_TERMINATING_POD_IP_ENABLED | true | Enable/disable IP GC for Terminating pod. |
| env | default | description |
|---------------------------------------------|---------|------------------------------------------------------------------------------------|
| SPIDERPOOL_LOG_LEVEL | info | Log level, optional values are "debug", "info", "warn", "error", "fatal", "panic". |
| SPIDERPOOL_ENABLED_METRIC | false | Enable/disable metrics. |
| SPIDERPOOL_ENABLED_DEBUG_METRIC | false | Enable spiderpool agent to collect debug level metrics. |
| SPIDERPOOL_METRIC_HTTP_PORT | false | The metrics port of spiderpool agent. |
| SPIDERPOOL_GOPS_LISTEN_PORT | 5724 | The gops port of spiderpool Controller. |
| SPIDERPOOL_WEBHOOK_PORT | 5722 | Webhook HTTP server port. |
| SPIDERPOOL_HEALTH_PORT | 5720 | The http Port for spiderpoolController, for health checking and http service. |
| SPIDERPOOL_GC_IP_ENABLED | true | Enable/disable IP GC. |
| SPIDERPOOL_GC_TERMINATING_POD_IP_ENABLED | true | Enable/disable IP GC for Terminating pod. |
| SPIDERPOOL_GC_ADDITIONAL_GRACE_DELAY | true | The gc delay seconds after the pod times out of deleting graceful period. |
| SPIDERPOOL_GC_DEFAULT_INTERVAL_DURATION | true | The gc all interval duration. |
| SPIDERPOOL_MULTUS_CONFIG_ENABLED | true | Enable/disable SpiderMultusConfig. |
| SPIDERPOOL_CNI_CONFIG_DIR | true | The host path of the cni config directory. |
| SPIDERPOOL_CILIUM_CONFIGMAP_NAMESPACE_NAME | true | The cilium's configMap, default is kube-system/cilium-config. |


## spiderpool-controller shutdown
Expand Down
44 changes: 44 additions & 0 deletions docs/usage/install/overlay/get-started-calico-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,50 @@ spiderpool-multus-m2kbt 1/1 Running
spiderpool-multus-sl65s 1/1 Running 0 1m
```

请检查 `Spidercoordinator.status` 中的 Phase 是否为 Synced, 并且 overlayPodCIDR 是否与集群中 Calico 的子网保持一致:

```shell
~# calicoctl get ippools
NAME CIDR SELECTOR
default-ipv4-ippool 10.222.64.0/18 all()
default-ipv4-ippool1 10.223.64.0/18 all()

~# kubectl get spidercoordinators.spiderpool.spidernet.io default -o yaml
apiVersion: spiderpool.spidernet.io/v2beta1
kind: SpiderCoordinator
metadata:
creationTimestamp: "2023-10-18T08:31:09Z"
finalizers:
- spiderpool.spidernet.io
generation: 7
name: default
resourceVersion: "195405"
uid: 8bdceced-15db-497b-be07-81cbcba7caac
spec:
detectGateway: false
detectIPConflict: false
hijackCIDR:
- 169.254.0.0/16
hostRPFilter: 0
hostRuleTable: 500
mode: auto
podCIDRType: calico
podDefaultRouteNIC: ""
podMACPrefix: ""
tunePodRoutes: true
status:
overlayPodCIDR:
- 10.222.64.0/18
- 10.223.64.0/18
phase: Synced
serviceCIDR:
- 10.233.0.0/18
```

> 1.如果 phase 不为 Synced, 那么将会阻止 Pod 被创建
>
> 2.如果 overlayPodCIDR 不正常, 可能会导致通信问题
### 创建 SpiderIPPool

本文集群节点网卡: `ens192` 所在子网为 `10.6.0.0/16`, 以该子网创建 SpiderIPPool:
Expand Down
39 changes: 39 additions & 0 deletions docs/usage/install/overlay/get-started-calico.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,45 @@ spiderpool-multus-m2kbt 1/1 Running
spiderpool-multus-sl65s 1/1 Running 0 1m
```

Please check if `Spidercoordinator.status.phase` is `Synced`, and if the overlayPodCIDR is consistent with the pod subnet configured by Cilium in the cluster:

```shell
~# kubectl get configmaps -n kube-system cilium-config -o yaml | grep cluster-pool
cluster-pool-ipv4-cidr: 10.244.64.0/18
cluster-pool-ipv4-mask-size: "24"
ipam: cluster-pool

~# kubectl get spidercoordinators.spiderpool.spidernet.io default -o yaml
apiVersion: spiderpool.spidernet.io/v2beta1
kind: SpiderCoordinator
metadata:
finalizers:
- spiderpool.spidernet.io
name: default
spec:
detectGateway: false
detectIPConflict: false
hijackCIDR:
- 169.254.0.0/16
hostRPFilter: 0
hostRuleTable: 500
mode: auto
podCIDRType: calico
podDefaultRouteNIC: ""
podMACPrefix: ""
tunePodRoutes: true
status:
overlayPodCIDR:
- 10.244.64.0/18
phase: Synced
serviceCIDR:
- 10.233.0.0/18
```

> 1.If the phase is not synced, the pod will be prevented from being created.
>
> 2.If the overlayPodCIDR does not meet expectations, it may cause pod communication issue.
### Create SpiderIPPool

The subnet for the interface `ens192` on the cluster nodes here is `10.6.0.0/16`. Create a SpiderIPPool using this subnet:
Expand Down
39 changes: 39 additions & 0 deletions docs/usage/install/overlay/get-started-cilium-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,45 @@ spiderpool-multus-hkxb6 1/1 Running
spiderpool-multus-l9dcs 1/1 Running 0 1m
```

请检查 `Spidercoordinator.status` 中的 Phase 是否为 Synced, 并且 overlayPodCIDR 是否与集群中 Cilium 配置的 Pod 子网保持一致:

```shell
~# kubectl get configmaps -n kube-system cilium-config -o yaml | grep cluster-pool
cluster-pool-ipv4-cidr: 10.244.64.0/18
cluster-pool-ipv4-mask-size: "24"
ipam: cluster-pool

~# kubectl get spidercoordinators.spiderpool.spidernet.io default -o yaml
apiVersion: spiderpool.spidernet.io/v2beta1
kind: SpiderCoordinator
metadata:
finalizers:
- spiderpool.spidernet.io
name: default
spec:
detectGateway: false
detectIPConflict: false
hijackCIDR:
- 169.254.0.0/16
hostRPFilter: 0
hostRuleTable: 500
mode: auto
podCIDRType: calico
podDefaultRouteNIC: ""
podMACPrefix: ""
tunePodRoutes: true
status:
overlayPodCIDR:
- 10.244.64.0/18
phase: Synced
serviceCIDR:
- 10.233.0.0/18
```

> 1.如果 phase 不为 Synced, 那么将会阻止 Pod 被创建
>
> 2.如果 overlayPodCIDR 不正常, 可能会导致通信问题
### 创建 SpiderIPPool

本文集群节点网卡: `ens192` 所在子网为 `10.6.0.0/16`, 以该子网创建 SpiderIPPool:
Expand Down
39 changes: 39 additions & 0 deletions docs/usage/install/overlay/get-started-cilium.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,45 @@ spiderpool-multus-hkxb6 1/1 Running
spiderpool-multus-l9dcs 1/1 Running 0 1m
```

Please check if `Spidercoordinator.status.phase` is `Synced`, and if the overlayPodCIDR is consistent with the pod subnet configured by Cilium in the cluster:

```shell
~# kubectl get configmaps -n kube-system cilium-config -o yaml | grep cluster-pool
cluster-pool-ipv4-cidr: 10.244.64.0/18
cluster-pool-ipv4-mask-size: "24"
ipam: cluster-pool

~# kubectl get spidercoordinators.spiderpool.spidernet.io default -o yaml
apiVersion: spiderpool.spidernet.io/v2beta1
kind: SpiderCoordinator
metadata:
finalizers:
- spiderpool.spidernet.io
name: default
spec:
detectGateway: false
detectIPConflict: false
hijackCIDR:
- 169.254.0.0/16
hostRPFilter: 0
hostRuleTable: 500
mode: auto
podCIDRType: calico
podDefaultRouteNIC: ""
podMACPrefix: ""
tunePodRoutes: true
status:
overlayPodCIDR:
- 10.244.64.0/18
phase: Synced
serviceCIDR:
- 10.233.0.0/18
```

> 1.If the phase is not synced, the pod will be prevented from being created.
>
> 2.If the overlayPodCIDR does not meet expectations, it may cause pod communication issue.
### Create SpiderIPPool

The subnet for the interface `ens192` on the cluster nodes here is `10.6.0.0/16`. Create a SpiderIPPool using this subnet:
Expand Down
Loading

0 comments on commit 9c31bab

Please sign in to comment.