Chapter 4. Multiple OpenShift Servers

As outlined in the OpenShift Enterprise Client Tools Installation Guide, previous versions of the client tools were configured for use with a single OpenShift server at a time. The configuration settings in the ~/.openshift/express.conf file would be overwritten each time the client tools were configured for use with a new server. Starting with OpenShift Enterprise 2.1.5, you can configure the client tools shipped with OpenShift Enterprise for use with multiple servers.
Configuring the client tools for multiple servers is useful for when you are using a single workstation to manage different applications hosted across multiple servers. For example, if your organization is using different OpenShift Enterprise servers for development, production, and testing, and you have an OpenShift Online account for personal use, you can manage applications on any of these servers from the same workstation without overwriting your client tools configuration each time.

4.1. Server Management

4.1.1. Adding a Server

Add an OpenShift server with the following command:
$ rhc server add server.name.example.com
This can be an OpenShift Enterprise, OpenShift Online, or OpenShift Origin server.
When adding a server, you can assign it a nickname to make it easier to reference in any future commands:
$ rhc server add server.name.example.com --nickname Server_Nickname
Note that when adding a server with the server name of openshift.redhat.com, the nickname defaults to online.
When adding a server, specifying a user name associates that user with the server, and you can have different user names with each server:
$ rhc server add server.name.example.com --nickname Server_Nickname --rhlogin user@company.com
The client tools automatically manage users when you switch between servers.

4.1.2. Switching Between Servers

When the client tools have been configured for multiple servers, switch to the desired server with the following command:
$ rhc server use server.name.example.com
If you assigned a nickname to a server, you can replace this with the server host name:
$ rhc server use Server_Nickname

4.1.3. Configuring Server Settings

When you run the rhc setup command for the first time, the ~/.openshift/express.conf file is created, containing the settings for your initial server configuration. When you add another server, or run the rhc setup command again with the --server option, the ~/.openshift/servers.yml file is created, containing the settings for each server. You can edit this file to make any changes to the server configuration, and this takes precedence over the initial ~/.openshift/express.conf file.

Example 4.1. Contents of the ~/.openshift/servers.yml File

-server:
	hostname: dev.openshift.company.com
	nickname: development
	login: user@company.com
	use_authorization_tokens: true
	insecure: true
		
-server
	hostname: openshift.redhat.com
	nickname: online
	login: user@personal.com
	use_authorization_tokens: true
	insecure: false
Configure any server settings with the following command, replacing Server_Setting with the desired server setting:
$ rhc server configure server.name.example.com Server_Setting
If you assigned a nickname to a server, you can replace this with the server host name:
$ rhc server configure Server_Nickname Server_Setting
You can use this command to configure any settings found in the ~/.openshift/servers.yml file, such as the server nickname, the user name associated with the server, or any authorization tokens associated with the account.

Example 4.2. Changing the Nickname of a Server

$ rhc server configure dev.openshift.company.com --nickname dev

Example 4.3. Changing the Default User

$ rhc server configure dev --rhlogin username@example.com

4.1.4. Listing Servers

List any servers you have added with the following command:
$ rhc server list
Alternatively, you can list servers with the rhc servers command.

4.1.5. Viewing a Server

To see information about a specific server, use the following command:
$ rhc server show server.name.example.com
If you assigned a nickname to a server, you can replace this with the server host name:
$ rhc server show Server_Nickname

4.1.6. Removing a Server

Remove a server with the following command:
$ rhc server remove server.name.example.com
If you assigned a nickname to a server, you can replace this with the server host name:
$ rhc server remove Server_Nickname

Note

You cannot remove the server you are currently using.