diff --git a/searxng/.gitignore b/searxng/.gitignore new file mode 100644 index 0000000..80bf7fc --- /dev/null +++ b/searxng/.gitignore @@ -0,0 +1 @@ +charts \ No newline at end of file diff --git a/searxng/Chart.lock b/searxng/Chart.lock new file mode 100644 index 0000000..7af9cb8 --- /dev/null +++ b/searxng/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: redis + repository: https://charts.pascaliske.dev + version: 0.2.2 +digest: sha256:be131ad838e2d4a147da1440bbfb74c50ffee2ae2b7bd4ce6e68c977342f988a +generated: "2022-12-21T18:58:04.08515531+01:00" diff --git a/searxng/Chart.yaml b/searxng/Chart.yaml index 068d121..94d7f1d 100644 --- a/searxng/Chart.yaml +++ b/searxng/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: latest description: SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. name: searxng -version: 1.0.0 +version: 2.0.0 kubeVersion: ">=1.16.0-0" keywords: - searx @@ -14,14 +14,15 @@ sources: - https://github.com/searxng/searxng - https://docs.searxng.org - https://hub.docker.com/r/searxng/searxng + maintainers: - name: unixfox email: searxngatunixfoxdoteu + - name: Cat Engineer + email: contact@cat.engineer + dependencies: - - name: common - repository: https://library-charts.k8s-at-home.com - version: 4.4.2 - name: redis - version: 0.0.3 + version: 0.2.2 repository: https://charts.pascaliske.dev - condition: redis.enabled + condition: searxng.server.limiter diff --git a/searxng/templates/NOTES.txt b/searxng/templates/NOTES.txt index 90f7b65..7b69cb3 100644 --- a/searxng/templates/NOTES.txt +++ b/searxng/templates/NOTES.txt @@ -1 +1,22 @@ -{{- include "common.notes.defaultNotes" . -}} +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "searxng.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 --namespace {{ .Release.Namespace }} svc -w {{ include "searxng.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "searxng.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "searxng.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/searxng/templates/_helpers.tpl b/searxng/templates/_helpers.tpl new file mode 100644 index 0000000..5980f4f --- /dev/null +++ b/searxng/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "searxng.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 "searxng.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 "searxng.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "searxng.labels" -}} +helm.sh/chart: {{ include "searxng.chart" . }} +{{ include "searxng.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "searxng.selectorLabels" -}} +app.kubernetes.io/name: {{ include "searxng.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "searxng.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "searxng.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/searxng/templates/common.yaml b/searxng/templates/common.yaml deleted file mode 100644 index f8490f9..0000000 --- a/searxng/templates/common.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{/* First Make sure all variables are set and merged properly */}} -{{- include "common.values.setup" . }} - -{{/* Append the configMap volume to the volumes */}} -{{- define "searxng.settingsVolume" -}} -enabled: "true" -mountPath: "/etc/searxng/settings.yml" -subPath: "settings.yml" -type: "custom" -volumeSpec: - secret: - secretName: {{ include "common.names.fullname" . }}-config -{{- end -}} -{{- $_ := set .Values.persistence "searxng-config" (include "searxng.settingsVolume" . | fromYaml) -}} - -{{/* Render the templates */}} -{{ include "common.all" . }} \ No newline at end of file diff --git a/searxng/templates/configmap.yaml b/searxng/templates/configmap.yaml index f27ea5d..ae39c7c 100644 --- a/searxng/templates/configmap.yaml +++ b/searxng/templates/configmap.yaml @@ -1,11 +1,9 @@ -{{- include "common.values.setup" . -}} ---- apiVersion: v1 -kind: Secret +kind: ConfigMap metadata: - name: {{ include "common.names.fullname" . }}-config + name: {{ include "searxng.fullname" . }}-config labels: - {{- include "common.labels" . | nindent 4 }} + {{- include "searxng.labels" . | nindent 4 }} data: settings.yml: |- -{{ toYaml .Values.searxng.config | b64enc | indent 4 }} \ No newline at end of file +{{ toYaml .Values.searxng | indent 4 }} \ No newline at end of file diff --git a/searxng/templates/deployment.yaml b/searxng/templates/deployment.yaml new file mode 100644 index 0000000..6750507 --- /dev/null +++ b/searxng/templates/deployment.yaml @@ -0,0 +1,81 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "searxng.fullname" . }} + labels: + {{- include "searxng.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "searxng.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "searxng.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "searxng.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: http + readinessProbe: + httpGet: + path: /healthz + port: http + startupProbe: + httpGet: + path: /healthz + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: settings-yml + mountPath: /etc/searxng/settings.yml + subPath: settings.yml + env: + {{- if .Values.searxng.server.limiter }} + - name: SEARXNG_REDIS_URL + value: redis://@searxng-redis:6379/0 + {{ end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: settings-yml + configMap: + name: {{ include "searxng.fullname" . }}-config + items: + - key: settings.yml + path: settings.yml diff --git a/searxng/templates/hpa.yaml b/searxng/templates/hpa.yaml new file mode 100644 index 0000000..726eace --- /dev/null +++ b/searxng/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "searxng.fullname" . }} + labels: + {{- include "searxng.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "searxng.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/searxng/templates/ingress.yaml b/searxng/templates/ingress.yaml new file mode 100644 index 0000000..0b99da8 --- /dev/null +++ b/searxng/templates/ingress.yaml @@ -0,0 +1,53 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "searxng.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if or (.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not (.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) -}} +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: + {{- include "searxng.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }} + pathType: Prefix + {{- end }} + {{- end }} + {{- end }} + {{- end }} diff --git a/searxng/templates/service.yaml b/searxng/templates/service.yaml new file mode 100644 index 0000000..2be6898 --- /dev/null +++ b/searxng/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "searxng.fullname" . }} + labels: + {{- include "searxng.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "searxng.selectorLabels" . | nindent 4 }} diff --git a/searxng/templates/serviceaccount.yaml b/searxng/templates/serviceaccount.yaml new file mode 100644 index 0000000..f10efa0 --- /dev/null +++ b/searxng/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "searxng.serviceAccountName" . }} + labels: + {{- include "searxng.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/searxng/values.yaml b/searxng/values.yaml index bf810a6..cd3df3d 100644 --- a/searxng/values.yaml +++ b/searxng/values.yaml @@ -4,6 +4,7 @@ # This chart inherits from our common library chart. You can check the default values/options here: # https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml # +replicaCount: 1 image: # -- image repository @@ -13,71 +14,88 @@ image: # -- image pull policy pullPolicy: Always -# Explanation about each environment variables here: -# https://docs.searxng.org/admin/installation-docker.html#command-line -env: - INSTANCE_NAME: "my-instance" - BASE_URL: "http://localhost:8080/" - AUTOCOMPLETE: "false" - # MORTY_URL: "http://morty:8080" - # MORTY_KEY: "mysecretkey" - # BIND_ADDRESS: "0.0.0.0:8080" +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" controller: strategy: "RollingUpdate" -# -- Configures service settings for the chart. -# @default -- See values.yaml -service: - main: - ports: - http: - port: 8080 +searxng: + # see https://docs.searxng.org/admin/engines/settings.html#use-default-settings + use_default_settings: true + server: + base_url: "https://localhost" + secret_key: "pleasechangeme" # change this! + limiter: true # can be disabled for a private instance + image_proxy: true + ui: + static_use_hash: true + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} -# -- Configure persistence settings for the chart under this key. -# @default -- See values.yaml -persistence: - config: - enabled: false +podSecurityContext: {} +# fsGroup: 2000 + +securityContext: + capabilities: + drop: + - ALL + add: + - CHOWN + - SETGID + - SETUID + - DAC_OVERRIDE + +service: + type: ClusterIP + port: 80 ingress: - # -- Enable and configure ingress settings for the chart under this key. - # @default -- See values.yaml - main: - enabled: false + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: search.local + paths: + - path: / -searxng: - config: - use_default_settings: true - server: - secret_key: pleasechangeme - # Uncomment when using the builtin rate limiter - # See https://docs.searxng.org/src/searx.plugins.limiter.html#limiter-plugin - # server.limiter: true - # redis.url: redis://@searxng-redis:6379/0 - -probes: - readiness: - custom: true - spec: - httpGet: - path: /healthz - port: 8080 - liveness: - custom: true - spec: - httpGet: - path: /healthz - port: 8080 - startup: - custom: true - spec: - httpGet: - path: /healthz - port: 8080 - -# Enable when using searxng builtin rate limiter -# Values: https://github.com/pascaliske/helm-charts/tree/master/charts/redis -redis: + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m +# memory: 128Mi + +autoscaling: enabled: false - \ No newline at end of file + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} \ No newline at end of file