Skip to content

Commit

Permalink
feat(k3): add k3 chart (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
xom4ek authored Jun 26, 2024
2 parents 5b2996d + 501f337 commit 31aa1f0
Show file tree
Hide file tree
Showing 16 changed files with 935 additions and 0 deletions.
1 change: 1 addition & 0 deletions charts/k3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
secret.yaml
9 changes: 9 additions & 0 deletions charts/k3/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
appVersion: 0.1.0
description: A Helm chart for Kubernetes
name: k3
type: application
version: 0.1.0
maintainers:
- name: xom4ek
email: [email protected]
112 changes: 112 additions & 0 deletions charts/k3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# k3 Helm Chart

## Introduction
This repository contains a Helm chart for Kubernetes, specifically for the AVS named "k3".
More information about k3 you can find here `https://docs.k3-labs.com/introduction/tech-documentation/operator-onboarding`

## Table of Contents
- [k3 Helm Chart](#k3-helm-chart)
- [Introduction](#introduction)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [Configuration](#configuration)
- [Dependencies](#dependencies)
- [Examples](#examples)
- [Troubleshooting](#troubleshooting)
- [Contributors](#contributors)
- [License](#license)

## Installation
To install the chart with the release name `my-release`:

```sh
helm repo add p2p-avs https://p2p-org.github.io/avs-helm-charts/
helm install my-release p2p-avs/k3
```

## Usage
To use this chart, you can override default values by providing your own `values.yaml` file:

```sh
helm install my-release p2p-avs/k3 -f values.yaml
```

## Features
- Deployment of the `k3` application
- Configurable service types and ports
- Customizable ingress settings
- Node-specific configurations and environment variables
- Support for custom image repositories and tags
- Probes for readiness checks

## Configuration
The following table lists the configurable parameters of the k3 chart and their default values.

| Parameter | Description | Default |
|-----------------------------|---------------------------------------------------------------|------------------------------|
| `replicaCount` | Number of replicas | `1` |
| `service.type` | Type of Kubernetes service | `ClusterIP` |
| `service.ports` | Service ports | `{...}` |
| `ingress.enabled` | Enable ingress | `false` |
| `ingress.host` | Ingress host | `example.com` |
| `node.image.repository` | Node image repository | `k3official/k3-labs-avs-operator` |
| `node.image.tag` | Node image tag | `latest` |
| `node.image.pullPolicy` | Image pull policy | `Always` |
| `node.resources.requests` | CPU/Memory resource requests | `2 CPU / 8Gi Memory` |
| `node.resources.limits` | CPU/Memory resource limits | `4 CPU / 16Gi Memory` |
| `serviceAccount.create` | Specifies whether a service account should be created | `true` |
| `serviceAccount.name` | Name of the service account | `""` |
| `vmPodScrape.enabled` | Enable VM Pod scraping | `true` |
| `register.enabled` | Enable register functionality | `true` |
| `register.image.repository` | Register image repository | `k3official/k3-labs-avs-operator` |
| `register.image.tag` | Register image tag | `latest` |
| `register.image.pullPolicy` | Register image pull policy | `Always` |
| `configs.operator.yaml` | Operator configuration | `empty` |

## Dependencies
This chart depends on several Kubernetes resources and should be used in a Kubernetes cluster. Ensure that you have Kubernetes and Helm installed and configured in your environment.

## Examples
Here is an example of how to configure the `values.yaml` for your deployment:

```yaml
replicaCount: 2

service:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80

ingress:
enabled: true
host: myapp.example.com

node:
image:
repository: myrepo/myapp
tag: "1.0.0"
resources:
limits:
cpu: "2"
memory: "4Gi"
requests:
cpu: "1"
memory: "2Gi"
```
## Troubleshooting
If you encounter any issues during installation or usage, check the following:
- Ensure that all required Kubernetes resources are available.
- Validate your `values.yaml` file against the provided `values.schema.json`.
- Check the logs of the Helm deployment for any errors.

## Contributors
- xom4ek (Aleksei Lazarev) - [email protected]

## License
This project is licensed under the MIT License. See the LICENSE file for details.
3 changes: 3 additions & 0 deletions charts/k3/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Generate keys

For generate keys read this doc https://docs.eigenlayer.xyz/eigenlayer/operator-guides/operator-installation
32 changes: 32 additions & 0 deletions charts/k3/example/wallet-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v1
stringData:

ecdsa-private-key: |
{
"address": "sadflkasmdflkamsldfas;df",
"crypto": {
"cipher": "aes-128-ctr",
"ciphertext": "as;dmflaskmdflasmdlfkmalsdf",
"cipherparams": {
"iv": "lakmdslfkmalsdmflkasdmfl"
},
"kdf": "scrypt",
"kdfparams": {
"dklen": 123,
"n": 123123,
"p": 12,
"r": 823,
"salt": "daslkfmklasdmfklmasdlkfmlakdsf"
},
"mac": "alsdkmflkamsdlfkmasldfmlaksdmlf"
},
"id": "alsdfmlkasmdlfkmasldf",
"version": 3
}
ecdsa-private-key-password: anlNASLdnfaljksdnLANSDlnalsdkjnASLKJDNlwnqlo21n3lkASLDndalsd
kind: Secret
metadata:
name: YOURSECREWITHWALLET
type: Opaque
68 changes: 68 additions & 0 deletions charts/k3/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "k3.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "k3.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "k3.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "k3.labels" -}}
helm.sh/chart: {{ include "k3.chart" . }}
{{ include "k3.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{- define "k3Register.labels" -}}
helm.sh/chart: {{ include "k3.chart" . }}
{{ include "k3Register.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "k3.selectorLabels" -}}
app.kubernetes.io/name: {{ include "k3.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "k3Register.selectorLabels" -}}
app.kubernetes.io/name: {{ include "k3.name" . }}-register
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/k3/templates/configmap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "k3.fullname" . }}-config
labels:
{{- include "k3.labels" . | nindent 4 }}
{{- with .Values.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end}}
data:
{{- if .Values.configs }}
{{- toYaml .Values.configs | nindent 2 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/k3/templates/ingress.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "k3.fullname" . }}
labels:
{{- include "k3.labels" . | nindent 4 }}
{{- with .Values.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end}}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: nginx
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "k3.fullname" . }}
port:
name: performer
{{- end }}
35 changes: 35 additions & 0 deletions charts/k3/templates/register.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "k3.fullname" . }}-register-job
labels:
{{- include "k3Register.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": "post-install"
spec:
template:
metadata:
labels:
{{- include "k3Register.labels" . | nindent 8 }}
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app: {{ include "k3.fullname" . }}
topologyKey: "kubernetes.io/hostname"
containers:
- name: register
image: "{{ .Values.register.image.repository }}:{{ .Values.register.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.register.image.pullPolicy }}
args:
{{- toYaml .Values.register.args | nindent 12 }}
env:
{{- toYaml .Values.node.env | nindent 12 }}
volumeMounts:
{{- toYaml .Values.node.volumeMounts | nindent 12 }}
restartPolicy: Never
volumes:
{{- toYaml .Values.volumes | nindent 8 }}
backoffLimit: 2
27 changes: 27 additions & 0 deletions charts/k3/templates/service.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "k3.fullname" . }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "k3.labels" . | nindent 4 }}
{{- with .Values.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end}}
spec:
type: {{ .Values.service.type }}
ports:
{{- range .Values.service.ports }}
- name: {{ .name }}
port: {{ .port }}
protocol: {{ .protocol }}
targetPort: {{ .targetPort }}
{{- end }}
selector:
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end}}
app: {{ include "k3.fullname" . }}
15 changes: 15 additions & 0 deletions charts/k3/templates/serviceaccount.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "k3.fullname" . }}
labels:
{{- include "k3.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end}}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit 31aa1f0

Please sign in to comment.