Créer un load balancer interne

Vous pouvez créer un load balancer interne pour distribuer le trafic réseau entrant entre plusieurs machines virtuelles (VM) d’un Net.

Créer un load balancer interne avec Cockpit v2

Avant de commencer :

  1. Créez un Net avec un Subnet. Pour en savoir plus, voir Nets.

  2. (optionnel) Créez un security group pour le load balancer avec les règles suivantes :

    • Autorisez les flux entrants en protocole TCP sur le port que vous souhaitez.

    • Autorisez les flux entrants venant des security groups des VM qui envoient les requêtes.

    • Autorisez les flux sortants vers l’ensemble des security groups des VM backend.

  3. (optionnel) Configurez le security group des futures VM backend avec les règles suivantes :

    • Autorisez les flux entrants en protocole TCP sur le port que vous souhaitez.

    • Autorisez les flux entrants venant du security group du load balancer.

Pour en savoir plus, voir Security Groups.

Ouvrir la fenêtre Créer un load balancer

Dans le dashboard Load Balancers, cliquez sur IconAddFull Créer un load balancer.
La boîte de dialogue CRÉER UN LOAD BALANCER apparaît.

Configurer votre load balancer

Choisir un nom

  1. Dans le champ Nom, tapez un nom pour le load balancer.

    • Ce nom doit être unique pour l’ensemble de la Région.

    • Il doit suivre des règles de noms de domaine, c’est-à-dire qu’il peut contenir au maximum 32 caractères alphanumériques ou tirets, mais ne peut pas commencer ou finir par un tiret.

  2. Cliquez sur Suivant.
    L’écran Type de load balancer apparaît.

Sélectionner la confidentalité, le type de load balancer, le Subnet, et le security group

  1. Dans la liste Confidentialité, sélectionnez Cloud privé.

  2. Dans la liste Type de load balancer, sélectionnez interne.

  3. Dans la liste Subnet, sélectionnez le Subnet dans lequel vous souhaitez créer le load balancer.

  4. Dans la liste Security group, sélectionnez :

    • Créer un nouveau security group pour associer un nouveau security group au load balancer.

      1. Dans le champ Nom, tapez un nom pour le security group.

      2. Dans le champ Description, tapez sa description.

        • Le nom doit être unique dans votre compte pour le Cloud public ou pour chaque Net.

        • Le nom du security group ne doit pas commencer par sg-.

        • Chaque nom et description peut contenir entre 1 et 255 caractères. Les caractères autorisés sont a-z, A-Z, 0-9, l’espace et _.-:/()#,@[]+=&;\{}!$*.

    • Sélectionner un ou plusieurs security groups pour sélectionner un security group pour le load balancer.

    • Poursuivre avec un security group par défaut pour sélectionner le security group par défaut du Net.

  5. Cliquez sur Suivant.
    L’écran Listeners apparaît.

Configurer les listeners

  1. Dans la liste Protocole, sélectionnez le protocole de routage du load balancer (HTTP, HTTPS, TCP, SSL).

  2. Dans le champ Port du load balancer, tapez le port d’écoute du load balancer ou sélectionnez-le avec les flèches (entre 1 et 65535, les deux étant inclus).

  3. Dans le champ Port de la VM backend, tapez le port d’écoute de la VM backend ou sélectionnez-le avec les flèches (entre 1 et 65535, les deux étant inclus).

  4. Cliquez sur Suivant.
    L’écran Listeners apparaît.

Configurer un health check

  1. Depuis la liste Protocole, sélectionnez le protocole pour l’URL de la VM (HTTP, HTTPS, TCP, SSL).

  2. Dans le champ Port, tapez le numéro d’écoute ou sélectionnez-le avec les flèches (entre 1 et 65535, les deux étant inclus).

  3. Dans le champ Intervalle, tapez le nombre de secondes entre deux requêtes ou sélectionnez-le avec les flèches (entre 5 et 600, les deux étant inclus).

  4. Dans le champ Délai d’expiration, tapez le temps d’attente maximum d’une réponse, en secondes, avant de considérer la VM comme défaillante ou sélectionnez-le avec les flèches (entre 2 et 60, les deux étant inclus).

  5. Dans le champ Seuil satisfaisant, tapez le nombre de requêtes successives réussies avant de considérer la VM comme saine ou sélectionnez-le avec les flèches (entre 2 et 10, les deux étant inclus).

  6. Dans le champ Seuil insuffisant, tapez le nombre de requêtes successives échouées avant de considérer la VM comme défaillante ou sélectionnez-le avec les flèches (entre 2 et 10, les deux étant inclus).

  7. Cliquez sur Suivant.
    L’écran Access logs apparaît.

Configurer les access logs

Le volume de données (en Gio) stockées dans votre bucket OOS sera ajouté à la consommation de vos ressources.

  1. (optionnel) Laissez Personnaliser les access logs activé, puis spécifiez les informations suivantes :

    • Dans le champ Nom du bucket OOS, tapez le nom du bucket OOS pour les access logs.

    • (optionnel) Dans le champ Préfixe du bucket OOS, tapez le chemin d’accès au dossier des access logs dans votre bucket OOS (par défaut, le niveau root de votre bucket).

    • Depuis la liste Intervalle de publication, sélectionnez l’intervalle de temps, en minutes, pour la publication des access logs dans votre bucket OOS. Cette valeur peut être soit 5 ou 60 (par défaut, 60).

  2. Cliquez sur Suivant.
    L’écran VM backend apparaît.

Configurer des VM backend

  1. Depuis la liste Enregistrer des VM backend, sélectionnez :

    • Sélectionner des VM backend pour sélectionner une ou plusieurs VM backend à enregistrer auprès du load balancer.

    • Poursuivre sans VM backend si vous ne souhaitez pas enregistrer de VM backend auprès du load balancer.

  2. Cliquez sur Suivant.
    L’écran Récapitulatif apparaît.

Confirmer la création du load balancer

  1. Vérifiez l’ensemble des paramètres du load balancer.

  2. Cliquez sur Créer.
    Le load balancer est créé.

    Le load balancer est disponible environ 1 minute après sa création.

Créer un load balancer interne avec OSC CLI

Avant de commencer :

  1. Créez un Net. Pour en savoir plus, voir Nets.

  2. Créez un security group pour le load balancer avec les règles suivantes :

    • Autorisez les flux entrants en protocole TCP sur le port que vous souhaitez.

    • Autorisez les flux entrants venant des security groups des VM qui envoient les requêtes.

    • Autorisez les flux sortants vers l’ensemble des security groups des VM backend.

  3. Configurez le security group des futures VM backend avec les règles suivantes :

    • Autorisez les flux entrants en protocole TCP sur le port que vous souhaitez.

    • Autorisez les flux entrants venant du security group du load balancer.

Pour en savoir plus, voir Security Groups.

À ce jour, cette section est disponible en anglais uniquement.

The CreateLoadBalancer command creates a load balancer.
The load balancer is created with a unique Domain Name Service (DNS) name. It receives the incoming traffic and routes it to its registered virtual machines (VMs).
By default, this action creates an Internet-facing load balancer, resolving to public IPs. To create an internal load balancer in a Net, resolving to private IPs, use the LoadBalancerType parameter.
You must specify either the Subnets or the SubregionNames parameters.

For more information, see About Load Balancers.

Request sample: Creating an internal load balancer in a Net
$ osc-cli api CreateLoadBalancer --profile "default" \
    --LoadBalancerName "private-lb-example" \
    --Listeners '[
        {
          "BackendPort": 80,
          "BackendProtocol": "TCP",
          "LoadBalancerPort": 80,
          "LoadBalancerProtocol": "TCP",
        },
      ]' \
    --Subnets '["subnet-12345678"]' \
    --SecurityGroups '["sg-12345678"]' \
    --LoadBalancerType "internal"

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • Listeners: One or more listeners to create.

    • BackendPort: (optional) The port on which the backend VM is listening (between 1 and 65535, both included).

    • BackendProtocol: (optional) The protocol for routing traffic to backend VMs (HTTP | HTTPS | TCP | SSL).

    • LoadBalancerPort: (optional) The port on which the load balancer is listening (between 1 and 65535, both included).

    • LoadBalancerProtocol: (optional) The routing protocol (HTTP | HTTPS | TCP | SSL).

    • ServerCertificateId: (optional) The OUTSCALE Resource Name (ORN) of the server certificate. For more information, see Resource Identifiers > OUTSCALE Resource Names (ORNs).

  • LoadBalancerName: The unique name of the load balancer, with a maximum length of 32 alphanumeric characters and dashes (-). This name must not start or end with a dash.

  • LoadBalancerType: (optional) The type of load balancer: internet-facing or internal. Use this parameter only for load balancers in a Net.

  • SecurityGroups: (optional) (Net only) One or more IDs of security groups you want to assign to the load balancer. If not specified, the default security group of the Net is assigned to the load balancer.

  • Subnets: (optional) (Net only) The ID of the Subnet in which you want to create the load balancer. Regardless of this Subnet, the load balancer can distribute traffic to all Subnets. This parameter is required in a Net.

  • Tags: (optional) One or more tags assigned to the load balancer.

    • Key: (optional) The key of the tag, with a minimum of 1 character.

    • Value: (optional) The value of the tag, between 0 and 255 characters.

The CreateLoadBalancer command returns the following elements:

  • LoadBalancer: Information about the load balancer.

    • AccessLog: Information about access logs.

      • IsEnabled: If true, access logs are enabled for your load balancer. If false, they are not. If you set this to true in your request, the OsuBucketName parameter is required.

      • OsuBucketName: The name of the OOS bucket for the access logs.

      • OsuBucketPrefix: The path to the folder of the access logs in your OOS bucket (by default, the root level of your bucket).

      • PublicationInterval: The time interval for the publication of access logs in the OOS bucket, in minutes. This value can be either 5 or 60 (by default, 60).

    • ApplicationStickyCookiePolicies: The stickiness policies defined for the load balancer.

      • CookieName: The name of the application cookie used for stickiness.

      • PolicyName: The mnemonic name for the policy being created. The name must be unique within a set of policies for this load balancer.

    • BackendIps: One or more public IPs of backend VMs.

    • BackendVmIds: One or more IDs of backend VMs for the load balancer.

    • DnsName: The DNS name of the load balancer.

    • HealthCheck: Information about the health check configuration.

      • CheckInterval: The number of seconds between two requests (between 5 and 600 both included).

      • HealthyThreshold: The number of consecutive successful requests before considering the VM as healthy (between 2 and 10 both included).

      • Path: If you use the HTTP or HTTPS protocols, the request URL path.

      • Port: The port number (between 1 and 65535, both included).

      • Protocol: The protocol for the URL of the VM (HTTP | HTTPS | TCP | SSL).

      • Timeout: The maximum waiting time for a response before considering the VM as unhealthy, in seconds (between 2 and 60 both included).

      • UnhealthyThreshold: The number of consecutive failed requests before considering the VM as unhealthy (between 2 and 10 both included).

    • Listeners: The listeners for the load balancer.

      • BackendPort: The port on which the backend VM is listening (between 1 and 65535, both included).

      • BackendProtocol: The protocol for routing traffic to backend VMs (HTTP | HTTPS | TCP | SSL).

      • LoadBalancerPort: The port on which the load balancer is listening (between 1 and 65535, both included).

      • LoadBalancerProtocol: The routing protocol (HTTP | HTTPS | TCP | SSL).

      • PolicyNames: The names of the policies. If there are no policies enabled, the list is empty.

      • ServerCertificateId: The OUTSCALE Resource Name (ORN) of the server certificate. For more information, see Resource Identifiers > OUTSCALE Resource Names (ORNs).

    • LoadBalancerName: The name of the load balancer.

    • LoadBalancerStickyCookiePolicies: The policies defined for the load balancer.

      • CookieExpirationPeriod: The time period, in seconds, after which the cookie should be considered stale.
        If 1, the stickiness session lasts for the duration of the browser session.

      • PolicyName: The name of the stickiness policy.

    • LoadBalancerType: The type of load balancer. Valid only for load balancers in a Net.
      If LoadBalancerType is internet-facing, the load balancer has a public DNS name that resolves to a public IP.
      If LoadBalancerType is internal, the load balancer has a public DNS name that resolves to a private IP.

    • NetId: The ID of the Net for the load balancer.

    • PublicIp: (internet-facing only) The public IP associated with the load balancer.

    • SecuredCookies: Whether secure cookies are enabled for the load balancer.

    • SecurityGroups: One or more IDs of security groups for the load balancers. Valid only for load balancers in a Net.

    • SourceSecurityGroup: Information about the source security group of the load balancer, which you can use as part of your inbound rules for your registered VMs.
      To only allow traffic from load balancers, add a security group rule that specifies this source security group as the inbound source.

      • SecurityGroupAccountId: The account ID of the owner of the security group.

      • SecurityGroupName: The name of the security group.

    • Subnets: The ID of the Subnet in which the load balancer was created.

    • SubregionNames: The ID of the Subregion in which the load balancer was created.

    • Tags: One or more tags associated with the load balancer.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample: Creating an internal load balancer in a Net
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LoadBalancer": {
    "Tags": [],
    "SourceSecurityGroup": {
      "SecurityGroupName": "security-group-example",
      "SecurityGroupAccountId": "123456789012"
    },
    "SecuredCookies": false,
    "Subnets": [
      "subnet-12345678"
    ],
    "NetId": "vpc-12345678",
    "BackendVmIds": [],
    "ApplicationStickyCookiePolicies": [],
    "SecurityGroups": [
      "sg-12345678"
    ],
    "LoadBalancerType": "internal",
    "AccessLog": {
      "PublicationInterval": 60,
      "IsEnabled": false
    },
    "DnsName": "internal-private-lb-example.123456789.eu-west-2.lbu.outscale.com",
    "HealthCheck": {
      "UnhealthyThreshold": 2,
      "Timeout": 5,
      "CheckInterval": 30,
      "Protocol": "TCP",
      "HealthyThreshold": 10,
      "Port": 80
    },
    "LoadBalancerStickyCookiePolicies": [],
    "SubregionNames": [
      "eu-west-2a"
    ],
    "Listeners": [
      {
        "BackendPort": 80,
        "BackendProtocol": "TCP",
        "LoadBalancerPort": 80,
        "LoadBalancerProtocol": "TCP"
      }
    ],
    "LoadBalancerName": "private-lb-example"
  }
}

Créer un load balancer interne avec AWS CLI

Avant de commencer :

  1. Créez un VPC. Pour en savoir plus, voir Nets.

  2. Créez un security group pour le load balancer avec les règles suivantes :

    • Autorisez les flux entrants en protocole TCP sur le port que vous souhaitez.

    • Autorisez les flux entrants venant des security groups des instances qui envoient les requêtes.

    • Autorisez les flux sortants vers l’ensemble des security groups des instances backend.

  3. Configurez le security group des futures instances backend avec les règles suivantes :

    • Autorisez les flux entrants en protocole TCP sur le port que vous souhaitez.

    • Autorisez les flux entrants venant du security group du load balancer.

Pour en savoir plus, voir Security Groups.

Pour créer un load balancer interne, utilisez la commande create-load-balancer en suivant cette syntaxe :

Exemple de requête
$ aws elb create-load-balancer \
    --profile YOUR_PROFILE \
    --load-balancer-name my_load_balancer \
    --listeners Protocol=TCP,LoadBalancerPort=62,InstanceProtocol=TCP,InstancePort=58 \
    --subnets subnet-12345678 \
    --security-groups sg-12345678 sg-87654321 \
    --scheme internal \
    --endpoint https://lbu.eu-west-2.outscale.com

Cette commande contient les attributs suivants que vous devez spécifier :

  • load-balancer-name : Le nom du load balancer.

    • Ce nom doit être unique pour l’ensemble de la Région.

    • Il doit suivre des règles de noms de domaine, c’est-à-dire qu’il peut contenir au maximum 32 caractères alphanumériques ou tirets, mais ne peut pas commencer ou finir par un tiret.

  • listeners : Un ou plusieurs listeners pour le load balancer. Cet attribut requiert les éléments suivants pour chaque listener :

    Pour ajouter plusieurs listeners, séparez-les à l’aide d’une espace.

    • Protocol : Le protocole de routage pour le load balancer (HTTP, HTTPS, TCP ou SSL).

    • LoadBalancerPort : Le port sur lequel le load balancer écoute (entre 1 et 65535, tous deux inclus).

    • InstancePort : Le port sur lequel les instances backend écoutent (entre 1 et 65535, tous deux inclus).

    • (optionnel) InstanceProtocol : Le protocole utilisé pour router le trafic vers les instances backend (HTTP, HTTPS, TCP ou SSL).

    • (optionnel) SSLCertificateId : L’OUTSCALE Resource Name (ORN) d’un certificat SSL. Pour en savoir plus, voir Obtenir des informations sur vos certificats serveur.

      Un certificat SSL est requis si le protocole du load balancer est HTTPS ou SSL.

      Pour en savoir plus sur comment configurer votre listener lorsque vous utilisez des certificats SSL, voir Configurer un load balancer pour une redirection SSL.

  • subnets : L’ID du subnet dans lequel vous voulez créer le load balancer. Quel que soit ce subnet, le load balancer peut distribuer du trafic vers tous les subnets.

  • (optionnel) security-groups : Un ou plusieurs ID de security groups que vous voulez attribuer au load balancer. Si rien n’est spécifié, le security group par défaut du VPC est attribué au load balancer.

  • scheme : Le type de load balancer que vous voulez créer (ici, internal).

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête.

La commande create-load-balancer renvoie l’élément suivant :

  • DNSName : Le nom de DNS attribué au load balancer.

Exemple de résultat
 {
    "DNSName": "my_load_balancer_1234567890.lbu.eu-west-2.outscale.com"
}

Pages connexes

Méthodes API correspondantes

AWS™ et Amazon Web Services™ sont des marques de commerce d’Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.