-
Notifications
You must be signed in to change notification settings - Fork 2
Dingpf/adding postgresql helm chart #13
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
Changes from 21 commits
d1b26e1
dace2ec
82d454a
f527ff4
9bfdd80
29ff11f
8ad39ed
387d280
8a34832
da6464d
df52bbc
c353565
edb9b0b
4e68c0e
328340c
4bb3355
b167e52
1117d4f
4416ec2
3d563df
39ae6f8
7535c47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Adminer | ||
|
|
||
| Adminer is a lightweight, single-file web UI for managing databases such as | ||
| PostgreSQL. This chart deploys Adminer in your Spin namespace. | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| helm install -n <namespace> <release-name> . | ||
| ``` | ||
|
|
||
| ## Configure | ||
|
|
||
| Edit `values.yaml` before installing or upgrading. | ||
|
|
||
| - `env.ADMINER_DEFAULT_SERVER`: default database host shown in the Adminer UI | ||
| (e.g. the PostgreSQL Service name like `postgres` or `postgresql`). | ||
| - `env.ADMINER_DESIGN`: UI theme (default `pepa-linha`). | ||
| - `service.port`: Adminer listens on 8080 by default. | ||
|
|
||
| ## Access after deployment | ||
|
|
||
| With `service.type: ClusterIP`, use port-forwarding: | ||
|
|
||
| ```bash | ||
| kubectl -n <namespace> port-forward svc/<release-name>-adminer 8080:8080 | ||
| ``` | ||
|
|
||
| Then open `http://127.0.0.1:8080` in a browser. | ||
|
|
||
| If you want external access, add an Ingress (not included in this chart). |
| 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 }} |
| 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 }} |
| 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 }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # 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: true | ||
| runAsUser: <your NERSC UID> | ||
|
dingp marked this conversation as resolved.
|
||
|
|
||
| command: | ||
| - php | ||
| args: | ||
| - "-S" | ||
| - "0.0.0.0:8080" | ||
| - "-t" | ||
| - "/var/www/html" | ||
|
|
||
| env: | ||
| ADMINER_DESIGN: pepa-linha | ||
| # Name of the PostgreSQL Service in the same namespace; update before installing. | ||
| ADMINER_DEFAULT_SERVER: "<your-postgres-service-name>" | ||
|
dingp marked this conversation as resolved.
|
||
|
|
||
| service: | ||
| type: ClusterIP | ||
| port: 8080 | ||
|
|
||
| resources: {} | ||
|
|
||
| nodeSelector: {} | ||
| tolerations: [] | ||
| affinity: {} | ||
| 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/ |
| 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: "18" |
| 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. | ||
|
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> . | ||
|
dingp marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| helm install -n <namespace> <release-name> . | ||
|
dingp marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| ## Upgrade or uninstall | ||
|
|
||
| ```bash | ||
| helm upgrade -n <namespace> <release-name> . | ||
|
dingp marked this conversation as resolved.
|
||
| helm uninstall -n <namespace> <release-name> | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - Persistent volume size is controlled by `persistentVolumeClaims.<deployment_name>.size` (where `deployment_name` defaults to `psql` in `prepare-values.sh`). | ||
| - Liveness and readiness probes use `pg_isready` with the configured database name and user. | ||
| 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" | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| version_tag="18" | ||||||||||||||||||||||||||||||
| deployment_name="psql" | ||||||||||||||||||||||||||||||
| db_name="<DB_name>" | ||||||||||||||||||||||||||||||
| db_user_password="<DB_password>" | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| 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 |
| 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 }} |
Uh oh!
There was an error while loading. Please reload this page.