Skip to content

Commit f91ff48

Browse files

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4587
-497
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,9 @@ go.work
2929
*.swp
3030
*.swo
3131
*~
32-
.drawio.dtmp
32+
*.drawio.dtmp
33+
*drawio.svg.bkp
3334
.DS_Store
35+
36+
# Temporary files
37+
tmp

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ Example of assigning a Prefix using PrefixClaim:
5555

5656
Key information can be found in the yaml formatted output of these resources, as well as in the events and Operator logs.
5757

58+
To test at scale, you can use yq to patch the Kubernetes manifests. The following is an example to create 100 IpAddressClaims based on the sample yaml file:
59+
60+
```bash
61+
for i in {001..100}; do
62+
name="ipc-${i}" yq e '.metadata.name=strenv(name)' config/samples/netbox_v1_ipaddressclaim.yaml | kubectl apply -f -
63+
done
64+
```
65+
5866
# Mixed usage of Prefixes
5967

6068
Note that NetBox does handle the Address management of Prefixes separately from IP Ranges and IP Addresses. This is important to know when you plan to use the same NetBox Prefix as a parentPrefix for your IpAddressClaims, IpRangeClaims and PrefixClaims.

docs/examples/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# NetBox Operator Examples
2+
3+
This folder shows some examples how the NetBox Operator can be used.
4+
5+
Each example folder contains a README.md which explains how you can set up your local enviroment to step through the examples.
6+
7+
Prerequisites:
8+
- go version v1.24.0+
9+
- docker image netbox-operatore:build-local
10+
- kustomize version v5.5.0+
11+
- kubectl version v1.32.2+
12+
- kind v0.27.0
13+
- docker cli
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Example 1: Getting Started
2+
3+
# 0.1 Create a local cluster with nebox-installed
4+
5+
1. use the 'create-kind' and 'deploy-kind' targets from the Makefile to create a kind cluster and deploy NetBox and NetBox Operator on it
6+
```bash
7+
make create-kind
8+
make deploy-kind
9+
```
10+
11+
# 0.2 Manually Create a Prefix in NetBox
12+
13+
Before prefixes and ip addresses can be claimed with the NetBox operator, a prefix has to be created in NetBox.
14+
15+
1. Port-forward NetBox:
16+
```bash
17+
kubectl port-forward deploy/netbox 8080:8080
18+
```
19+
2. Open <http://localhost:8080> in your favorite browser and log in with the username `admin` and password `admin`
20+
3. Create a new prefix '3.0.0.64/26' with custom field 'environment: prod'
21+
22+
# 0.3 Navigate to the example folder
23+
24+
Navigate to 'docs/examples/example1-getting-started' to run the examples below
25+
26+
# 1.1 Claim a Prefix
27+
28+
In this example, we use a `.spec.parentPrefix` that we know in advance. This is useful if you already know exactly from which prefix you want to claim from.
29+
30+
1. Inspect the spec of the sample prefix claim CR
31+
```bash
32+
cat prefixclaim-simple.yaml
33+
```
34+
2. Apply the manifest defining the prefix claim
35+
```bash
36+
kubectl apply -f prefixclaim-simple.yaml
37+
```
38+
3. Check that the prefix claim CR got a prefix assigned
39+
```bash
40+
kubectl get pxc,px
41+
```
42+
43+
![Example 1.1](prefixclaim-simple.drawio.svg)
44+
45+
# 1.2 Dynamically Claim a Prefix with a Parent Prefix Selector
46+
47+
In this example, we use a `.spec.parentPrefixSelector`, which is a list of selectors that tell NetBox Operator from which parent prefixes to claim our Prefix from.
48+
49+
Navigate to 'docs/examples/example1-getting-started' to run the following commands.
50+
51+
1. Inspect the spec of the sample prefix claim CR
52+
```bash
53+
cat prefixclaim-dynamic.yaml
54+
```
55+
2. Apply the manifest defining the prefix claim
56+
```bash
57+
kubectl apply -f prefixclaim-dynamic.yaml
58+
```
59+
3. Check that the prefix claim CR got a prefix addigned
60+
```bash
61+
kubectl get pxc,px
62+
```
63+
64+
![Example 1.2](prefixclaim-dynamic.drawio.svg)

docs/examples/example1-getting-started/dynamic_prefixclaim-large-font.drawio.svg

Lines changed: 532 additions & 0 deletions
Loading

docs/examples/example1-getting-started/prefixclaim-dynamic.drawio.svg

Lines changed: 469 additions & 0 deletions
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: netbox.dev/v1
2+
kind: PrefixClaim
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: netbox-operator
6+
app.kubernetes.io/managed-by: kustomize
7+
name: dynamic-prefix-claim
8+
spec:
9+
tenant: "MY_TENANT"
10+
parentPrefixSelector:
11+
environment: prod
12+
family: IPv4
13+
prefixLength: "/30"

docs/examples/example1-getting-started/prefixclaim-simple.drawio.svg

Lines changed: 463 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: netbox.dev/v1
2+
kind: PrefixClaim
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: netbox-operator
6+
app.kubernetes.io/managed-by: kustomize
7+
name: simple-prefixclaim
8+
spec:
9+
tenant: "MY_TENANT"
10+
parentPrefix: 3.0.0.64/26
11+
prefixLength: "/30"

docs/examples/example1-getting-started/simple_prefixclaim-large-font.drawio.svg

Lines changed: 485 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)