Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defrag CronJob #221

Open
kvaps opened this issue May 20, 2024 · 5 comments
Open

Add defrag CronJob #221

kvaps opened this issue May 20, 2024 · 5 comments
Milestone

Comments

@kvaps
Copy link
Member

kvaps commented May 20, 2024

Kubernetes recomends using etcd-defrag to run defragmentation of the cluster.

Since this is expensive operation this tool allows to specify specific rule, eg:

dbQuotaUsage > 0.8 || dbSize - dbSizeInUse > 200*1024*1024

https://github.com/ahrtr/etcd-defrag/blob/main/doc/etcd-defrag-cronjob.yaml

This is slightly diferent from kamaji-etcd implementation
https://github.com/clastix/kamaji-etcd/blob/433989a4badeb8edc0925cfc671fb0cc66448e66/charts/kamaji-etcd/templates/etcd_cronjob_defrag.yaml#L11

In Cozystack we currnelty added it into Helm chart:
https://github.com/aenix-io/cozystack/pull/137/files#diff-0dcf3889fea1c88eb22a0d84208697a4ed71c8cb111d1d29ec714a71529d5822

@kvaps kvaps added this to the v0.3.0 milestone May 20, 2024
@kvaps
Copy link
Member Author

kvaps commented May 20, 2024

@Kirill-Garbar commented:

Let's discuss whether it's a cron job or not, just that. Personally, I don't like cron jobs even though they are simple

@kvaps
Copy link
Member Author

kvaps commented May 28, 2024

Probably depends on #204

@kvaps kvaps modified the milestones: v0.3.0, v0.4.0 Jun 25, 2024
@kvaps
Copy link
Member Author

kvaps commented Jul 9, 2024

---
apiVersion: etcd.aenix.io/v1alpha1
kind: EtcdCluster
metadata:
  name: test
  namespace: test-tls-auth-etcd-cluster
spec:
  options:
  defrag:
    schedule: "*/15 * * * *"
    rule: # TODO: check the common Kubernetes syntax
     operator: Or|And
     quotaMoreThan: 80%
     dbFreeSizeLessThan: 200MB
  storage:
    volumeClaimTemplate:
      spec:
        storageClassName: gp3
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 10Gi
  security:
    enableAuth: true
    tls:
      peerTrustedCASecret: ca-peer-secret
      peerSecret: peer-secret
      serverTrustedCASecret: ca-server-secret
      serverSecret: server-secret
      clientTrustedCASecret: ca-client-secret
      clientSecret: client-secret
 status:
   conditions:
   - lastProbeTime: null
     lastTransitionTime: "2024-03-06T18:39:45Z"
     status: "True"
     type: DefragChecked

@kvaps
Copy link
Member Author

kvaps commented Jul 9, 2024

@lllamnyp also sugested to use go templates:

rule: {{ and (gt .dbAvailableSize 200*1024*1024) (gt .dbInUsePercent 80) }}

@kvaps
Copy link
Member Author

kvaps commented Jul 9, 2024

defragJobTerms:
- matchExpressions:
  - key: dbSpaceFree
    operator: Lt
    values: 200Mi
  - key: dbQuotaUsage
    operator: Gt
    values: 20%

@kvaps kvaps modified the milestones: v0.4.0, v0.5.0 Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant