This is a basic demo you can use for working with persistent data in Kubernetes deployments, as well as a lot of other things. This demo has a PHP front end which pulls image URLs out of a PostgreSQL database. Okay I admit it, it's all cat pictures.
- PostgreSQL 9.5
- PHP with PostgreSQL support enabled.
- A web server which can run PHP files.
-
Put the contents of the
web
directory into your webroot. -
Put the contents of the
main
directory into your PostgreSQL data directory. (In most cases this will be/var/lib/postgresql/9.5/main
.)
Digital Ocean article on how to do that:
If you need to create the database by hand, here are the commands.
Create the database:
sudo -u postgres psql
create database cat_storage;
\c cat_storage;
create user cat_dev with encrypted password '9lives';
grant all privileges on database cat_storage to cat_dev;
grant all privileges on all tables in schema public to cat_dev;
Add a table for the pics:
CREATE TABLE cat_pictures(
cat_id serial primary key,
cat_name text,
pic_url text
);
insert images
insert into cat_pictures(cat_name,pic_url) values('Autumn', 'cats/autumn.jpg');
insert into cat_pictures(cat_name,pic_url) values('Cat and Goat', 'cats/cat-and-goat.jpg');
insert into cat_pictures(cat_name,pic_url) values('Kitten', 'cats/kitten.jpg');
insert into cat_pictures(cat_name,pic_url) values('Kitten', 'cats/pawsup.png');
insert into cat_pictures(cat_name,pic_url) values('Cutest Kitten', 'cats/cutestkitten.jpg');
insert into cat_pictures(cat_name,pic_url) values('Smile!', 'cats/smile.jpg');
insert into cat_pictures(cat_name,pic_url) values('Purrito', 'cats/purrito.jpg');
insert into cat_pictures(cat_name,pic_url) values('Purrito', 'cats/tuxedo.jpg');