Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
6 changes: 6 additions & 0 deletions adminer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: adminer
description: Adminer Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "latest"
Comment thread
dingp marked this conversation as resolved.
51 changes: 51 additions & 0 deletions adminer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "adminer.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 "adminer.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 "adminer.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "adminer.selectorLabels" -}}
app.kubernetes.io/name: {{ include "adminer.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
64 changes: 64 additions & 0 deletions adminer/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "adminer.fullname" . }}
labels:
{{- include "adminer.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "adminer.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "adminer.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: container-0
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
{{- toYaml .Values.command | nindent 12 }}
args:
{{- toYaml .Values.args | nindent 12 }}
env:
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
ports:
- containerPort: {{ .Values.service.port }}
name: adminer-web
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
15 changes: 15 additions & 0 deletions adminer/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "adminer.fullname" . }}
labels:
{{- include "adminer.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
protocol: TCP
name: adminer-web
selector:
{{- include "adminer.selectorLabels" . | nindent 4 }}
51 changes: 51 additions & 0 deletions adminer/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Default values for adminer.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
# Update the placeholders below before installing the chart.

replicaCount: 1

image:
repository: adminer
pullPolicy: Always
tag: latest

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

podAnnotations: {}
podLabels: {}

podSecurityContext: {}

securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: false
runAsNonRoot: false
Comment thread
dingp marked this conversation as resolved.
Outdated

command:
- php
args:
- "-S"
- "0.0.0.0:8080"
- "-t"
- "/var/www/html"

env:
ADMINER_DESIGN: pepa-linha
ADMINER_DEFAULT_SERVER: postgres
Comment thread
dingp marked this conversation as resolved.
Outdated

service:
type: ClusterIP
port: 8080

resources: {}

nodeSelector: {}
tolerations: []
affinity: {}
23 changes: 23 additions & 0 deletions postgresql/.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/
25 changes: 25 additions & 0 deletions postgresql/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v2
name: postgresql
description: A PostgreSQL Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into
# versioned archives to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer.
# They're included as a dependency of application charts to inject those
# utilities and functions into the rendering pipeline. Library charts do not
# define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time
# you make changes to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version
# number should be incremented each time you make changes to the application.
# Versions are not expected to follow Semantic Versioning. They should reflect
# the version the application is using. It is recommended to use it with quotes.
appVersion: "17"
Comment thread
dingp marked this conversation as resolved.
Outdated
49 changes: 49 additions & 0 deletions postgresql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# PostgreSQL Helm Chart

This chart deploys PostgreSQL on Spin. Update the placeholders in
`values_template.yaml`, or use the helper script to generate `values.yaml`.

## Prerequisites

- `kubectl` and `helm` installed
- Access to a Spin namespace and its kubeconfig

See `tls-acme/README.md` for installation steps for kubectl/helm and kubeconfig.
Comment thread
dingp marked this conversation as resolved.

## Configure values

1. Edit `postgresql/prepare-values.sh` with your settings.
2. Generate a rendered values file:

```bash
./prepare-values.sh
```

This writes `values.yaml` (or a custom path if you pass one).

## Quick start

```bash
cd postgresql
./prepare-values.sh
helm lint .
helm install -n <namespace> <release-name> .
Comment thread
dingp marked this conversation as resolved.
```

## Install

```bash
helm install -n <namespace> <release-name> .
Comment thread
dingp marked this conversation as resolved.
```

## Upgrade or uninstall

```bash
helm upgrade -n <namespace> <release-name> .
Comment thread
dingp marked this conversation as resolved.
helm uninstall -n <namespace> <release-name>
```

## Notes

- Persistent volume size is controlled by `persistentVolumeClaims.testdb.size`.
Comment thread
dingp marked this conversation as resolved.
Outdated
- Liveness and readiness probes use `pg_isready` with the configured database name and user.
32 changes: 32 additions & 0 deletions postgresql/prepare-values.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail

base_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
values_file="${1:-"${base_dir}/values_template.yaml"}"
output_file="${2:-"${base_dir}/values.yaml"}"

# Update these values before running this script.
# Output goes to values.yaml unless you pass a second argument.
nersc_user_id="<nersc UID>"
nersc_user_group="<nersc GID>"
app_name="postgresql"

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable "app_name" is defined in the prepare-values.sh script but is never used in any sed replacement command or referenced in the values_template.yaml file. Either remove this unused variable or add the corresponding replacement if it's intended to be used.

Copilot uses AI. Check for mistakes.
version_tag="18"
deployment_name="psql"
db_name="<DB_name>"
db_user_password="<DB_password>"

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database password is being written into the values.yaml file in plaintext by the prepare-values.sh script. This means the password will be stored unencrypted in the filesystem and potentially committed to version control. Consider adding values.yaml to .gitignore and documenting that this file should never be committed, or use a more secure approach like referencing an existing Kubernetes Secret.

Suggested change
db_user_password="<DB_password>"
# Load the database user password from the environment or prompt interactively,
# instead of hardcoding it in this script.
if [[ "${DB_USER_PASSWORD-}" != "" ]]; then
db_user_password="${DB_USER_PASSWORD}"
else
read -s -p "Enter database user password: " db_user_password
echo
fi
if [[ -z "${db_user_password}" ]]; then
echo "Error: database user password must not be empty. Set DB_USER_PASSWORD or enter a value when prompted." >&2
exit 1
fi

Copilot uses AI. Check for mistakes.
db_user_name="user"
pvc_size="10Gi"
Comment thread
dingp marked this conversation as resolved.

tmp_file="$(mktemp)"
sed \
-e "s|{{nersc_user_id}}|${nersc_user_id}|g" \
-e "s|{{nersc_user_group}}|${nersc_user_group}|g" \
-e "s|{{app_name}}|${app_name}|g" \
-e "s|{{version_tag}}|${version_tag}|g" \
-e "s|{{deployment_name}}|${deployment_name}|g" \
-e "s|{{db_name}}|${db_name}|g" \
-e "s|{{db_user_password}}|${db_user_password}|g" \
-e "s|{{db_user_name}}|${db_user_name}|g" \
-e "s|{{pvc_size}}|${pvc_size}|g" \
"$values_file" > "$tmp_file"
mv "$tmp_file" "$output_file"
22 changes: 22 additions & 0 deletions postgresql/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.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "postgresql.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 its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "postgresql.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "postgresql.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 "postgresql.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 }}
Loading