You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by "Copilot (via GitHub)" <gi...@apache.org> on 2026/09/18 05:34:25 UTC
Re: [PR] Feat: Add support for stickyness policy [cloudstack-kubernetes-provider]
Copilot commented on code in PR #88:
URL: https://github.com/apache/cloudstack-kubernetes-provider/pull/88#discussion_r4044085153
##########
README.md:
##########
@@ -178,6 +178,70 @@ list, which briefly interrupts traffic on that port.
Setting it to an empty value (`""`) sends an empty CIDR list to CloudStack — it does not block all
traffic.
+#### `service.beta.kubernetes.io/cloudstack-load-balancer-stickiness-method-name`
+
+**Type:** String
+
+**Default:** Not set (no stickiness policy)
+
+**Description:** Creates a CloudStack **LB stickiness policy** on every load balancer rule belonging
+to the service, making the load balancer keep a client on the same backend node between requests.
+
+The value is the CloudStack stickiness method name and is passed through to CloudStack, which
+validates it against the methods the network's load balancer provider offers. The VirtualRouter
+(HAProxy) provider supports `LbCookie`, `AppCookie` and `SourceBased`. An unsupported method makes
+the service fail to sync with an `error creating stickiness policy` error.
+
+Each service port has its own load balancer rule, so a service exposing several ports gets one
+policy per port, all with the same method and parameters.
+
+**Use Case:** Applications that keep per-client state in the backend — a session held in process
+memory, for example — and therefore need successive requests from one client to land on the same
+node.
+
+**Example:**
+```yaml
+apiVersion: v1
+kind: Service
+metadata:
+ name: my-service
+ annotations:
+ service.beta.kubernetes.io/cloudstack-load-balancer-stickiness-method-name: "LbCookie"
+ service.beta.kubernetes.io/cloudstack-load-balancer-stickiness-method-param: "name=SERVERID"
Review Comment:
This example uses `name`, but CloudStack's VirtualRouter stickiness methods expect the parameter key `cookie-name`; the controller passes annotation keys through unchanged, so this example will send an unsupported key and the service sync will fail. Use the actual CloudStack key here.
##########
cloudstack_loadbalancer.go:
##########
@@ -1236,6 +1372,23 @@ func getStringFromServiceAnnotation(service *corev1.Service, annotationKey strin
return defaultSetting
}
+// parseStickinessParams parses a comma-separated string of key=value pairs into a map.
+// Empty values and malformed entries are ignored.
Review Comment:
This comment says empty values are ignored, but the implementation deliberately preserves `key=` values and the README documents that behavior. Clarify that empty entries are ignored while empty values are preserved so the comment does not mislead future changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org