acouvreur / sablier

Start your containers on demand, shut them down automatically when there's no activity. Docker, Docker Swarm Mode and Kubernetes compatible.
https://acouvreur.github.io/sablier/
GNU Affero General Public License v3.0
1.17k stars 44 forks source link

Sablier Deployment starting and stopping on its own #124

Closed chandakanant closed 1 week ago

chandakanant commented 1 year ago

Describe the bug My application auto scales up and down perfectly when using Sablier Middleware but when the application pods are scaled down to 0 then Sablier is scaling up and scaling down the application by its own even though I am not hitting the endpoint URL. Also, I checked the sablier logs after 24 hours without hitting the endpoint URL, the application pod scaled up and down 4 times on its own. Sometime it is more and sometime it is less in the 24 hour time interval.

Here are my deployment, service, ingress and middleware that I use.

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: prometheus-flask-app
    chart: sbd-prometheus-flask-app-1.1
    heritage: Helm
    release: prometheus-flask-app
  name: prometheus-flask-app
  namespace: knative-deployment
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: prometheus-flask-app
      release: prometheus-flask-app
  template:
    metadata:
      labels:
        app: prometheus-flask-app
        release: prometheus-flask-app
    spec:
      containers:
      - image: flaskapp:latest
        imagePullPolicy: Always
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 5000
            scheme: HTTP
          initialDelaySeconds: 60
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: sbd-prometheus-flask-app
        ports:
        - containerPort: 5000
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 5000
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          requests:
            cpu: 20m
            memory: 100Mi

Service

apiVersion: v1
kind: Service
metadata:
  name: prometheus-flask-app-svc
  labels:
    app: prometheus-flask-app
    chart: sbd-prometheus-flask-app-1.1
    release: prometheus-flask-app
    heritage: Helm
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 5000
      protocol: TCP
      name: sbd-prometheus-flask-app
  selector:
    app: prometheus-flask-app
    release: prometheus-flask-app

Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    test: test
    traefik.ingress.kubernetes.io/router.middlewares: knative-deployment-prometheus-flask-app-middleware@kubernetescrd
  name: prometheus-flask-app-ingress
spec:
  ingressClassName: traefik
  rules:
  - http:
      paths:
      - backend:
          service:
            name: prometheus-flask-app-svc
            port:
              number: 80
        path: /app
        pathType: Prefix
status:
  loadBalancer: {}

Middleware

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: prometheus-flask-app-middleware
spec:
  plugin:
    sablier:
      blocking:
        timeout: 30s
        # showDetails: true
        # theme: shuffle
      names: deployment_knative-deployment_prometheus-flask-app_1
      sablierUrl: http://sablier.knative-deployment:10000
      sessionDuration: 1m

ScreenShot of Sablier Logs of 2 different times

image

image

ScreenShot of Traefik Logs of same time when application scaled up and down

image

Context

Expected behavior The application pod should not scale up till I hit the endpoint URL.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.