Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added helm chart and moved kustomize files #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
k8s/helm/ceramic/charts/*.tgz
11 changes: 11 additions & 0 deletions k8s/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Helm

Helm chart for ceramic nodes.

## Installation

`helm upgrade -i ceramic . -f values.yaml`

## Secrets

Secret management / encryption is left to the user. [sops](https://github.com/getsops/sops) and [helm secrets](https://github.com/jkroepke/helm-secrets) strongly recommended.
23 changes: 23 additions & 0 deletions k8s/helm/ceramic/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions k8s/helm/ceramic/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: postgresql
repository: oci://registry-1.docker.io/bitnamicharts
version: 12.12.10
digest: sha256:15969c760981b7095769908d0dd717284552998dcb4460f4f2300f048e37f5a6
generated: "2023-10-25T22:17:57.286738+03:00"
11 changes: 11 additions & 0 deletions k8s/helm/ceramic/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: ceramic
description: Helm Package for Ceramic Node
type: application
version: 0.1.0
appVersion: "1.16.0"
dependencies:
- name: postgresql
version: 12.12.10
repository: "oci://registry-1.docker.io/bitnamicharts"
condition: postgresql.helm.enabled
Empty file.
22 changes: 22 additions & 0 deletions k8s/helm/ceramic/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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.composedb.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "ceramic.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.composedb.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 "ceramic.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "ceramic.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.composedb.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "ceramic.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 }}
91 changes: 91 additions & 0 deletions k8s/helm/ceramic/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ceramic.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "ceramic.ipfs.name" -}}
{{- printf "%s-ipfs" (include "ceramic.name" .) | trunc 63 -}}
{{- 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 "ceramic.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 }}

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

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

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

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "ceramic.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ceramic.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}


11 changes: 11 additions & 0 deletions k8s/helm/ceramic/templates/compose-admin-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
kind: Secret
apiVersion: v1
metadata:
name: {{ include "ceramic.fullname" . }}-admin
labels:
{{- include "ceramic.labels" . | nindent 4 }}
data:
private-key: {{ .Values.composedb.secret.privateKey | b64enc }}
db-username: {{ .Values.postgresql.auth.username | b64enc }}
db-password: {{ .Values.postgresql.auth.password | b64enc }}
12 changes: 12 additions & 0 deletions k8s/helm/ceramic/templates/compose-env-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "ceramic.fullname" . }}-env
labels:
{{- include "ceramic.labels" . | nindent 4 }}
data:
{{- with .Values.composedb.env }}
{{- toYaml . | nindent 4 }}
{{- end }}
CERAMIC_IPFSHOST: http://{{ include "ceramic.ipfs.fullname" . }}:{{ .Values.ipfs.service.api.port }}
51 changes: 51 additions & 0 deletions k8s/helm/ceramic/templates/compose-init-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "ceramic.fullname" . }}-init
labels:
{{- include "ceramic.labels" . | nindent 4 }}
data:
compose-init.sh: |
#!/bin/bash

set -eo pipefail

export CERAMIC_ADMIN_DID=$(composedb did:from-private-key ${CERAMIC_ADMIN_PRIVATE_KEY})

CERAMIC_ADMIN_DID=$CERAMIC_ADMIN_DID envsubst < /composedb-init/daemon-config.json > /config/daemon-config.json
daemon-config.json: |-
{
"anchor": {},
"http-api": {
"cors-allowed-origins": [
"{{ .Values.composedb.config.corsAllowedOrigins }}"
],
"admin-dids": [
"${CERAMIC_ADMIN_DID}"
]
},
"ipfs": {
"mode": "remote",
"host": "${CERAMIC_IPFSHOST}"
},
"logger": {
"log-level": {{ .Values.composedb.config.logLevel }},
"log-to-files": false
},
"metrics": {
"metrics-exporter-enabled": {{ .Values.composedb.config.metricsExporterEnabled }}
},
"network": {
"name": "{{ .Values.composedb.config.network }}"
},
"node": {},
"state-store": {
"mode": "fs",
"local-directory": "{{ .Values.composedb.config.stateStorePath }}"
},
"indexing": {
"db": "postgres://${CERAMIC_INDEXING_DB_USERNAME}:${CERAMIC_INDEXING_DB_PASSWORD}@{{ .Values.postgresql.auth.host }}/{{ .Values.postgresql.auth.database }}",
"allow-queries-before-historical-sync": true
}
}
15 changes: 15 additions & 0 deletions k8s/helm/ceramic/templates/compose-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "ceramic.fullname" . }}
labels:
{{- include "ceramic.labels" . | nindent 4 }}
spec:
type: {{ .Values.composedb.service.type }}
ports:
- port: {{ .Values.composedb.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "ceramic.selectorLabels" . | nindent 4 }}
Loading