konstructio / gitops-catalog

kubefirst gitops catalog repository
24 stars 25 forks source link

feat: add cluster autoscaler civo #160

Closed mrsimonemms closed 3 months ago

mrsimonemms commented 3 months ago

Description

Adds Cluster Autoscaler for Civo.

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

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: git@github.com: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 commented 3 months ago

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.