cloudflare_dns_operator/lib.rs
1//! [](https://crates.io/crates/cloudflare-dns-operator)
2//! [](https://docs.rs/cloudflare-dns-operator)
3//! [](/LICENSE)
4//!
5//! [This is a kubernetes operator](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) (custom resource definition + kubernetes controller) to manage cloudflare DNS entries from within kubernetes using the cloudflare API.
6//!
7//! __Note:__ This is an unofficial project and not affiliated in any way with cloudflare.
8//!
9//! ## Installation
10//!
11//! In your kubernetes cluster install the [`crds.yaml`](./crds.yaml) file and a deployment matching
12//! [examples/deployment.yaml](./examples/deployment.yaml). Note that you'll need to set the env var
13//! `CLOUDFLARE_API_TOKEN` to a valid cloudflare API token.
14//!
15//! This sets up the controller as a deployment. It'll watch for `CloudflareDNSRecord` resources and
16//! create/update/delete DNS records in cloudflare.
17//!
18//! You can optionally have the controller check the records by doing DNS lookups from 1.1.1.1. The resolution result
19//! will be reflected in the `status.pending` field of the `CloudflareDNSRecord` resource. For this to be enabled, set
20//! the env var `CHECK_DNS_RESOLUTION` to a human readable duration like `5m` or `1h` or `60s`.
21//!
22//! You can then create a new DNS record like this:
23//!
24//! ```yaml
25//! apiVersion: dns.cloudflare.com/v1alpha1
26//! kind: CloudflareDNSRecord
27//! metadata:
28//! name: my-cloudflare-dns-record
29//! spec:
30//! name: foo.example.com
31//! type: A
32//! ttl: 3600
33//! content:
34//! value: "1.2.3.4"
35//! zone:
36//! name:
37//! value: example.com
38//! comment: "Managed by the Cloudflare DNS Operator"
39//! tags:
40//! - k8s
41//! ```
42//!
43//! You can also automatically expose IPs from LoadBalancer services or external IP services by referencing a service in
44//! the `content` instead of a static IP:
45//!
46//! ```yaml
47//! # ...
48//! content:
49//! service:
50//! name: traefik
51//! namespace: traefik
52//! # ...
53//! ```
54//!
55//! The zone can also be set with a `secret` or `configMap` reference like this:
56//!
57//! ```yaml
58//! # ...
59//! zone:
60//! name:
61//! from:
62//! secret:
63//! name: cloudflare-dns-secret
64//! key: zone-name
65//! # ...
66//! ```
67//!
68//! See [CloudflareDNSRecordSpec](https://docs.rs/cloudflare-dns-operator/latest/cloudflare_dns_operator/resources/struct.CloudflareDNSRecordSpec.html) for more details.
69
70#[macro_use]
71extern crate tracing;
72
73pub mod conditions;
74pub mod context;
75pub mod dns;
76pub mod dns_check;
77pub mod reconcile;
78pub mod resources;
79pub mod services;