Skip to content

Commit 12e6681

Browse files
docs(tutorials): add IONOS Cloud setup tutorial for ExternalDNS
1 parent 2481c07 commit 12e6681

File tree

1 file changed

+255
-0
lines changed

1 file changed

+255
-0
lines changed

docs/tutorials/ionoscloud.md

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
# IONOS Cloud
2+
3+
This tutorial describes how to set up ExternalDNS for use within a Kubernetes cluster using IONOS Cloud DNS.
4+
5+
## Creating a DNS Zone with IONOS Cloud DNS
6+
7+
If you are new to IONOS Cloud DNS, we recommend you first read the following instructions for creating a DNS zone:
8+
9+
- [Manage DNS Zones in Data Centre Designer](https://docs.ionos.com/cloud/network-services/cloud-dns/dcd-how-tos/manage-dns-zone)
10+
- [Creating a DNS Zone using the IONOS Cloud DNS API](https://docs.ionos.com/cloud/network-services/cloud-dns/api-how-tos/create-dns-zone)
11+
12+
### Steps to Create a DNS Zone
13+
14+
1. Log in to the [IONOS Cloud Data Center Designer](https://dcd.ionos.com/).
15+
2. Navigate to the **Network Services** section and select **Cloud DNS**.
16+
3. Click on **Create Zone** and provide the following details:
17+
- **Zone Name**: Enter the domain name (e.g., `example.com`).
18+
- **Description**: It is optional to provide a description of your zone.
19+
4. Save the zone configuration.
20+
21+
For more advanced configurations, such as adding records or managing subdomains, refer to the [IONOS Cloud DNS Documentation](https://docs.ionos.com/cloud/network-services/cloud-dns/).
22+
23+
## Creating an IONOS API Token
24+
25+
To use ExternalDNS with IONOS Cloud DNS, you need an API token with sufficient privileges to manage DNS zones and records. Follow these steps to create an API token:
26+
27+
1. Log in to the [IONOS Cloud Data Center Designer](https://dcd.ionos.com/).
28+
2. Navigate to the **Management** section in the top right corner and select **Token Manager**.
29+
3. Select the Time To Live(TTL) of the token and click on **Create Token**.
30+
4. Copy the generated token and store it securely. You will use this token to authenticate ExternalDNS.
31+
32+
## Deploy ExternalDNS
33+
34+
### Step 1: Create a Kubernetes Secret for the IONOS API Token
35+
36+
Store your IONOS API token securely in a Kubernetes secret:
37+
38+
```bash
39+
kubectl create secret generic ionos-credentials --from-literal=api-key='<IONOS_API_TOKEN>'
40+
```
41+
42+
Replace `<IONOS_API_TOKEN>` with your actual IONOS API token.
43+
44+
### Step 2: Configure ExternalDNS
45+
46+
Create a Helm values file for the ExternalDNS Helm chart that includes the webhook configuration. In this example, the values file is called `external-dns-ionos-values.yaml` .
47+
48+
```yaml
49+
logLevel: debug # ExternalDNS Log level, reduce in production
50+
51+
namespaced: false # if true, ExternalDNS will run in a namespaced scope (Role and Rolebinding will be namespaced too).
52+
triggerLoopOnEvent: true # if true, ExternalDNS will trigger a loop on every event (create/update/delete) on the resources it watches.
53+
54+
logLevel: debug
55+
sources:
56+
- ingress
57+
- service
58+
provider:
59+
name: webhook
60+
webhook:
61+
image:
62+
repository: ghcr.io/ionos-cloud/external-dns-ionos-webhook
63+
tag: latest
64+
pullPolicy: IfNotPresent
65+
env:
66+
- name: IONOS_API_KEY
67+
valueFrom:
68+
secretKeyRef:
69+
name: ionos-credentials
70+
key: api-key
71+
- name: SERVER_PORT
72+
value: "8888"
73+
- name: METRICS_PORT
74+
value: "8080"
75+
- name: DRY_RUN
76+
value: "false"
77+
```
78+
79+
### Step 3: Install ExternalDNS Using Helm
80+
81+
Install ExternalDNS with the IONOS webhook provider:
82+
83+
```bash
84+
helm repo add external-dns https://kubernetes-sigs.github.io/external-dns/
85+
helm upgrade --install external-dns external-dns/external-dns -f external-dns-ionos-values.yaml
86+
```
87+
88+
## Deploying an Example Application
89+
90+
### Step 1: Create a Deployment
91+
92+
In this step we will create `echoserver` application manifest with the following content:
93+
94+
```yaml
95+
apiVersion: apps/v1
96+
kind: Deployment
97+
metadata:
98+
name: echoserver
99+
namespace: default
100+
spec:
101+
replicas: 1
102+
selector:
103+
matchLabels:
104+
app: echoserver
105+
template:
106+
metadata:
107+
labels:
108+
app: echoserver
109+
spec:
110+
containers:
111+
- name: echoserver
112+
image: ealen/echo-server:latest
113+
ports:
114+
- containerPort: 80
115+
```
116+
117+
Deployment manifest can be saved in `echoserver_deployment.yaml` file.
118+
119+
Next, we will apply the deployment:
120+
121+
```bash
122+
kubectl apply -f echoserver-deployment.yaml
123+
```
124+
125+
### Step 2: Create a Service
126+
127+
In this step, we will create a `Service` manifest to expose the `echoserver` application within the cluster. The service will also include an annotation for ExternalDNS to create a DNS record for the specified hostname.
128+
129+
Save the following content in a file named `echoserver-service.yaml`:
130+
131+
132+
133+
```yaml
134+
apiVersion: v1
135+
kind: Service
136+
metadata:
137+
name: echoserver
138+
annotations:
139+
external-dns.alpha.kubernetes.io/hostname: app.example.com
140+
spec:
141+
ports:
142+
- port: 80
143+
targetPort: 80
144+
selector:
145+
app: echoserver
146+
```
147+
**Note:** Replace `app.example.com` with a subdomain of your DNS zone configured in IONOS Cloud DNS. For example, if your DNS zone is `example.com`, you can use a subdomain like `app.example.com`.
148+
149+
150+
Next, apply the service:
151+
152+
```bash
153+
kubectl apply -f echoserver-service.yaml
154+
```
155+
156+
This service will expose the echoserver application on port 80 and instruct ExternalDNS to create a DNS record for `app.example.com`.
157+
158+
### Step 3: Create an Ingress
159+
160+
In this step, we will create an `Ingress` resource to expose the `echoserver` application externally. The ingress will route HTTP traffic to the `echoserver` service and include a hostname that ExternalDNS will use to create the corresponding DNS record.
161+
162+
Save the following content in a file named `echoserver-ingress.yaml` :
163+
164+
```yaml
165+
apiVersion: networking.k8s.io/v1
166+
kind: Ingress
167+
metadata:
168+
name: echoserver
169+
annotations:
170+
kubernetes.io/ingress.class: nginx
171+
spec:
172+
rules:
173+
- host: app.example.com
174+
http:
175+
paths:
176+
- path: /
177+
pathType: Prefix
178+
backend:
179+
service:
180+
name: echoserver
181+
port:
182+
number: 80
183+
```
184+
185+
**Note:** Replace `app.example.com` with a subdomain of your DNS zone configured in IONOS Cloud DNS. For example, if your DNS zone is `example.com`, you can use a subdomain like `app.example.com`.
186+
187+
Next, apply the ingress manifest:
188+
189+
```bash
190+
kubectl apply -f echoserver-ingress.yaml
191+
```
192+
193+
This ingress will expose the `echoserver` application at `http://app.example.com` and instruct ExternalDNS to create a DNS record for the specified hostname.
194+
195+
## Accessing the Application
196+
197+
Once the `Ingress` resource has been applied and the DNS records have been created, you can access the application using the hostname specified in the ingress (`app.example.com`).
198+
199+
### Verify Application Access
200+
201+
Use the following `curl` command to verify that the application is accessible:
202+
203+
```bash
204+
curl -I http://app.example.com
205+
```
206+
Replace app.example.com with the subdomain you configured in your DNS zone.
207+
208+
**Note:** Ensure that your DNS changes have propagated and that the hostname resolves to the correct IP address before running the command.
209+
210+
### Expected result
211+
212+
You should see an HTTP response header indicating that the application is running, such as:
213+
214+
```bash
215+
HTTP/1.1 200 OK
216+
```
217+
218+
> **Troubleshooting:**
219+
>
220+
>If you encounter any issues, verify the following:
221+
>
222+
> - The DNS record for `app.example.com` (replace with your own subdomain configured in IONOS Cloud DNS) has been created in IONOS Cloud DNS.
223+
> - The ingress controller is running and properly configured in your Kubernetes cluster.
224+
> - The `echoserver` application is running and accessible within the cluster.
225+
226+
## Verifying IONOS Cloud DNS Records
227+
228+
Use the IONOS Cloud Console or API to verify that the A and TXT records for your domain have been created. For example, you can use the following API call:
229+
230+
```bash
231+
curl --location --request GET 'https://dns.de-fra.ionos.com/records?filter.name=app' \
232+
--header 'Authorization: Bearer <IONOS_API_TOKEN>'
233+
```
234+
235+
Replace `<IONOS_API_TOKEN>` with your actual API token.
236+
237+
The API response should include the `A` and `TXT` records for the subdomain you configured.
238+
239+
> **Note:** DNS changes may take a few minutes to propagate. If the records are not visible immediately, wait and try again.
240+
241+
## Cleanup
242+
243+
> **Optional:** Perform the cleanup step only if you no longer need the deployed resources.
244+
245+
Once you have verified the setup, you can clean up the resources created during this tutorial:
246+
247+
```bash
248+
kubectl delete -f echoserver_deployment.yaml
249+
kubectl delete -f echoserver-service.yaml
250+
kubectl delete -f echoserver-ingress.yaml
251+
```
252+
253+
## Summary
254+
255+
In this tutorial, you successfully deployed ExternalDNS webhook with IONOS Cloud DNS as the provider. You created a Kubernetes deployment, service, and ingress, and verified that DNS records were created and the application was accessible. You also learned how to clean up the resources when they are no longer needed.

0 commit comments

Comments
 (0)