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

     1  # Setting up ExternalDNS for Services on GoDaddy
     2  
     3  This tutorial describes how to setup ExternalDNS for use within a
     4  Kubernetes cluster using GoDaddy DNS.
     5  
     6  Make sure to use **>=0.6** version of ExternalDNS for this tutorial.
     7  
     8  ## Creating a zone with GoDaddy DNS
     9  
    10  If you are new to GoDaddy, we recommend you first read the following
    11  instructions for creating a zone.
    12  
    13  [Creating a zone using the GoDaddy web console](https://www.godaddy.com/)
    14  
    15  [Creating a zone using the GoDaddy API](https://developer.godaddy.com/)
    16  
    17  ## Creating GoDaddy API key
    18  
    19  You first need to create an API Key.
    20  
    21  Using the [GoDaddy documentation](https://developer.godaddy.com/getstarted) you will have your `API key` and `API secret`
    22  
    23  ## Deploy ExternalDNS
    24  
    25  Connect your `kubectl` client to the cluster with which you want to test ExternalDNS, and then apply one of the following manifest files for deployment:
    26  
    27  ### Manifest (for clusters without RBAC enabled)
    28  
    29  ```yaml
    30  apiVersion: apps/v1
    31  kind: Deployment
    32  metadata:
    33    name: external-dns
    34  spec:
    35    strategy:
    36      type: Recreate
    37    selector:
    38      matchLabels:
    39        app: external-dns
    40    template:
    41      metadata:
    42        labels:
    43          app: external-dns
    44      spec:
    45        containers:
    46        - name: external-dns
    47          image: registry.k8s.io/external-dns/external-dns:v0.14.0
    48          args:
    49          - --source=service # ingress is also possible
    50          - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above.
    51          - --provider=godaddy
    52          - --txt-prefix=external-dns. # In case of multiple k8s cluster
    53          - --txt-owner-id=owner-id # In case of multiple k8s cluster
    54          - --godaddy-api-key=<Your API Key>
    55          - --godaddy-api-secret=<Your API secret>
    56  ```
    57  
    58  ### Manifest (for clusters with RBAC enabled)
    59  
    60  ```yaml
    61  apiVersion: v1
    62  kind: ServiceAccount
    63  metadata:
    64    name: external-dns
    65  ---
    66  apiVersion: rbac.authorization.k8s.io/v1
    67  kind: ClusterRole
    68  metadata:
    69    name: external-dns
    70  rules:
    71  - apiGroups: [""]
    72    resources: ["services"]
    73    verbs: ["get","watch","list"]
    74  - apiGroups: [""]
    75    resources: ["pods"]
    76    verbs: ["get","watch","list"]
    77  - apiGroups: ["extensions","networking.k8s.io"]
    78    resources: ["ingresses"]
    79    verbs: ["get","watch","list"]
    80  - apiGroups: [""]
    81    resources: ["nodes"]
    82    verbs: ["list","watch"]
    83  - apiGroups: [""]
    84    resources: ["endpoints"]
    85    verbs: ["get","watch","list"]
    86  ---
    87  apiVersion: rbac.authorization.k8s.io/v1
    88  kind: ClusterRoleBinding
    89  metadata:
    90    name: external-dns-viewer
    91  roleRef:
    92    apiGroup: rbac.authorization.k8s.io
    93    kind: ClusterRole
    94    name: external-dns
    95  subjects:
    96  - kind: ServiceAccount
    97    name: external-dns
    98    namespace: default
    99  ---
   100  apiVersion: apps/v1
   101  kind: Deployment
   102  metadata:
   103    name: external-dns
   104  spec:
   105    strategy:
   106      type: Recreate
   107    selector:
   108      matchLabels:
   109        app: external-dns
   110    template:
   111      metadata:
   112        labels:
   113          app: external-dns
   114      spec:
   115        serviceAccountName: external-dns
   116        containers:
   117        - name: external-dns
   118          image: registry.k8s.io/external-dns/external-dns:v0.14.0
   119          args:
   120          - --source=service # ingress is also possible
   121          - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above.
   122          - --provider=godaddy
   123          - --txt-prefix=external-dns. # In case of multiple k8s cluster
   124          - --txt-owner-id=owner-id # In case of multiple k8s cluster
   125          - --godaddy-api-key=<Your API Key>
   126          - --godaddy-api-secret=<Your API secret>
   127  ```
   128  
   129  ## Deploying an Nginx Service
   130  
   131  Create a service file called 'nginx.yaml' with the following contents:
   132  
   133  ```yaml
   134  apiVersion: apps/v1
   135  kind: Deployment
   136  metadata:
   137    name: nginx
   138  spec:
   139    selector:
   140      matchLabels:
   141        app: nginx
   142    template:
   143      metadata:
   144        labels:
   145          app: nginx
   146      spec:
   147        containers:
   148        - image: nginx
   149          name: nginx
   150          ports:
   151          - containerPort: 80
   152  ---
   153  apiVersion: v1
   154  kind: Service
   155  metadata:
   156    name: nginx
   157    annotations:
   158      external-dns.alpha.kubernetes.io/hostname: example.com
   159      external-dns.alpha.kubernetes.io/ttl: "120" #optional
   160  spec:
   161    selector:
   162      app: nginx
   163    type: LoadBalancer
   164    ports:
   165      - protocol: TCP
   166        port: 80
   167        targetPort: 80
   168  ```
   169  
   170  **A note about annotations**
   171  
   172  Verify that the annotation on the service uses the same hostname as the GoDaddy DNS zone created above. The annotation may also be a subdomain of the DNS zone (e.g. 'www.example.com').
   173  
   174  The TTL annotation can be used to configure the TTL on DNS records managed by ExternalDNS and is optional. If this annotation is not set, the TTL on records managed by ExternalDNS will default to 10.
   175  
   176  ExternalDNS uses the hostname annotation to determine which services should be registered with DNS. Removing the hostname annotation will cause ExternalDNS to remove the corresponding DNS records.
   177  
   178  ### Create the deployment and service
   179  
   180  ```
   181  $ kubectl create -f nginx.yaml
   182  ```
   183  
   184  Depending on where you run your service, it may take some time for your cloud provider to create an external IP for the service. Once an external IP is assigned, ExternalDNS detects the new service IP address and synchronizes the GoDaddy DNS records.
   185  
   186  ## Verifying GoDaddy DNS records
   187  
   188  Use the GoDaddy web console or API to verify that the A record for your domain shows the external IP address of the services.
   189  
   190  ## Cleanup
   191  
   192  Once you successfully configure and verify record management via ExternalDNS, you can delete the tutorial's example:
   193  
   194  ```
   195  $ kubectl delete -f nginx.yaml
   196  $ kubectl delete -f externaldns.yaml
   197  ```