-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified scripts for install-storage
- Loading branch information
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
echo "Checking characters table" | ||
|
||
if [ "$(oc get pods -o name -l deployment=postgresql-persistent)" != "" ] | ||
then | ||
APP="deployment/postgresql-persistent" | ||
elif [ "$(oc get pods -o name -l deployment=postgresql-persistent2)" != "" ] | ||
then | ||
APP="deployment/postgresql-persistent2" | ||
else | ||
echo "ERROR: deployment/postgresql-persistent not found" | ||
echo "ERROR: deployment/postgresql-persistent2 not found" | ||
fi | ||
|
||
if [ -n "${APP}" ] | ||
then | ||
if [[ "$(oc exec ${APP} -i redhat123 -t -- /usr/bin/psql -U redhat persistentdb -c '\d characters' 2>&1)" != *"exit code 1"* ]] | ||
then | ||
OUTPUT=$(oc exec ${APP} -i redhat123 -t -- /usr/bin/psql -U redhat persistentdb -c 'select id,name,nationality from characters' 2>&1) | ||
fi | ||
fi | ||
|
||
if [ -n "${OUTPUT}" ] | ||
then | ||
echo "${OUTPUT}" | ||
else | ||
echo "ERROR: 'characters' table does not exist" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
echo "Checking characters table" | ||
|
||
if [ "$(oc get pods -o name -l deployment=db-storage-demo)" != "" ] | ||
then | ||
APP="deployment/db-storage-demo" | ||
elif [ "$(oc get pods -o name -l deployment=db-storage-demo2)" != "" ] | ||
then | ||
APP="deployment/db-storage-demo2" | ||
else | ||
echo "ERROR: deployment/db-storge-demo not found" | ||
echo "ERROR: deployment/db-storage-demo2 not found" | ||
fi | ||
|
||
if [ -n "${APP}" ] | ||
then | ||
if [[ "$(oc exec ${APP} -i redhat123 -t -- /usr/bin/psql -U redhat demodb -c '\d characters' 2>&1)" != *"exit code 1"* ]] | ||
then | ||
OUTPUT=$(oc exec ${APP} -i redhat123 -t -- /usr/bin/psql -U redhat demodb -c 'select id,name,nationality from characters' 2>&1) | ||
fi | ||
fi | ||
|
||
if [ -n "${OUTPUT}" ] | ||
then | ||
echo "${OUTPUT}" | ||
else | ||
echo "ERROR: 'characters' table does not exist" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Create the postgresql-persistent deployment | ||
oc new-app --name postgresql-persistent \ | ||
--docker-image registry.redhat.io/rhel8/postgresql-12:1-43 \ | ||
-e POSTGRESQL_USER=redhat \ | ||
-e POSTGRESQL_PASSWORD=redhat123 \ | ||
-e POSTGRESQL_DATABASE=persistentdb | ||
|
||
|
||
# Create a PVC and volume for the postgresql-persistent deployment | ||
oc set volumes deployment/postgresql-persistent \ | ||
--add --name postgresql-storage --type pvc --claim-class nfs-storage \ | ||
--claim-mode rwo --claim-size 10Gi --mount-path /var/lib/pgsql \ | ||
--claim-name postgresql-storage | ||
|
||
|
||
# List persistent volumes with custom columns | ||
oc get pv \ | ||
-o custom-columns=NAME:.metadata.name,CLAIM:.spec.claimRef.name | ||
|
||
# Create the postgresql-persistent2 deployment | ||
oc new-app --name postgresql-persistent2 \ | ||
--docker-image registry.redhat.io/rhel8/postgresql-12:1-43 \ | ||
-e POSTGRESQL_USER=redhat \ | ||
-e POSTGRESQL_PASSWORD=redhat123 \ | ||
-e POSTGRESQL_DATABASE=persistentdb | ||
|
||
|
||
# Attach the existing PVC to the postgresql-persistent2 deployment | ||
oc set volumes \ | ||
deployment/postgresql-persistent2 \ | ||
--add --name postgresql-storage --type pvc \ | ||
--claim-name postgresql-storage --mount-path /var/lib/pgsql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
echo "Populating characters table" | ||
oc exec deployment.apps/postgresql-persistent -i redhat123 -- /usr/bin/psql -U redhat persistentdb < /home/student/DO280/labs/install-storage/init_data.sql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CREATE TABLE characters ( | ||
id SERIAL PRIMARY KEY, | ||
name varchar(50), | ||
nationality varchar(50) | ||
); | ||
|
||
INSERT INTO characters (name, nationality) | ||
VALUES | ||
('Wolfgang Amadeus Mozart', 'Prince-Archbishopric of Salzburg'), | ||
('Ludwig van Beethoven', 'Bonn, Germany'), | ||
('Johann Sebastian Bach', 'Eisenach, Germany'), | ||
('José Pablo Moncayo', 'Guadalajara, México'), | ||
('Niccolò Paganini', 'Genoa, Italy'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
echo "Populating characters table" | ||
oc exec deployment.apps/db-storage-demo -i redhat123 -- /usr/bin/psql -U redhat demodb < /home/student/DO280/labs/install-storage/init_data.sql | ||
|