Sign inSign up

voxsoft/kube-synchro-scale

By voxsoft

•Updated over 3 years ago

Publish metrics that allows you to scale 2 Kubernetes Deployments almost synchronously using HPA.

Image
0

1.3K

voxsoft/kube-synchro-scale repository overview

⁠kube-synchro-scale

Source: https://gitlab.com/voxsoft/tools/kube-synchro-scale⁠
dockerhub-voxsoft

Publish metrics that allows you to scale 2 Kubernetes Deployments almost synchronously using HPA

⁠How does it works

HTTP server gives you an synchro_scale_coefficient metric on /metrics URL path which represent next formula: Source Deploy Replicas / Target Deploy Replicas

⁠Configuration

Use environment variables to configure the application

Environment variable nameDescriptionDefault value
METRIC_PORTMetrics port9102
METRIC_PATHMetrics URL path/metrics
DEPLOY_SOURCE_NAMEDeployment name to be in sync with
DEPLOY_SOURCE_NAMESPACEDeployment namespace to be in sync with
DEPLOY_TARGET_NAMEDeployment name to be synced
DEPLOY_TARGET_NAMESPACEDeployment namespace to be synced

⁠Required permissions

  • List and Get Deployments

⁠Example usage

Minimal setup (Permissions and prometheus configuration not included)

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: targetapp
spec:
  selector:
    matchLabels:
      app: targetapp
  template:
    metadata:
      labels:
        app: targetapp
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/path: /metrics
        prometheus.io/port: '9102'
    spec:
      containers:
        - name: kube-synchro-scale
          image: voxsoft/kube-synchro-scale:1.0.0
          imagePullPolicy: Always
          ports:
            - containerPort: 9102
              protocol: TCP
          env:
            - name: DEPLOY_SOURCE_NAME
              value: sourceapp
            - name: DEPLOY_SOURCE_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: DEPLOY_TARGET_NAME
              value: targetapp
            - name: DEPLOY_TARGET_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace

---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: scale-targetapp-based-on-sourceapp-replicas
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: targetapp
  minReplicas: 1
  maxReplicas: 10
  metrics:
    - type: Pods
      pods:
        metric:
          name: synchro_scale_coefficient
        target:
          type: AverageValue
          averageValue: 1000m

Other examples ./examples⁠

Tag summary

Content type

Image

Digest

sha256:daecfb2c9…

Size

54.2 MB

Last updated

over 3 years ago

docker pull voxsoft/kube-synchro-scale