Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Add CoreDNS template for community-catalog #746

Merged
merged 4 commits into from
Mar 1, 2018
Merged

Add CoreDNS template for community-catalog #746

merged 4 commits into from
Mar 1, 2018

Conversation

Jason-ZW
Copy link

Hi,all:

This PR added coredns for community-catalog.

Details as below:

CoreDNS image: coredns/coredns:1.0.1

Use confd(backend rancher) sidekick generate CoreDNS's Corefile.

Currently CoreDNS for this catalog only support etcd backend.If you want to use Kubernetes backend,please use coredns helm chart.

  • support 7+ plugins, user can customization plugin through catalog template.

  • support A/AAAA,PTR records.

  • support forward

  • support upstream

If you want to learn more, please see README documentation.

Hope this PR can be merged.

Best Regards!

version: 0.8.0
category: External DNS
labels:
io.rancher.orchestration.supported: 'cattle,mesos,swarm,kubernetes'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only cattle here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niusmallnan only cattle, because for kubernetes it already had coredns helm chart, which better support for kubernetes.

- 53:53/tcp
- 53:53/udp
volumes_from:
- data

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a unified indentation

@Jason-ZW Jason-ZW changed the title Add CoreDNS template for community-catalog WIP: Add CoreDNS template for community-catalog Feb 28, 2018
@Jason-ZW Jason-ZW changed the title WIP: Add CoreDNS template for community-catalog Add CoreDNS template for community-catalog Feb 28, 2018
- Log plugin support: weather to enable log plugin.
- Proxy plugin support: weather to enable proxy plugin.
- Cache plugin support: weather to enable cache plugin.
- Loadbalance plugin support: weatherto enable loadbalance plugin.
Copy link

@niusmallnan niusmallnan Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weatherto is a typo.
whether?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed.

label: "Forward addresses"
description: "The address which to be forwarded DNS query."
type: "string"
default: "8.8.8.8:53,4.4.4.4:53"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to use 8.8.4.4?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my mistake.Already fixed.

@@ -0,0 +1,84 @@
.catalog:
name: "CoreDNS"
version: "0.8.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if you use the coredns version.
For users, they may not know the meaning of the 0.8 version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 1.0.1 compatible with coredns version.

volumes_from:
- data
data:
image: zhenyangzhao/coredns-file:v0.8.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if you need a different image here.
Can you reuse the coredns/coredns image? If not, it's ok.
It's up to you.

Copy link
Author

@Jason-ZW Jason-ZW Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this can not be reused.

@@ -0,0 +1,84 @@
.catalog:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use compose version 2 notation??

-.catalog:
+version: '2'
+catalog:

strategy: recreate
request_line: GET "/health" "HTTP/1.0"
reinitializing_timeout: 60000

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use compose version 2 notation??

-coredns:
-  scale: 1
-  health_check:
-    response_timeout: 4000
-    healthy_threshold: 2
-    port: 8080
-    unhealthy_threshold: 3
-    initializing_timeout: 60000
-    interval: 2000
-    strategy: recreate
-    request_line: GET "/health" "HTTP/1.0"
-    reinitializing_timeout: 60000
+services:
+  coredns:
+    scale: 1
+    health_check:
+      response_timeout: 4000
+      healthy_threshold: 2
+      port: 8080
+      unhealthy_threshold: 3
+      initializing_timeout: 60000
+      interval: 2000
+      strategy: recreate
+      request_line: GET "/health" "HTTP/1.0"
+      reinitializing_timeout: 60000

PLUGIN_FORWARDS: ${FORWARDS}
volumes:
- /etc/coredns

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use compose version 2 notation??

-coredns:
-  image: coredns/coredns:1.0.1
-  labels:
-    io.rancher.sidekicks: data
-    io.rancher.container.hostname_override: container_name
-  command: [ "-conf", "/etc/coredns/Corefile" ]
-  ports:
-    - 53:53/tcp
-    - 53:53/udp
-  volumes_from:
-    - data
-data:
-  image: zhenyangzhao/coredns-file:v0.8.0
-  labels:
-    io.rancher.container.start_once: 'true'
-  environment:
-    PLUGIN_ZONES: ${ZONES}
-    PLUGIN_ROOT_PATH: ${ROOT_PATH}
-    PLUGIN_ETCD_ENDPOINTS: ${ETCD_ENDPOINTS}
-    PLUGIN_UPSTREAM: ${UPSTREAM}
-    PLUGIN_PROM: ${PLUGIN_PROM}
-    PLUGIN_ERRORS: ${PLUGIN_ERRORS}
-    PLUGIN_LOG: ${PLUGIN_LOG}
-    PLUGIN_HEALTH: true
-    PLUGIN_PROXY: ${PLUGIN_PROXY}
-    PLUGIN_CACHE: ${PLUGIN_CACHE}
-    PLUGIN_LOADBALANCE: ${PLUGIN_LOADBALANCE}
-    PLUGIN_FORWARDS: ${FORWARDS}
-  volumes:
-    - /etc/coredns
+version: '2'
+services:
+  coredns:
+    image: coredns/coredns:1.0.1
+    labels:
+      io.rancher.sidekicks: data
+      io.rancher.container.hostname_override: container_name
+    command: [ "-conf", "/etc/coredns/Corefile" ]
+    ports:
+      - 53:53/tcp
+      - 53:53/udp
+    volumes_from:
+      - data
+  data:
+    image: zhenyangzhao/coredns-file:v0.8.0
+    labels:
+      io.rancher.container.start_once: 'true'
+    environment:
+      PLUGIN_ZONES: ${ZONES}
+      PLUGIN_ROOT_PATH: ${ROOT_PATH}
+      PLUGIN_ETCD_ENDPOINTS: ${ETCD_ENDPOINTS}
+      PLUGIN_UPSTREAM: ${UPSTREAM}
+      PLUGIN_PROM: ${PLUGIN_PROM}
+      PLUGIN_ERRORS: ${PLUGIN_ERRORS}
+      PLUGIN_LOG: ${PLUGIN_LOG}
+      PLUGIN_HEALTH: true
+      PLUGIN_PROXY: ${PLUGIN_PROXY}
+      PLUGIN_CACHE: ${PLUGIN_CACHE}
+      PLUGIN_LOADBALANCE: ${PLUGIN_LOADBALANCE}
+      PLUGIN_FORWARDS: ${FORWARDS}
+    volumes:
+      - coredns_data:/etc/coredns
+volumes:
+  coredns_data:
+    driver: local
+    per_container: true

command: [ "-conf", "/etc/coredns/Corefile" ]
ports:
- 53:53/tcp
- 53:53/udp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think if you add a question PUBLISH_PORT, with default value of 53, to be able to publish the service in configurable port??

-    - 53:53/tcp
-    - 53:53/udp
+    - ${PUBLISH_PORT}:${PUBLISH_PORT}/tcp
+    - ${PUBLISH_PORT}:${PUBLISH_PORT}/udp

Also a modification at line 1 of https://github.com/Jason-ZW/Dockerfile/blob/master/coredns/Corefile.tmpl would be needed.

-.:53 {
+.:{{ getenv "PUBLISH_PORT" }} {

PLUGIN_PROXY: ${PLUGIN_PROXY}
PLUGIN_CACHE: ${PLUGIN_CACHE}
PLUGIN_LOADBALANCE: ${PLUGIN_LOADBALANCE}
PLUGIN_FORWARDS: ${FORWARDS}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using variable PUBLISH_PORT

+    PUBLISH_PORT: ${PUBLISH_PORT}

description: "Etcd service endpoints."
type: "string"
default: "http://localhost:2379"
required: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside container will be already running an etcd service?? If not, default value wouldn't work...
May be it'd be better to leave blank default value, to force users to set the correct etcd endpoints. btw, multiple values are allowed??

@rawmind0
Copy link
Contributor

rawmind0 commented Mar 1, 2018

Hi @Jason-ZW , thanks for the PR and contribute. :)

Please, take a look to the changes requested.

@Jason-ZW
Copy link
Author

Jason-ZW commented Mar 1, 2018

@rawmind0 Thanks for reply me. I have modified the code according to all the Suggestions. Could you please to review it again?
Thanks a lot.

@rawmind0
Copy link
Contributor

rawmind0 commented Mar 1, 2018

@Jason-ZW , thanks for the changes.

The package is right now, but there is a little error at Corefile.tmpl. I've opened a PR to fix it, please take a look. Jason-ZW/Dockerfile#1

Another question, sidekick has to keep running?? It's getting config from env vars, in which circumstances config could automatically change?? May be better to run confd with --onetime and sidekick as run once and network_mode: none?? Config would be updated running again sidekick.

@Jason-ZW
Copy link
Author

Jason-ZW commented Mar 1, 2018

@rawmind0 Already removed run_once label from sidekick container. Already added io.rancher.container.pull_image: always on sidekick container.

@rawmind0
Copy link
Contributor

rawmind0 commented Mar 1, 2018

Then, sidekick needs to keep running?? It's getting config from env vars, in which circumstances config could automatically get updated??

@Jason-ZW
Copy link
Author

Jason-ZW commented Mar 1, 2018

@rawmind0 Sorry for reply later. I just reviewed coredns's docs, there is no way to refresh server's config but restart or maybe i'm not found.So i rollback the code to make sidekick container start_once=true. Dockerfile already added -onetime parameter.Thanks a lot.

@rawmind0
Copy link
Contributor

rawmind0 commented Mar 1, 2018

Thanks, i think better like that. Other point, why are you using rancher backend in confd execution?? You are just getting data from env variables, you don't need metadata backend connection.

You could use env backend confd -onetime -backend env and disable network at sidekick network_mode: none. Tested and working fine.

Please, take a look to the changes requested.

PLUGIN_FORWARDS: ${FORWARDS}
PUBLISH_PORT: ${PUBLISH_PORT}
volumes:
- coredns_data:/etc/coredns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using env backend and disabling network at sidekick.

+    network_mode: none
+    entrypoint:
+      - confd 
+      - -backend 
+      - env
+      - -onetime

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rawmind0 Fixed as you said. :)

@rawmind0
Copy link
Contributor

rawmind0 commented Mar 1, 2018

@Jason-ZW , thanks for the changes...

LGTM...

@rawmind0 rawmind0 merged commit 8ef1b8c into rancher:master Mar 1, 2018
@Jason-ZW
Copy link
Author

Jason-ZW commented Mar 2, 2018

@rawmind0 Thank you for your patience.:)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants