traefikServiceFabricPlugin

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 17 Imported by: 0

README

Traefik service-fabric-plugin

This provider plugin allows Traefik to query the Service Fabric management API to discover what services are currently running on a Service Fabric cluster. The provider then maps routing rules to these service instances. The provider will take into account the Health and Status of each of the services to ensure requests are only routed to healthy service instances.

  • This is a community/unofficial implementation in development

Installation

The plugin needs to be configured in the Traefik static configuration before it can be used.

Configuration

The plugin currently supports the following configuration settings:

  • pollInterval: The interval for polling the management endpoint for changes, in seconds.
  • clusterManagementURL: The URL for the Service Fabric Management API endpoint (e.g. http://dariotraefik1.southcentralus.cloudapp.azure.com:19080/)
  • certificate: The path to a certificate file or the PEM certificate content. If not provided, HTTP will be used.
  • certificateKey: The path to a private key file or the key content. If not provided, HTTP will be used.

Example configuration

entryPoints:
  web:
    address: :9999
    
api:
  dashboard: true

log:
  level: DEBUG

pilot:
  token: xxxxx

experimental:
  traefikServiceFabricPlugin:
    moduleName: github.com/dariopb/traefikServiceFabricPlugin
    version: v0.2.2

providers:
  plugin:
    traefikServiceFabricPlugin:
      pollInterval: 4s
      clusterManagementURL: http://dariotraefik1.southcentralus.cloudapp.azure.com:19080/
      #certificate : ./cert.pem
      #certificateKey: ./cert.key

Sample deployments

For a complete way to deploy and use the proxy in a Service Fabric cluster, please look here: https://github.com/dariopb/sf-reverseproxies-templates (those are samples only and should be modified according to your needs)

ServiceManifest file

This is a sample SF enabled service showing the currently supported labels. If the sf name is fabric:/pinger/PingerService, the endpoint will be expose at that prefix: '/pinger/PingerService/'

  ...
  <ServiceTypes>
    <StatelessServiceType ServiceTypeName="PingerServiceType" UseImplicitHost="true">
      <Extensions>
        <Extension Name="traefik">
        <Labels xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
          <Label Key="traefik.http.enable">true</Label>
          <Label Key="traefik.http.loadbalancer.passhostheader">true</Label>
          <Label Key="traefik.http.loadbalancer.healthcheck.path">/</Label>
          <Label Key="traefik.http.loadbalancer.healthcheck.interval">10s</Label>
          <Label Key="traefik.http.loadbalancer.healthcheck.scheme">http</Label>
        </Labels>
        </Extension>
      </Extensions>
    </StatelessServiceType>
  </ServiceTypes>
  ...

Supported Labels (since 0.2.x)

Rule section

  • traefik.http.rule Traefik rule to apply [PathPrefix(/dario))]. This rule is added on top of the default path generation. If this is set, you have to define a middleware to remove the prefix for the service to receive the stripped path.

Loadbalancer section

  • traefik.http.loadbalancer.passhostheader passhostheaders ['true'/'false']
  • traefik.http.loadbalancer.healthcheck.path Healthcheck endpoint path ['/healtz']
  • traefik.http.loadbalancer.healthcheck.interval Healthcheck interval ['10s']
  • traefik.http.loadbalancer.healthcheck.scheme Healthcheck scheme ['http']

Middleware section

  • traefik.http.middleware.stripprefix prefix to strip ['/dario']

License

This software is released under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBoolValue added in v0.1.4

func GetBoolValue(labels map[string]string, labelName string, defaultValue bool) bool

GetBoolValue get bool value associated to a label.

func GetIntValue added in v0.1.4

func GetIntValue(labels map[string]string, labelName string, defaultValue int) int

GetIntValue get int value associated to a label.

func GetStringValue added in v0.1.4

func GetStringValue(labels map[string]string, labelName, defaultValue string) string

GetStringValue get string value associated to a label.

Types

type ClientTLS

type ClientTLS struct {
	CA                 string `json:"ca,omitempty" toml:"ca,omitempty" yaml:"ca,omitempty"`
	CAOptional         bool   `json:"caOptional,omitempty" toml:"caOptional,omitempty" yaml:"caOptional,omitempty" export:"true"`
	Cert               string `json:"cert,omitempty" toml:"cert,omitempty" yaml:"cert,omitempty"`
	Key                string `json:"key,omitempty" toml:"key,omitempty" yaml:"key,omitempty"`
	InsecureSkipVerify bool   `json:"insecureSkipVerify,omitempty" toml:"insecureSkipVerify,omitempty" yaml:"insecureSkipVerify,omitempty" export:"true"`
}

ClientTLS holds the TLS specific configurations as client CA, Cert and Key can be either path or file contents.

func (*ClientTLS) CreateTLSConfig

func (c *ClientTLS) CreateTLSConfig() (*tls.Config, error)

CreateTLSConfig creates a TLS config from ClientTLS structures.

type Config

type Config struct {
	PollInterval         string `json:"pollInterval,omitempty"`
	ClusterManagementURL string `json:"clusterManagementURL,omitempty"`

	Certificate    string `json:"certificate,omitempty"`
	CertificateKey string `json:"certificateKey,omitempty"`
}

Config the plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates the default plugin configuration.

type PartitionItemExtended

type PartitionItemExtended struct {
	sf.PartitionItem
	Replicas  []sf.ReplicaItem
	Instances []sf.InstanceItem
}

PartitionItemExtended provides a flattened view of a services partitions.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider a simple provider plugin.

func New

func New(ctx context.Context, config *Config, name string) (*Provider, error)

New creates a new Provider plugin.

func (*Provider) Init

func (p *Provider) Init() error

Init the provider.

func (*Provider) Provide

func (p *Provider) Provide(cfgChan chan<- json.Marshaler) error

Provide creates and send dynamic configuration.

func (*Provider) Stop

func (p *Provider) Stop() error

Stop to stop the provider and the related go routines.

type ServiceItemExtended

type ServiceItemExtended struct {
	sf.ServiceItem
	Application sf.ApplicationItem
	Partitions  []PartitionItemExtended
	Labels      map[string]string
}

ServiceItemExtended provides a flattened view of the service with details of the application it belongs too and the replicas/partitions.

Jump to

Keyboard shortcuts

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