-
Notifications
You must be signed in to change notification settings - Fork 19
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
sbryzak
wants to merge
1
commit into
fabric8-services:master
Choose a base branch
from
sbryzak:issue-9
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -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. | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
} | ||
] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.