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

feat: add cluster autoscaler civo #160

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

mrsimonemms
Copy link
Contributor

@mrsimonemms mrsimonemms commented Aug 22, 2024

Description

Adds Cluster Autoscaler for Civo.

I made a couple of design decisions which are worth explaining:

  • the name is cluster-autoscaler-<cloud>. That will ensure that future deployments for AWS, GCP etc are all located in the same area of codebase/catalogue
  • I've done this on a per-cloud basis. I'm not a great fan of this approach and would prefer a single cluster-autoscaler deployment where the correct configuration can be generated. However, I can't see a way of achieving the necessary templating as things currently stand - if there is an undocumented way of achieving that, please tell me.

Related Issue(s)

Fixes #

How to test

Scale-up

  1. Create a physical Civo cluster with a single node
  2. Add the YAML files to your gitops repo's registry/cluster/<cluster-name> replacing the variables as necessary
  3. Deploy something and watch the additional nodes deploy

Scale-down

  1. In the Civo dashboard, increase the number of nodes on your cluster to 10
  2. After ~5 mins, it should drop down to 1-2 nodes

Examples

cluster-autoscaler-civo.yaml

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: sje-cluster-autoscaler-cluster-autoscaler-civo-components
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-wave: '100'
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  source:
    repoURL: [email protected]:mrsimonemmsorg/gitops.git
    path: registry/clusters/sje-cluster-autoscaler/components/cluster-autoscaler-civo
    targetRevision: HEAD
  destination:
    name: in-cluster
    namespace: kube-system
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

components/cluster-autoscaler-civo/application.yaml

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: sje-cluster-autoscaler-cluster-autoscaler-civo
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-wave: '20'
spec:
  project: sje-cluster-autoscaler
  source:
    repoURL: https://kubernetes.github.io/autoscaler
    targetRevision: 9.37.0
    chart: cluster-autoscaler
    helm:
      releaseName: cluster-autoscaler-civo
      values: |
        autoDiscovery:
          clusterName: sje-cluster-autoscale
        cloudProvider: civo
        extraArgs:
          nodes: 1:10:sje-cluster-autoscaler
          skip-nodes-with-local-storage: false
          skip-nodes-with-system-pods: false
        extraEnvSecrets:
          CIVO_API_KEY:
            name: civo-api-access
            key: api-key
          CIVO_API_URL:
            name: civo-api-access
            key: api-url
          CIVO_CLUSTER_ID:
            name: civo-api-access
            key: cluster-id
          CIVO_REGION:
            name: civo-api-access
            key: region
  destination:
    name: sje-cluster-autoscaler
    namespace: kube-system
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

@patrickdappollonio
Copy link
Member

Re:

I've done this on a per-cloud basis. I'm not a great fan of this approach and would prefer a single cluster-autoscaler deployment where the correct configuration can be generated. However, I can't see a way of achieving the necessary templating as things currently stand - if there is an undocumented way of achieving that, please tell me.

100% agree. I don't think there's a generic way to do it since between cloud controller managers being able to be internal or external plus the cloud-specific settings, I don't think we could find a simple way to do this in a way that doesn't warrant repetition imho.

@mrsimonemms mrsimonemms marked this pull request as ready for review August 22, 2024 16:50
@mrsimonemms mrsimonemms merged commit 49a8b05 into main Aug 28, 2024
6 checks passed
@mrsimonemms mrsimonemms deleted the sje/cluster-autoscaler branch August 28, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants