diff --git a/README.md b/README.md index e9204e7..86c6665 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -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 diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..f728db1 --- /dev/null +++ b/docs/README.md @@ -0,0 +1 @@ +# FlatNetwork Workload Examples diff --git a/docs/ipvlan/0-subnet-example-ipv6.yaml b/docs/ipvlan/0-subnet-example-ipv6.yaml new file mode 100644 index 0000000..a6c6d7b --- /dev/null +++ b/docs/ipvlan/0-subnet-example-ipv6.yaml @@ -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 diff --git a/docs/ipvlan/0-subnet-example.yaml b/docs/ipvlan/0-subnet-example.yaml new file mode 100644 index 0000000..b652d01 --- /dev/null +++ b/docs/ipvlan/0-subnet-example.yaml @@ -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 diff --git a/docs/ipvlan/daemonset-example.yaml b/docs/ipvlan/daemonset-example.yaml new file mode 100644 index 0000000..dc8aa16 --- /dev/null +++ b/docs/ipvlan/daemonset-example.yaml @@ -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 diff --git a/docs/ipvlan/deployment-example.yaml b/docs/ipvlan/deployment-example.yaml new file mode 100644 index 0000000..e808619 --- /dev/null +++ b/docs/ipvlan/deployment-example.yaml @@ -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 diff --git a/docs/ipvlan/service-example.yaml b/docs/ipvlan/service-example.yaml new file mode 100644 index 0000000..07b556d --- /dev/null +++ b/docs/ipvlan/service-example.yaml @@ -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 diff --git a/docs/macvlan/0-subnet-example-ipv6.yaml b/docs/macvlan/0-subnet-example-ipv6.yaml new file mode 100644 index 0000000..a6dce37 --- /dev/null +++ b/docs/macvlan/0-subnet-example-ipv6.yaml @@ -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 diff --git a/docs/macvlan/0-subnet-example.yaml b/docs/macvlan/0-subnet-example.yaml new file mode 100644 index 0000000..b4c4910 --- /dev/null +++ b/docs/macvlan/0-subnet-example.yaml @@ -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 diff --git a/docs/macvlan/daemonset-example.yaml b/docs/macvlan/daemonset-example.yaml new file mode 100644 index 0000000..78880a4 --- /dev/null +++ b/docs/macvlan/daemonset-example.yaml @@ -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 diff --git a/docs/macvlan/deployment-example.yaml b/docs/macvlan/deployment-example.yaml new file mode 100644 index 0000000..67e42da --- /dev/null +++ b/docs/macvlan/deployment-example.yaml @@ -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 diff --git a/docs/macvlan/service-example.yaml b/docs/macvlan/service-example.yaml new file mode 100644 index 0000000..7281968 --- /dev/null +++ b/docs/macvlan/service-example.yaml @@ -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