-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy to openshift - cloweder (#40)
Changes: - Create a postgres pod, service - Create spiceDB secret - Create spiceDB bootstrap file via configmap - Changes to clowdapp yaml to accomodate the same - new script added deploy.sh to simply the entire process - will rbing up the whole stack
- Loading branch information
1 parent
94109a6
commit 22f553b
Showing
6 changed files
with
226 additions
and
7 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,3 @@ | ||
POSTGRES_DB=authz | ||
POSTGRES_USER=authz | ||
POSTGRES_PASSWORD=supersecretpassword |
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
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
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,68 @@ | ||
#!/bin/bash | ||
source ../.secrets/postgres.env | ||
|
||
# Export tags | ||
IMAGE=quay.io/ciam_authz/insights-rebac | ||
IMAGE_TAG=latest | ||
|
||
# Prepare bonfire env | ||
VENV_DIR=~/bonfire_venv | ||
mkdir -p $VENV_DIR | ||
python3 -m venv $VENV_DIR | ||
. $VENV_DIR/bin/activate | ||
|
||
# Function to check if a command is available | ||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
# pre-flight checks | ||
if command_exists bonfire; then | ||
echo "Bonfire is OK " | ||
else | ||
echo "bonfire needs to be installed" | ||
exit 1 | ||
fi | ||
|
||
# Reserve a namespace | ||
bonfire namespace reserve --duration 8h | ||
NAMESPACE=$(oc config view --minify -o 'jsonpath={..namespace}') | ||
|
||
if [[ -z "${NAMESPACE}" ]]; then | ||
echo "Namespace is not set" | ||
exit 1 | ||
fi | ||
echo "Using Namespace:" $NAMESPACE | ||
|
||
#Prepare the bonfire config yaml file | ||
currentpath=$(pwd) | ||
file_location=~/.config/bonfire/config.yaml | ||
cat > $file_location <<EOF | ||
apps: | ||
- name: relationships | ||
components: | ||
- name: relationships | ||
host: local | ||
repo: $currentpath | ||
path: clowdapp.yaml | ||
parameters: | ||
NAMESPACE: $NAMESPACE | ||
IMAGE: $IMAGE | ||
IMAGE_TAG: $IMAGE_TAG | ||
EOF | ||
|
||
# Create postgres pod,service and the spiceDB secret | ||
oc process -f postgres.yaml -p NAMESPACE=$NAMESPACE -p POSTGRES_USER=$POSTGRES_USER -p POSTGRES_PASSWORD=$POSTGRES_PASSWORD -p POSTGRES_DB=$POSTGRES_DB | oc apply --wait=true -f - | ||
|
||
# check the postgres service and secret are created | ||
while [[ -z $(oc get deployments.apps -n $NAMESPACE postgres -o jsonpath="{.status.readyReplicas}" 2>/dev/null) ]]; do | ||
echo "still waiting for postgres" | ||
sleep 1 | ||
done | ||
echo "postgress is ready" | ||
|
||
# Create spiceDB bootstrap schema configmap | ||
oc create configmap spicedb-schema --from-file=schema.yaml -n $NAMESPACE | ||
|
||
#Deploy Relations service, spiceDB service | ||
bonfire deploy relationships -n $NAMESPACE --local-config-method override |
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,80 @@ | ||
apiVersion: template.openshift.io/v1 | ||
kind: Template | ||
metadata: | ||
name: relationships | ||
objects: | ||
- apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: postgres | ||
name: postgres | ||
namespace: ${NAMESPACE} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: postgres | ||
template: | ||
metadata: | ||
labels: | ||
app: postgres | ||
spec: | ||
containers: | ||
- env: | ||
- name: POSTGRESQL_DATABASE | ||
value: ${POSTGRES_DB} | ||
- name: POSTGRESQL_USER | ||
value: ${POSTGRES_USER} | ||
- name: POSTGRESQL_PASSWORD | ||
value: ${POSTGRES_PASSWORD} | ||
- name: PGDATA | ||
value: /temp/data | ||
image: registry.redhat.io/rhel9/postgresql-15:1-54 | ||
imagePullPolicy: Always | ||
name: postgres | ||
ports: | ||
- containerPort: 5432 | ||
protocol: TCP | ||
resources: | ||
limits: | ||
cpu: 60m | ||
memory: 256Mi | ||
requests: | ||
cpu: 30m | ||
memory: 128Mi | ||
restartPolicy: Always | ||
|
||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: postgres | ||
name: postgres | ||
namespace: ${NAMESPACE} | ||
spec: | ||
ports: | ||
- name: http | ||
port: 5432 | ||
protocol: TCP | ||
selector: | ||
app: postgres | ||
- apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: dev-spicedb-config | ||
stringData: | ||
preshared_key: "averysecretpresharedkey" | ||
datastore_uri: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres.${NAMESPACE}.svc.cluster.local:5432/${POSTGRES_DB}?sslmode=disable | ||
parameters: | ||
- description: Namespace to deploy into | ||
name: NAMESPACE | ||
value: ${NAMESPACE} | ||
- description: Postgres DB name | ||
name: POSTGRES_DB | ||
value: ${POSTGRES_DB} | ||
- description: Postgres DB username | ||
name: POSTGRES_USER | ||
value: ${POSTGRES_USER} | ||
- description: Postgres DB password | ||
name: POSTGRES_PASSWORD | ||
value: ${POSTGRES_PASSWORD} |
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,30 @@ | ||
schema: |- | ||
definition user {} | ||
definition group { | ||
relation member: user | group#member | ||
} | ||
definition role { | ||
relation view_the_thing: user:* | ||
} | ||
definition role_binding { | ||
relation subject : user | group#member | ||
relation granted: role | ||
permission view_the_thing = subject & granted->view_the_thing | ||
} | ||
definition workspace { | ||
relation parent: workspace | ||
relation user_grant: role_binding | ||
permission view_the_thing = user_grant->view_the_thing | ||
} | ||
definition thing { | ||
relation workspace: workspace | ||
permission view = workspace->view_the_thing | ||
} |