sigs.k8s.io/external-dns@v0.14.1/docs/tutorials/plural.md (about) 1 # Setting up ExternalDNS for Services on Plural 2 3 This tutorial describes how to setup ExternalDNS for usage within a Kubernetes cluster using Plural DNS. 4 5 Make sure to use **>=0.12.3** version of ExternalDNS for this tutorial. 6 7 ## Creating Plural Credentials 8 9 A secret containing the a Plural access token is needed for this provider. You can get a token for your user [here](https://app.plural.sh/profile/tokens). 10 11 To create the secret you can run `kubectl create secret generic plural-env --from-literal=PLURAL_ACCESS_TOKEN=<replace-with-your-access-token>`. 12 13 ## Deploy ExternalDNS 14 15 Connect your `kubectl` client to the cluster you want to test ExternalDNS with. 16 Then apply one of the following manifests file to deploy ExternalDNS. 17 18 ### Manifest (for clusters without RBAC enabled) 19 20 ```yaml 21 apiVersion: apps/v1 22 kind: Deployment 23 metadata: 24 name: external-dns 25 spec: 26 strategy: 27 type: Recreate 28 selector: 29 matchLabels: 30 app: external-dns 31 template: 32 metadata: 33 labels: 34 app: external-dns 35 spec: 36 containers: 37 - name: external-dns 38 image: registry.k8s.io/external-dns/external-dns:v0.14.0 39 args: 40 - --source=service # ingress is also possible 41 - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above. 42 - --provider=plural 43 - --plural-cluster=example-plural-cluster 44 - --plural-provider=aws # gcp, azure, equinix and kind are also possible 45 env: 46 - name: PLURAL_ACCESS_TOKEN 47 valueFrom: 48 secretKeyRef: 49 key: PLURAL_ACCESS_TOKEN 50 name: plural-env 51 - name: PLURAL_ENDPOINT # (optional) use an alternative endpoint for Plural; defaults to https://app.plural.sh 52 value: https://app.plural.sh 53 ``` 54 55 ### Manifest (for clusters with RBAC enabled) 56 57 ```yaml 58 apiVersion: v1 59 kind: ServiceAccount 60 metadata: 61 name: external-dns 62 --- 63 apiVersion: rbac.authorization.k8s.io/v1 64 kind: ClusterRole 65 metadata: 66 name: external-dns 67 rules: 68 - apiGroups: [""] 69 resources: ["services","endpoints","pods"] 70 verbs: ["get","watch","list"] 71 - apiGroups: ["extensions","networking.k8s.io"] 72 resources: ["ingresses"] 73 verbs: ["get","watch","list"] 74 - apiGroups: [""] 75 resources: ["nodes"] 76 verbs: ["list", "watch"] 77 --- 78 apiVersion: rbac.authorization.k8s.io/v1 79 kind: ClusterRoleBinding 80 metadata: 81 name: external-dns-viewer 82 roleRef: 83 apiGroup: rbac.authorization.k8s.io 84 kind: ClusterRole 85 name: external-dns 86 subjects: 87 - kind: ServiceAccount 88 name: external-dns 89 namespace: default 90 --- 91 apiVersion: apps/v1 92 kind: Deployment 93 metadata: 94 name: external-dns 95 spec: 96 strategy: 97 type: Recreate 98 selector: 99 matchLabels: 100 app: external-dns 101 template: 102 metadata: 103 labels: 104 app: external-dns 105 spec: 106 containers: 107 - name: external-dns 108 image: registry.k8s.io/external-dns/external-dns:v0.14.0 109 args: 110 - --source=service # ingress is also possible 111 - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above. 112 - --provider=plural 113 - --plural-cluster=example-plural-cluster 114 - --plural-provider=aws # gcp, azure, equinix and kind are also possible 115 env: 116 - name: PLURAL_ACCESS_TOKEN 117 valueFrom: 118 secretKeyRef: 119 key: PLURAL_ACCESS_TOKEN 120 name: plural-env 121 - name: PLURAL_ENDPOINT # (optional) use an alternative endpoint for Plural; defaults to https://app.plural.sh 122 value: https://app.plural.sh 123 ``` 124 125 ## Deploying an Nginx Service 126 127 Create a service file called 'nginx.yaml' with the following contents: 128 129 ```yaml 130 apiVersion: apps/v1 131 kind: Deployment 132 metadata: 133 name: nginx 134 spec: 135 selector: 136 matchLabels: 137 app: nginx 138 template: 139 metadata: 140 labels: 141 app: nginx 142 spec: 143 containers: 144 - image: nginx 145 name: nginx 146 ports: 147 - containerPort: 80 148 --- 149 apiVersion: v1 150 kind: Service 151 metadata: 152 name: nginx 153 annotations: 154 external-dns.alpha.kubernetes.io/hostname: example.com 155 spec: 156 selector: 157 app: nginx 158 type: LoadBalancer 159 ports: 160 - protocol: TCP 161 port: 80 162 targetPort: 80 163 ``` 164 165 Note the annotation on the service; use the same hostname as the Plural DNS zone created above. The annotation may also be a subdomain 166 of the DNS zone (e.g. 'www.example.com'). 167 168 By setting the TTL annotation on the service, you have to pass a valid TTL, which must be 120 or above. 169 This annotation is optional, if you won't set it, it will be 1 (automatic) which is 300. 170 171 ExternalDNS uses this annotation to determine what services should be registered with DNS. Removing the annotation 172 will cause ExternalDNS to remove the corresponding DNS records. 173 174 Create the deployment and service: 175 176 ``` 177 $ kubectl create -f nginx.yaml 178 ``` 179 180 Depending where you run your service it can take a little while for your cloud provider to create an external IP for the service. 181 182 Once the service has an external IP assigned, ExternalDNS will notice the new service IP address and synchronize 183 the Plural DNS records. 184 185 ## Verifying Plural DNS records 186 187 Check your [Plural domain overview](https://app.plural.sh/account/domains) to view the domains associated with your Plural account. There you can view the records for each domain. 188 189 The records should show the external IP address of the service as the A record for your domain. 190 191 ## Cleanup 192 193 Now that we have verified that ExternalDNS will automatically manage Plural DNS records, we can delete the tutorial's example: 194 195 ``` 196 $ kubectl delete -f nginx.yaml 197 $ kubectl delete -f externaldns.yaml