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

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