Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-9, README file enhancements. #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
150 changes: 149 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,154 @@
# Keycloak-deployment


This repository contains all our scripts to deploy keycloak on Openshift and minishift.
Also we have scripts to bake our own docker image using the keycloak source code
from our repository `almighty/keycloak`.

# Almighty-Keycloak Docker Image

To build this image it is necessary to have previously generated the executables of this
project. When building Keycloak for the first time, it is necessary to execute this Maven
command in the almighty/keycloak repository:

`$ mvn clean install -DskipTests -am -P distribution`

After running successfully, build the keycloak-server-dist distribution in the almighty/keycloak repository also:

`$ mvn clean install -DskipTests -pl :keycloak-server-dist -am -P distribution`

This generates some tarballs with the required executables. To build the docker image,
copy the generated tar file (e.g. `keycloak-3.0.0.Final.tar.gz`) from the almighty/keycloak
repository into the docker folder, like so:

`$ cp $KEYCLOAK_REPO/distribution/server-dist/target/keycloak-3.0.0.Final.tar.gz $KEYCLOAK_DEPLOYMENT_REPO/docker`

Then you just need to build the docker image. Change into the docker directory and run the following command:

`$ docker build --tag IMAGE_NAME .`

If you would like to build image for clustered mode add build argument

`$ docker build --build-arg OPERATING_MODE=clustered --tag IMAGE_NAME .`

Note that, this docker image installs the certificate to securely talk to OpenShift Online.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part might not be required anymore, we're currently testing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the certificate installation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.. this is why this PR is now conflicting. This section has been removed from the readme. But we still need to verify if it's really not needed anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still needed to do it to test oAuth between KC and minishift, before installing the certificate my log was full of certificate-related errors and nothing worked.

This step is done inside the `install_certificate.sh` script which adds this
certificate into the Java system keystore at building time. We assume this certificate
points to `tsrv.devshift.net`. So any change to the certificate requires rebuilding the
Docker image.

In the content of the Dockerfile, you can find these ENV variables:
```
ENV OSO_ADDRESS tsrv.devshift.net:8443
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need certificate handling anymore

ENV OSO_DOMAIN_NAME tsrv.devshift.net
```

Also note that it is possible to use a certificate from minishift. To do this, first obtain the
IP address of your minishift instance:

```
minishift ip
```

Then edit docker/Dockerfile and replace these values with the minishift IP (this is just an example,
the address will most likely be different):

```
ENV OSO_ADDRESS 192.168.42.134:8443
ENV OSO_DOMAIN_NAME 192.168.42.134
```

The command for building the docker image will need to be slightly different, since docker build by default does not
have access to local IP addresses. Add the --network="host" parameter to allow the install_certificate.sh script to
connect to minishift and retrieve the certificate:

`$ docker build --network="host" --tag IMAGE_NAME .`


# Openshift Configuration for clustered deployment

Majority of the config is defined in `DeploymentConfig` files you can find in `openshift` folder in the root of this repository.

There is one thing needed however to have properly functioning cluster (using [k8s PING protocol in `jgroups`](https://github.com/jgroups-extras/jgroups-kubernetes)).
Service account has to have `view` privileges. This can be enabled using `oc` cli as follows:

```
$ oc policy add-role-to-user view system:serviceaccount:$(oc project -q):default -n $(oc project -q)
```

# Deploying Keycloak to Minishift

To deploy a Keycloak cluster in minishift use the following commands:

```
oc new-project keycloak --display-name="Keycloak server" \
--description="keycloak server + postgres"

oc new-app -f postgresql.json
sleep 20

# deploying 3 keycloak instances
oc new-app -f keycloak.json
```

### Customization options

#### KeyCloak

edit environment variables:

"env":[
{
"name":"KEYCLOAK_USER",
"value":"admin"
},
{
"name":"KEYCLOAK_PASSWORD",
"value":"admin"
},
{
"name":"POSTGRES_DATABASE",
"value":"userdb"
},
{
"name":"POSTGRES_USER",
"value":"keycloak"
},
{
"name":"POSTGRES_PASSWORD",
"value":"password"
},
{
"name":"POSTGRES_PORT_5432_TCP_ADDR",
"value":"postgres"
},
{
"name":"POSTGRES_PORT_5432_TCP_PORT",
"value":"5432"
},
{
"name":"OPERATING_MODE",
"value":"clustered"
}
]


#### Postgresql

"env": [
{
"name": "POSTGRESQL_USER",
"value": "keycloak"
},
{
"name": "POSTGRESQL_PASSWORD",
"value": "password"
},
{
"name": "POSTGRESQL_DATABASE",
"value": "userdb"
},
{
"name": "POSTGRESQL_ADMIN_PASSWORD",
"value": "password"
}
]
46 changes: 0 additions & 46 deletions docker/README.md

This file was deleted.

77 changes: 0 additions & 77 deletions minishift/README.md

This file was deleted.