Skip to content

Commit

Permalink
Add helm chart (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Kyle Dodson <[email protected]>
  • Loading branch information
sunuk-salad and seniorquico authored Oct 19, 2023
1 parent 01e6cf7 commit b1df6b2
Show file tree
Hide file tree
Showing 14 changed files with 516 additions and 37 deletions.
13 changes: 11 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
.git/
.github/
.vscode/
bin/
charts/
docker/
images/
openapi/
**/.gitignore
**/*Dockerfile*
.dockerignore
.editorconfig
.gitattributes
.gitignore
.prettierrc.yaml
LICENSE
NOTICE
Makefile
README.md
*.yaml
66 changes: 36 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
# Virtual Kubelet Provider for SaladCloud
# SaladCloud Virtual Kubelet Provider

[![License](https://img.shields.io/github/license/SaladTechnologies/virtual-kubelet-saladcloud)](./LICENSE) [![CI Workflow](https://github.com/SaladTechnologies/virtual-kubelet-saladcloud/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/SaladTechnologies/virtual-kubelet-saladcloud/actions/workflows/ci.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/SaladTechnologies/virtual-kubelet-saladcloud)](https://goreportcard.com/report/github.com/SaladTechnologies/virtual-kubelet-saladcloud)

Salad's Virtual Kubelet (VK) provider for SaladCloud enables running Kubernetes (K8s) pods as container group deployments.

To Setup the project
1. Clone the repo command
```bash
git clone
```
2. Install the dependencies
```bash
go mod download
```
3. Build the project
```bash
go build -o virtual-kubelet ./cmd/virtual-kubelet/main.go
```
4. Run the project
```bash
go run main.go --nodename {valid_node_name} --sce-project-name {projectName} --sce-organization-name {organizationName} --sce-api-key {api-key} --kubeconfig {kubeconfig}
```

## Prerequisites
You should have valid configuration required to run the project

go to portal.salad.io and create a project and get the api-key and organization name
set the kubeconfig to the valid kubeconfig file


1. Valid ApiKey and OrganizationName
2. Valid Kubeconfig
3. Valid NodeName
4. Valid ProjectName
## Development

Follow the steps below to get started with local development.

### Prerequisites

- [Git](https://git-scm.com/downloads)
- [Go](https://go.dev/dl)
- [Docker Desktop](https://docs.docker.com/get-docker/) with a [local Kubernetes cluster](https://docs.docker.com/desktop/kubernetes/)

### Getting Started

1. Clone the repository.

```sh
git clone https://github.com/SaladTechnologies/virtual-kubelet-saladcloud.git
```

2. Restore the dependencies.

```sh
go mod download
go mod verify
```

3. Build the project.

```sh
go build -o ./bin/virtual-kubelet ./cmd/virtual-kubelet/main.go
```

4. Run the project.

```sh
./bin/virtual-kubelet --sce-api-key {apiKey} --sce-project-name {projectName} --sce-organization-name {organizationName}
```
23 changes: 23 additions & 0 deletions charts/virtual-kubelet/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
description: Deploy containers to SaladCloud from your Kubernetes cluster using a virtual node.
home: https://github.com/SaladTechnologies/virtual-kubelet-saladcloud
icon: https://raw.githubusercontent.com/SaladTechnologies/virtual-kubelet-saladcloud/main/images/salad-logo-500x500.png
keywords:
- gpu
- kubelet
- kubernetes
- salad
- saladcloud
- virtual-kubelet
- virtual-kubelet-provider
- vk
kubeVersion: ">=v1.26.0-0"
maintainers:
- email: [email protected]
name: Salad Chefs
url: https://salad.com/
name: virtual-kubelet-saladcloud
sources:
- https://github.com/SaladTechnologies/virtual-kubelet-saladcloud
type: application
version: 0.1.0
98 changes: 98 additions & 0 deletions charts/virtual-kubelet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# SaladCloud Virtual Kubelet Provider



![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square)

Deploy containers to SaladCloud from your Kubernetes cluster using a virtual node.

## Installation

Follow the steps below to get started with the SaladCloud Virtual Kubelet Provider.

### Prerequisites

- [Kubernetes 1.26+](https://kubernetes.io/docs/setup/)
- [Helm v3+](https://helm.sh/docs/intro/quickstart/#install-helm)

### Installing the chart

1. Clone the repository.

```sh
git clone https://github.com/SaladTechnologies/virtual-kubelet-saladcloud.git
```

2. Install the chart.

```shell
helm install \
--create-namespace \
--namespace saladcloud
--set salad.apiKey=$SCE_API_KEY \
--set salad.organizationName=$SCE_ORGANIZATION_NAME \
--set salad.projectName=$SCE_PROJECT_NAME \
mysaladcloud ./charts/virtual-kubelet
```

3. Verify that the virtual node is available.

```sh
kubectl get nodes
```

<details>
<summary>Results</summary>

```shell
NAME STATUS ROLES AGE VERSION
saladcloud-node Ready agent 1m v1.0.0
```

</details>

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| additionalLabels | object | `{}` | The collection of additional labels applied to all resources. |
| clusterRoleNameOverride | string | `""` | When set to a non-empty value, overrides the `virtual-kubelet-saladcloud.fullName` value in the `ClusterRoleBinding` resource. |
| fullNameOverride | string | `""` | When set to a non-empty value, overrides the `virtual-kubelet-saladcloud.fullName` value. |
| imagePullSecrets | list | `[]` | The list of `Secret` names containing the registry credentials. |
| name | string | `"virtual-kubelet"` | The SaladCloud Virtual Kubelet Provider name. |
| nameOverride | string | `""` | When set to a non-empty value, overrides the `virtual-kubelet-saladcloud.name` value. |
| provider.deploymentAnnotations | object | `{}` | The collection of annotations applied to the `Deployment` resource. |
| provider.image.digest | string | `""` | The SaladCloud Virtual Kubelet Provider image digest. When set to a non-empty value, the image is pulled by digest (ignore the tag value). |
| provider.image.pullPolicy | string | `"IfNotPresent"` | The `imagePullPolicy` for the SaladCloud Virtual Kubelet Provider image. May be `IfNotPresent`, `Always`, or `Never`. |
| provider.image.repository | string | `"ghcr.io/saladtechnologies/virtual-kubelet-saladcloud"` | The SaladCloud Virtual Kubelet Provider image repository URI. |
| provider.image.tag | string | `""` | The SaladCloud Virtual Kubelet Provider image tag. |
| provider.logLevel | string | `"warn"` | The log level. May be `error`, `warn`, `info`, `debug`, or `trace`. |
| provider.nodeSelector | object | `{}` | The collection of labels used to assign the SaladCloud Virtual Kubelet Provider pod. |
| provider.nodename | string | `"saladcloud-node"` | The SaladCloud Virtual Kubelet Provider node name. |
| provider.podAnnotations | object | `{}` | The collection of annotations applied to the `Pod` resources created by the deployment. |
| provider.taintEnabled | bool | `true` | The flag indicating whether the SaladCloud Virtual Kubelet Provider node is tainted. |
| rbac.annotations | object | `{}` | The collection of annotations applied to the `ClusterRoleBinding` resource. |
| rbac.clusterRoleName | string | `"cluster-admin"` | The name of the `ClusterRole` resource. |
| rbac.create | bool | `true` | The flag indicating whether the `ClusterRoleBinding` resource should be created. |
| salad.apiKey | string | `""` | The SaladCloud API key. |
| salad.organizationName | string | `""` | The SaladCloud organization name. |
| salad.projectName | string | `""` | The SaladCloud project name. |
| serviceAccount.annotations | object | `{}` | The collection of annotations applied to the `ServiceAccount` resource. |
| serviceAccount.create | bool | `true` | The flag indicating whether the `ServiceAccount` resources should be created. |
| serviceAccountNameOverride | string | `""` | When set to a non-empty value, overrides the `virtual-kubelet-saladcloud.fullName` value in the `ServiceAccount` resource. |

## Requirements

Kubernetes: `>=v1.26.0-0`



## Source Code

* <https://github.com/SaladTechnologies/virtual-kubelet-saladcloud>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| Salad Chefs | <[email protected]> | <https://salad.com/> |
60 changes: 60 additions & 0 deletions charts/virtual-kubelet/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SaladCloud Virtual Kubelet Provider

{{ template "chart.deprecationWarning" . }}

{{ template "chart.typeBadge" . }} {{ template "chart.versionBadge" . }}

{{ template "chart.description" . }}

## Installation

Follow the steps below to get started with the SaladCloud Virtual Kubelet Provider.

### Prerequisites

- [Kubernetes 1.26+](https://kubernetes.io/docs/setup/)
- [Helm v3+](https://helm.sh/docs/intro/quickstart/#install-helm)

### Installing the chart

1. Clone the repository.

```sh
git clone https://github.com/SaladTechnologies/virtual-kubelet-saladcloud.git
```

2. Install the chart.

```shell
helm install \
--create-namespace \
--namespace saladcloud
--set salad.apiKey=$SCE_API_KEY \
--set salad.organizationName=$SCE_ORGANIZATION_NAME \
--set salad.projectName=$SCE_PROJECT_NAME \
mysaladcloud ./charts/virtual-kubelet
```

3. Verify that the virtual node is available.

```sh
kubectl get nodes
```

<details>
<summary>Results</summary>

```shell
NAME STATUS ROLES AGE VERSION
saladcloud-node Ready agent 1m v1.0.0
```

</details>

{{ template "chart.valuesSection" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.sourcesSection" . }}

{{ template "chart.maintainersSection" . }}
21 changes: 21 additions & 0 deletions charts/virtual-kubelet/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The SaladCloud virtual node is deploying to your cluster.

To verify the deployment, run:

kubectl --namespace={{ .Release.Namespace }} get pods --selector='app.kubernetes.io/name={{ include "virtual-kubelet-saladcloud.name" . }},app.kubernetes.io/instance={{ .Release.Name }}'

To verify the virtual node, run:

kubectl get node {{ .Values.provider.nodename }}

{{- if lt .Capabilities.KubeVersion.Minor "26" }}
-------------------------------------------------------------------------------------
WARNING - Running on unsupported Kubernetes version "1.{{.Capabilities.KubeVersion.Minor}}". This is supported and tested on Kubernetes "1.26" or higher.
-------------------------------------------------------------------------------------
{{- end }}

Learn more about SaladCloud and running workloads:

- https://docs.salad.com/
- https://portal.salad.com/
- https://salad.com/
85 changes: 85 additions & 0 deletions charts/virtual-kubelet/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{{/*
Return the chart name, formatted for use as a label.
*/}}
{{- define "virtual-kubelet-saladcloud.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the chart name and version, formatted for use as a label.
*/}}
{{- define "virtual-kubelet-saladcloud.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the common labels used by components.
*/}}
{{- define "virtual-kubelet-saladcloud.labels" -}}
app.kubernetes.io/component: kubelet
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: {{ include "virtual-kubelet-saladcloud.name" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
helm.sh/chart: {{ include "virtual-kubelet-saladcloud.chart" . }}
{{ include "virtual-kubelet-saladcloud.matchLabels" . }}
{{- with .Values.additionalLabels -}}
{{ toYaml . }}
{{- end -}}
{{- end -}}

{{/*
Return the common labels used by selectors.
*/}}
{{- define "virtual-kubelet-saladcloud.matchLabels" -}}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/name: {{ include "virtual-kubelet-saladcloud.name" . }}
{{- end -}}

{{/*
Return a fully qualified name.
*/}}
{{- define "virtual-kubelet-saladcloud.fullName" -}}
{{- if .Values.fullNameOverride -}}
{{- .Values.fullNameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- printf "%s-%s" .Release.Name .Values.name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s-%s" .Release.Name $name .Values.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return a fully qualified `ClusterRole` and `ClusterRoleBinding` name.
*/}}
{{- define "virtual-kubelet-saladcloud.clusterRoleName" -}}
{{- if .Values.clusterRoleNameOverride -}}
{{- .Values.clusterRoleNameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- include "virtual-kubelet-saladcloud.fullName" . -}}
{{- end -}}
{{- end -}}

{{/*
Return a fully qualified `ServiceAccount` name.
*/}}
{{- define "virtual-kubelet-saladcloud.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{- default (include "virtual-kubelet-saladcloud.fullName" .) .Values.serviceAccountNameOverride -}}
{{- else -}}
{{- default "default" .Values.serviceAccountNameOverride -}}
{{- end -}}
{{- end -}}

{{/*
Return the most appropriate `apiVersion` for RBAC.
*/}}
{{- define "virtual-kubelet-saladcloud.rbacApiVersion" -}}
{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" -}}
{{- print "rbac.authorization.k8s.io/v1" -}}
{{- else -}}
{{- print "rbac.authorization.k8s.io/v1beta1" -}}
{{- end -}}
{{- end -}}
Loading

0 comments on commit b1df6b2

Please sign in to comment.