infoblox.md 7.84 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
# Setting up ExternalDNS for Infoblox

This tutorial describes how to setup ExternalDNS for usage with Infoblox.

Make sure to use **>=0.4.6** version of ExternalDNS for this tutorial. The only WAPI version that
has been validated is **v2.3.1**. It is assumed that the API user has rights to create objects of
the following types: `zone_auth`, `record:a`, `record:cname`, `record:txt`.

This tutorial assumes you have substituted the correct values for the following environment variables:

```
Khris Richardson's avatar
Khris Richardson committed
12
13
14
15
16
export GRID_HOST=127.0.0.1
export WAPI_PORT=443
export WAPI_VERSION=2.3.1
export WAPI_USERNAME=admin
export WAPI_PASSWORD=infoblox
17
18
19
20
21
22
23
24
25
26
27
28
29
```

## Creating an Infoblox DNS zone

The Infoblox provider for ExternalDNS will find suitable zones for domains it manages; it will
not automatically create zones.

Create an Infoblox DNS zone for "example.com":

```
$ curl -kl \
      -X POST \
      -d fqdn=example.com \
Khris Richardson's avatar
Khris Richardson committed
30
31
      -u ${WAPI_USERNAME}:${WAPI_PASSWORD} \
         https://${GRID_HOST}:${WAPI_PORT}/wapi/v${WAPI_VERSION}/zone_auth
32
33
34
35
36
37
38
39
40
41
42
43
```

Substitute a domain you own for "example.com" if desired.

## Creating an Infoblox Configuration Secret

For ExternalDNS to access the Infoblox API, create a Kubernetes secret.

To create the secret:

```
$ kubectl create secret generic external-dns \
Khris Richardson's avatar
Khris Richardson committed
44
45
      --from-literal=EXTERNAL_DNS_INFOBLOX_WAPI_USERNAME=${WAPI_USERNAME} \
      --from-literal=EXTERNAL_DNS_INFOBLOX_WAPI_PASSWORD=${WAPI_PASSWORD}
46
47
48
49
```

## Deploy ExternalDNS

50
51
Connect your `kubectl` client to the cluster you want to test ExternalDNS with.
Then apply one of the following manifests file to deploy ExternalDNS.
52

53
54
### Manifest (for clusters without RBAC enabled)
```yaml
55
apiVersion: apps/v1
56
57
58
59
60
61
kind: Deployment
metadata:
  name: external-dns
spec:
  strategy:
    type: Recreate
62
63
64
  selector:
    matchLabels:
      app: external-dns
65
66
67
68
69
70
71
  template:
    metadata:
      labels:
        app: external-dns
    spec:
      containers:
      - name: external-dns
72
        image: k8s.gcr.io/external-dns/external-dns:v0.7.3
73
74
        args:
        - --source=service
Khris Richardson's avatar
Khris Richardson committed
75
        - --domain-filter=example.com       # (optional) limit to only example.com domains.
76
        - --provider=infoblox
Khris Richardson's avatar
Khris Richardson committed
77
78
79
80
        - --infoblox-grid-host=${GRID_HOST} # (required) IP of the Infoblox Grid host.
        - --infoblox-wapi-port=443          # (optional) Infoblox WAPI port. The default is "443".
        - --infoblox-wapi-version=2.3.1     # (optional) Infoblox WAPI version. The default is "2.3.1"
        - --infoblox-ssl-verify             # (optional) Use --no-infoblox-ssl-verify to skip server certificate verification.
81
82
        env:
        - name: EXTERNAL_DNS_INFOBLOX_HTTP_POOL_CONNECTIONS
Khris Richardson's avatar
Khris Richardson committed
83
          value: "10" # (optional) Infoblox WAPI request connection pool size. The default is "10".
84
        - name: EXTERNAL_DNS_INFOBLOX_HTTP_REQUEST_TIMEOUT
Khris Richardson's avatar
Khris Richardson committed
85
          value: "60" # (optional) Infoblox WAPI request timeout in seconds. The default is "60".
86
87
88
89
90
91
92
93
94
95
96
97
        - name: EXTERNAL_DNS_INFOBLOX_WAPI_USERNAME
          valueFrom:
            secretKeyRef:
              name: external-dns
              key: EXTERNAL_DNS_INFOBLOX_WAPI_USERNAME
        - name: EXTERNAL_DNS_INFOBLOX_WAPI_PASSWORD
          valueFrom:
            secretKeyRef:
              name: external-dns
              key: EXTERNAL_DNS_INFOBLOX_WAPI_PASSWORD
```

98
### Manifest (for clusters with RBAC enabled)
99

100
101
102
103
104
105
106
107
108
109
110
111
```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: external-dns
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: external-dns
rules:
- apiGroups: [""]
Alfred Krohmer's avatar
Alfred Krohmer committed
112
  resources: ["services","endpoints","pods"]
113
  verbs: ["get","watch","list"]
114
- apiGroups: ["extensions","networking.k8s.io"]
115
116
  resources: ["ingresses"] 
  verbs: ["get","watch","list"]
117
118
119
- apiGroups: [""]
  resources: ["nodes"]
  verbs: ["list"]
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: external-dns-viewer
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: external-dns
subjects:
- kind: ServiceAccount
  name: external-dns
  namespace: default
---
134
apiVersion: apps/v1
135
136
137
138
139
140
kind: Deployment
metadata:
  name: external-dns
spec:
  strategy:
    type: Recreate
141
142
143
  selector:
    matchLabels:
      app: external-dns
144
145
146
147
148
149
150
151
  template:
    metadata:
      labels:
        app: external-dns
    spec:
      serviceAccountName: external-dns
      containers:
      - name: external-dns
152
        image: k8s.gcr.io/external-dns/external-dns:v0.7.3
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
        args:
        - --source=service
        - --domain-filter=example.com       # (optional) limit to only example.com domains.
        - --provider=infoblox
        - --infoblox-grid-host=${GRID_HOST} # (required) IP of the Infoblox Grid host.
        - --infoblox-wapi-port=443          # (optional) Infoblox WAPI port. The default is "443".
        - --infoblox-wapi-version=2.3.1     # (optional) Infoblox WAPI version. The default is "2.3.1"
        - --infoblox-ssl-verify             # (optional) Use --no-infoblox-ssl-verify to skip server certificate verification.
        env:
        - name: EXTERNAL_DNS_INFOBLOX_HTTP_POOL_CONNECTIONS
          value: "10" # (optional) Infoblox WAPI request connection pool size. The default is "10".
        - name: EXTERNAL_DNS_INFOBLOX_HTTP_REQUEST_TIMEOUT
          value: "60" # (optional) Infoblox WAPI request timeout in seconds. The default is "60".
        - name: EXTERNAL_DNS_INFOBLOX_WAPI_USERNAME
          valueFrom:
            secretKeyRef:
              name: external-dns
              key: EXTERNAL_DNS_INFOBLOX_WAPI_USERNAME
        - name: EXTERNAL_DNS_INFOBLOX_WAPI_PASSWORD
          valueFrom:
            secretKeyRef:
              name: external-dns
              key: EXTERNAL_DNS_INFOBLOX_WAPI_PASSWORD
176
```
177

178
179
180
181
182
183

## Deploying an Nginx Service

Create a service file called 'nginx.yaml' with the following contents:

```yaml
184
apiVersion: apps/v1
185
186
187
188
kind: Deployment
metadata:
  name: nginx
spec:
189
190
191
  selector:
    matchLabels:
      app: nginx
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  annotations:
    external-dns.alpha.kubernetes.io/hostname: example.com
spec:
  selector:
    app: nginx
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
```

Note the annotation on the service; use the same hostname as the Infoblox DNS zone created above. The annotation may also be a subdomain
of the DNS zone (e.g. 'www.example.com').

ExternalDNS uses this annotation to determine what services should be registered with DNS.  Removing the annotation
will cause ExternalDNS to remove the corresponding DNS records.

Create the deployment and service:

```
$ kubectl create -f nginx.yaml
```

It takes a little while for the Infoblox cloud provider to create an external IP for the service.  Check the status by running
`kubectl get services nginx`.  If the `EXTERNAL-IP` field shows an address, the service is ready to be accessed externally.

Once the service has an external IP assigned, ExternalDNS will notice the new service IP address and synchronize
the Infoblox DNS records.

## Verifying Infoblox DNS records

Run the following command to view the A records for your Infoblox DNS zone:

```
$ curl -kl \
      -X GET \
Khris Richardson's avatar
Khris Richardson committed
244
245
      -u ${WAPI_USERNAME}:${WAPI_PASSWORD} \
         https://${GRID_HOST}:${WAPI_PORT}/wapi/v${WAPI_VERSION}/record:a?zone=example.com
246
247
248
249
250
251
252
253
254
255
256
257
258
259
```

Substitute the zone for the one created above if a different domain was used.

This should show the external IP address of the service as the A record for your domain ('@' indicates the record is for the zone itself).

## Clean up

Now that we have verified that ExternalDNS will automatically manage Infoblox DNS records, we can delete the tutorial's
DNS zone:

```
$ curl -kl \
      -X DELETE \
Khris Richardson's avatar
Khris Richardson committed
260
261
      -u ${WAPI_USERNAME}:${WAPI_PASSWORD} \
         https://${GRID_HOST}:${WAPI_PORT}/wapi/v${WAPI_VERSION}/zone_auth?fqdn=example.com
262
```