{"modulePath":"github.com/DevFactory/smartnat","version":"v2.1.2+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package mapping\n\n## Functions\n\n```go\nfunc Add(mgr manager.Manager, heartbeatChan chan\u003c- string) error\n```\nAdd creates a new Mapping Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller and Start it when the Manager is Started.\n\n```go\nfunc GetHeartbeatString() string\n```\nGetHeartbeatString returns string printed by heartbeat http request\n\n## Types\n\n```go\ntype DNATProvider interface {\n\tSetupDNAT(externalIP net.IP, mapping *v1alpha1.Mapping, svc *v1.Service, eps *v1.Endpoints,\n\t\tsetupMasquerade bool) error\n\tDeleteDNAT(externalIP net.IP, mapping *v1alpha1.Mapping) error\n}\n```\nDNATProvider provides and interface to configure necessary DNAT rules from an External IP. The target of the translation a exact meanings to perform it are implementation specific.\n\nSetupDNAT configures and synchronizes DNAT rules for the specified externalIP and mapping, service, endpoints trio\n\nDeleteDNAT deletes all the configuration introduced by SetupDNAT for the specified externalIP and mapping.\n\n```go\nfunc NewThroughServiceDNATProvider(iptables nettools.IPTablesHelper, ipset nettools.IPSetHelper,\n\tnamer Namer) DNATProvider\n```\nNewThroughServiceDNATProvider returns new instance of the ThroughServiceDNAT\n\n```go\ntype IPRouteSmartNatHelper interface {\n\tEnsureOnlyOneIPRuleExistsForFwMark(rule nettools.IPRule) ([]nettools.IPRule, time.Duration, error)\n\tetime.Refresher\n}\n```\nIPRouteSmartNatHelper is a customized nettools.IPRouteProvider, which supports auto-refreshing of ip addresses and routes\n\n```go\nfunc NewChanIPRouteSmartNatHelper(ipRouteHelper nettools.IPRouteHelper, ifaceProvider nettools.InterfaceProvider,\n\tupdateChan chan time.Time, refreshOnCreate bool, gwAddressOffset int32) IPRouteSmartNatHelper\n```\nNewChanIPRouteSmartNatHelper creates IPRouteSmartNatHelper with routing rules refresh ran every time there's a new message on the update channel\n\n```go\nfunc NewIPRouteSmartNatHelper(routeHelperExecutor command.Executor, routeHelperIoOp nettools.SimpleFileOperator,\n\tifaceProvider nettools.InterfaceProvider, refreshPeriod time.Duration, gwAddressOffset int32) IPRouteSmartNatHelper\n```\nNewIPRouteSmartNatHelper creates IPRouteSmartNatHelper with periodic autorefreshing for them\n\n```go\ntype IPTablesHelp struct {\n\t// contains filtered or unexported fields\n}\n```\nIPTablesHelp implements IPTablesHelper interface using Linux iptables\n\n```go\nfunc (h *IPTablesHelp) DeleteDNAT(externalIP net.IP, mapping *v1alpha1.Mapping) error\n```\nDeleteDNAT implements IPTablesHelper.DeleteDNAT using linux iptables.\n\n```go\nfunc (h *IPTablesHelp) DeleteMark(externalIP net.IP, mapping *v1alpha1.Mapping) error\n```\nDeleteMark implements IPTablesHelper.DeleteMark using linux iptables.\n\n```go\nfunc (h *IPTablesHelp) DeleteSNAT(externalIP net.IP, mapping *v1alpha1.Mapping) error\n```\nDeleteSNAT implements IPTablesHelper.DeleteSNAT using linux iptables.\n\n```go\nfunc (h *IPTablesHelp) SetupDNAT(externalIP net.IP, mapping *v1alpha1.Mapping, svc *v1.Service,\n\teps *v1.Endpoints, setupMasquerade bool) error\n```\nSetupDNAT implements IPTablesHelper.SetupDNAT using linux iptables.\n\n```go\nfunc (h *IPTablesHelp) SetupMark(externalIP net.IP, mapping *v1alpha1.Mapping) error\n```\nSetupMark implements IPTablesHelper.SetupMark using linux iptables.\n\n```go\nfunc (h *IPTablesHelp) SetupSNAT(externalIP net.IP, mapping *v1alpha1.Mapping, svc *v1.Service,\n\teps *v1.Endpoints) error\n```\nSetupSNAT implements IPTablesHelper.SetupSNAT using linux iptables.\n\n```go\ntype IPTablesHelper interface {\n\tSetupDNAT(externalIP net.IP, mapping *v1alpha1.Mapping, svc *v1.Service, eps *v1.Endpoints,\n\t\tsetupMasquerade bool) error\n\tSetupSNAT(externalIP net.IP, mapping *v1alpha1.Mapping, svc *v1.Service, eps *v1.Endpoints) error\n\tSetupMark(externalIP net.IP, mapping *v1alpha1.Mapping) error\n\tDeleteDNAT(externalIP net.IP, mapping *v1alpha1.Mapping) error\n\tDeleteSNAT(externalIP net.IP, mapping *v1alpha1.Mapping) error\n\tDeleteMark(externalIP net.IP, mapping *v1alpha1.Mapping) error\n}\n```\nIPTablesHelper provides high level operations tuned for smart-nat-controller on system's -\n\nSetupDNAT sets up a DNAT rule for a traffic coming to externalIP to Service/Endpoints passed as the arguments for ports and sources listed in Maping.Spec.\n\nSetupSNAT sets up a SNAT rule for a traffic coming from any pod listed in Endpoints and going out through the interface with externalIP.\n\n### SetupMark sets up an iptables mark rule for the set associated with this mapping and external IP {#hdr-SetupMark_sets_up_an_iptables_mark_rule_for_the_set_associated_with_this_mapping_and_external_IP}\n\nDeleteDNAT deletes all DNAT entries created by SetupDNAT for externalIP and mapping passed as arguments.\n\nDeleteSNAT deletes all SNAT entries created by SetupSNAT for externalIP and mapping passed as arguments.\n\nDeleteMark deletes Mark entry created by SetupMark for externalIP and mapping passed as arguments.\n\n```go\nfunc NewIPTablesHelper(dnatProvider DNATProvider, iptables nettools.IPTablesHelper, namer Namer,\n\tifaceProvider nettools.InterfaceProvider, setupMasquerade, setupSNAT bool) (\n\tIPTablesHelper, error)\n```\nNewIPTablesHelper returns new NewIPTablesHelper implemented by NewIPTablesHelp\n\n```go\ntype LinuxSyncer struct {\n\t// contains filtered or unexported fields\n}\n```\nLinuxSyncer handles state synchronization between API objects and operating system configuration\n\n```go\nfunc (s *LinuxSyncer) DeleteMapping(mapping *v1alpha1.Mapping, externalIP net.IP) (dirty bool, err error)\n```\nDeleteMapping deletes all operating system configuration related to given mapping. When configuration is delted, it updates Status field of the mapping.\n\n```go\nfunc (s *LinuxSyncer) SyncMapping(mapping *v1alpha1.Mapping, svc *v1.Service, eps *v1.Endpoints) (\n\tdirty bool, err error)\n```\nSyncMapping syncs Mapping into a configuration in the operating system. Updates Mapping.Status.\n\n```go\ntype Namer interface {\n\tName(objectMeta metav1.ObjectMeta) ShortName\n}\n```\nNamer provides a consistent, unique and concise names for full namespace/name names\n\nName returns a concise name for a give namespaced name\n\n```go\nfunc NewNamer() Namer\n```\nNewNamer returns new implementation of Namer\n\n```go\ntype ReconcileMapping struct {\n\tclient.Client\n\t// contains filtered or unexported fields\n}\n```\nReconcileMapping reconciles a Mapping object\n\n```go\nfunc (r *ReconcileMapping) Reconcile(request reconcile.Request) (reconcile.Result, error)\n```\nReconcile reads that state of the cluster for a Mapping object and makes changes based on the state read and what is in the Mapping.Spec Automatically generate RBAC rules to allow the Controller to read and write Mappings, Services and Endpoints +kubebuilder:rbac:groups=apps,resources=services;endpoints,verbs=get;list;watch +kubebuilder:rbac:groups=smartnat.aureacentral.com,resources=mappings,verbs=get;list;watch;create;update;patch;delete\n\n```go\ntype Scrubber interface {\n\n\t// ScrubMapping does scrubbing on *v1alpha1.Mapping object, including validating ports\n\t// and setting their defaults if needed, validating CIDR expressions and checking if IP\n\t// address is local. It also checks for externalIP:port conflicts with mappings in\n\t// slice passed as the second argument.\n\tScrubMapping(sn *v1alpha1.Mapping, others []v1alpha1.Mapping) (valid, dirty bool, validErrMessage string,\n\t\tlocalExternalIP *net.IP)\n\n\t// ValidateEndpoints checks if Endpoints have only 0 or 1 Subsets\n\tValidateEndpoints(mapping *smartnatv1alpha1.Mapping, endpoints *v1.Endpoints) error\n}\n```\nScrubber provides validation, scrubbing and safe defaults for objects passed to it.\n\n```go\nfunc NewScrubber(interfaceProvider nettools.InterfaceProvider, cfg *config.Config) Scrubber\n```\nNewScrubber returns a scrubber for SmartNat objects\n\n```go\ntype ShortName = string\n```\nShortName is a at most 24 characters long name based on original metav1.ObjectMeta namespace and name\n\n```go\ntype Syncer interface {\n\n\t// DeleteMapping deletes all the configuration related to the\n\t// Mapping passed as an argument\n\tDeleteMapping(sn *v1alpha1.Mapping, externalIP net.IP) (dirty bool, err error)\n\n\t// SyncMapping reconciles data input and output paths, setting up everything\n\t// that is needed for the traffic arriving on External IP to reach\n\t// the given Service and then get back to a client\n\tSyncMapping(sn *v1alpha1.Mapping, svc *v1.Service, eps *v1.Endpoints) (dirty bool, err error)\n}\n```\nSyncer runs everything required to reconcile a single Mapping\n\n```go\nfunc NewSyncer(namer Namer, interfaceProvider nettools.InterfaceProvider,\n\tipRouteHelper IPRouteSmartNatHelper, conntrackHelper nettools.ConntrackHelper,\n\tiptHelper IPTablesHelper, ipsetHelper nettools.IPSetHelper, setupSNAT,\n\tsetupMasq bool) Syncer\n```\nNewSyncer creates a new Linux based Syncer\n\n```go\ntype ThroughServiceDNAT struct {\n\t// contains filtered or unexported fields\n}\n```\nThroughServiceDNAT implements DNATProvider by doing translation from External IP to ClusterIP of the service. The translation is done using iptables and will only work if kube-proxy is not running in 'iptables' mode. 'IPVS' kube-proxy is highly recommended and the only supported configuration.\n\n```go\nfunc (p *ThroughServiceDNAT) DeleteDNAT(externalIP net.IP, mapping *v1alpha1.Mapping) error\n```\nDeleteDNAT implements DNATProvider.DeleteDNAT by removing translation in iptables from External IP to ClusterIP of the Service.\n\n```go\nfunc (p *ThroughServiceDNAT) SetupDNAT(externalIP net.IP, mapping *v1alpha1.Mapping, svc *v1.Service,\n\t_ *v1.Endpoints, setupMasquerade bool) error\n```\nSetupDNAT implements DNATProvider.SetupDNAT by doing translation with iptables from External IP to ClusterIP of the Service.\n\n","path":"github.com/DevFactory/smartnat/pkg/controller/mapping","name":"mapping","synopsis":"","isRedistributable":true}
