cloudstack

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

README

cloudstack

cloudstack is a CoreDNS plugin for Apache CloudStack.

Name

cloudstack - adds the ability to convert CloudStack server names into their public IPs.

Description

This plugin allows to resolve names build like *.<vm_name>.zone into the corresponding public IP address. It also allows PTR requests (reverse lookup).

VM Instances can be requested if they have a public IP address, with Static NAT enabled. If more than one of these VM instances have the same hostname, then the plugin returns NXDOMAIN for that domain.

Syntax

cloudstack [ZONES...] {
    api_url API_URL
    api_key API_KEY
    api_secret SECRET_KEY
    no_verify_ssl
    ttl SECONDS
    fallthrough [ZONES...]
    reload DURATION
}

With only the directive specified, the cloudstack plugin will default to the zone(s) specified in the server's block. If ZONES is used it specifies all the zones the plugin should be authoritative for. The primary zone, used for PTR requests, is the first non-reverse zone.

  • api_url specifies the CloudStack API URL. It can use "http" or "https" scheme. Defaults to http://localhost:8080/client/api.
  • api_key specifies the API key for the root admin user. Defaults to coredns. Required.
  • api_secret specifies the secret key for the root admin user. Required.
  • no_verify_ssl set this option to skip SSL verification. Optional
  • ttl specifies the DNS TTL of the records generated (forward and reverse). Defaults to 3600 seconds (1 hour).
  • fallthrough If zone matches and no record can be generated, pass request to the next plugin. If [ZONES...] is omitted, then fallthrough happens for all zones for which the plugin is authoritative. If specific zones are listed (for example in-addr.arpa), then only queries for those zones will be subject to fallthrough.
  • reload specifies the duration between two consecutive CloudStack imports. A time of zero seconds disables the feature. Examples of valid durations: "300ms", "1.5h" or "2h45m" are valid duration with units "ns" (nanosecond), "us" (or "µs" for microsecond), "ms" (millisecond), "s" (second), "m" (minute), "h" (hour). Defaults to 30s.

Examples

Use zones from server block:

example.net. {
  cloudstack {
    api_url https://cloudstack.example.net:8080/client/api
    api_key jdJ...5Jp
    api_secret l84...P5k
    no_verify_ssl
    ttl 1800
    fallthrough
  }
}

Provide the zones where the plugin is authoritative:

. {
  cloudstack domain.local 192.168.5.0/24 {
    api_url https://cloudstack.example.net:8080/client/api
    api_key jdJ...5Jp
    api_secret l84...P5k
    reload 60s
  }
}

Ready

This plugin reports readiness to the ready plugin. This will happen after it has synced to the CloudStack API.

Metrics

If monitoring is enabled (via the prometheus plugin) then the following metrics are exported:

  • coredns_cloudstack_requests_total - Counter of requests made.
  • coredns_cloudstack_entries - Number of CloudStack Public IP addresses with static NAT.
  • coredns_cloudstack_reload_timestamp_seconds - Timestamp of the last valid reload of CloudStack IP addresses.
  • coredns_cloudstack_api_request_duration_seconds - Histogram of the time (in seconds) each CloudStack API request took.

See also

License

Copyright 2018-2022 Apalia

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this project except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	sync.RWMutex

	Next             plugin.Handler
	Fall             fall.F
	Options          Options
	Zones            []string
	PrimaryZoneIndex int

	HasSynced          bool
	IPAddressesByName  map[string]net.IP
	NamesByIPAddresses map[string]string
	// contains filtered or unexported fields
}

Handler is the handler of this CloudStack plugin.

func NewHandler

func NewHandler(
	zones []string,
) *Handler

NewHandler creates a new instance of Handler.

func (*Handler) Name

func (h *Handler) Name() string

Name implements the plugin.Handler interface.

func (*Handler) Ready

func (h *Handler) Ready() bool

Ready implements the ready.Readiness interface (github.com/coredns/coredns/plugin/ready).

func (*Handler) ServeDNS

func (h *Handler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

type Options

type Options struct {
	APIUrl    string
	APIKey    string
	APISecret string
	VerifySsl bool
	TTL       uint32
	Reload    time.Duration
}

Options contains plugin settings.

func NewOptions

func NewOptions() Options

NewOptions creates a new Options with default values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL