Skip to content

Commit

Permalink
Add example docs & Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
STARRY-S committed Jul 10, 2024
1 parent debc56f commit 357bdf7
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To build and run this flat-network operator manually:
1. Apply CRDs.

```console
$ kubectl apply -f ./charts/rancher-flat-network-operator-crd/templates/crd.yaml
$ kubectl apply -f ./charts/rancher-flat-network/templates/crd.yaml
```

1. Build and run flat-network operator.
Expand All @@ -45,7 +45,7 @@ To build and run this flat-network operator manually:
$ go build . && ./rancher-flat-network-operator --webhook-server=false
```

1. Launch another terminal to create example workloads.
1. Example workloads are available in [docs](./docs/) directory, run following command to create example subnet & workloads for test.

```console
$ kubectl apply -f ./docs/macvlan
Expand All @@ -60,6 +60,10 @@ Environment variables for operator:
- `CATTLE_ELECTION_RENEW_DEADLINE`: leader election renew deadline, default `30s`.
- `CATTLE_ELECTION_RETRY_PERIOD`: leader election retry period, default `2s`.

### CNI

> WIP

## License

Copyright 2024 SUSE Rancher
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# FlatNetwork Workload Examples
16 changes: 16 additions & 0 deletions docs/ipvlan/0-subnet-example-ipv6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: flatnetwork.pandaria.io/v1
kind: FlatNetworkSubnet
metadata:
name: ipvlan-ipv6-subnet201
namespace: cattle-flat-network
spec:
vlan: 201
cidr: fd00:eeee::/64
flatMode: ipvlan
gateway: ""
master: eth0
mode: "l2"
podDefaultGateway: {}
ranges:
- from: fd00:eeee::1000
to: fd00:eeee::ffff
18 changes: 18 additions & 0 deletions docs/ipvlan/0-subnet-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: flatnetwork.pandaria.io/v1
kind: FlatNetworkSubnet
metadata:
name: ipvlan-subnet200
namespace: cattle-flat-network
spec:
vlan: 200
cidr: 192.168.200.0/24
flatMode: ipvlan
gateway: ""
master: eth0
mode: "l2"
podDefaultGateway:
enable: true
serviceCIDR: '10.43.0.0/16'
ranges:
- from: 192.168.200.100
to: 192.168.200.200
54 changes: 54 additions & 0 deletions docs/ipvlan/daemonset-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-ipvlan-deployment
namespace: default
labels:
app: nginx-ipvlan-deployment
spec:
selector:
matchLabels:
app: nginx-ipvlan-deployment
template:
metadata:
labels:
app: nginx-ipvlan-deployment
annotations:
flatnetwork.pandaria.io/ip: "auto"
flatnetwork.pandaria.io/subnet: "ipvlan-subnet200"
flatnetwork.pandaria.io/mac: ""
k8s.v1.cni.cncf.io/networks: '[{"name":"rancher-flat-network","interface":"eth1"}]'
spec:
containers:
- name: nginx-ipvlan-deployment
image: nginx
imagePullPolicy: Always
securityContext:
privileged: true

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-ipvlan-deployment-ipv6
namespace: default
labels:
app: nginx-ipvlan-deployment-ipv6
spec:
selector:
matchLabels:
app: nginx-ipvlan-deployment-ipv6
template:
metadata:
labels:
app: nginx-ipvlan-deployment-ipv6
annotations:
flatnetwork.pandaria.io/ip: "auto"
flatnetwork.pandaria.io/subnet: "ipvlan-ipv6-subnet201"
flatnetwork.pandaria.io/mac: ""
k8s.v1.cni.cncf.io/networks: '[{"name":"rancher-flat-network","interface":"eth1"}]'
spec:
containers:
- name: nginx-ipvlan-deployment-ipv6
image: nginx
imagePullPolicy: Always
52 changes: 52 additions & 0 deletions docs/ipvlan/deployment-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-ipvlan-deployment
namespace: default
labels:
app: nginx-ipvlan
spec:
replicas: 2
selector:
matchLabels:
app: nginx-ipvlan
template:
metadata:
labels:
app: nginx-ipvlan
annotations:
flatnetwork.pandaria.io/ip: "auto"
flatnetwork.pandaria.io/subnet: "ipvlan-subnet200"
flatnetwork.pandaria.io/mac: ""
k8s.v1.cni.cncf.io/networks: '[{"name":"rancher-flat-network","interface":"eth1"}]'
spec:
containers:
- name: nginx-ipvlan
image: nginx

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-ipvlan-deployment-ipv6
namespace: default
labels:
app: nginx-ipvlan-ipv6
spec:
replicas: 2
selector:
matchLabels:
app: nginx-ipvlan-ipv6
template:
metadata:
labels:
app: nginx-ipvlan-ipv6
annotations:
flatnetwork.pandaria.io/ip: "auto"
flatnetwork.pandaria.io/subnet: "ipvlan-ipv6-subnet201"
flatnetwork.pandaria.io/mac: ""
k8s.v1.cni.cncf.io/networks: '[{"name":"rancher-flat-network","interface":"eth1"}]'
spec:
containers:
- name: nginx-ipvlan
image: nginx
28 changes: 28 additions & 0 deletions docs/ipvlan/service-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Service
metadata:
name: example-ipvlan-service
spec:
type: NodePort
selector:
app: nginx-ipvlan
ports:
- port: 80
# By default and for convenience, the `targetPort` is set to
# the same value as the `port` field.
targetPort: 80

---
apiVersion: v1
kind: Service
metadata:
name: example-ipvlan-service-ipv6
spec:
type: NodePort
selector:
app: nginx-ipvlan-ipv6
ports:
- port: 80
# By default and for convenience, the `targetPort` is set to
# the same value as the `port` field.
targetPort: 80
16 changes: 16 additions & 0 deletions docs/macvlan/0-subnet-example-ipv6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: flatnetwork.pandaria.io/v1
kind: FlatNetworkSubnet
metadata:
name: macvlan-ipv6-subnet101
namespace: cattle-flat-network
spec:
vlan: 101
cidr: fd00:aaaa::/112
flatMode: macvlan
gateway: "fd00:aaaa::0001"
master: eth0
mode: "bridge"
podDefaultGateway: {}
ranges:
- from: fd00:aaaa::1000
to: fd00:aaaa::ffff
19 changes: 19 additions & 0 deletions docs/macvlan/0-subnet-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: flatnetwork.pandaria.io/v1
kind: FlatNetworkSubnet
metadata:
creationTimestamp: null
labels:
project: ""
name: macvlan-subnet100
namespace: cattle-flat-network
spec:
vlan: 100
cidr: 10.2.3.0/24
flatMode: macvlan
gateway: "10.2.3.1"
master: eth0
mode: "bridge"
podDefaultGateway: {}
ranges:
- from: 10.2.3.100
to: 10.2.3.200
53 changes: 53 additions & 0 deletions docs/macvlan/daemonset-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-macvlan-daemonset
namespace: default
labels:
app: nginx-macvlan-daemonset
spec:
selector:
matchLabels:
app: nginx-macvlan-daemonset
template:
metadata:
labels:
app: nginx-macvlan-daemonset
annotations:
flatnetwork.pandaria.io/ip: "auto"
flatnetwork.pandaria.io/subnet: "macvlan-subnet100"
flatnetwork.pandaria.io/mac: ""
k8s.v1.cni.cncf.io/networks: '[{"name":"rancher-flat-network","interface":"eth1"}]'
# v1.multus-cni.io/default-network: '[{"name":"rancher-flat-network","interface":"eth0"}]'
spec:
containers:
- name: nginx-macvlan-daemonset
image: nginx
imagePullPolicy: Always

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-macvlan-daemonset-ipv6
namespace: default
labels:
app: nginx-macvlan-daemonset-ipv6
spec:
selector:
matchLabels:
app: nginx-macvlan-daemonset-ipv6
template:
metadata:
labels:
app: nginx-macvlan-daemonset-ipv6
annotations:
flatnetwork.pandaria.io/ip: "auto"
flatnetwork.pandaria.io/subnet: "macvlan-ipv6-subnet101"
flatnetwork.pandaria.io/mac: ""
k8s.v1.cni.cncf.io/networks: '[{"name":"rancher-flat-network","interface":"eth1"}]'
spec:
containers:
- name: nginx-macvlan-daemonset-ipv6
image: nginx
imagePullPolicy: Always
52 changes: 52 additions & 0 deletions docs/macvlan/deployment-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-macvlan-deployment
namespace: default
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
flatnetwork.pandaria.io/ip: "auto"
flatnetwork.pandaria.io/subnet: "macvlan-subnet100"
flatnetwork.pandaria.io/mac: ""
k8s.v1.cni.cncf.io/networks: '[{"name":"rancher-flat-network","interface":"eth1"}]'
spec:
containers:
- name: nginx
image: nginx

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-macvlan-deployment-ipv6
namespace: default
labels:
app: nginx-ipv6
spec:
replicas: 3
selector:
matchLabels:
app: nginx-ipv6
template:
metadata:
labels:
app: nginx-ipv6
annotations:
flatnetwork.pandaria.io/ip: "auto"
flatnetwork.pandaria.io/subnet: "macvlan-ipv6-subnet101"
flatnetwork.pandaria.io/mac: ""
k8s.v1.cni.cncf.io/networks: '[{"name":"rancher-flat-network","interface":"eth1"}]'
spec:
containers:
- name: nginx-ipv6
image: nginx
36 changes: 36 additions & 0 deletions docs/macvlan/service-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v1
kind: Service
metadata:
name: example-service
spec:
type: NodePort
selector:
app: nginx
ports:
- port: 80
# By default and for convenience, the `targetPort` is set to
# the same value as the `port` field.
targetPort: 80
# Optional field
# By default and for convenience, the Kubernetes control plane
# will allocate a port from a range (default: 30000-32767)
nodePort: 0

---
apiVersion: v1
kind: Service
metadata:
name: example-service-ipv6
spec:
type: NodePort
selector:
app: nginx-ipv6
ports:
- port: 80
# By default and for convenience, the `targetPort` is set to
# the same value as the `port` field.
targetPort: 80
# Optional field
# By default and for convenience, the Kubernetes control plane
# will allocate a port from a range (default: 30000-32767)
nodePort: 0

0 comments on commit 357bdf7

Please sign in to comment.