sigs.k8s.io/external-dns@v0.14.1/docs/tutorials/civo.md (about) 1 # Setting up ExternalDNS for Services on Civo 2 3 This tutorial describes how to setup ExternalDNS for usage within a Kubernetes cluster using Civo DNS Manager. 4 5 Make sure to use **>0.13.5** version of ExternalDNS for this tutorial. 6 7 ## Managing DNS with Civo 8 9 If you want to learn about how to use Civo DNS Manager read the following tutorials: 10 11 [An Introduction to Managing DNS](https://www.civo.com/learn/configure-dns) 12 13 ## Get Civo Token 14 15 Copy the token in the settings for your account 16 The environment variable `CIVO_TOKEN` will be needed to run ExternalDNS with Civo. 17 18 ## Deploy ExternalDNS 19 20 Connect your `kubectl` client to the cluster you want to test ExternalDNS with. 21 Then apply one of the following manifests file to deploy ExternalDNS. 22 23 ### Manifest (for clusters without RBAC enabled) 24 25 ```yaml 26 apiVersion: apps/v1 27 kind: Deployment 28 metadata: 29 name: external-dns 30 spec: 31 strategy: 32 type: Recreate 33 selector: 34 matchLabels: 35 app: external-dns 36 template: 37 metadata: 38 labels: 39 app: external-dns 40 spec: 41 containers: 42 - name: external-dns 43 image: registry.k8s.io/external-dns/external-dns:v0.14.0 44 args: 45 - --source=service # ingress is also possible 46 - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above. 47 - --provider=civo 48 env: 49 - name: CIVO_TOKEN 50 value: "YOUR_CIVO_API_TOKEN" 51 ``` 52 53 ### Manifest (for clusters with RBAC enabled) 54 55 ```yaml 56 apiVersion: v1 57 kind: ServiceAccount 58 metadata: 59 name: external-dns 60 --- 61 apiVersion: rbac.authorization.k8s.io/v1 62 kind: ClusterRole 63 metadata: 64 name: external-dns 65 rules: 66 - apiGroups: [""] 67 resources: ["services","endpoints","pods"] 68 verbs: ["get","watch","list"] 69 - apiGroups: ["extensions","networking.k8s.io"] 70 resources: ["ingresses"] 71 verbs: ["get","watch","list"] 72 - apiGroups: [""] 73 resources: ["nodes"] 74 verbs: ["list"] 75 --- 76 apiVersion: rbac.authorization.k8s.io/v1 77 kind: ClusterRoleBinding 78 metadata: 79 name: external-dns-viewer 80 roleRef: 81 apiGroup: rbac.authorization.k8s.io 82 kind: ClusterRole 83 name: external-dns 84 subjects: 85 - kind: ServiceAccount 86 name: external-dns 87 namespace: default 88 --- 89 apiVersion: apps/v1 90 kind: Deployment 91 metadata: 92 name: external-dns 93 spec: 94 strategy: 95 type: Recreate 96 selector: 97 matchLabels: 98 app: external-dns 99 template: 100 metadata: 101 labels: 102 app: external-dns 103 spec: 104 serviceAccountName: external-dns 105 containers: 106 - name: external-dns 107 image: registry.k8s.io/external-dns/external-dns:v0.14.0 108 args: 109 - --source=service # ingress is also possible 110 - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above. 111 - --provider=civo 112 env: 113 - name: CIVO_TOKEN 114 value: "YOUR_CIVO_API_TOKEN" 115 ``` 116 117 ## Deploying an Nginx Service 118 119 Create a service file called 'nginx.yaml' with the following contents: 120 121 ```yaml 122 apiVersion: apps/v1 123 kind: Deployment 124 metadata: 125 name: nginx 126 spec: 127 selector: 128 matchLabels: 129 app: nginx 130 template: 131 metadata: 132 labels: 133 app: nginx 134 spec: 135 containers: 136 - image: nginx 137 name: nginx 138 ports: 139 - containerPort: 80 140 --- 141 apiVersion: v1 142 kind: Service 143 metadata: 144 name: nginx 145 annotations: 146 external-dns.alpha.kubernetes.io/hostname: my-app.example.com 147 spec: 148 selector: 149 app: nginx 150 type: LoadBalancer 151 ports: 152 - protocol: TCP 153 port: 80 154 targetPort: 80 155 ``` 156 157 Note the annotation on the service; use the same hostname as the Civo DNS zone created above. 158 159 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. 160 161 Create the deployment and service: 162 163 ```console 164 $ kubectl create -f nginx.yaml 165 ``` 166 167 Depending where you run your service it can take a little while for your cloud provider to create an external IP for the service. 168 169 Once the service has an external IP assigned, ExternalDNS will notice the new service IP address and synchronize the Civo DNS records. 170 171 ## Verifying Civo DNS records 172 173 Check your [Civo UI](https://www.civo.com/account/dns) to view the records for your Civo DNS zone. 174 175 Click on the zone for the one created above if a different domain was used. 176 177 This should show the external IP address of the service as the A record for your domain. 178 179 ## Cleanup 180 181 Now that we have verified that ExternalDNS will automatically manage Civo DNS records, we can delete the tutorial's example: 182 183 ``` 184 $ kubectl delete service -f nginx.yaml 185 $ kubectl delete service -f externaldns.yaml 186 ```