bagetter / BaGetter

A lightweight NuGet and symbol server
https://www.bagetter.com
MIT License
166 stars 38 forks source link

Supply a helm chart #116

Open Khaos66 opened 3 months ago

Khaos66 commented 3 months ago

Is your feature request related to a problem? Please describe.

I'm setting up a local kubernetes cluster and need a local Nuget feed. I came acros this repo and see it's very active. There also is a docker image on Docker Hub already. So a helm chart is the logical expansion to that.

Describe the solution you'd like

Create a helm chart to deploy BeGetter on kubernetes.

Describe alternatives you've considered

I could write the yaml files to define the kubernetes resources myself, but I prefer helm to do it for me.

Additional context

I can prepare a PR if you want this, too

Hechamon commented 3 months ago

Do you have a helm chart ready? Otherwise I can upload the one I created for my company to base your PR off of. If you're interested

Khaos66 commented 3 months ago

No I don't. That would be nice

Regenhardt commented 3 months ago

That sounds interesting. Never worked with Helm, this is new to me. What other tools would you compare it with? Is Ansible on a too abstract level? Or a Nomad deployment config file (not sure what those are called)? Or docker compose? I wonder how to store these cleanly in our directory structure. Top level "deloy[ment[s]]" folder maybe?

Khaos66 commented 3 months ago

I'm not a pro. But Ansible is too high level. There is a kubernetes.core.helm task for ansible however to download an apply the chart. Never worked with Nomad. Docker Compose is the nearest of the ones mentioned, I guess.

To deploy anything in k8s you normaly need a quite long yaml definition file containing all your k8s resources. What helm does is building these yaml files from predefined templates with parameter values.

So someone defines a template with a lot of parameters to customize the deployment and everybody else is thankfull for the time safed ;)

Even writing helm charts has become quite easy with the introduction of library charts, that can be reused. All the helm chats share a lot of common parameters and resources. This is one used commonly: https://github.com/bjw-s/helm-charts/tree/main/charts/library/common

I found this easy example of how it might be used: https://github.com/djjudas21/charts/tree/main/charts/heimdall

Hechamon commented 3 months ago

I quickly removed the company info from the helm chart I wrote for bagetter and pushed it in a new branch here: https://github.com/Hechamon/BaGetter/tree/feature/add_helm_chart/helm

I ran Helm lint on it and it passes, but the version that I have deployed myself looks a bit different because it contains more stuff that is company specific, so make sure you test it beforehand :-)

Also I would suggest adding some more variables to the values file, like resource requests and pvc size.

Khaos66 commented 3 months ago

@Hechamon Thank you for your chart. It inspired my PR.

I used the common-library to create this chart, so the k8s resources are definined correctly.

This is only the chart itself. In a next step it can be privided through a helm repository. Meanwhile you need to clone this repo and install the chart from it sources

git cone https://github.com/bagetter/BaGetter.git
helm install bagetter ./chart/bagetter/

You may modify the deployment parameters by creating a custom myvalues.yaml which overrides or extends the default values.yaml.

helm install bagetter ./chart/bagetter/ -f myvalues.yaml
Khaos66 commented 3 months ago

Btw. this is my ansible playbook to deploy this chart

---
- name: Create a bagetter namespace
  kubernetes.core.k8s:
    name: bagetter
    api_version: v1
    kind: Namespace
    state: present

- name: Clone bagetter git repo
  git:
    repo: "{{ bagetter_git_repo }}"
    dest: /tmp/bagetter

- name: Build helm dependencies
  shell: helm dependency build /tmp/bagetter/chart/bagetter
  args:
    creates: /tmp/bagetter/chart/bagetter/Chart.lock

- name: Deploy bagetter helm chart
  kubernetes.core.helm:
    name: bagetter
    chart_ref: /tmp/bagetter/chart/bagetter
    release_namespace: bagetter
    state: present
    values:
      configMaps:
        bagetter-env:
          data:
            ApiKey: "{{ bagetter_apikey }}"
            Mirror__Enabled: "true"
            Mirror__PackageSource: "https://api.nuget.org/v3/index.json"
      defaultPodOptions:
        nodeSelector:
          kubernetes.io/os: linux
      controllers:
        bagetter:
          containers:
            bagetter:
              probes:
                liveness:
                  enabled: true
                  type: HTTP
                  path: /
                  initialDelaySeconds: 10
                  periodSeconds: 10
      ingress:
        bagetter-ingress:
          enabled: true
          className: nginx
          annotations:
            cert-manager.io/cluster-issuer: "{{our_cluster_issuer}}"
            kubernetes.io/ingress.class: nginx
          hosts:
            - host: "{{bagetter_host}}"
              paths:
              - path: /
                pathType: ImplementationSpecific
                service:
                  name: bagetter
                  port: 8080
          tls:
            - secretName: tls-bagetter
              hosts:
                - "{{bagetter_host}}"
      persistence:
        bagetter-data:
          size: 100Gi
github-actions[bot] commented 6 days ago

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