Documentation ¶
Overview ¶
Package discovery contains functionality to discover the type of etcd used in back up and restore operations as well as what Kubernetes distro is used.
Index ¶
- func CountKeysFor(endpoint string, distro types.KubernetesDistro) (int, int, error)
- func ProbeEtcd(endpoint string) (string, bool, error)
- func ProbeKubernetesDistro(endpoint string) (types.KubernetesDistro, error)
- func Visit2(kapi client.KeysAPI, path string, fn types.Reap) error
- func Visit3(c3 *clientv3.Client, path string, distro types.KubernetesDistro, fn types.Reap) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountKeysFor ¶
CountKeysFor iterates over well-known keys of a given Kubernetes distro and returns the number of keys and their values total size, in the respective key range/subtree.
Example ¶
Shows how to glean stats from etcd by walking well-known keys of a given Kubernetes distro. It assumes that the etcd process is servering on 127.0.0.1:2379 and the vanilla Kubernetes distro is using it.
// define the URL etcd is available at: etcdurl := "http://127.0.0.1:2379" // carry out the stats walk and handle errors as they occur: numkeys, totalsize, err := CountKeysFor(etcdurl, types.Vanilla) if err != nil { log.Fatal(err) return } fmt.Printf("Found %d keys and overall payload size of %d bytes.\n", numkeys, totalsize)
Output: Found 1024 keys and overall payload size of 350876 bytes.
func ProbeEtcd ¶
ProbeEtcd probes an endpoint at path /version to figure which version of etcd it is and in which mode (secure or insecure) it is used.
Example ¶
Shows how to probe etcd to determine which version is running and in which mode (secure or insecure) it is used. It assumes that the etcd process is servering on 127.0.0.1:2379.
// define the URL etcd is available at: etcdurl := "http://127.0.0.1:2379" // carry out the probe and handle errors as they occur: version, secure, err := ProbeEtcd(etcdurl) if err != nil { log.Fatal(err) return } fmt.Printf("Discovered etcd in version %s, running in secure mode: %t\n", version, secure)
Output: Discovered etcd in version 3.1.0, running in secure mode: false
func ProbeKubernetesDistro ¶
func ProbeKubernetesDistro(endpoint string) (types.KubernetesDistro, error)
ProbeKubernetesDistro probes an etcd cluster for which Kubernetes distribution is present by scanning the available keys.
Example ¶
Shows how to probe etcd to determine which Kubernetes distribution is present (if at all) by scanning the available keys. It assumes that the etcd process is servering on 127.0.0.1:2379 and the OpenShift Kubernetes distro is using it.
// define the URL etcd is available at: etcdurl := "http://127.0.0.1:2379" // a textual description of the Kubernetes distro var distro string // carry out the probe and handle errors as they occur: distrotype, err := ProbeKubernetesDistro(etcdurl) if err != nil { log.Fatal(err) return } switch distrotype { case types.Vanilla: distro = "Vanilla Kubernetes" case types.OpenShift: distro = "OpenShift" default: distro = "no Kubernetes distro found" } fmt.Printf("Discovered Kubernetes distro: %s\n", distro)
Output: Discovered Kubernetes distro: OpenShift
Types ¶
This section is empty.