Skip to content

Commit 8039bc4

Browse files
committed
move examples from new to examples folder
1 parent d8b63c2 commit 8039bc4

32 files changed

+684
-87
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Example 1: Getting Started
2+
3+
# 0.1 Create a local cluster with nebox-installed
4+
5+
1. use the 'create-kind' target from the Makefile to create a kind cluster and deploy NetBox on it
6+
```bash
7+
make create-kind
8+
```
9+
10+
# 0.2 Manually Create a Prefix in NetBox
11+
12+
Before prefixes and ip addresses can be claimed with the NetBox operator, a prefix has to be created in NetBox.
13+
14+
1. Port-forward NetBox:
15+
```bash
16+
kubectl port-forward deploy/netbox 8080:8080
17+
```
18+
2. Open <http://localhost:8080> in your favorite browser and log in with the username `admin` and password `admin`
19+
3. Create a new prefix '3.0.0.64/26' with custom field 'environment: prod'
20+
21+
# 1.1 Claim a Prefix
22+
23+
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.
24+
25+
Navigate to 'docs/examples/example1-getting-started' to run the following commands.
26+
27+
1. Inspect the spec of the sample prefix claim CR
28+
```bash
29+
cat prefixclaim-simple.yaml
30+
```
31+
2. Apply the manifest defining the prefix claim
32+
```bash
33+
kubectl apply -f prefixclaim-simple.yaml
34+
```
35+
3. Check that the prefix claim CR got a prefix assigned
36+
```bash
37+
kubectl get pxc,px
38+
```
39+
40+
![Example 1.1](prefixclaim-simple.drawio.svg)
41+
42+
# 1.2 Dynamically Claim a Prefix with a Parent Prefix Selector
43+
44+
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.
45+
46+
Navigate to 'docs/examples/example1-getting-started' to run the following commands.
47+
48+
1. Inspect the spec of the sample prefix claim CR
49+
```bash
50+
cat prefixclaim-dynamic.yaml
51+
```
52+
2. Apply the manifest defining the prefix claim
53+
```bash
54+
kubectl apply -f prefixclaim-dynamic.yaml
55+
```
56+
3. Check that the prefix claim CR got a prefix addigned
57+
```bash
58+
kubectl get pxc,px
59+
```
60+
61+
![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
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Example 2: Glue NetBox CRs to MetalLB CRs
2+
3+
## Introduction
4+
5+
So we have Prefixes represented as Kubernetes Resources. Now what can we do with this?
6+
7+
We use kro.run to glue this to MetalLB IPAddressPools
8+
9+
Navigate to 'docs/examples/example2-krm-glue' to run the following commands.
10+
11+
0. Install kro and metallb with the installation script `docs/examples/new/example2-krm-glue/prepare-demo-env.sh`
12+
Then navigate to 'docs/examples/example2-krm-glue' to follow the steps below.
13+
14+
1. Inspect the spec of the sample prefix claim CR
15+
```bash
16+
cat kro-rdg-poolfromnetbox.yaml
17+
```
18+
2. Apply the manifests to create a deployment with a service and a metallb-ip-address-pool-netbox to create a metalLB IPAddressPool from the prefix claimed from NetBox
19+
```bash
20+
kubectl apply -f kro-rdg-poolfromnetbox.yaml
21+
```
22+
3. Check if the prefixclaim CR and the metalLB ipaddresspool CR got created
23+
```bash
24+
kubectl get pxc,ipaddresspool -A
25+
```
26+
4. Inspect the spec of the sample prefix claim CR
27+
```bash
28+
cat sample-deployment.yaml
29+
```
30+
5. Apply the manifests to createa deployment with a service that gets a ip assigned from the metalLB pool created in the prevoius step
31+
```bash
32+
kubectl apply -f sample-deployment.yaml
33+
```
34+
6. check if the service got an external ip address assigned
35+
```bash
36+
kubectl get svc my-nginx -n nginx
37+
```
38+
7. try to connect to your service with the external ip
39+
```bash
40+
k exec curl -it -- sh
41+
curl <external-ip>
42+
```
43+
44+
45+
![Example 2](metallb-ipaddresspool-netbox.drawio.svg)

docs/examples/set-up/metallb-ip-address-pool-netbox.yaml renamed to docs/examples/example2-krm-glue/metallb-ip-address-pool-netbox.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: kro.run/v1alpha1
22
kind: ResourceGraphDefinition
33
metadata:
4-
name: metallb-ip-address-pool--netbox
4+
name: metallb-ip-address-pool-netbox
55
spec:
66
schema:
77
apiVersion: v1alpha1
@@ -10,7 +10,6 @@ spec:
1010
name: string
1111
tenant: string
1212
prefixLength: string
13-
preserveInNetbox: boolean
1413
parentPrefixSelector:
1514
tenant: string
1615
environment: string
@@ -29,7 +28,6 @@ spec:
2928
tenant: ${schema.spec.tenant}
3029
prefixLength: ${schema.spec.prefixLength}
3130
parentPrefixSelector: ${schema.spec.parentPrefixSelector}
32-
preserveInNetbox: ${schema.spec.preserveInNetbox}
3331

3432
- id: ipaddresspool
3533
template:

0 commit comments

Comments
 (0)