Skip to content

Commit

Permalink
Merge pull request spidernet-io#1904 from Icarus9913/fix/wk/docs
Browse files Browse the repository at this point in the history
update CRD documentation
  • Loading branch information
weizhoublue authored Jul 25, 2023
2 parents dcb33a0 + 42e37f9 commit 4a54033
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,23 @@ spec:
- mode
- name
type: object
master:
items:
type: string
type: array
spiderpoolConfigPools:
ippools:
description: SpiderpoolPools could specify the IPAM spiderpool
CNI configuration default IPv4&IPv6 pools.
properties:
IPv4IPPool:
ipv4:
items:
type: string
type: array
IPv6IPPool:
ipv6:
items:
type: string
type: array
type: object
master:
items:
type: string
type: array
vlanID:
format: int32
maximum: 4094
Expand All @@ -155,23 +155,23 @@ spec:
- mode
- name
type: object
master:
items:
type: string
type: array
spiderpoolConfigPools:
ippools:
description: SpiderpoolPools could specify the IPAM spiderpool
CNI configuration default IPv4&IPv6 pools.
properties:
IPv4IPPool:
ipv4:
items:
type: string
type: array
IPv6IPPool:
ipv6:
items:
type: string
type: array
type: object
master:
items:
type: string
type: array
vlanID:
format: int32
maximum: 4094
Expand All @@ -182,21 +182,21 @@ spec:
type: object
sriov:
properties:
resourceName:
type: string
spiderpoolConfigPools:
ippools:
description: SpiderpoolPools could specify the IPAM spiderpool
CNI configuration default IPv4&IPv6 pools.
properties:
IPv4IPPool:
ipv4:
items:
type: string
type: array
IPv6IPPool:
ipv6:
items:
type: string
type: array
type: object
resourceName:
type: string
vlanID:
format: int32
maximum: 4094
Expand Down
121 changes: 56 additions & 65 deletions docs/concepts/spiderendpoint.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,71 @@
# SpiderEndpoint

A SpiderEndpoint resource represents IP address allocation details for a specific endpoint object.

## CRD definition

The SpiderEndpoint custom resource is modeled after a standard Kubernetes resource
and is split into the `status` section:

```text
type SpiderEndpoint struct {
[...]
// Status is the status of the SpiderEndpoint
Status WorkloadEndpointStatus `json:"status,omitempty"`
}
A SpiderEndpoint resource represents IP address allocation details for the corresponding pod. This resource one to one pod, and it will inherit the pod name and pod namespace.

## Sample YAML

```yaml
apiVersion: spiderpool.spidernet.io/v2beta1
kind: SpiderEndpoint
metadata:
name: test-app-1-9dc78fb9-rs99d
status:
current:
ips:
- cleanGateway: false
interface: eth0
ipv4: 172.31.199.193/20
ipv4Gateway: 172.31.207.253
ipv4Pool: worker-172
vlan: 0
node: dc-test02
uid: e7b50a38-25c2-41d0-b332-7f619c69194e
ownerControllerName: test-app-1
ownerControllerType: Deployment
```
### SpiderEndpoint status

The `status` section contains some fields to describe details about the current Endpoint allocation.

```text
// WorkloadEndpointStatus defines the observed state of SpiderEndpoint
type WorkloadEndpointStatus struct {
// the endpoint current allocation details
Current *PodIPAllocation `json:"current,omitempty"`
## SpiderEndpoint definition
// the endpoint history allocation details
History []PodIPAllocation `json:"history,omitempty"`
### Metadata
// kubernetes controller owner reference
OwnerControllerType string `json:"ownerControllerType"`
}
| Field | Description | Schema | Validation |
|-----------|-----------------------------------------------|--------|------------|
| name | the name of this SpiderEndpoint resource | string | required |
| namespace | the namespace of this SpiderEndpoint resource | string | required |
type PodIPAllocation struct {
// container ID
ContainerID string `json:"containerID"`
### Status (subresource)
// node name
Node *string `json:"node,omitempty"`
The IPPool status is a subresource that processed automatically by the system to summarize the current state.
// allocated IPs
IPs []IPAllocationDetail `json:"ips,omitempty"`
| Field | Description | Schema | Validation |
|---------------------|----------------------------------------------------|--------------------------------------------------------|------------|
| current | the IP allocation details of the corresponding pod | [PodIPAllocation](./spiderendpoint.md#PodIPAllocation) | required |
| ownerControllerType | the corresponding pod top owner controller type | string | required |
| ownerControllerName | the corresponding pod top owner controller name | string | required |
// created time
CreationTime *metav1.Time `json:"creationTime,omitempty"`
}
#### PodIPAllocation
type IPAllocationDetail struct {
// interface name
NIC string `json:"interface"`
This property describes the SpiderEndpoint corresponding pod details.
// IPv4 address
IPv4 *string `json:"ipv4,omitempty"`
| Field | Description | Schema | Validation |
|-------|-------------------------------------|----------------------------------------------------------------------|------------|
| uid | corresponding pod uid | string | required |
| node | total IP counts of this pool to use | string | required |
| ips | current allocated IP counts | list of [IPAllocationDetail](./spiderendpoint.md#IPAllocationDetail) | required |
// IPv6 address
IPv6 *string `json:"ipv6,omitempty"`
#### IPAllocationDetail
// IPv4 SpiderIPPool name
IPv4Pool *string `json:"ipv4Pool,omitempty"`
This property describes single Interface allocation details.
// IPv6 SpiderIPPool name
IPv6Pool *string `json:"ipv6Pool,omitempty"`
// vlan ID
Vlan *int64 `json:"vlan,omitempty"`
// IPv4 gateway
IPv4Gateway *string `json:"ipv4Gateway,omitempty"`
// IPv6 gateway
IPv6Gateway *string `json:"ipv6Gateway,omitempty"`
CleanGateway *bool `json:"cleanGateway,omitempty"`
// route
Routes []Route `json:"routes,omitempty"`
}
```
| Field | Description | Schema | Validation | Default |
|--------------|------------------------------------------------------------|------------------------------------------|------------|---------|
| interface | single interface name | string | required | |
| ipv4 | single IPv4 allocated IP address | string | optional | |
| ipv6 | single IPv6 allocated IP address | string | optional | |
| ipv4Pool | the IPv4 allocated IP address corresponding pool | string | optional | |
| ipv6Pool | the IPv6 allocated IP address corresponding pool | string | optional | |
| vlan | vlan ID | int | optional | 0 |
| ipv4Gateway | the IPv4 gateway IP address | string | optional | |
| ipv6Gateway | the IPv6 gateway IP address | string | optional | |
| cleanGateway | a flag to choose whether need default route by the gateway | boolean | optional | |
| routes | the allocation routes | list if [Route](./spiderippool.md#Route) | optional | |
152 changes: 63 additions & 89 deletions docs/concepts/spiderippool.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,84 @@

A SpiderIPPool resource represents a collection of IP addresses from which Spiderpool expects endpoint IPs to be assigned.

## CRD definition

The SpiderIPPool custom resource is modeled after a standard Kubernetes resource
and is split into a `spec` and a `status` section:

```text
type SpiderIPPool struct {
[...]
// Spec is the specification of the IPPool
Spec IPPoolSpec `json:"spec,omitempty"`
// Status is the status of the IPPool
Status IPPoolStatus `json:"status,omitempty"`
}
## Sample YAML

```yaml
apiVersion: spiderpool.spidernet.io/v2beta1
kind: SpiderIPPool
metadata:
name: master-172
spec:
ipVersion: 4
subnet: 172.31.192.0/20
ips:
- 172.31.199.180-172.31.199.189
- 172.31.199.205-172.31.199.209
excludeIPs:
- 172.31.199.186-172.31.199.188
- 172.31.199.207
gateway: 172.31.207.253
default: true
disable: false
```
### IPPool spec
## SpiderIPPool definition
The `spec` section embeds a specific IPPool field which allows to define the list of all IPs, ExcludeIPs, Routes,
and some other data to the IPPool object for allocation:
### Metadata
```text
// IPPoolSpec defines the desired state of SpiderIPPool
type IPPoolSpec struct {
// specify the IPPool's IP version
IPVersion *int64 `json:"ipVersion,omitempty"`
| Field | Description | Schema | Validation |
|-------|----------------------------------------|--------|------------|
| name | the name of this SpiderIPPool resource | string | required |
// specify the IPPool's subnet
Subnet string `json:"subnet"`
### Spec
// specify the IPPool's IP ranges
IPs []string `json:"ips"`
This is the IPPool spec for users to configure.
// determine whether ths IPPool could be used or not
Disable *bool `json:"disable,omitempty"`
| Field | Description | Schema | Validation | Values | Default |
|-------------------|---------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|------------|------------------------------------------|---------|
| ipVersion | IP version of this pool | int | optional | 4,6 | |
| subnet | subnet of this pool | string | required | IPv4 or IPv6 CIDR.<br/>Must not overlap | |
| ips | IP ranges for this pool to use | list of strings | optional | array of IP ranges and single IP address | |
| excludeIPs | isolated IP ranges for this pool to filter | list of strings | optional | array of IP ranges and single IP address | |
| gateway | gateway for this pool | string | optional | an IP address | |
| vlan | vlan ID | int | optional | [0,4094] | 0 |
| routes | custom routes in this pool | list of [route](./spiderippool.md#Route) | optional | | |
| podAffinity | specify which pods can use this pool | [labelSelector](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L1195) | optional | kubernetes LabelSelector | |
| namespaceAffinity | specify which namespaces pods can use this pool | [labelSelector](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L1195) | optional | kubernetes LabelSelector | |
| namespaceName | specify which namespaces pods can use this pool | list of strings | optional | | |
| nodeAffinity | specify which nodes pods can use this pool | [labelSelector](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L1195) | optional | kubernetes LabelSelector | |
| nodeName | specify which nodes pods can use this pool | list of strings | optional | | |
| multusName | specify which multus net-attach-def objects can use this pool | list of strings | optional | | |
| default | configure this resource as a default pool for pods | boolean | optional | true,false | false |
| disable | configure whether the pool is usable | boolean | optional | true,false | false |
// specify the exclude IPs for the IPPool
ExcludeIPs []string `json:"excludeIPs,omitempty"`
### Status (subresource)
// specify the gateway
Gateway *string `json:"gateway,omitempty"`
The IPPool status is a subresource that processed automatically by the system to summarize the current state
// specify the vlan
Vlan *int64 `json:"vlan,omitempty"`
| Field | Description | Schema |
|-------------------|-------------------------------------|--------|
| allocatedIPs | current IP allocations in this pool | string |
| totalIPCount | total IP counts of this pool to use | int |
| allocatedIPCount | current allocated IP counts | int |
//specify the routes
Routes []Route `json:"routes,omitempty"`
#### Route
PodAffinity *metav1.LabelSelector `json:"podAffinity,omitempty"`
| Field | Description | Schema | Validation |
|-------|---------------------------|--------|-------------|
| dst | destination of this route | string | required |
| gw | gateway of this route | string | required |
NamesapceAffinity *metav1.LabelSelector `json:"namespaceAffinity,omitempty"`
### Pod Affinity
NodeAffinity *metav1.LabelSelector `json:"nodeAffinity,omitempty"`
}
For details on configuring SpiderIPPool podAffinity, please read the [Pod Affinity of IPPool](./../usage/ippool-affinity-pod.md).
type Route struct {
// destination
Dst string `json:"dst"`
// gateway
Gw string `json:"gw"`
}
```

### IPPool status

The `status` section contains some fields to describe details about the current IPPool allocation.
The IPPool status reports all used addresses.

```text
// IPPoolStatus defines the observed state of SpiderIPPool
type IPPoolStatus struct {
// all used addresses details
AllocatedIPs PoolIPAllocations `json:"allocatedIPs,omitempty"`
// the IPPool total addresses counts
TotalIPCount *int64 `json:"totalIPCount,omitempty"`
### Namespace Affinity
// the IPPool used addresses counts
AllocatedIPCount *int64 `json:"allocatedIPCount,omitempty"`
}
For details on configuring SpiderIPPool namespaceAffinity or namespaceName, please read the [Namespace Affinity of IPPool](./../usage/ippool-affinity-namespace.md).
> Notice: `namespaceName` has higher priority than `namespaceAffinity`.

// PoolIPAllocations is a map of allocated IPs indexed by IP
type PoolIPAllocations map[string]PoolIPAllocation
### Node Affinity

// PoolIPAllocation is an IP already has been allocated
type PoolIPAllocation struct {
// container ID
ContainerID string `json:"containerID"`
// interface name
NIC string `json:"interface"`
// node name
Node string `json:"node"`
// namespace
Namespace string `json:"namespace"`
// pod name
Pod string `json:"pod"`
// kubernetes controller owner reference
OwnerControllerType string `json:"ownerControllerType"`
}
```
For details on configuring SpiderIPPool nodeAffinity or nodeName, please read the [Node Affinity of IPPool](./../usage/ippool-affinity-node.md) and [Network topology allocation](./../usage/network-topology.md).
> Notice: `nodeName` has higher priority than `nodeAffinity`.
Loading

0 comments on commit 4a54033

Please sign in to comment.