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
- Variables
- func CreateDefaultIPPoolFromOpts(ctx context.Context, client client.Interface, opts TopologyOptions, ...) (*api.IPPool, error)
- func CreateDefaultProfile(c client.Interface, name string, labels map[string]string, ...)
- func DatastoreDescribe(description string, datastores []apiconfig.DatastoreType, ...) bool
- func DeleteDefaultIPPool(ctx context.Context, client client.Interface) (*api.IPPool, error)
- func DeleteIPPoolByName(ctx context.Context, client client.Interface, name string) (*api.IPPool, error)
- func EnsureTLSCredentials()
- func RemoveTLSCredentials()
- func RunEtcd() *containers.Container
- func RunExtClient(namePrefix string) *containers.Container
- func StartNNodeEtcdTopology(n int, opts TopologyOptions) (felixes []*Felix, etcd *containers.Container, client client.Interface, ...)
- func StartSingleNodeEtcdTopology(options TopologyOptions) (felix *Felix, etcd *containers.Container, calicoClient client.Interface, ...)
- func TearDownK8sInfra(kds *K8sDatastoreInfra)
- type BPFIfState
- type DatastoreInfra
- type EtcdDatastoreInfra
- func (eds *EtcdDatastoreInfra) AddAllowToDatastore(selector string) error
- func (eds *EtcdDatastoreInfra) AddDefaultAllow() string
- func (eds *EtcdDatastoreInfra) AddDefaultDeny() error
- func (eds *EtcdDatastoreInfra) AddNode(felix *Felix, idx int, needBGP bool)
- func (eds *EtcdDatastoreInfra) AddWorkload(wep *libapi.WorkloadEndpoint) (*libapi.WorkloadEndpoint, error)
- func (eds *EtcdDatastoreInfra) DumpErrorData()
- func (eds *EtcdDatastoreInfra) GetBadEndpointDockerArgs() []string
- func (eds *EtcdDatastoreInfra) GetCalicoClient() client.Interface
- func (eds *EtcdDatastoreInfra) GetClusterGUID() string
- func (eds *EtcdDatastoreInfra) GetDockerArgs() []string
- func (eds *EtcdDatastoreInfra) RemoveNodeAddresses(felix *Felix)
- func (eds *EtcdDatastoreInfra) RemoveWorkload(ns string, name string) error
- func (eds *EtcdDatastoreInfra) SetExpectedIPIPTunnelAddr(felix *Felix, idx int, needBGP bool)
- func (eds *EtcdDatastoreInfra) SetExpectedVXLANTunnelAddr(felix *Felix, idx int, needBGP bool)
- func (eds *EtcdDatastoreInfra) SetExpectedVXLANV6TunnelAddr(felix *Felix, idx int, needBGP bool)
- func (eds *EtcdDatastoreInfra) SetExpectedWireguardTunnelAddr(felix *Felix, idx int, needWireguard bool)
- func (eds *EtcdDatastoreInfra) SetExpectedWireguardV6TunnelAddr(felix *Felix, idx int, needWireguard bool)
- func (eds *EtcdDatastoreInfra) Stop()
- type Felix
- func RunFelix(infra DatastoreInfra, id int, options TopologyOptions) *Felix
- func StartNNodeTopology(n int, opts TopologyOptions, infra DatastoreInfra) (felixes []*Felix, client client.Interface)
- func StartSingleNodeTopology(options TopologyOptions, infra DatastoreInfra) (felix *Felix, calicoClient client.Interface)
- func (f *Felix) AttachTCPDump(iface string) *tcpdump.TCPDump
- func (f *Felix) BPFIfState() map[string]BPFIfState
- func (f *Felix) GetFelixPID() int
- func (f *Felix) GetFelixPIDs() []int
- func (f *Felix) ProgramIptablesDNAT(serviceIP, targetIP, chain string)
- func (f *Felix) Restart()
- func (f *Felix) SetEvn(env map[string]string)
- func (f *Felix) Stop()
- func (f *Felix) TriggerDelayedStart()
- type InfraFactory
- type K8sDatastoreInfra
- func (kds *K8sDatastoreInfra) AddAllowToDatastore(selector string) error
- func (kds *K8sDatastoreInfra) AddDefaultAllow() string
- func (kds *K8sDatastoreInfra) AddDefaultDeny() error
- func (kds *K8sDatastoreInfra) AddNode(felix *Felix, idx int, needBGP bool)
- func (kds *K8sDatastoreInfra) AddWorkload(wep *libapi.WorkloadEndpoint) (*libapi.WorkloadEndpoint, error)
- func (kds *K8sDatastoreInfra) CleanUp()
- func (kds *K8sDatastoreInfra) DumpErrorData()
- func (kds *K8sDatastoreInfra) EnsureReady()
- func (kds *K8sDatastoreInfra) GetBadEndpointDockerArgs() []string
- func (kds *K8sDatastoreInfra) GetCalicoClient() client.Interface
- func (kds *K8sDatastoreInfra) GetClusterGUID() string
- func (kds *K8sDatastoreInfra) GetDockerArgs() []string
- func (kds *K8sDatastoreInfra) PerTestSetup()
- func (kds *K8sDatastoreInfra) RemoveNodeAddresses(felix *Felix)
- func (kds *K8sDatastoreInfra) RemoveWorkload(ns, name string) error
- func (kds *K8sDatastoreInfra) SetExpectedIPIPTunnelAddr(felix *Felix, idx int, needBGP bool)
- func (kds *K8sDatastoreInfra) SetExpectedVXLANTunnelAddr(felix *Felix, idx int, needBGP bool)
- func (kds *K8sDatastoreInfra) SetExpectedVXLANV6TunnelAddr(felix *Felix, idx int, needBGP bool)
- func (kds *K8sDatastoreInfra) SetExpectedWireguardTunnelAddr(felix *Felix, idx int, needWg bool)
- func (kds *K8sDatastoreInfra) SetExpectedWireguardV6TunnelAddr(felix *Felix, idx int, needWg bool)
- func (kds *K8sDatastoreInfra) SetExternalIP(felix *Felix, idx int)
- func (kds *K8sDatastoreInfra) Stop()
- type TopologyOptions
- type Typha
Constants ¶
const ( DefaultIPPoolName = "test-pool" DefaultIPPoolCIDR = "10.65.0.0/16" DefaultIPv6PoolName = "test-pool-v6" DefaultIPv6PoolCIDR = "dead:beef::/64" )
const CreateCgroupV2 = false
FIXME: isolate individual Felix instances in their own cgroups. Unfortunately, this doesn't work on systems that are using cgroupv1 see https://elixir.bootlin.com/linux/v5.3.11/source/include/linux/cgroup-defs.h#L788 for explanation.
Variables ¶
var CertDir = ""
var (
DeleteImmediately = metav1.DeleteOptions{
GracePeriodSeconds: &zeroGracePeriod,
}
)
Functions ¶
func CreateDefaultProfile ¶
func CreateDefaultProfile(c client.Interface, name string, labels map[string]string, entityRuleSelector string)
Creates a default profile that allows workloads with this profile to talk to each other in the absence of any Policy.
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 DeleteDefaultIPPool ¶
func DeleteIPPoolByName ¶
func EnsureTLSCredentials ¶
func EnsureTLSCredentials()
func RemoveTLSCredentials ¶
func RemoveTLSCredentials()
func RunEtcd ¶
func RunEtcd() *containers.Container
func RunExtClient ¶
func RunExtClient(namePrefix string) *containers.Container
func StartNNodeEtcdTopology ¶
func StartNNodeEtcdTopology(n int, opts TopologyOptions) (felixes []*Felix, etcd *containers.Container, client client.Interface, infra DatastoreInfra)
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, infra DatastoreInfra)
StartSingleNodeEtcdTopology starts an etcd container and a single Felix container; it initialises the datastore and installs a Node resource for the Felix node.
func TearDownK8sInfra ¶
func TearDownK8sInfra(kds *K8sDatastoreInfra)
Types ¶
type BPFIfState ¶
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 // GetClusterGUID will return the cluster GUID. GetClusterGUID() string // 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) // SetExpectedVXLANTunnelAddr will set the Felix object's // ExpectedVXLANTunnelAddr field, if we expect Felix to see that field being // set after it has started up for the first time. SetExpectedVXLANTunnelAddr(felix *Felix, idx int, needVXLAN bool) SetExpectedVXLANV6TunnelAddr(felix *Felix, idx int, needVXLAN bool) // SetExpectedWireguardTunnelAddr will set the Felix object's // ExpectedWireguardTunnelAddr field, if we expect Felix to see that field being // set after it has started up for the first time. SetExpectedWireguardTunnelAddr(felix *Felix, idx int, needWireguard bool) // SetExpectedWireguardV6TunnelAddr will set the Felix object's // ExpectedWireguardV6TunnelAddr field, if we expect Felix to see that field being // set after it has started up for the first time. SetExpectedWireguardV6TunnelAddr(felix *Felix, idx int, needWireguard bool) // RemoveNodeAddresses will remove all the addresses (InternalIP, ExternalIP) RemoveNodeAddresses(felix *Felix) // 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 // *libapi.WorkloadEndpoint will be returned, otherwise an error will be // returned. AddWorkload(wep *libapi.WorkloadEndpoint) (*libapi.WorkloadEndpoint, error) // RemoveWorkload reverses the effect of AddWorkload. RemoveWorkload(ns string, name string) error // AddDefaultAllow will ensure that the datastore is configured so that // the default profile/namespace will allow traffic. Returns the name of the // default profile. AddDefaultAllow() string // 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() string
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 *libapi.WorkloadEndpoint) (*libapi.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) GetClusterGUID ¶
func (eds *EtcdDatastoreInfra) GetClusterGUID() string
func (*EtcdDatastoreInfra) GetDockerArgs ¶
func (eds *EtcdDatastoreInfra) GetDockerArgs() []string
func (*EtcdDatastoreInfra) RemoveNodeAddresses ¶
func (eds *EtcdDatastoreInfra) RemoveNodeAddresses(felix *Felix)
func (*EtcdDatastoreInfra) RemoveWorkload ¶
func (eds *EtcdDatastoreInfra) RemoveWorkload(ns string, name string) error
func (*EtcdDatastoreInfra) SetExpectedIPIPTunnelAddr ¶
func (eds *EtcdDatastoreInfra) SetExpectedIPIPTunnelAddr(felix *Felix, idx int, needBGP bool)
func (*EtcdDatastoreInfra) SetExpectedVXLANTunnelAddr ¶
func (eds *EtcdDatastoreInfra) SetExpectedVXLANTunnelAddr(felix *Felix, idx int, needBGP bool)
func (*EtcdDatastoreInfra) SetExpectedVXLANV6TunnelAddr ¶
func (eds *EtcdDatastoreInfra) SetExpectedVXLANV6TunnelAddr(felix *Felix, idx int, needBGP bool)
func (*EtcdDatastoreInfra) SetExpectedWireguardTunnelAddr ¶
func (eds *EtcdDatastoreInfra) SetExpectedWireguardTunnelAddr(felix *Felix, idx int, needWireguard bool)
func (*EtcdDatastoreInfra) SetExpectedWireguardV6TunnelAddr ¶
func (eds *EtcdDatastoreInfra) SetExpectedWireguardV6TunnelAddr(felix *Felix, idx int, needWireguard 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 SetExpectedIPIPTunnelAddr(). ExpectedIPIPTunnelAddr string // ExpectedVXLANTunnelAddr contains the IP that the infrastructure expects to // get assigned to the IPv4 VXLAN tunnel. Filled in by SetExpectedVXLANTunnelAddr(). ExpectedVXLANTunnelAddr string // ExpectedVXLANV6TunnelAddr contains the IP that the infrastructure expects to // get assigned to the IPv6 VXLAN tunnel. Filled in by SetExpectedVXLANV6TunnelAddr(). ExpectedVXLANV6TunnelAddr string // ExpectedWireguardTunnelAddr contains the IPv4 address that the infrastructure expects to // get assigned to the IPv4 Wireguard tunnel. Filled in by SetExpectedWireguardTunnelAddr(). ExpectedWireguardTunnelAddr string // ExpectedWireguardV6TunnelAddr contains the IPv6 address that the infrastructure expects to // get assigned to the IPv6 Wireguard tunnel. Filled in by SetExpectedWireguardV6TunnelAddr(). ExpectedWireguardV6TunnelAddr string // IP of the Typha that this Felix is using (if any). TyphaIP string // If set, acts like an external IP of a node. Filled in by SetExternalIP(). ExternalIP string Workloads []workload // contains filtered or unexported fields }
func RunFelix ¶
func RunFelix(infra DatastoreInfra, id int, options TopologyOptions) *Felix
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 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) AttachTCPDump ¶
AttachTCPDump returns tcpdump attached to the container
func (*Felix) BPFIfState ¶
func (f *Felix) BPFIfState() map[string]BPFIfState
func (*Felix) GetFelixPID ¶
func (*Felix) GetFelixPIDs ¶
func (*Felix) ProgramIptablesDNAT ¶
func (*Felix) TriggerDelayedStart ¶
func (f *Felix) TriggerDelayedStart()
type InfraFactory ¶
type InfraFactory func() DatastoreInfra
type K8sDatastoreInfra ¶
type K8sDatastoreInfra struct { K8sClient *kubernetes.Clientset Endpoint string EndpointIP 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() string
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 *libapi.WorkloadEndpoint) (*libapi.WorkloadEndpoint, error)
func (*K8sDatastoreInfra) CleanUp ¶
func (kds *K8sDatastoreInfra) CleanUp()
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) GetClusterGUID ¶
func (kds *K8sDatastoreInfra) GetClusterGUID() string
func (*K8sDatastoreInfra) GetDockerArgs ¶
func (kds *K8sDatastoreInfra) GetDockerArgs() []string
func (*K8sDatastoreInfra) PerTestSetup ¶
func (kds *K8sDatastoreInfra) PerTestSetup()
func (*K8sDatastoreInfra) RemoveNodeAddresses ¶
func (kds *K8sDatastoreInfra) RemoveNodeAddresses(felix *Felix)
func (*K8sDatastoreInfra) RemoveWorkload ¶
func (kds *K8sDatastoreInfra) RemoveWorkload(ns, name string) error
func (*K8sDatastoreInfra) SetExpectedIPIPTunnelAddr ¶
func (kds *K8sDatastoreInfra) SetExpectedIPIPTunnelAddr(felix *Felix, idx int, needBGP bool)
func (*K8sDatastoreInfra) SetExpectedVXLANTunnelAddr ¶
func (kds *K8sDatastoreInfra) SetExpectedVXLANTunnelAddr(felix *Felix, idx int, needBGP bool)
func (*K8sDatastoreInfra) SetExpectedVXLANV6TunnelAddr ¶
func (kds *K8sDatastoreInfra) SetExpectedVXLANV6TunnelAddr(felix *Felix, idx int, needBGP bool)
func (*K8sDatastoreInfra) SetExpectedWireguardTunnelAddr ¶
func (kds *K8sDatastoreInfra) SetExpectedWireguardTunnelAddr(felix *Felix, idx int, needWg bool)
func (*K8sDatastoreInfra) SetExpectedWireguardV6TunnelAddr ¶
func (kds *K8sDatastoreInfra) SetExpectedWireguardV6TunnelAddr(felix *Felix, idx int, needWg bool)
func (*K8sDatastoreInfra) SetExternalIP ¶
func (kds *K8sDatastoreInfra) SetExternalIP(felix *Felix, idx int)
func (*K8sDatastoreInfra) Stop ¶
func (kds *K8sDatastoreInfra) Stop()
type TopologyOptions ¶
type TopologyOptions struct { FelixLogSeverity string EnableIPv6 bool // Temporary flag to implement and test IPv6 in bpf dataplane. // TODO: Remove it when IPv6 implementation in BPF mode is complete. BPFEnableIPv6 bool ExtraEnvVars map[string]string ExtraVolumes map[string]string WithTypha bool WithFelixTyphaTLS bool TestManagesBPF bool TyphaLogSeverity string IPIPEnabled bool IPIPRoutesEnabled bool VXLANMode api.VXLANMode WireguardEnabled bool WireguardEnabledV6 bool InitialFelixConfiguration *api.FelixConfiguration NATOutgoingEnabled bool DelayFelixStart bool AutoHEPsEnabled bool TriggerDelayedFelixStart bool FelixStopGraceful bool ExternalIPs bool UseIPPools bool NeedNodeIP bool }
func DefaultTopologyOptions ¶
func DefaultTopologyOptions() TopologyOptions
type Typha ¶
type Typha struct {
*containers.Container
}
func RunTypha ¶
func RunTypha(infra DatastoreInfra, options TopologyOptions) *Typha