aboutsummaryrefslogtreecommitdiff
path: root/plugin/k8s_external/setup.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-12-14 09:41:51 +0000
committerGravatar GitHub <noreply@github.com> 2018-12-14 09:41:51 +0000
commitc1c98924c3733b853115c62adc1a2b5978ae2df3 (patch)
tree6006978128c2ffd02eb9c5eaaeb16993f38f205b /plugin/k8s_external/setup.go
parentd9880681c3b28f8506e2a5b15bbc404b2a155b00 (diff)
downloadcoredns-c1c98924c3733b853115c62adc1a2b5978ae2df3.tar.gz
coredns-c1c98924c3733b853115c62adc1a2b5978ae2df3.tar.zst
coredns-c1c98924c3733b853115c62adc1a2b5978ae2df3.zip
Add new plugin: external - resolve k8s ingress and LB address with external names (#2379)
* Add new plugin: external This plugin works in conjunction with the kubernetes plugin and exports ingress and LB addresses as DNS records. It bypasses backend.go and backend_lookup.go flow because it is not needed. README, tests are implemented. The tests only exercise the unit tests, this has not been tested in any ci. Signed-off-by: Miek Gieben <miek@miek.nl> * Rename to k8s_external Signed-off-by: Miek Gieben <miek@miek.nl> * go gen Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/k8s_external/setup.go')
-rw-r--r--plugin/k8s_external/setup.go86
1 files changed, 86 insertions, 0 deletions
diff --git a/plugin/k8s_external/setup.go b/plugin/k8s_external/setup.go
new file mode 100644
index 000000000..ede34c6ce
--- /dev/null
+++ b/plugin/k8s_external/setup.go
@@ -0,0 +1,86 @@
+package external
+
+import (
+ "strconv"
+
+ "github.com/coredns/coredns/core/dnsserver"
+ "github.com/coredns/coredns/plugin"
+
+ "github.com/mholt/caddy"
+)
+
+func init() {
+ caddy.RegisterPlugin("k8s_external", caddy.Plugin{
+ ServerType: "dns",
+ Action: setup,
+ })
+}
+
+func setup(c *caddy.Controller) error {
+ e, err := parse(c)
+ if err != nil {
+ return plugin.Error("k8s_external", err)
+ }
+
+ // Do this in OnStartup, so all plugins have been initialized.
+ c.OnStartup(func() error {
+ m := dnsserver.GetConfig(c).Handler("kubernetes")
+ if m == nil {
+ return nil
+ }
+ if x, ok := m.(Externaler); ok {
+ e.externalFunc = x.External
+ e.externalAddrFunc = x.ExternalAddress
+ }
+ return nil
+ })
+
+ dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
+ e.Next = next
+ return e
+ })
+
+ return nil
+}
+
+func parse(c *caddy.Controller) (*External, error) {
+ e := New()
+
+ for c.Next() { // external
+ zones := c.RemainingArgs()
+ e.Zones = zones
+ if len(zones) == 0 {
+ e.Zones = make([]string, len(c.ServerBlockKeys))
+ copy(e.Zones, c.ServerBlockKeys)
+ }
+ for i, str := range e.Zones {
+ e.Zones[i] = plugin.Host(str).Normalize()
+ }
+ for c.NextBlock() {
+ switch c.Val() {
+ case "ttl":
+ args := c.RemainingArgs()
+ if len(args) == 0 {
+ return nil, c.ArgErr()
+ }
+ t, err := strconv.Atoi(args[0])
+ if err != nil {
+ return nil, err
+ }
+ if t < 0 || t > 3600 {
+ return nil, c.Errf("ttl must be in range [0, 3600]: %d", t)
+ }
+ e.ttl = uint32(t)
+ case "apex":
+ args := c.RemainingArgs()
+ if len(args) == 0 {
+ return nil, c.ArgErr()
+ }
+ e.apex = args[0]
+ default:
+ return nil, c.Errf("unknown property '%s'", c.Val())
+ }
+ }
+ }
+ return e, nil
+}
-with-md-support'>fork/markdoc-poc-with-md-support Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/examples/docs/src/pages (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-04-26Revert "fix: replace serialize-javascript & random-bytes with custom internal...Gravatar Nate Moore 7-565/+215
2022-04-26[ci] formatGravatar okikio 2-271/+315
2022-04-26fix: replace serialize-javascript & random-bytes with custom internal modulesGravatar Okiki 7-215/+521
2022-04-26[ci] release (#3182)create-astro@0.10.0astro@1.0.0-beta.18@astrojs/vercel@0.1.4@astrojs/tailwind@0.2.1@astrojs/svelte@0.1.2@astrojs/netlify@0.3.3Gravatar github-actions[bot] 54-146/+130
2022-04-26[ci] formatGravatar matthewp 1-1/+1
2022-04-26fix(vercel): `trailingSlash` fix for non-html pages (#3185)Gravatar Juan Martín Seery 2-29/+42
2022-04-26Prevent watcher from running during the build (#3207)Gravatar Matthew Phillips 2-0/+9
2022-04-26Fix lockfile (#3210)Gravatar Juan Martín Seery 1-6/+0
2022-04-26Add missing is:raw in AstroBuiltinAttributes (#3209)Gravatar Erika 2-0/+6
2022-04-26Feat: support `astro add` without npm installing (#3183)Gravatar Ben Holmes 6-30/+49
2022-04-26Add Astro attributes to svg elements (#3205)Gravatar Erika 2-1/+9
2022-04-26[ci] formatGravatar bholmesdev 2-9/+9
2022-04-26Feat: `create astro` add install step (#3190)Gravatar Ben Holmes 7-162/+299
2022-04-26[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-25fix(markdown): file.url fixes (#3198)Gravatar Juan Martín Seery 11-10/+149
2022-04-25[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-24add vite to licenseGravatar Fred K. Schott 2-24/+29
2022-04-24feat(markdown): Improved types (#3191)Gravatar Juan Martín Seery 3-6/+47
2022-04-24[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-23[ci] collect statsGravatar FredKSchott 1-0/+1