Skip to content

Commit

Permalink
Forked and added Meilisearch chart
Browse files Browse the repository at this point in the history
  • Loading branch information
NishaSharma14 committed Jul 7, 2022
1 parent 6f893b9 commit 638646d
Show file tree
Hide file tree
Showing 14 changed files with 620 additions and 0 deletions.
21 changes: 21 additions & 0 deletions charts/meilisearch/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
10 changes: 10 additions & 0 deletions charts/meilisearch/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
appVersion: "v0.27.1"
description: A Helm chart for the Meilisearch search engine
name: meilisearch
version: 0.1.37
icon: https://res.cloudinary.com/meilisearch/image/upload/v1597822872/Logo/logo_img.svg
home: https://github.com/meilisearch/meilisearch-kubernetes/charts
maintainers:
- name: Nisha Sharma
email: [email protected]
117 changes: 117 additions & 0 deletions charts/meilisearch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Meilisearch

Helm works as a package manager to run pre-configured Kubernetes resources.

Meilisearch provides a customizable Helm chart, ready to deploy a [Meilisearch](https://github.com/meilisearch/meilisearch) instance on your Kubernetes cluster.

# Getting started

First of all, you will need a Kubernetes cluster up and running. If you are not familiar with how Kuberentes works or need some help with this step, please check the [Kubernetes documentation](https://kubernetes.io/docs/home/).

## Install kubectl

`kubectl` is the most commonly used CLI to handle a Kubernetes cluster. The installation instructions are [available here](https://kubernetes.io/docs/tasks/tools/install-kubectl/).

## Install helm

Helm CLI is a Command Line Interface which will automate chart management and installation on your Kubernetes cluster. To install Helm, follow the [Helm installation instructions](https://helm.sh/docs/intro/install/)

### Install Meilisearch chart

Clone this repository and install the chart

```bash
git clone https://github.com/meilisearch/meilisearch-kubernetes.git
cd meilisearch-kubernetes
# Replace <your-instance-name> with the name you would like to give to your service
helm install <your-service-name> charts/meilisearch
```

This command deploys Meilisearch on your Kubernetes cluster using the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation.

## Uninstalling the Chart

To uninstall/delete the `Meilisearch` deployment:

```bash
# Replace <your-instance-name> with the name of your deployed service
helm uninstall <your-service-name>
```

## Parameters

| Parameter | Description | Default |
|----------------------------------|----------------------------------------------------------------|-----------------------------------|
| `nameOverride` | String to partially override meilisearch.fullname | `nil`
| | |
| `fullnameOverride` | String to fully override meilisearch.fullname | `nil`
| | |
| `replicaCount` | Number of Meilisearch pods to run | `1`
| | |
| `environment.MEILI_ENV` | Sets the environment. Either **production** or **development** | `development`
| | |
| `environment.MEILI_NO_ANALYTICS` | Deactivates analytics | `true`
| | |
| `auth.existingMasterKeySecret` | Uses an existing secret that has the MEILI_MASTER_KEY set | `nil`
| | |
| `image.repository` | Meilisearch image name | `getmeili/meilisearch`
| | |
| `image.tag` | Meilisearch image tag | `{TAG_NAME}`
| | |
| `image.pullPolicy` | Meilisearch image pull policy | `IfNotPresent`
| | |
| `image.pullSecret` | Secret to authenticate against the docker registry | '' |
| | |
| `serviceAccount.create` | Should this chart create a service account | `true`
| | |
| `serviceAccount.annotations` | Additional annotations for created service account | `{}`
| | |
| `serviceAccount.name` | Custom service account name, if not created by this chart | ''
| | |
| `ingress.enabled` | Enable ingress controller resource | `false`
| | |
| `ingress.annotations` | Ingress annotations | `{}`
| | |
| `ingress.path` | Path within the host | `/`
| | |
| `ingress.hosts` | List of hostnames | `[meilisearch-example.local]`
| | |
| `ingress.tls` | TLS specification | `[]`
| | |
| `service.port` | Service HTTP port | `7700`
| | |
| `service.type` | Kubernetes Service type | `ClusterIP`
| | |
| `service.externalTrafficPolicy` | Service external traffic policy | `-` (No external traffic policy)
| | |
| `service.loadBalancerIP` | Service load balancer IP | `-` (No load balancer IP)
| | |
| `service.annotations` | Additional annotations for service | `{}`
| | |
| `persistence.enabled` | Enable persistence using PVC | `false`
| | |
| `persistence.accessMode` | PVC Access Mode | `ReadWriteOnce`
| | |
| `persistence.storageClass` | PVC Storage Class | `-` (No storage class)
| | |
| `persistence.size` | PVC Storage Request | `10Gi`
| | |
| `persistence.annotations` | Additional annotations for PVC | `{}`
| | |
| `resources` | Resources allocation (Requests and Limits) | `{}`
| | |
| `command` | Pod command | `[]`
| | |
| `tolerations` | Tolerations for pod assignment | `[]`
| | |
| `nodeSelector` | Node labels for pod assignment | `{}`
| | |
| `affinity` | Affinity for pod assignment | `{}`
| | |


### Environment

The `environment` block allows to specify all the environment variables declared on [Meilisearch Configuration](https://docs.meilisearch.com/guides/advanced_guides/configuration.html#passing-arguments-via-the-command-line)

For production deployment, the `environment.MEILI_MASTER_KEY` is required. If `MEILI_ENV` is set to "production" without setting `environment.MEILI_MASTER_KEY`, then this chart will automatically create a secure `environment.MEILI_MASTER_KEY` as a secret. To get the value of this secret, you can read it with this command: `kubectl get secret meilisearch-master-key --template={{.data.MEILI_MASTER_KEY}} | base64 --decode`. You can also use `auth.existingMasterKeySecret` to use an existing secret that has the key `MEILI_MASTER_KEY`
18 changes: 18 additions & 0 deletions charts/meilisearch/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "meilisearch.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "meilisearch.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "meilisearch.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "meilisearch.fullname" . }} {{ .Values.service.port }}:{{ .Values.service.port }} &
echo "Visit http://127.0.0.1:{{ .Values.service.port }} to use your application"
{{- end }}
51 changes: 51 additions & 0 deletions charts/meilisearch/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "meilisearch.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 "meilisearch.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 "meilisearch.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Checks for environment being set to "production" without a master key being set explicitly
*/}}
{{- define "isProductionWithoutMasterKey" -}}
{{- if and (eq .Values.environment.MEILI_ENV "production") (not .Values.environment.MEILI_MASTER_KEY) (not .Values.auth.existingMasterKeySecret) -}}
{{- "true" -}}
{{- else -}}
{{- "false" -}}
{{- end -}}
{{- end -}}

{{- define "secretMasterKeyName" -}}
{{- if .Values.auth.existingMasterKeySecret -}}
{{- printf "%s" (tpl .Values.auth.existingMasterKeySecret $) -}}
{{- else -}}
{{- printf "%s-master-key" (include "meilisearch.fullname" .) -}}
{{- end -}}
{{- end -}}
16 changes: 16 additions & 0 deletions charts/meilisearch/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "meilisearch.fullname" . }}-environment
labels:
app.kubernetes.io/name: {{ include "meilisearch.name" . }}
helm.sh/chart: {{ include "meilisearch.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
data:
{{- range $key, $value := .Values.environment }}
{{ $key }}: {{ $value | quote}}
{{- end }}
61 changes: 61 additions & 0 deletions charts/meilisearch/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "meilisearch.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app.kubernetes.io/name: {{ include "meilisearch.name" . }}
helm.sh/chart: {{ include "meilisearch.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
annotations:
{{- . | toYaml | nindent 4 }}
{{- end }}
spec:
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (.Values.ingress.className) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: Prefix
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/meilisearch/templates/master-key-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if eq (include "isProductionWithoutMasterKey" .) "true" }}
{{- $secretName := printf "%s-%s" (include "meilisearch.fullname" . ) "master-key" }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace $secretName) -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ $secretName }}
labels:
app.kubernetes.io/name: {{ include "meilisearch.name" . }}
helm.sh/chart: {{ include "meilisearch.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
data:
{{- if $secret }}
MEILI_MASTER_KEY: {{ $secret.data.MEILI_MASTER_KEY }}
{{ else }}
MEILI_MASTER_KEY: {{ randAlphaNum 20 | b64enc }}
{{- end }}
{{ end }}
33 changes: 33 additions & 0 deletions charts/meilisearch/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .Values.persistence.enabled }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "meilisearch.fullname" . }}
annotations:
"helm.sh/resource-policy": keep
labels:
app.kubernetes.io/name: {{ include "meilisearch.name" . }}
helm.sh/chart: {{ include "meilisearch.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.persistence.annotations }}
annotations:
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
37 changes: 37 additions & 0 deletions charts/meilisearch/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "meilisearch.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "meilisearch.name" . }}
helm.sh/chart: {{ include "meilisearch.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.service.annotations }}
annotations:
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{.Values.service.externalTrafficPolicy}}
{{- end }}
type: {{ .Values.service.type }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{.Values.service.loadBalancerIP}}
{{- end }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
{{- if eq "NodePort" .Values.service.type }}
{{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "meilisearch.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
Loading

0 comments on commit 638646d

Please sign in to comment.