Giter VIP home page Giter VIP logo

rhsso-with-ext-postgresql-db's Introduction

Using an external Postgresql database with Red Hat SSO for Openshift

Example of using an external Postgresql database with the Red Hat Single Sign On (SSO) container for Openshift.

This example does not add a Postgresql JDBC driver as the Red Hat SSO image currently provides a version of the Postgresql JDBC driver. Please be aware that this could change in future versions of the RHSSO image where third party JDBC drivers might not be provided and would need to be installed. A datasource is created at deploy time that uses the Postgresql JDBC driver. This example assumes that the Postgresql database is visible to pods via DNS alone.

NOTE: This example requires that specifics for the Posgresql database be provided. This example will fail if the default values from the template and datasources.env file are used. Some of the defaults are dummy data.

This repository provides a working reference which includes:

How it works

The modified template sso72-https-postgresql-external.json is used to introduce a buildconfig that will incorporate the datasources.env file which is used to describe and configure the database for the RHSSO pod to use. The build process clones this git repository into a build pod that performs a build of the RHSSO container. The Openshift build process produces a container image to be used for an RHSSO pod.

When the resulting container image is used to produce an RHSSO pod, the pod is configured at deploy time to include datasource settings provided by the datasources.env. The JBoss EAP configuration file (/opt/eap/standalone/configuration/standalone-openshift.xml) that is provided in the RHSSO container is updated to include the KeycloakDS datasource configuration backed by a Postgresql database.

Requirements

Steps to use this example

  • Create a project and a serviceaccount. Then add visibility for the system servieaccount.
oc new-project rhsso-ext-postgres
oc create serviceaccount sso-service-account
oc policy add-role-to-user view system:serviceaccount:$(oc project -q):sso-service-account
  • Create the template in your project namespace or in the openshift namespace, should you wish for the template to be viewable by other users/developers.
oc create -f sso72-https-postgresql-external.json -n rhsso-ext-postgres
  • Create (or supply existing) certs and trust stores for encrypted communication. I have a script for this, so you will see environment variables being referenced. This is just for reference as you likely have your own certs and trust stores to use. Use the appropriate values when creating the RHSSO pod in a later step. You can find out more about these steps in the RHSSO documentation.

    • Create CA key and cert
    openssl req -new -newkey rsa:4096 -x509 -keyout $CAKEY -out $CACERT -days 365 -subj "/CN=xpaas-sso-demo.ca" -passin pass:$CAPASS -passout pass:$CAPASS
    
    • Create HTTPS keystore
    keytool -genkeypair -keyalg RSA -keysize 2048 -dname "CN=$HOSTNAME_HTTPS" -alias $HTTPS_NAME -keystore $HTTPS_KEYSTORE -keypass $HTTPS_PASSWORD -storepass $HTTPS_PASSWORD
    
    • Create HTTPS cert request
    keytool -certreq -keyalg rsa -alias $HTTPS_NAME -keystore $HTTPS_KEYSTORE -file $SSOSIGNREQ -keypass $HTTPS_PASSWORD -storepass $HTTPS_PASSWORD
    
    • Create SSO cert
    openssl x509 -trustout -req -CA $CACERT -CAkey $CAKEY -in $SSOSIGNREQ -out $SSOCERT -days 365 -CAcreateserial -passin pass:$CAPASS
    
    • Add CA cert to HTTPS keystore
    keytool -import -noprompt -trustcacerts -file $CACERT -alias $CAALIAS -keystore $HTTPS_KEYSTORE -keypass $HTTPS_PASSWORD -storepass $HTTPS_PASSWORD
    
    • Add SSO cert to HTTPS keystore
    keytool -import -noprompt -trustcacerts -file $SSOCERT -alias $HTTPS_NAME -keystore $HTTPS_KEYSTORE -keypass $HTTPS_PASSWORD -storepass $HTTPS_PASSWORD
    
    • Add CA cert to SSO truststore
    keytool -import -noprompt -trustcacerts -file $CACERT -alias $CAALIAS -keystore $SSO_TRUSTSTORE -keypass $CAPASS -storepass $CAPASS
    
    • Create JGROUPS keystore
    keytool -genseckey -alias $JGROUPS_ENCRYPT_NAME -storetype JCEKS -keypass $JGROUPS_ENCRYPT_PASSWORD -storepass $JGROUPS_ENCRYPT_PASSWORD -keystore $JGROUPS_ENCRYPT_KEYSTORE
    
  • Create one secret for all stores

oc create secret generic $HTTPS_SECRET --from-file=$JGROUPS_ENCRYPT_KEYSTORE --from-file=$HTTPS_KEYSTORE --from-file=$SSO_TRUSTSTORE
oc secret add sa/sso-service-account secret/$HTTPS_SECRET
  • Create the RHSSO pod passing in some parameters that you may want to specifically set.
oc process openshift//sso72-https-postgresql-external \
-p APPLICATION_NAME=rhsso-ext-postgres-app \
-p IMAGE_STREAM_NAMESPACE=openshift \
-p SOURCE_REPOSITORY_URL=https://github.com/travisrogers05/rhsso-with-ext-postgresql-db \
-p SOURCE_REPOSITORY_REF=master \
-p DB_DATABASE=rhsso \
-p DB_USERNAME=joe \
-p DB_PASSWORD=user \
-p HOSTNAME_HTTP=rhsso-ext-postgres-app-rhsso-ext-postgres.example.com \
-p HOSTNAME_HTTPS=secure-rhsso-ext-postgres-app-rhsso-ext-postgres.example.com \
-p HTTPS_KEYSTORE=sso-https.jks \
-p HTTPS_KEYSTORE_TYPE=jks \
-p HTTPS_NAME=sso-https-key \
-p HTTPS_PASSWORD=password \
-p JGROUPS_ENCRYPT_SECRET=sso-app-secret \
-p JGROUPS_ENCRYPT_KEYSTORE=jgroups.jceks \
-p JGROUPS_ENCRYPT_NAME=jgroups \
-p JGROUPS_ENCRYPT_PASSWORD=password \
-p SSO_ADMIN_USERNAME=admin \
-p SSO_ADMIN_PASSWORD=admin \
-p SSO_REALM=demo \
-p SSO_SERVICE_USERNAME=sso \
-p SSO_SERVICE_PASSWORD=password \
-p SSO_TRUSTSTORE=truststore.jks \
-p SSO_TRUSTSTORE_PASSWORD=password \
-p SSO_TRUSTSTORE_SECRET=sso-app-secret \
| oc create -f -

At this point you should see a build process initiate followed by a deployment of the RHSSO pod.

rhsso-with-ext-postgresql-db's People

Contributors

travisrogers05 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.