Skip to content
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
87 changes: 87 additions & 0 deletions postgres-on-kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
![postgres logo](https://raw.githubusercontent.com/docker-library/docs/01c12653951b2fe592c1f93a13b4e289ada0e3a1/postgres/logo.png "Postgres Logo")

## What is PostgreSQL?

---

PostgreSQL, often simply "Postgres", is an object-relational database management system (ORDBMS) with an emphasis on extensibility and standards-compliance. It can handle workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users. Recent versions also provide replication of the database itself for security and scalability.

## Features

---

- User-defined types.
- Table inheritance.
- Sophisticated locking mechanism.
- Foreign key referential integrity.
- Views, rules, subquery.
- Nested transactions (savepoints)
- Multi-version concurrency control (MVCC)
- Asynchronous replication.

## Installation

---

1. Select the devices to which PostgreSQL will be installed from 'Devices' page.

2. Navigate to the 'App Marketplace' tab and select the 'PostgreSQL' application.

3. The 'Install Now' button should now appear near the top of the screen. Select this button.

4. Give your installation a name and fill all the parameters. Click 'Install PostgrSQL' in the bottom right corner.

## Required Parameters

---

**POSTGRES_USERNAME**
This variable is used in conjunction with `POSTGRES_PASSWORD` to set a user and its password.

**POSTGRES_PASSWORD**
This variable is used in conjunction with `POSTGRES_USERNAME` to set a user and its password.

## Additional Parameters

---

**Installation Name**

Here you will put your app name. Although the app name is MariaDB on the portal, you can personalize the name that is shown on the device's Applications.

**NAMESPACE_NAME**
This variable is used to create a namespace in Kubernetes. Leave it in blank to install pods on default namespace.

## Using PostgreSQL

---

Use device shell to execute commands using psql client. This command will open psql client in interactive mode.

kubectl exec -it -n <yournamespace> postgres-0 -- psql -U <yourusername> -W

After executing this command, you will be asked for the password you already assign in the Postgres installation.

Then, you can execute psql commands to use the database.

## OS Architectures

---

- Arm64

## Limitations / Known issues

---

## PostgreSQL Platform Video

---

[![Demo Image](http://img.youtube.com/vi/tzbA7VniRpw/0.jpg)](https://youtu.be/tzbA7VniRpw)

## Docs

---

For more information: <https://github.com/docker-library/docs/tree/master/postgres/README.md>
16 changes: 16 additions & 0 deletions postgres-on-kubernetes/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "postgres-on-kubernetes",
"display_name": "postgres-on-kubernetes",
"description": "postgres-on-kubernetes",
"parameters": [],
"main": "postgres-on-kubernetes/run.sh",
"dependencies": [
"postgres-on-kubernetes/run.sh",
"postgres-on-kubernetes/postgres-secret.yaml",
"postgres-on-kubernetes/postgres-service.yaml",
"postgres-on-kubernetes/postgres-configmap.yaml",
"postgres-on-kubernetes/postgres-storage.yaml",
"postgres-on-kubernetes/postgres-statefulset.yaml",
"utils/cachengo.sh"
]
}
9 changes: 9 additions & 0 deletions postgres-on-kubernetes/postgres-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: postgres
namespace: #namespace_name#
data:
postgres-url: postgres-service
9 changes: 9 additions & 0 deletions postgres-on-kubernetes/postgres-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
namespace: #namespace_name#
type: Opaque
stringData:
postgres-user: #postgres_user#
postgres-password: #postgres_password#
14 changes: 14 additions & 0 deletions postgres-on-kubernetes/postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: postgres-service
namespace: #namespace_name#
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
nodePort: 32400
type: NodePort
41 changes: 41 additions & 0 deletions postgres-on-kubernetes/postgres-statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# PostgreSQL StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
namespace: #namespace_name#
spec:
serviceName: postgres-service
selector:
matchLabels:
app: postgres-jitsu
replicas: 1
template:
metadata:
labels:
app: postgres-jitsu
spec:
containers:
- name: postgres
image: postgres:14
volumeMounts:
- name: postgresdb
mountPath: /var/lib/postgresql/data
subPath: postgres-data
ports:
- containerPort: 5432
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: postgres-password
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-secret
key: postgres-user
volumes:
- name: postgresdb
persistentVolumeClaim:
claimName: postgres-pvc
12 changes: 12 additions & 0 deletions postgres-on-kubernetes/postgres-storage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-pvc
namespace: #namespace_name#
spec:
storageClassName: longhorn
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30Gi
58 changes: 58 additions & 0 deletions postgres-on-kubernetes/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

source "utils/cachengo.sh"
source "postgres-on-kubernetes/postgres-secret.yaml"
source "postgres-on-kubernetes/postgres-service.yaml"
source "postgres-on-kubernetes/postgres-configmap.yaml"
source "postgres-on-kubernetes/postgres-storage.yaml"
source "postgres-on-kubernetes/postgres-statefulset.yaml"

function do_install {
set -e
cachengo-cli updateInstallStatus "$APPID" "Installing"

if [ -n "$NAMESPACE_NAME" ]; then

kubectl create namespace $NAMESPACE_NAME
sed -i "s|#namespace_name#|$NAMESPACE_NAME|g" postgres-on-kubernetes/postgres-configmap.yaml
sed -i "s|#namespace_name#|$NAMESPACE_NAME|g" postgres-on-kubernetes/postgres-secret.yaml
sed -i "s|#namespace_name#|$NAMESPACE_NAME|g" postgres-on-kubernetes/postgres-service.yaml
sed -i "s|#namespace_name#|$NAMESPACE_NAME|g" postgres-on-kubernetes/postgres-statefulset.yaml
sed -i "s|#namespace_name#|$NAMESPACE_NAME|g" postgres-on-kubernetes/postgres-storage.yaml

else

sed -i "s|#namespace_name#|default|g" postgres-on-kubernetes/postgres-configmap.yaml
sed -i "s|#namespace_name#|default|g" postgres-on-kubernetes/postgres-secret.yaml
sed -i "s|#namespace_name#|default|g" postgres-on-kubernetes/postgres-service.yaml
sed -i "s|#namespace_name#|default|g" postgres-on-kubernetes/postgres-statefulset.yaml
sed -i "s|#namespace_name#|default|g" postgres-on-kubernetes/postgres-storage.yaml

fi

sed -i "s|#postgres_user#|$POSTGRES_USER|g" postgres-on-kubernetes/postgres-secret.yaml
sed -i "s|#postgres_password#|$POSTGRES_PASSWORD|g" postgres-on-kubernetes/postgres-secret.yaml
kubectl apply -f postgres-on-kubernetes/postgres-secret.yaml

kubectl apply -f postgres-on-kubernetes/postgres-service.yaml
kubectl apply -f postgres-on-kubernetes/postgres-statefulset.yaml
kubectl apply -f postgres-on-kubernetes/postgres-configmap.yaml
kubectl apply -f postgres-on-kubernetes/postgres-storage.yaml

}

function do_uninstall {
cachengo-cli updateInstallStatus "$APPID" "Uninstalling"

kubectl delete -f postgres-on-kubernetes/postgres-service.yaml
kubectl delete -f postgres-on-kubernetes/postgres-secret.yaml
kubectl delete -f postgres-on-kubernetes/postgres-statefulset.yaml
kubectl delete -f postgres-on-kubernetes/postgres-configmap.yaml
kubectl delete -f postgres-on-kubernetes/postgres-storage.yaml

cachengo-cli updateInstallStatus "$APPID" "Uninstalled"
}
case "$1" in
install) do_install ;;
uninstall) do_uninstall ;;
esac