Documentation
¶
Index ¶
- Constants
- Variables
- func AnnotateIPCacheKeyWithClusterID(key string, clusterID uint32) string
- func ValidateClusterID(clusterID uint32) error
- func ValidateClusterName(name string) error
- type AddrCluster
- func (ac AddrCluster) Addr() netip.Addr
- func (ac AddrCluster) As20() (ac20 [20]byte)
- func (ac AddrCluster) AsNetIP() net.IP
- func (ac AddrCluster) AsPrefixCluster() PrefixCluster
- func (ac AddrCluster) ClusterID() uint32
- func (in *AddrCluster) DeepCopy() *AddrCluster
- func (in *AddrCluster) DeepCopyInto(out *AddrCluster)
- func (ac0 *AddrCluster) DeepEqual(ac1 *AddrCluster) bool
- func (ac0 AddrCluster) Equal(ac1 AddrCluster) bool
- func (ac AddrCluster) Is4() bool
- func (ac AddrCluster) Is6() bool
- func (ac AddrCluster) IsUnspecified() bool
- func (ac0 AddrCluster) Less(ac1 AddrCluster) bool
- func (ac AddrCluster) String() string
- type CiliumClusterConfig
- type CiliumClusterConfigCapabilities
- type ClusterInfo
- func (c ClusterInfo) ExtendedClusterMeshEnabled() bool
- func (def ClusterInfo) Flags(flags *pflag.FlagSet)
- func (c ClusterInfo) InitClusterIDMax() error
- func (c ClusterInfo) Validate(log logrus.FieldLogger) error
- func (c ClusterInfo) ValidateRemoteConfig(config CiliumClusterConfig) error
- func (c ClusterInfo) ValidateStrict(log logrus.FieldLogger) error
- type PrefixCluster
- func (pc PrefixCluster) AddrCluster() AddrCluster
- func (pc PrefixCluster) AsIPNet() net.IPNet
- func (pc PrefixCluster) AsPrefix() netip.Prefix
- func (pc PrefixCluster) ClusterID() uint32
- func (pc0 PrefixCluster) Equal(pc1 PrefixCluster) bool
- func (pc PrefixCluster) IsSingleIP() bool
- func (pc PrefixCluster) IsValid() bool
- func (pc PrefixCluster) String() string
- type PrefixClusterOpts
Constants ¶
const ( // OptClusterName is the name of the OptClusterName option OptClusterName = "cluster-name" // OptClusterID is the name of the OptClusterID option OptClusterID = "cluster-id" // OptMaxConnectedClusters is the name of the OptMaxConnectedClusters option OptMaxConnectedClusters = "max-connected-clusters" )
const ( // ClusterIDMin is the minimum value of the cluster ID ClusterIDMin = 0 ClusterIDExt511 = 511 ClusterIDUnset = ClusterIDMin )
const AddrClusterLen = 20
Variables ¶
var ClusterIDMax uint32 = defaults.MaxConnectedClusters
ClusterIDMax is the maximum value of the cluster ID
var DefaultClusterInfo = ClusterInfo{ ID: 0, Name: defaults.ClusterName, MaxConnectedClusters: defaults.MaxConnectedClusters, }
DefaultClusterInfo represents the default ClusterInfo values.
Functions ¶
func AnnotateIPCacheKeyWithClusterID ¶
This function is solely exists for annotating IPCache's key string with ClusterID. IPCache's key string is IP address or Prefix string (10.0.0.1 and 10.0.0.0/32 are different entry). This function assumes given string is one of those format and just put @<ClusterID> suffix and there's no format check for performance reason. User must make sure the input is a valid IP or Prefix string.
We should eventually remove this function once we finish refactoring IPCache and stop using string as a key. At that point, we should consider using PrefixCluster type for IPCache's key.
func ValidateClusterID ¶
ValidateClusterID ensures that the given clusterID is within the configured range of the ClusterMesh.
func ValidateClusterName ¶ added in v1.16.0
ValidateClusterName validates that the given name matches the cluster name specifications.
Types ¶
type AddrCluster ¶
type AddrCluster struct {
// contains filtered or unexported fields
}
AddrCluster is a type that holds a pair of IP and ClusterID. We should use this type as much as possible when we implement IP + Cluster addressing. We should avoid managing IP and ClusterID separately. Otherwise, it is very hard for code readers to see where we are using cluster-aware addressing.
func AddrClusterFrom ¶
func AddrClusterFrom(addr netip.Addr, clusterID uint32) AddrCluster
AddrClusterFrom creates AddrCluster from netip.Addr and ClusterID
func AddrClusterFromIP ¶
func AddrClusterFromIP(ip net.IP) (AddrCluster, bool)
AddrClusterFromIP parses the given net.IP using ip.AddrFromIP and returns AddrCluster with ClusterID = 0.
func MustAddrClusterFromIP ¶
func MustAddrClusterFromIP(ip net.IP) AddrCluster
func MustParseAddrCluster ¶
func MustParseAddrCluster(s string) AddrCluster
MustParseAddrCluster calls ParseAddr(s) and panics on error. It is intended for use in tests with hard-coded strings.
func ParseAddrCluster ¶
func ParseAddrCluster(s string) (AddrCluster, error)
ParseAddrCluster parses s as an IP + ClusterID and returns AddrCluster. The string s can be a bare IP string (any IP address format allowed in netip.ParseAddr()) or IP string + @ + ClusterID with decimal. Bare IP string is considered as IP string + @ + ClusterID = 0.
func (AddrCluster) Addr ¶
func (ac AddrCluster) Addr() netip.Addr
Addr returns IP address part of AddrCluster as netip.Addr. This function exists for keeping backward compatibility between the existing components which are not aware of the cluster-aware addressing. Calling this function against the AddrCluster which has non-zero clusterID will lose the ClusterID information. It should be used with an extra care.
func (AddrCluster) As20 ¶
func (ac AddrCluster) As20() (ac20 [20]byte)
As20 returns the AddrCluster in its 20-byte representation which consists of 16-byte IP address part from netip.Addr.As16 and 4-byte ClusterID part.
func (AddrCluster) AsNetIP ¶
func (ac AddrCluster) AsNetIP() net.IP
AsNetIP returns the IP address part of AddCluster as a net.IP type. This function exists for keeping backward compatibility between the existing components which are not aware of the cluster-aware addressing. Calling this function against the AddrCluster which has non-zero clusterID will lose the ClusterID information. It should be used with an extra care.
func (AddrCluster) AsPrefixCluster ¶
func (ac AddrCluster) AsPrefixCluster() PrefixCluster
func (AddrCluster) ClusterID ¶
func (ac AddrCluster) ClusterID() uint32
ClusterID returns ClusterID part of AddrCluster as uint32. We should avoid using this function as much as possible and treat IP address and ClusterID together.
func (*AddrCluster) DeepCopy ¶
func (in *AddrCluster) DeepCopy() *AddrCluster
DeepCopy returns a new copy of AddrCluster
func (*AddrCluster) DeepCopyInto ¶
func (in *AddrCluster) DeepCopyInto(out *AddrCluster)
DeepCopyInto copies in to out
func (*AddrCluster) DeepEqual ¶
func (ac0 *AddrCluster) DeepEqual(ac1 *AddrCluster) bool
This is an alias of Equal which only exists for satisfying deepequal-gen
func (AddrCluster) Equal ¶
func (ac0 AddrCluster) Equal(ac1 AddrCluster) bool
Equal returns true when given AddrCluster has a same IP address and ClusterID
func (AddrCluster) Is4 ¶
func (ac AddrCluster) Is4() bool
Is4 reports whether IP address part of AddrCluster is an IPv4 address.
func (AddrCluster) Is6 ¶
func (ac AddrCluster) Is6() bool
Is6 reports whether IP address part of AddrCluster is an IPv6 address.
func (AddrCluster) IsUnspecified ¶
func (ac AddrCluster) IsUnspecified() bool
IsUnspecified reports whether IP address part of the AddrCluster is an unspecified address, either the IPv4 address "0.0.0.0" or the IPv6 address "::".
func (AddrCluster) Less ¶
func (ac0 AddrCluster) Less(ac1 AddrCluster) bool
Less compares ac0 and ac1 and returns true if ac0 is lesser than ac1
func (AddrCluster) String ¶
func (ac AddrCluster) String() string
String returns the string representation of the AddrCluster. If AddrCluster.clusterID = 0, it returns bare IP address string. Otherwise, it returns IP string + "@" + ClusterID (e.g. 10.0.0.1@1)
type CiliumClusterConfig ¶
type CiliumClusterConfig struct { ID uint32 `json:"id,omitempty"` Capabilities CiliumClusterConfigCapabilities `json:"capabilities,omitempty"` }
type CiliumClusterConfigCapabilities ¶
type CiliumClusterConfigCapabilities struct { // Supports per-prefix "synced" canaries SyncedCanaries bool `json:"syncedCanaries,omitempty"` // The information concerning the given cluster is cached from an external // kvstore (for instance, by kvstoremesh). This implies that keys are stored // under the dedicated "cilium/cache" prefix, and all are cluster-scoped. Cached bool `json:"cached,omitempty"` // The maximum number of clusters the given cluster can support in a ClusterMesh. MaxConnectedClusters uint32 `json:"maxConnectedClusters,omitempty"` }
type ClusterInfo ¶ added in v1.15.0
type ClusterInfo struct { ID uint32 `mapstructure:"cluster-id"` Name string `mapstructure:"cluster-name"` MaxConnectedClusters uint32 `mapstructure:"max-connected-clusters"` }
ClusterInfo groups together the ClusterID and the ClusterName
func (ClusterInfo) ExtendedClusterMeshEnabled ¶ added in v1.15.0
func (c ClusterInfo) ExtendedClusterMeshEnabled() bool
ExtendedClusterMeshEnabled returns true if MaxConnectedClusters value has been set to a value larger than the default 255.
func (ClusterInfo) Flags ¶ added in v1.15.0
func (def ClusterInfo) Flags(flags *pflag.FlagSet)
Flags implements the cell.Flagger interface, to register the given flags.
func (ClusterInfo) InitClusterIDMax ¶ added in v1.15.0
func (c ClusterInfo) InitClusterIDMax() error
InitClusterIDMax validates and sets the ClusterIDMax package level variable.
func (ClusterInfo) Validate ¶ added in v1.15.0
func (c ClusterInfo) Validate(log logrus.FieldLogger) error
Validate validates that the ClusterID is in the valid range (including ClusterID == 0), and that the ClusterName is different from the default value if the ClusterID != 0.
func (ClusterInfo) ValidateRemoteConfig ¶ added in v1.15.0
func (c ClusterInfo) ValidateRemoteConfig(config CiliumClusterConfig) error
ValidateRemoteConfig validates the remote CiliumClusterConfig to ensure compatibility with this cluster's configuration.
func (ClusterInfo) ValidateStrict ¶ added in v1.15.0
func (c ClusterInfo) ValidateStrict(log logrus.FieldLogger) error
ValidateStrict validates that the ClusterID is in the valid range, but not 0, and that the ClusterName is different from the default value.
type PrefixCluster ¶
type PrefixCluster struct {
// contains filtered or unexported fields
}
PrefixCluster is a type that holds a pair of prefix and ClusterID. We should use this type as much as possible when we implement prefix + Cluster addressing. We should avoid managing prefix and ClusterID separately. Otherwise, it is very hard for code readers to see where we are using cluster-aware addressing.
func MustParsePrefixCluster ¶
func MustParsePrefixCluster(s string) PrefixCluster
MustParsePrefixCluster calls ParsePrefixCluster(s) and panics on error. It is intended for use in tests with hard-coded strings.
func ParsePrefixCluster ¶
func ParsePrefixCluster(s string) (PrefixCluster, error)
ParsePrefixCluster parses s as an Prefix + ClusterID and returns PrefixCluster. The string s can be a bare IP prefix string (any prefix format allowed in netip.ParsePrefix()) or prefix string + @ + ClusterID with decimal. Bare prefix string is considered as prefix string + @ + ClusterID = 0.
func PrefixClusterFrom ¶
func PrefixClusterFrom(addr netip.Addr, bits int, opts ...PrefixClusterOpts) PrefixCluster
func PrefixClusterFromCIDR ¶
func PrefixClusterFromCIDR(c *cidr.CIDR, opts ...PrefixClusterOpts) PrefixCluster
func (PrefixCluster) AddrCluster ¶
func (pc PrefixCluster) AddrCluster() AddrCluster
func (PrefixCluster) AsIPNet ¶
func (pc PrefixCluster) AsIPNet() net.IPNet
AsIPNet returns the IP prefix part of PrefixCluster as a net.IPNet type. This function exists for keeping backward compatibility between the existing components which are not aware of the cluster-aware addressing. Calling this function against the PrefixCluster which has non-zero clusterID will lose the ClusterID information. It should be used with an extra care.
func (PrefixCluster) AsPrefix ¶ added in v1.15.0
func (pc PrefixCluster) AsPrefix() netip.Prefix
AsPrefix returns the IP prefix part of PrefixCluster as a netip.Prefix type. This function exists for keeping backward compatibility between the existing components which are not aware of the cluster-aware addressing. Calling this function against the PrefixCluster which has non-zero clusterID will lose the ClusterID information. It should be used with an extra care.
func (PrefixCluster) ClusterID ¶
func (pc PrefixCluster) ClusterID() uint32
func (PrefixCluster) Equal ¶
func (pc0 PrefixCluster) Equal(pc1 PrefixCluster) bool
func (PrefixCluster) IsSingleIP ¶
func (pc PrefixCluster) IsSingleIP() bool
func (PrefixCluster) IsValid ¶
func (pc PrefixCluster) IsValid() bool
func (PrefixCluster) String ¶
func (pc PrefixCluster) String() string
type PrefixClusterOpts ¶
type PrefixClusterOpts func(*PrefixCluster)
func WithClusterID ¶
func WithClusterID(id uint32) PrefixClusterOpts