Skip to content

oliviabarrick/ipvs-operator

Repository files navigation

Kubernetes operator for setting IPVS weights on Kubernetes ClusterIP services.

The operator provides a new Kubernetes resource called a WeightedService.

build status image version image size

This operator is in very early alpha and should be used with care.

Installation

Follow the IPVS guide to configure your Kubernetes cluster to use IPVS instead of iptables.

To install the operator, simply apply the manifest:

kubectl apply -f https://raw.githubusercontent.com/justinbarrick/ipvs-operator/master/deploy/operator.yaml

This will install the IPVS operator as a DaemonSet on all of your nodes.

WeightedServices

You can use a WeightedService to apply IPVS load balancing weights to pods matching certain labels.

A WeightService can enable canary deployments by setting different weights for your canary and production deployments. See the IPVS weighted round-robin documentation for more information. If a scheduler is not set, it defaults to "wrr".

For example, to send 10% of traffic to your canary deployment:

apiVersion: codesink.net/v1alpha1
kind: WeightedService
metadata:
  name: example
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 80
    targetPort: www
  scheduler: wlc
  weights:
  - weight: 10
    selector:
      env: prod
  - weight: 1
    selector:
      env: canary

The WeightedService will create a Service matching the provided ServiceSpec and assign weights to pods that match the specified labels.

See test/example.yaml for a full example.

Note that the service weights will not apply for anything that routes directly to endpoint IPs (e.g., some ingress controllers by default), but will work for the service IP. For example, if you're using the nginx ingress controller set the service-upstream annotation:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "canary-demo.local"
  annotations:
    nginx.ingress.kubernetes.io/service-upstream: "true"
spec:
  rules:
  - host: canary-demo.local
    http:
      paths:
        - path: /
          backend:
            serviceName: example
            servicePort: 80

About

Operator for adjusting IPVS weights and scheduling algorithms for services in Kubernetes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages