Skip to content

Commit 86bdf1d

Browse files
Kamil PrzybylKamil Przybyl
authored andcommitted
chore: add alb ingress controller docs run-it-locally how-to
1 parent ae98179 commit 86bdf1d

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

docs/ingress-controller.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
### Run the ALB Ingress controller locally
2+
To run the controller on your local machine, ensure you have a valid kubeconfig pointing to the target Kubernetes cluster where the ALB resources should be managed.
3+
4+
##### Environment Variables
5+
The controller requires specific configuration and credentials to interact with the STACKIT APIs and your network infrastructure. Set the following variables:
6+
- STACKIT_SERVICE_ACCOUNT_TOKEN: Your authentication token for performing CRUD operations via the ALB and Certificates SDK.
7+
- STACKIT_REGION: The STACKIT region where the infrastructure resides (e.g., eu01).
8+
- PROJECT_ID: The unique identifier of your STACKIT project where the ALB will be provisioned.
9+
- NETWORK_ID: The ID of the STACKIT network where the ALB will be provisioned.
10+
```
11+
export STACKIT_SERVICE_ACCOUNT_TOKEN=<your-token>
12+
export STACKIT_REGION=<region>
13+
export PROJECT_ID=<project-id>
14+
export NETWORK_ID=<network-id>
15+
```
16+
Kubernetes Context
17+
The controller uses the default Kubernetes client. Ensure your KUBECONFIG environment variable is set or your current context is correctly configured:
18+
```
19+
export KUBECONFIG=~/.kube/config
20+
```
21+
#### Run
22+
Use the provided Makefile in the root of repository to start the controller:
23+
```
24+
make run
25+
```
26+
27+
### Create your deployment and expose it via Ingress
28+
1. Create your k8s deployment, here’s an example of a simple http web server:
29+
```
30+
apiVersion: apps/v1
31+
kind: Deployment
32+
metadata:
33+
labels:
34+
app: httpbin-deployment
35+
name: httpbin-deployment
36+
namespace: default
37+
spec:
38+
replicas: 2
39+
selector:
40+
matchLabels:
41+
app: httpbin-deployment
42+
template:
43+
metadata:
44+
labels:
45+
app: httpbin-deployment
46+
spec:
47+
containers:
48+
- image: kennethreitz/httpbin
49+
name: httpbin
50+
ports:
51+
- containerPort: 80
52+
```
53+
2. Now, create a k8s service so that the traffic can be routed to the pods:
54+
```
55+
apiVersion: v1
56+
kind: Service
57+
metadata:
58+
labels:
59+
app: httpbin-deployment
60+
name: httpbin
61+
namespace: default
62+
spec:
63+
ports:
64+
- port: 80
65+
protocol: TCP
66+
targetPort: 80
67+
nodePort: 30000
68+
selector:
69+
app: httpbin-deployment
70+
type: NodePort
71+
```
72+
>NOTE: The service has to be of type NodePort to enable access to the nodes from the outside of the cluster.
73+
3. Create an IngressClass that specifies the ALB Ingress controller:
74+
```
75+
apiVersion: networking.k8s.io/v1
76+
kind: IngressClass
77+
metadata:
78+
namespace: default
79+
name: alb-01
80+
spec:
81+
controller: stackit.cloud/alb-ingress
82+
```
83+
4. Lastly, create an ingress resource that references the previously created IngressClass:
84+
```
85+
apiVersion: networking.k8s.io/v1
86+
kind: Ingress
87+
metadata:
88+
name: alb-ingress
89+
namespace: default
90+
spec:
91+
ingressClassName: alb-01
92+
rules:
93+
- host: example.gg
94+
http:
95+
paths:
96+
- path: /
97+
pathType: Prefix
98+
backend:
99+
service:
100+
name: httpbin
101+
port:
102+
number: 80
103+
```

0 commit comments

Comments
 (0)