kubernetes

package
v0.0.0-...-6e08bca Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// KubednsConfigmap is the header used for defining the kube-dns configmap
	KubednsConfigmap = `apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-dns
  namespace: kube-system
data:
`

	// ExampleNet is an example upstream zone file
	ExampleNet = `` /* 178-byte string literal not displayed */

	CoreDNSLabel   = "k8s-app=kube-dns"
	APIServerLabel = "component=kube-apiserver"
)

configmap is the header used for defining the coredns configmap

Variables

This section is empty.

Functions

func CoreDNSPodIPs

func CoreDNSPodIPs() ([]string, error)

CoreDNSPodIPs return the ips of all coredns pods

func CorednsLogs

func CorednsLogs() string

CorednsLogs returns the current coredns log

func DoIntegrationTest

func DoIntegrationTest(tc test.Case, namespace string) (*dns.Msg, error)

DoIntegrationTest executes a test case

func DoIntegrationTests

func DoIntegrationTests(t *testing.T, testCases []test.Case, namespace string)

DoIntegrationTests executes test cases

func FetchDockerContainerID

func FetchDockerContainerID(containerName string) (string, error)

FetchDockerContainerID fetches the docker container ID from the container name

func HasResourceRestarted

func HasResourceRestarted(label string) (bool, error)

HasResourceRestarted verifies if any of the specified containers in the kube-system namespace has restarted.

func Kubectl

func Kubectl(args string) (result string, err error)

Kubectl executes the kubectl command with the given arguments

func LoadCorefile

func LoadCorefile(corefile string) error

LoadCorefile calls loadCorefileAndZonefile without a zone file

func LoadCorefileAndZonefile

func LoadCorefileAndZonefile(corefile, zonefile string, restart bool) error

LoadCorefileAndZonefile constructs a configmap defining files for the corefile and zone, If restart is true, restarts the coredns pod to load the new configmap, and waits for the coredns pod to be ready.

func LoadKubednsConfigmap

func LoadKubednsConfigmap(stubdata, upstreamdata string) error

func ParseDigAXFR

func ParseDigAXFR(s *bufio.Scanner) (*dns.Msg, error)

ParseDigAXFR specifically parses AXFR responses which have a different format.

func ParseDigResponse

func ParseDigResponse(r string, dp DigParser) ([]*dns.Msg, error)

ParseDigResponse parses dig-like command output and returns a dns.Msg

func ScrapeMetrics

func ScrapeMetrics(t *testing.T) []byte

func StartClientPod

func StartClientPod(namespace string) error

StartClientPod starts a dns client pod in the namespace

func UpstreamServer

func UpstreamServer(t *testing.T, zone, zoneFile string) (func(), *caddy.Instance, string)

UpstreamServer starts a local instance of coredns with the given zone file

func ValidateAXFR

func ValidateAXFR(xfr []dns.RR, expected []dns.RR) []error

ValidateAXFR compares the dns records returned against a set of expected records. It ensures that the axfr response begins and ends with an SOA record. It will only test the first 3 tuples of each A record.

func WaitForClientPodRecord

func WaitForClientPodRecord(namespace string) error

WaitForClientPodRecord waits for the client pod A record to be served by CoreDNS

func WaitNReady

func WaitNReady(maxWait, n int) error

WaitReady waits for n corednses to be ready or times out after maxWait seconds with an error

func WaitReady

func WaitReady(maxWait int) error

WaitReady waits for 1 coredns to be ready or times out after maxWait seconds with an error

Types

type DigParser

type DigParser func(s *bufio.Scanner) (*dns.Msg, error)

DigParser is a function that specialises in parsing different responses from running dig. The regular parseDig parser is acceptable for most tests, whilst the ParseDigAXFR handles this special case.

Jump to

Keyboard shortcuts

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