infrastructure

package
v3.3.7+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Copyright (c) 2018 Tigera, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 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.

Index

Constants

This section is empty.

Variables

View Source
var DeleteImmediately = &metav1.DeleteOptions{
	GracePeriodSeconds: &zeroGracePeriod,
}

Functions

func DatastoreDescribe

func DatastoreDescribe(description string, datastores []apiconfig.DatastoreType, body func(InfraFactory)) bool

DatastoreDescribe is a replacement for ginkgo.Describe which invokes Describe multiple times for one or more different datastore drivers - passing in the function to retrieve the appropriate datastore infrastructure. This allows easy construction of end-to-end tests covering multiple different datastore drivers.

The *datastores* parameter is a slice of the DatastoreTypes to test.

func EnsureTLSCredentials

func EnsureTLSCredentials()

func RemoveTLSCredentials

func RemoveTLSCredentials()

func RunEtcd

func RunEtcd() *containers.Container

func TearDownK8sInfra

func TearDownK8sInfra(kds *K8sDatastoreInfra)

Types

type DatastoreInfra

type DatastoreInfra interface {
	// GetDockerArgs returns a string slice of args to be passed to the docker
	// run command when starting Typha or Felix. It includes
	// CALICO_DATASTORE_TYPE, FELIX_DATASTORETYPE, an appropriate endpoint,
	// and any datastore specific needed ones.
	GetDockerArgs() []string
	// GetBadEndpointDockerArgs returns the same as GetDockerArgs but the
	// endpoint returned will have the incorrect port.
	GetBadEndpointDockerArgs() []string

	// GetCalicoClient will return a client.Interface configured to access
	// the datastore.
	GetCalicoClient() client.Interface
	// SetExpectedIPIPTunnelAddr will set the Felix object's
	// ExpectedIPIPTunnelAddr field, if we expect Felix to see that field being
	// set after it has started up for the first time.
	SetExpectedIPIPTunnelAddr(felix *Felix, idx int, needBGP bool)
	// AddNode will take the appropriate steps to add a node to the datastore.
	// From the passed in felix the Hostname and IPv4 address will be pulled
	// and added to the Node appropriately.
	// The passed in idx will be used to setup the Tunnel or PodCIDR (from
	// which the tunnel is created). needBGP is used (only in etcd) to
	// add a NodeBGPSpec if true or otherwise not.
	AddNode(felix *Felix, idx int, needBGP bool)
	// AddWorkload will take the appropriate steps to create a workload in the
	// datastore with the passed in wep values. If this succeeds then the
	// *api.WorkloadEndpoint will be returned, otherwise an error will be
	// returned.
	AddWorkload(wep *api.WorkloadEndpoint) (*api.WorkloadEndpoint, error)
	// AddDefaultAllow will ensure that the datastore is configured so that
	// the default profile/namespace will allow traffic.
	AddDefaultAllow() error
	// AddDefaultDeny will ensure that the datastore is configured so that
	// the default profile/namespace will deny ingress traffic.
	AddDefaultDeny() error
	// AddAllowToDatastore adds a policy to allow endpoints that match the given
	// selector to reach the datastore.
	AddAllowToDatastore(selector string) error

	// DumpErrorData prints out extra information that may help when an error
	// occurs.
	DumpErrorData()

	// Stop cleans up anything necessary in preparation for the end of the test.
	Stop()
}

DatastoreInfra is an interface that is to be used to abstract away the datastore being used and the functions that are datastore specific

type EtcdDatastoreInfra

type EtcdDatastoreInfra struct {
	Endpoint    string
	BadEndpoint string
	// contains filtered or unexported fields
}

func GetEtcdDatastoreInfra

func GetEtcdDatastoreInfra() (*EtcdDatastoreInfra, error)

func (*EtcdDatastoreInfra) AddAllowToDatastore

func (eds *EtcdDatastoreInfra) AddAllowToDatastore(selector string) error

func (*EtcdDatastoreInfra) AddDefaultAllow

func (eds *EtcdDatastoreInfra) AddDefaultAllow() error

func (*EtcdDatastoreInfra) AddDefaultDeny

func (eds *EtcdDatastoreInfra) AddDefaultDeny() error

func (*EtcdDatastoreInfra) AddNode

func (eds *EtcdDatastoreInfra) AddNode(felix *Felix, idx int, needBGP bool)

func (*EtcdDatastoreInfra) AddWorkload

func (eds *EtcdDatastoreInfra) AddWorkload(wep *api.WorkloadEndpoint) (*api.WorkloadEndpoint, error)

func (*EtcdDatastoreInfra) DumpErrorData

func (eds *EtcdDatastoreInfra) DumpErrorData()

func (*EtcdDatastoreInfra) GetBadEndpointDockerArgs

func (eds *EtcdDatastoreInfra) GetBadEndpointDockerArgs() []string

func (*EtcdDatastoreInfra) GetCalicoClient

func (eds *EtcdDatastoreInfra) GetCalicoClient() client.Interface

func (*EtcdDatastoreInfra) GetDockerArgs

func (eds *EtcdDatastoreInfra) GetDockerArgs() []string

func (*EtcdDatastoreInfra) SetExpectedIPIPTunnelAddr

func (eds *EtcdDatastoreInfra) SetExpectedIPIPTunnelAddr(felix *Felix, idx int, needBGP bool)

func (*EtcdDatastoreInfra) Stop

func (eds *EtcdDatastoreInfra) Stop()

type Felix

type Felix struct {
	*containers.Container

	// ExpectedIPIPTunnelAddr contains the IP that the infrastructure expects to
	// get assigned to the IPIP tunnel.  Filled in by AddNode().
	ExpectedIPIPTunnelAddr string
}

func RunFelix

func RunFelix(infra DatastoreInfra, options TopologyOptions) *Felix

func StartNNodeEtcdTopology

func StartNNodeEtcdTopology(n int, opts TopologyOptions) (felixes []*Felix, etcd *containers.Container, client client.Interface)

StartNNodeEtcdTopology starts an etcd container and a set of Felix hosts. If n > 1, sets up IPIP, otherwise this is skipped.

  • Configures an IPAM pool for 10.65.0.0/16 (so that Felix programs the all-IPAM blocks IP set) but (for simplicity) we don't actually use IPAM to assign IPs.
  • Configures routes between the hosts, giving each host 10.65.x.0/24, where x is the index in the returned array. When creating workloads, use IPs from the relevant block.
  • Configures the Tunnel IP for each host as 10.65.x.1.

func StartNNodeTopology

func StartNNodeTopology(n int, opts TopologyOptions, infra DatastoreInfra) (felixes []*Felix, client client.Interface)

StartNNodeEtcdTopology starts an etcd container and a set of Felix hosts. If n > 1, sets up IPIP, otherwise this is skipped.

  • Configures an IPAM pool for 10.65.0.0/16 (so that Felix programs the all-IPAM blocks IP set) but (for simplicity) we don't actually use IPAM to assign IPs.
  • Configures routes between the hosts, giving each host 10.65.x.0/24, where x is the index in the returned array. When creating workloads, use IPs from the relevant block.
  • Configures the Tunnel IP for each host as 10.65.x.1.

func StartSingleNodeEtcdTopology

func StartSingleNodeEtcdTopology(options TopologyOptions) (felix *Felix, etcd *containers.Container, calicoClient client.Interface)

StartSingleNodeEtcdTopology starts an etcd container and a single Felix container; it initialises the datastore and installs a Node resource for the Felix node.

func StartSingleNodeTopology

func StartSingleNodeTopology(options TopologyOptions, infra DatastoreInfra) (felix *Felix, calicoClient client.Interface)

StartSingleNodeEtcdTopology starts an etcd container and a single Felix container; it initialises the datastore and installs a Node resource for the Felix node.

func (*Felix) GetFelixPID

func (f *Felix) GetFelixPID() int

func (*Felix) GetFelixPIDs

func (f *Felix) GetFelixPIDs() []int

type InfraFactory

type InfraFactory func() (DatastoreInfra, error)

type K8sDatastoreInfra

type K8sDatastoreInfra struct {
	K8sClient *kubernetes.Clientset

	Endpoint    string
	BadEndpoint string

	CertFileName string
	// contains filtered or unexported fields
}
var (
	K8sInfra *K8sDatastoreInfra
)

func GetK8sDatastoreInfra

func GetK8sDatastoreInfra() (*K8sDatastoreInfra, error)

func (*K8sDatastoreInfra) AddAllowToDatastore

func (kds *K8sDatastoreInfra) AddAllowToDatastore(selector string) error

func (*K8sDatastoreInfra) AddDefaultAllow

func (kds *K8sDatastoreInfra) AddDefaultAllow() error

func (*K8sDatastoreInfra) AddDefaultDeny

func (kds *K8sDatastoreInfra) AddDefaultDeny() error

func (*K8sDatastoreInfra) AddNode

func (kds *K8sDatastoreInfra) AddNode(felix *Felix, idx int, needBGP bool)

func (*K8sDatastoreInfra) AddWorkload

func (kds *K8sDatastoreInfra) AddWorkload(wep *api.WorkloadEndpoint) (*api.WorkloadEndpoint, error)

func (*K8sDatastoreInfra) DumpErrorData

func (kds *K8sDatastoreInfra) DumpErrorData()

func (*K8sDatastoreInfra) EnsureReady

func (kds *K8sDatastoreInfra) EnsureReady()

func (*K8sDatastoreInfra) GetBadEndpointDockerArgs

func (kds *K8sDatastoreInfra) GetBadEndpointDockerArgs() []string

func (*K8sDatastoreInfra) GetCalicoClient

func (kds *K8sDatastoreInfra) GetCalicoClient() client.Interface

func (*K8sDatastoreInfra) GetDockerArgs

func (kds *K8sDatastoreInfra) GetDockerArgs() []string

func (*K8sDatastoreInfra) SetExpectedIPIPTunnelAddr

func (kds *K8sDatastoreInfra) SetExpectedIPIPTunnelAddr(felix *Felix, idx int, needBGP bool)

func (*K8sDatastoreInfra) Stop

func (kds *K8sDatastoreInfra) Stop()

type TopologyOptions

type TopologyOptions struct {
	FelixLogSeverity          string
	EnableIPv6                bool
	ExtraEnvVars              map[string]string
	ExtraVolumes              map[string]string
	WithTypha                 bool
	WithFelixTyphaTLS         bool
	TyphaLogSeverity          string
	IPIPEnabled               bool
	IPIPRoutesEnabled         bool
	InitialFelixConfiguration *api.FelixConfiguration
}

func DefaultTopologyOptions

func DefaultTopologyOptions() TopologyOptions

type Typha

type Typha struct {
	*containers.Container
}

func RunTypha

func RunTypha(infra DatastoreInfra, options TopologyOptions) *Typha

func (*Typha) GetTyphaPID

func (f *Typha) GetTyphaPID() int

func (*Typha) GetTyphaPIDs

func (f *Typha) GetTyphaPIDs() []int

Jump to

Keyboard shortcuts

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