...

Package ingress

import "k8s.io/kubernetes/test/e2e/framework/ingress"
Overview
Index

Overview ▾

Index ▾

Constants
func BuildInsecureClient(timeout time.Duration) *http.Client
func DescribeIng(ns string)
func GenerateRSACerts(host string, isCA bool) ([]byte, []byte, error)
func PollURL(ctx context.Context, route, host string, timeout time.Duration, interval time.Duration, httpClient *http.Client, expectUnreachable bool) error
func SimpleGET(ctx context.Context, c *http.Client, url, host string) (string, error)
type ConformanceTests
    func CreateIngressComformanceTests(ctx context.Context, jig *TestJig, ns string, annotations map[string]string) []ConformanceTests
type E2ELogger
    func (l *E2ELogger) Errorf(format string, args ...interface{})
    func (l *E2ELogger) Infof(format string, args ...interface{})
type NegStatus
type NginxIngressController
    func (cont *NginxIngressController) Init(ctx context.Context)
    func (cont *NginxIngressController) TearDown(ctx context.Context)
type TestJig
    func NewIngressTestJig(c clientset.Interface) *TestJig
    func (j *TestJig) AddHTTPS(ctx context.Context, secretName string, hosts ...string)
    func (j *TestJig) ConstructFirewallForIngress(ctx context.Context, firewallRuleName string, nodeTags []string) *compute.Firewall
    func (j *TestJig) CreateIngress(ctx context.Context, manifestPath, ns string, ingAnnotations map[string]string, svcAnnotations map[string]string)
    func (j *TestJig) DeleteTestResource(ctx context.Context, cs clientset.Interface, deploy *appsv1.Deployment, svc *v1.Service, ing *networkingv1.Ingress) []error
    func (j *TestJig) GetDistinctResponseFromIngress(ctx context.Context) (sets.String, error)
    func (j *TestJig) GetIngressNodePorts(ctx context.Context, includeDefaultBackend bool) []string
    func (j *TestJig) GetRootCA(secretName string) (rootCA []byte)
    func (j *TestJig) GetServicePorts(ctx context.Context, includeDefaultBackend bool) map[string]v1.ServicePort
    func (j *TestJig) PrepareTLSSecret(ctx context.Context, namespace, secretName string, hosts ...string) error
    func (j *TestJig) RemoveHTTPS(ctx context.Context, secretName string)
    func (j *TestJig) SetHTTPS(ctx context.Context, secretName string, hosts ...string)
    func (j *TestJig) SetUpBacksideHTTPSIngress(ctx context.Context, cs clientset.Interface, namespace string, staticIPName string) (*appsv1.Deployment, *v1.Service, *networkingv1.Ingress, error)
    func (j *TestJig) TryDeleteIngress(ctx context.Context)
    func (j *TestJig) Update(ctx context.Context, update func(ing *networkingv1.Ingress))
    func (j *TestJig) VerifyURL(ctx context.Context, route, host string, iterations int, interval time.Duration, httpClient *http.Client) error
    func (j *TestJig) WaitForGivenIngressWithTimeout(ctx context.Context, ing *networkingv1.Ingress, waitForNodePort bool, timeout time.Duration) error
    func (j *TestJig) WaitForIngress(ctx context.Context, waitForNodePort bool)
    func (j *TestJig) WaitForIngressAddress(ctx context.Context, c clientset.Interface, ns, ingName string, timeout time.Duration) (string, error)
    func (j *TestJig) WaitForIngressToStable(ctx context.Context)
    func (j *TestJig) WaitForIngressWithCert(ctx context.Context, waitForNodePort bool, knownHosts []string, cert []byte) error
type TestLogger

Package files

ingress_utils.go

Constants

const (

    // IngressClassKey is ingress class annotation defined in ingress repository.
    // TODO: All these annotations should be reused from
    // ingress-gce/pkg/annotations instead of duplicating them here.
    IngressClassKey = "kubernetes.io/ingress.class"

    // MulticlusterIngressClassValue is ingress class annotation value for multi cluster ingress.
    MulticlusterIngressClassValue = "gce-multi-cluster"

    // IngressStaticIPKey is static IP annotation defined in ingress repository.
    IngressStaticIPKey = "kubernetes.io/ingress.global-static-ip-name"

    // IngressAllowHTTPKey is Allow HTTP annotation defined in ingress repository.
    IngressAllowHTTPKey = "kubernetes.io/ingress.allow-http"

    // IngressPreSharedCertKey is Pre-shared-cert annotation defined in ingress repository.
    IngressPreSharedCertKey = "ingress.gcp.kubernetes.io/pre-shared-cert"

    // ServiceApplicationProtocolKey annotation defined in ingress repository.
    ServiceApplicationProtocolKey = "service.alpha.kubernetes.io/app-protocols"

    // IngressManifestPath is the parent path to yaml test manifests.
    IngressManifestPath = "test/e2e/testing-manifests/ingress"

    // GCEIngressManifestPath is the parent path to GCE-specific yaml test manifests.
    GCEIngressManifestPath = IngressManifestPath + "/gce"

    // IngressReqTimeout is the timeout on a single http request.
    IngressReqTimeout = 10 * time.Second

    // NEGAnnotation is NEG annotation.
    NEGAnnotation = "cloud.google.com/neg"

    // NEGStatusAnnotation is NEG status annotation.
    NEGStatusAnnotation = "cloud.google.com/neg-status"

    // StatusPrefix is prefix for annotation keys used by the ingress controller to specify the
    // names of GCP resources such as forwarding rules, url maps, target proxies, etc
    // that it created for the corresponding ingress.
    StatusPrefix = "ingress.kubernetes.io"
)

func BuildInsecureClient

func BuildInsecureClient(timeout time.Duration) *http.Client

BuildInsecureClient returns an insecure http client. Can be used for "curl -k".

func DescribeIng

func DescribeIng(ns string)

DescribeIng describes information of ingress by running kubectl describe ing.

func GenerateRSACerts

func GenerateRSACerts(host string, isCA bool) ([]byte, []byte, error)

GenerateRSACerts generates a basic self signed certificate using a key length of rsaBits, valid for validFor time.

func PollURL

func PollURL(ctx context.Context, route, host string, timeout time.Duration, interval time.Duration, httpClient *http.Client, expectUnreachable bool) error

PollURL polls till the url responds with a healthy http code. If expectUnreachable is true, it breaks on first non-healthy http code instead.

func SimpleGET

func SimpleGET(ctx context.Context, c *http.Client, url, host string) (string, error)

SimpleGET executes a get on the given url, returns error if non-200 returned.

type ConformanceTests

ConformanceTests contains a closure with an entry and exit log line.

type ConformanceTests struct {
    EntryLog string
    Execute  func()
    ExitLog  string
}

func CreateIngressComformanceTests

func CreateIngressComformanceTests(ctx context.Context, jig *TestJig, ns string, annotations map[string]string) []ConformanceTests

CreateIngressComformanceTests generates an slice of sequential test cases: a simple http ingress, ingress with HTTPS, ingress HTTPS with a modified hostname, ingress https with a modified URLMap

type E2ELogger

E2ELogger is test logger.

type E2ELogger struct{}

func (*E2ELogger) Errorf

func (l *E2ELogger) Errorf(format string, args ...interface{})

Errorf outputs log.

func (*E2ELogger) Infof

func (l *E2ELogger) Infof(format string, args ...interface{})

Infof outputs log.

type NegStatus

NegStatus contains name and zone of the Network Endpoint Group resources associated with this service. Needs to be consistent with the NEG internal structs in ingress-gce.

type NegStatus struct {
    // NetworkEndpointGroups returns the mapping between service port and NEG
    // resource. key is service port, value is the name of the NEG resource.
    NetworkEndpointGroups map[int32]string `json:"network_endpoint_groups,omitempty"`
    Zones                 []string         `json:"zones,omitempty"`
}

type NginxIngressController

NginxIngressController manages implementation details of Ingress on Nginx.

type NginxIngressController struct {
    Ns string

    Client clientset.Interface
    // contains filtered or unexported fields
}

func (*NginxIngressController) Init

func (cont *NginxIngressController) Init(ctx context.Context)

Init initializes the NginxIngressController

func (*NginxIngressController) TearDown

func (cont *NginxIngressController) TearDown(ctx context.Context)

TearDown cleans up the NginxIngressController.

type TestJig

TestJig holds the relevant state and parameters of the ingress test.

type TestJig struct {
    Client clientset.Interface
    Logger TestLogger

    RootCAs map[string][]byte
    Address string
    Ingress *networkingv1.Ingress
    // class was the value of the annotation keyed under `kubernetes.io/ingress.class`.
    // A new ingressClassName field has been added that is used to reference the IngressClass.
    // It's added to all ingresses created by this jig.
    Class string

    // The interval used to poll urls
    PollInterval time.Duration
}

func NewIngressTestJig

func NewIngressTestJig(c clientset.Interface) *TestJig

NewIngressTestJig instantiates struct with client

func (*TestJig) AddHTTPS

func (j *TestJig) AddHTTPS(ctx context.Context, secretName string, hosts ...string)

AddHTTPS updates the ingress to add this secret for these hosts.

func (*TestJig) ConstructFirewallForIngress

func (j *TestJig) ConstructFirewallForIngress(ctx context.Context, firewallRuleName string, nodeTags []string) *compute.Firewall

ConstructFirewallForIngress returns the expected GCE firewall rule for the ingress resource

func (*TestJig) CreateIngress

func (j *TestJig) CreateIngress(ctx context.Context, manifestPath, ns string, ingAnnotations map[string]string, svcAnnotations map[string]string)

CreateIngress creates the Ingress and associated service/rc. Required: ing.yaml, rc.yaml, svc.yaml must exist in manifestPath Optional: secret.yaml, ingAnnotations If ingAnnotations is specified it will overwrite any annotations in ing.yaml If svcAnnotations is specified it will overwrite any annotations in svc.yaml

func (*TestJig) DeleteTestResource

func (j *TestJig) DeleteTestResource(ctx context.Context, cs clientset.Interface, deploy *appsv1.Deployment, svc *v1.Service, ing *networkingv1.Ingress) []error

DeleteTestResource deletes given deployment, service and ingress.

func (*TestJig) GetDistinctResponseFromIngress

func (j *TestJig) GetDistinctResponseFromIngress(ctx context.Context) (sets.String, error)

GetDistinctResponseFromIngress tries GET call to the ingress VIP and return all distinct responses.

func (*TestJig) GetIngressNodePorts

func (j *TestJig) GetIngressNodePorts(ctx context.Context, includeDefaultBackend bool) []string

GetIngressNodePorts returns related backend services' nodePorts. Current GCE ingress controller allows traffic to the default HTTP backend by default, so retrieve its nodePort if includeDefaultBackend is true.

func (*TestJig) GetRootCA

func (j *TestJig) GetRootCA(secretName string) (rootCA []byte)

GetRootCA returns a rootCA from the ingress test jig.

func (*TestJig) GetServicePorts

func (j *TestJig) GetServicePorts(ctx context.Context, includeDefaultBackend bool) map[string]v1.ServicePort

GetServicePorts returns related backend services' svcPorts. Current GCE ingress controller allows traffic to the default HTTP backend by default, so retrieve its nodePort if includeDefaultBackend is true.

func (*TestJig) PrepareTLSSecret

func (j *TestJig) PrepareTLSSecret(ctx context.Context, namespace, secretName string, hosts ...string) error

PrepareTLSSecret creates a TLS secret and caches the cert.

func (*TestJig) RemoveHTTPS

func (j *TestJig) RemoveHTTPS(ctx context.Context, secretName string)

RemoveHTTPS updates the ingress to not use this secret for TLS. Note: Does not delete the secret.

func (*TestJig) SetHTTPS

func (j *TestJig) SetHTTPS(ctx context.Context, secretName string, hosts ...string)

SetHTTPS updates the ingress to use only this secret for these hosts.

func (*TestJig) SetUpBacksideHTTPSIngress

func (j *TestJig) SetUpBacksideHTTPSIngress(ctx context.Context, cs clientset.Interface, namespace string, staticIPName string) (*appsv1.Deployment, *v1.Service, *networkingv1.Ingress, error)

SetUpBacksideHTTPSIngress sets up deployment, service and ingress with backside HTTPS configured.

func (*TestJig) TryDeleteIngress

func (j *TestJig) TryDeleteIngress(ctx context.Context)

TryDeleteIngress attempts to delete the ingress resource and logs errors if they occur.

func (*TestJig) Update

func (j *TestJig) Update(ctx context.Context, update func(ing *networkingv1.Ingress))

Update retrieves the ingress, performs the passed function, and then updates it.

func (*TestJig) VerifyURL

func (j *TestJig) VerifyURL(ctx context.Context, route, host string, iterations int, interval time.Duration, httpClient *http.Client) error

VerifyURL polls for the given iterations, in intervals, and fails if the given url returns a non-healthy http code even once.

func (*TestJig) WaitForGivenIngressWithTimeout

func (j *TestJig) WaitForGivenIngressWithTimeout(ctx context.Context, ing *networkingv1.Ingress, waitForNodePort bool, timeout time.Duration) error

WaitForGivenIngressWithTimeout waits till the ingress acquires an IP, then waits for its hosts/urls to respond to a protocol check (either http or https). If waitForNodePort is true, the NodePort of the Service is verified before verifying the Ingress. NodePort is currently a requirement for cloudprovider Ingress.

func (*TestJig) WaitForIngress

func (j *TestJig) WaitForIngress(ctx context.Context, waitForNodePort bool)

WaitForIngress waits for the Ingress to get an address. WaitForIngress returns when it gets the first 200 response

func (*TestJig) WaitForIngressAddress

func (j *TestJig) WaitForIngressAddress(ctx context.Context, c clientset.Interface, ns, ingName string, timeout time.Duration) (string, error)

WaitForIngressAddress waits for the Ingress to acquire an address.

func (*TestJig) WaitForIngressToStable

func (j *TestJig) WaitForIngressToStable(ctx context.Context)

WaitForIngressToStable waits for the LB return 100 consecutive 200 responses.

func (*TestJig) WaitForIngressWithCert

func (j *TestJig) WaitForIngressWithCert(ctx context.Context, waitForNodePort bool, knownHosts []string, cert []byte) error

WaitForIngressWithCert waits till the ingress acquires an IP, then waits for its hosts/urls to respond to a protocol check (either http or https). If waitForNodePort is true, the NodePort of the Service is verified before verifying the Ingress. NodePort is currently a requirement for cloudprovider Ingress. Hostnames and certificate need to be explicitly passed in.

type TestLogger

TestLogger is an interface for log.

type TestLogger interface {
    Infof(format string, args ...interface{})
    Errorf(format string, args ...interface{})
}