sigs.k8s.io/external-dns@v0.14.1/docs/tutorials/vultr.md (about)

     1  # Setting up ExternalDNS for Services on Vultr
     2  
     3  This tutorial describes how to setup ExternalDNS for usage within a Kubernetes cluster using Vultr DNS.
     4  
     5  Make sure to use **>=0.6** version of ExternalDNS for this tutorial.
     6  
     7  ## Managing DNS with Vultr
     8  
     9  If you want to read up on vultr DNS service you can read the following tutorial: 
    10  [Introduction to Vultr DNS](https://www.vultr.com/docs/introduction-to-vultr-dns)
    11  
    12  Create a new DNS Zone where you want to create your records in. For the examples we will be using `example.com`
    13  
    14  ## Creating Vultr Credentials
    15  
    16  You will need to create a new API Key which can be found on the [Vultr Dashboard](https://my.vultr.com/settings/#settingsapi).
    17  
    18  The environment variable `VULTR_API_KEY` will be needed to run ExternalDNS with Vultr.
    19  
    20  ## Deploy ExternalDNS
    21  
    22  Connect your `kubectl` client to the cluster you want to test ExternalDNS with.
    23  Then apply one of the following manifests file to deploy ExternalDNS.
    24  
    25  ### Manifest (for clusters without RBAC enabled)
    26  
    27  ```yaml
    28  apiVersion: apps/v1
    29  kind: Deployment
    30  metadata:
    31    name: external-dns
    32  spec:
    33    strategy:
    34      type: Recreate
    35    selector:
    36      matchLabels:
    37        app: external-dns
    38    template:
    39      metadata:
    40        labels:
    41          app: external-dns
    42      spec:
    43        containers:
    44        - name: external-dns
    45          image: registry.k8s.io/external-dns/external-dns:v0.14.0
    46          args:
    47          - --source=service # ingress is also possible
    48          - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above.
    49          - --provider=vultr
    50          env:
    51          - name: VULTR_API_KEY
    52            value: "YOU_VULTR_API_KEY"
    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"]
    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        serviceAccountName: external-dns
   107        containers:
   108        - name: external-dns
   109          image: registry.k8s.io/external-dns/external-dns:v0.14.0
   110          args:
   111          - --source=service # ingress is also possible
   112          - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above.
   113          - --provider=vultr
   114          env:
   115          - name: VULTR_API_KEY
   116            value: "YOU_VULTR_API_KEY"
   117  ```
   118  
   119  ## Deploying a Nginx Service
   120  
   121  Create a service file called 'nginx.yaml' with the following contents:
   122  
   123  ```yaml
   124  apiVersion: apps/v1
   125  kind: Deployment
   126  metadata:
   127    name: nginx
   128  spec:
   129    selector:
   130      matchLabels:
   131        app: nginx
   132    template:
   133      metadata:
   134        labels:
   135          app: nginx
   136      spec:
   137        containers:
   138        - image: nginx
   139          name: nginx
   140          ports:
   141          - containerPort: 80
   142  ---
   143  apiVersion: v1
   144  kind: Service
   145  metadata:
   146    name: nginx
   147    annotations:
   148      external-dns.alpha.kubernetes.io/hostname: my-app.example.com
   149  spec:
   150    selector:
   151      app: nginx
   152    type: LoadBalancer
   153    ports:
   154      - protocol: TCP
   155        port: 80
   156        targetPort: 80
   157  ```
   158  
   159  Note the annotation on the service; use the same hostname as the Vultr DNS zone created above.
   160  
   161  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.
   162  
   163  Create the deployment and service:
   164  
   165  ```console
   166  $ kubectl create -f nginx.yaml
   167  ```
   168  
   169  Depending where you run your service it can take a little while for your cloud provider to create an external IP for the service.
   170  
   171  Once the service has an external IP assigned, ExternalDNS will notice the new service IP address and synchronize the Vultr DNS records.
   172  
   173  ## Verifying Vultr DNS records
   174  
   175  Check your [Vultr UI](https://my.vultr.com/dns/) to view the records for your Vultr DNS zone.
   176  
   177  Click on the zone for the one created above if a different domain was used.
   178  
   179  This should show the external IP address of the service as the A record for your domain.
   180  
   181  ## Cleanup
   182  
   183  Now that we have verified that ExternalDNS will automatically manage Vultr DNS records, we can delete the tutorial's example:
   184  
   185  ```
   186  $ kubectl delete service -f nginx.yaml
   187  $ kubectl delete service -f externaldns.yaml
   188  ```