Repository files navigation

cc-docker

This is a docker-compose setup which provides a quickly started environment for ClusterCockpit development and testing, using cc-backend. A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP, SLURM), or easily added by manual configuration (MariaDB).

It includes the following containers:

Service full namedocker service nameport
Slurm Controllerslurmctld6818
Slurm Databaseslurmdbd6817
Slurm Rest (JWT)slurmrestd6820
Slurm Workernode016818
NATS servicenats4222, 6222, 8222
cc-metric-storecc-metric-store8084
KeyCloakkeycloak8080
OpenLDAPopenldap389, 636

The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, and a LDAP user directory.

Prerequisites

For all the docker services to work correctly, you will need the following tools installed:

  1. docker and docker-compose
  2. golang (for compiling cc-metric-store)
  3. perl (for migrateTimestamp.pl) with Cpanel::JSON::XS, Data::Dumper, Time::Piece, Sort::Versions and File::Slurp perl modules.
  4. npm (for cc-backend)
  5. make (for building slurm base image)

It is also recommended to add docker service to sudo user group since the setupDev.sh script assumes sudo permissions for docker and docker-compose services.

You can use:

sudo groupadd docker
sudo usermod -aG docker $USER
# restart after adding your docker with your user to sudo group
sudo shutdown -r -t 0

Note: You can install all these dependencies via predefined installation steps in prerequisite_installation_script.sh.

If you are using different Linux flavors, you will have to adapt prerequisite_installation_script.sh as well as setupDev.sh.

Setup Procedure

  1. Clone cc-backend repository in chosen base folder: $> git clone https://github.com/ClusterCockpit/cc-backend.git

  2. Run the setup bash file: $> ./setupDev.sh: NOTICE The script will download files of a total size of 338MB (mostly for the cc-metric-store data).

  3. The setup-script launches the supporting container stack in the background automatically if everything went well. Run

./cc-backend/cc-backend -server -dev

to start cc-backend.

  1. By default, you can access cc-backend in your browser at http://localhost:8088 (port 8080 is taken by the KeyCloak container). You can shut down the cc-backend server by pressing CTRL-C, remember to also shut down all containers via $> docker-compose down afterwards.

  2. You can restart the containers with: $> docker-compose up -d.

Credentials for logging into clustercockpit

Credentials for the preconfigured demo user are:

  • User: demo
  • Password: demo

The LDAP user directory is defined in ./data/ldap/add_users.ldif. Every account's password equals its user name:

UserGroupRole in ClusterCockpit
ldapuseruser
ccuseruser
ccadmincc-adminuser, admin
ccsupportcc-supportuser
ccmanagercc-manageruser
ccapicc-apiuser

LDAP role sync

cc-backend can derive elevated roles from LDAP group membership via auth.ldap.role-filters in config.json. Each entry maps a role to an LDAP filter that is evaluated against the user entry; the preconfigured setup maps the cc-admin group to the admin role:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)"
}

The memberOf attribute is maintained automatically by the memberof overlay of the openldap image, which is configured for groupOfUniqueNames / uniqueMember — the group entries in the ldif use those classes accordingly.

LDAP is authoritative for every role listed in role-filters: a role is granted when the filter matches and revoked when it no longer does. Roles that are not listed are never touched. To exercise the other groups, add them as well:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)",
"support": "(memberOf=cn=cc-support,ou=groups,dc=example,dc=com)",
"manager": "(memberOf=cn=cc-manager,ou=groups,dc=example,dc=com)",
"api": "(memberOf=cn=cc-api,ou=groups,dc=example,dc=com)"
}

Roles are applied when the account is first synced (sync-user-on-login) and refreshed on every subsequent login (update-user-on-login), as well as by the periodic sync task (sync-interval).

Note: The ldif is only applied when the openldap container initialises its database. After changing it, recreate the container and its volumes with docker compose rm -sfv openldap, or load the changes into the running directory manually with ldapadd.

OIDC login via KeyCloak

The KeyCloak container imports the realm clustercockpit from ./keycloak/import/clustercockpit-realm.json on first start. It defines the confidential client cc-backend, the realm roles cc-admin, cc-support, cc-manager and cc-api, and these accounts (password equals user name):

UserRealm roleRole in ClusterCockpit
kcuseruser
kcadmincc-adminadmin
kcsupportcc-supportuser
kcmanagercc-manageruser
kcapicc-apiuser

The KeyCloak admin console is at http://localhost:8080 (admin / admin).

The auth.oidc.role-mapping section of config.json translates realm roles into ClusterCockpit roles. The preconfigured setup maps cc-admin to admin:

"oidc": {
"provider": "http://localhost:8080/realms/clustercockpit",
"client-id": "cc-backend",
"client-secret": "cc-backend-dev-secret",
"sync-user-on-login": true,
"update-user-on-login": true,
"role-mapping": {
"cc-admin": "admin"
}
}

Unlike the LDAP role filters, role-mapping is the sole source of roles for OIDC logins: a role in the token grants a ClusterCockpit role only if it is listed here, and unmapped roles are ignored — literal role names such as admin would also have to be mapped explicitly. Accounts without a mapped role get user. Add the remaining groups to exercise them:

"role-mapping": {
"cc-admin": "admin",
"cc-support": "support",
"cc-manager": "manager",
"cc-api": "api"
}

Roles are read from the realm_access.roles claim of the ID token. The built-in KeyCloak roles client scope only adds that claim to the access token, so the imported client carries its own realm roles in id token protocol mapper with id.token.claim enabled. Keep that mapper when editing the realm, otherwise every OIDC login falls back to the plain user role.

Note: cc-backend resolves the OIDC provider at startup and aborts if it is unreachable, so the KeyCloak container has to be up before starting the server. The realm is only imported while the KeyCloak database is empty — to re-import after editing the realm file, recreate KeyCloak and its database with docker compose rm -sf keycloak postgres.

Preconfigured setup between docker services and ClusterCockpit components

When you are done cloning the cc-backend repo and once you execute setupDev.sh file, it will copy a preconfigured config.json from misc/config.json and replace the cc-backend/config.json, which will be used by cc-backend, once you start the server. The preconfigured config.json attaches to:

1. OpenLDAP docker service on port 389

2. cc-metric-store docker service on port 8084

3. cc-slurm-adapter is running on slurmctld docker service

cc-metric-store also has a preconfigured config.json in cc-metric-store/config.json which attaches to NATS docker service on port 4222 and subscribes to topic 'hpc-nats'.

Basically, all the ClusterCockpit components and the docker services attach to each other like lego pieces.

Docker commands to access the services

Note: You need to be in cc-docker directory in order to execute any docker command

You can view all docker processes running on either of the VM instance by using this command:

docker ps

Now that you can see the docker services, and if you want to manually access the docker services, you have to run bash command in those running services.

Example: You want to run slurm commands like sinfo or squeue or scontrol on slurm controller, you cannot directly access it.

You need to open a bash session in the running service by using the following command:

$ docker exec -it <docker service name> bash
#example
$ docker exec -it slurmctld bash
#or
$ docker exec -it cc-metric-store bash

Once you start a bash on any docker service, then you may execute any service related commands in that bash.

But for Cluster Cockpit development, you only need ports to access these docker services. You have to use localhost:<port> when trying to access any docker service. You may need to configure the cc-backend/config.json based on these docker services and ports.

Slurm setup in cc-docker

1. Slurm controller

Currently slurm controller is aware of the 1 node that we have setup in our mini cluster i.e. node01.

In order to execute slurm commands, you may need to bash into the slurmctld docker service.

docker exec -it slurmctld bash

Then you may be able to run slurm controller commands. A few examples without output are:

sinfo

or

squeue

or

scontrol show nodes

2. Slurm rest service

You do not need to bash into the slurmrestd service but can directly access the rest API via localhost:6820. A simple example on how to CURL to the slurm rest API is given in the curl_slurmrestd.sh.

You can directly use curl_slurmrestd.sh with a never expiring JWT token ( can be found in /data/slurm/secret/jwt_token.txt )

You may also use the never expiring token directly from the file for any of your custom CURL commands.

Known Issues

  • docker-compose installed on Ubuntu (18.04, 20.04) via apt-get can not correctly parse docker-compose.yml due to version differences. Install latest version of docker-compose from https://docs.docker.com/compose/install/ instead.
  • You need to ensure that no other web server is running on ports 8088 (cc-backend), 8080 (KeyCloak), 8084 (cc-metric-store), 4222 and 8222 (Nats). If one or more ports are already in use, you have to adapt the related config accordingly.
  • Existing VPN connections sometimes cause problems with docker. If docker-compose does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.

Docker services and restarting the services

You can find all the docker services in docker-compose.yml. Feel free to modify it.

Whenever you modify it, please use

docker compose down

in order to shut down all the services in all the VM’s (maininstance, nodeinstance, nodeinstance2) and then start all the services by using

docker compose up

TODO: Update job archive and all other metric data. The job archive with 1867 jobs originates from the second half of 2020. Roughly 2700 jobs from the first week of 2021 are loaded with data from InfluxDB. Some views of ClusterCockpit (e.g. the Users view) show the last week or month. To show some data there you have to set the filter to time periods with jobs (August 2020 to January 2021).

About

A configurable docker compose setup for development and testing of ClusterCockpit

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

cc-docker

This is a docker-compose setup which provides a quickly started environment for ClusterCockpit development and testing, using cc-backend. A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP, SLURM), or easily added by manual configuration (MariaDB).

It includes the following containers:

Service full namedocker service nameport
Slurm Controllerslurmctld6818
Slurm Databaseslurmdbd6817
Slurm Rest (JWT)slurmrestd6820
Slurm Workernode016818
NATS servicenats4222, 6222, 8222
cc-metric-storecc-metric-store8084
KeyCloakkeycloak8080
OpenLDAPopenldap389, 636

The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, and a LDAP user directory.

Prerequisites

For all the docker services to work correctly, you will need the following tools installed:

  1. docker and docker-compose
  2. golang (for compiling cc-metric-store)
  3. perl (for migrateTimestamp.pl) with Cpanel::JSON::XS, Data::Dumper, Time::Piece, Sort::Versions and File::Slurp perl modules.
  4. npm (for cc-backend)
  5. make (for building slurm base image)

It is also recommended to add docker service to sudo user group since the setupDev.sh script assumes sudo permissions for docker and docker-compose services.

You can use:

sudo groupadd docker
sudo usermod -aG docker $USER
# restart after adding your docker with your user to sudo group
sudo shutdown -r -t 0

Note: You can install all these dependencies via predefined installation steps in prerequisite_installation_script.sh.

If you are using different Linux flavors, you will have to adapt prerequisite_installation_script.sh as well as setupDev.sh.

Setup Procedure

  1. Clone cc-backend repository in chosen base folder: $> git clone https://github.com/ClusterCockpit/cc-backend.git

  2. Run the setup bash file: $> ./setupDev.sh: NOTICE The script will download files of a total size of 338MB (mostly for the cc-metric-store data).

  3. The setup-script launches the supporting container stack in the background automatically if everything went well. Run

./cc-backend/cc-backend -server -dev

to start cc-backend.

  1. By default, you can access cc-backend in your browser at http://localhost:8088 (port 8080 is taken by the KeyCloak container). You can shut down the cc-backend server by pressing CTRL-C, remember to also shut down all containers via $> docker-compose down afterwards.

  2. You can restart the containers with: $> docker-compose up -d.

Credentials for logging into clustercockpit

Credentials for the preconfigured demo user are:

  • User: demo
  • Password: demo

The LDAP user directory is defined in ./data/ldap/add_users.ldif. Every account's password equals its user name:

UserGroupRole in ClusterCockpit
ldapuseruser
ccuseruser
ccadmincc-adminuser, admin
ccsupportcc-supportuser
ccmanagercc-manageruser
ccapicc-apiuser

LDAP role sync

cc-backend can derive elevated roles from LDAP group membership via auth.ldap.role-filters in config.json. Each entry maps a role to an LDAP filter that is evaluated against the user entry; the preconfigured setup maps the cc-admin group to the admin role:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)"
}

The memberOf attribute is maintained automatically by the memberof overlay of the openldap image, which is configured for groupOfUniqueNames / uniqueMember — the group entries in the ldif use those classes accordingly.

LDAP is authoritative for every role listed in role-filters: a role is granted when the filter matches and revoked when it no longer does. Roles that are not listed are never touched. To exercise the other groups, add them as well:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)",
"support": "(memberOf=cn=cc-support,ou=groups,dc=example,dc=com)",
"manager": "(memberOf=cn=cc-manager,ou=groups,dc=example,dc=com)",
"api": "(memberOf=cn=cc-api,ou=groups,dc=example,dc=com)"
}

Roles are applied when the account is first synced (sync-user-on-login) and refreshed on every subsequent login (update-user-on-login), as well as by the periodic sync task (sync-interval).

Note: The ldif is only applied when the openldap container initialises its database. After changing it, recreate the container and its volumes with docker compose rm -sfv openldap, or load the changes into the running directory manually with ldapadd.

OIDC login via KeyCloak

The KeyCloak container imports the realm clustercockpit from ./keycloak/import/clustercockpit-realm.json on first start. It defines the confidential client cc-backend, the realm roles cc-admin, cc-support, cc-manager and cc-api, and these accounts (password equals user name):

UserRealm roleRole in ClusterCockpit
kcuseruser
kcadmincc-adminadmin
kcsupportcc-supportuser
kcmanagercc-manageruser
kcapicc-apiuser

The KeyCloak admin console is at http://localhost:8080 (admin / admin).

The auth.oidc.role-mapping section of config.json translates realm roles into ClusterCockpit roles. The preconfigured setup maps cc-admin to admin:

"oidc": {
"provider": "http://localhost:8080/realms/clustercockpit",
"client-id": "cc-backend",
"client-secret": "cc-backend-dev-secret",
"sync-user-on-login": true,
"update-user-on-login": true,
"role-mapping": {
"cc-admin": "admin"
}
}

Unlike the LDAP role filters, role-mapping is the sole source of roles for OIDC logins: a role in the token grants a ClusterCockpit role only if it is listed here, and unmapped roles are ignored — literal role names such as admin would also have to be mapped explicitly. Accounts without a mapped role get user. Add the remaining groups to exercise them:

"role-mapping": {
"cc-admin": "admin",
"cc-support": "support",
"cc-manager": "manager",
"cc-api": "api"
}

Roles are read from the realm_access.roles claim of the ID token. The built-in KeyCloak roles client scope only adds that claim to the access token, so the imported client carries its own realm roles in id token protocol mapper with id.token.claim enabled. Keep that mapper when editing the realm, otherwise every OIDC login falls back to the plain user role.

Note: cc-backend resolves the OIDC provider at startup and aborts if it is unreachable, so the KeyCloak container has to be up before starting the server. The realm is only imported while the KeyCloak database is empty — to re-import after editing the realm file, recreate KeyCloak and its database with docker compose rm -sf keycloak postgres.

Preconfigured setup between docker services and ClusterCockpit components

When you are done cloning the cc-backend repo and once you execute setupDev.sh file, it will copy a preconfigured config.json from misc/config.json and replace the cc-backend/config.json, which will be used by cc-backend, once you start the server. The preconfigured config.json attaches to:

1. OpenLDAP docker service on port 389

2. cc-metric-store docker service on port 8084

3. cc-slurm-adapter is running on slurmctld docker service

cc-metric-store also has a preconfigured config.json in cc-metric-store/config.json which attaches to NATS docker service on port 4222 and subscribes to topic 'hpc-nats'.

Basically, all the ClusterCockpit components and the docker services attach to each other like lego pieces.

Docker commands to access the services

Note: You need to be in cc-docker directory in order to execute any docker command

You can view all docker processes running on either of the VM instance by using this command:

docker ps

Now that you can see the docker services, and if you want to manually access the docker services, you have to run bash command in those running services.

Example: You want to run slurm commands like sinfo or squeue or scontrol on slurm controller, you cannot directly access it.

You need to open a bash session in the running service by using the following command:

$ docker exec -it <docker service name> bash
#example
$ docker exec -it slurmctld bash
#or
$ docker exec -it cc-metric-store bash

Once you start a bash on any docker service, then you may execute any service related commands in that bash.

But for Cluster Cockpit development, you only need ports to access these docker services. You have to use localhost:<port> when trying to access any docker service. You may need to configure the cc-backend/config.json based on these docker services and ports.

Slurm setup in cc-docker

1. Slurm controller

Currently slurm controller is aware of the 1 node that we have setup in our mini cluster i.e. node01.

In order to execute slurm commands, you may need to bash into the slurmctld docker service.

docker exec -it slurmctld bash

Then you may be able to run slurm controller commands. A few examples without output are:

sinfo

or

squeue

or

scontrol show nodes

2. Slurm rest service

You do not need to bash into the slurmrestd service but can directly access the rest API via localhost:6820. A simple example on how to CURL to the slurm rest API is given in the curl_slurmrestd.sh.

You can directly use curl_slurmrestd.sh with a never expiring JWT token ( can be found in /data/slurm/secret/jwt_token.txt )

You may also use the never expiring token directly from the file for any of your custom CURL commands.

Known Issues

  • docker-compose installed on Ubuntu (18.04, 20.04) via apt-get can not correctly parse docker-compose.yml due to version differences. Install latest version of docker-compose from https://docs.docker.com/compose/install/ instead.
  • You need to ensure that no other web server is running on ports 8088 (cc-backend), 8080 (KeyCloak), 8084 (cc-metric-store), 4222 and 8222 (Nats). If one or more ports are already in use, you have to adapt the related config accordingly.
  • Existing VPN connections sometimes cause problems with docker. If docker-compose does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.

Docker services and restarting the services

You can find all the docker services in docker-compose.yml. Feel free to modify it.

Whenever you modify it, please use

docker compose down

in order to shut down all the services in all the VM’s (maininstance, nodeinstance, nodeinstance2) and then start all the services by using

docker compose up

TODO: Update job archive and all other metric data. The job archive with 1867 jobs originates from the second half of 2020. Roughly 2700 jobs from the first week of 2021 are loaded with data from InfluxDB. Some views of ClusterCockpit (e.g. the Users view) show the last week or month. To show some data there you have to set the filter to time periods with jobs (August 2020 to January 2021).

About

A configurable docker compose setup for development and testing of ClusterCockpit

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

cc-docker

This is a docker-compose setup which provides a quickly started environment for ClusterCockpit development and testing, using cc-backend. A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP, SLURM), or easily added by manual configuration (MariaDB).

It includes the following containers:

Service full namedocker service nameport
Slurm Controllerslurmctld6818
Slurm Databaseslurmdbd6817
Slurm Rest (JWT)slurmrestd6820
Slurm Workernode016818
NATS servicenats4222, 6222, 8222
cc-metric-storecc-metric-store8084
KeyCloakkeycloak8080
OpenLDAPopenldap389, 636

The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, and a LDAP user directory.

Prerequisites

For all the docker services to work correctly, you will need the following tools installed:

  1. docker and docker-compose
  2. golang (for compiling cc-metric-store)
  3. perl (for migrateTimestamp.pl) with Cpanel::JSON::XS, Data::Dumper, Time::Piece, Sort::Versions and File::Slurp perl modules.
  4. npm (for cc-backend)
  5. make (for building slurm base image)

It is also recommended to add docker service to sudo user group since the setupDev.sh script assumes sudo permissions for docker and docker-compose services.

You can use:

sudo groupadd docker
sudo usermod -aG docker $USER
# restart after adding your docker with your user to sudo group
sudo shutdown -r -t 0

Note: You can install all these dependencies via predefined installation steps in prerequisite_installation_script.sh.

If you are using different Linux flavors, you will have to adapt prerequisite_installation_script.sh as well as setupDev.sh.

Setup Procedure

  1. Clone cc-backend repository in chosen base folder: $> git clone https://github.com/ClusterCockpit/cc-backend.git

  2. Run the setup bash file: $> ./setupDev.sh: NOTICE The script will download files of a total size of 338MB (mostly for the cc-metric-store data).

  3. The setup-script launches the supporting container stack in the background automatically if everything went well. Run

./cc-backend/cc-backend -server -dev

to start cc-backend.

  1. By default, you can access cc-backend in your browser at http://localhost:8088 (port 8080 is taken by the KeyCloak container). You can shut down the cc-backend server by pressing CTRL-C, remember to also shut down all containers via $> docker-compose down afterwards.

  2. You can restart the containers with: $> docker-compose up -d.

Credentials for logging into clustercockpit

Credentials for the preconfigured demo user are:

  • User: demo
  • Password: demo

The LDAP user directory is defined in ./data/ldap/add_users.ldif. Every account's password equals its user name:

UserGroupRole in ClusterCockpit
ldapuseruser
ccuseruser
ccadmincc-adminuser, admin
ccsupportcc-supportuser
ccmanagercc-manageruser
ccapicc-apiuser

LDAP role sync

cc-backend can derive elevated roles from LDAP group membership via auth.ldap.role-filters in config.json. Each entry maps a role to an LDAP filter that is evaluated against the user entry; the preconfigured setup maps the cc-admin group to the admin role:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)"
}

The memberOf attribute is maintained automatically by the memberof overlay of the openldap image, which is configured for groupOfUniqueNames / uniqueMember — the group entries in the ldif use those classes accordingly.

LDAP is authoritative for every role listed in role-filters: a role is granted when the filter matches and revoked when it no longer does. Roles that are not listed are never touched. To exercise the other groups, add them as well:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)",
"support": "(memberOf=cn=cc-support,ou=groups,dc=example,dc=com)",
"manager": "(memberOf=cn=cc-manager,ou=groups,dc=example,dc=com)",
"api": "(memberOf=cn=cc-api,ou=groups,dc=example,dc=com)"
}

Roles are applied when the account is first synced (sync-user-on-login) and refreshed on every subsequent login (update-user-on-login), as well as by the periodic sync task (sync-interval).

Note: The ldif is only applied when the openldap container initialises its database. After changing it, recreate the container and its volumes with docker compose rm -sfv openldap, or load the changes into the running directory manually with ldapadd.

OIDC login via KeyCloak

The KeyCloak container imports the realm clustercockpit from ./keycloak/import/clustercockpit-realm.json on first start. It defines the confidential client cc-backend, the realm roles cc-admin, cc-support, cc-manager and cc-api, and these accounts (password equals user name):

UserRealm roleRole in ClusterCockpit
kcuseruser
kcadmincc-adminadmin
kcsupportcc-supportuser
kcmanagercc-manageruser
kcapicc-apiuser

The KeyCloak admin console is at http://localhost:8080 (admin / admin).

The auth.oidc.role-mapping section of config.json translates realm roles into ClusterCockpit roles. The preconfigured setup maps cc-admin to admin:

"oidc": {
"provider": "http://localhost:8080/realms/clustercockpit",
"client-id": "cc-backend",
"client-secret": "cc-backend-dev-secret",
"sync-user-on-login": true,
"update-user-on-login": true,
"role-mapping": {
"cc-admin": "admin"
}
}

Unlike the LDAP role filters, role-mapping is the sole source of roles for OIDC logins: a role in the token grants a ClusterCockpit role only if it is listed here, and unmapped roles are ignored — literal role names such as admin would also have to be mapped explicitly. Accounts without a mapped role get user. Add the remaining groups to exercise them:

"role-mapping": {
"cc-admin": "admin",
"cc-support": "support",
"cc-manager": "manager",
"cc-api": "api"
}

Roles are read from the realm_access.roles claim of the ID token. The built-in KeyCloak roles client scope only adds that claim to the access token, so the imported client carries its own realm roles in id token protocol mapper with id.token.claim enabled. Keep that mapper when editing the realm, otherwise every OIDC login falls back to the plain user role.

Note: cc-backend resolves the OIDC provider at startup and aborts if it is unreachable, so the KeyCloak container has to be up before starting the server. The realm is only imported while the KeyCloak database is empty — to re-import after editing the realm file, recreate KeyCloak and its database with docker compose rm -sf keycloak postgres.

Preconfigured setup between docker services and ClusterCockpit components

When you are done cloning the cc-backend repo and once you execute setupDev.sh file, it will copy a preconfigured config.json from misc/config.json and replace the cc-backend/config.json, which will be used by cc-backend, once you start the server. The preconfigured config.json attaches to:

1. OpenLDAP docker service on port 389

2. cc-metric-store docker service on port 8084

3. cc-slurm-adapter is running on slurmctld docker service

cc-metric-store also has a preconfigured config.json in cc-metric-store/config.json which attaches to NATS docker service on port 4222 and subscribes to topic 'hpc-nats'.

Basically, all the ClusterCockpit components and the docker services attach to each other like lego pieces.

Docker commands to access the services

Note: You need to be in cc-docker directory in order to execute any docker command

You can view all docker processes running on either of the VM instance by using this command:

docker ps

Now that you can see the docker services, and if you want to manually access the docker services, you have to run bash command in those running services.

Example: You want to run slurm commands like sinfo or squeue or scontrol on slurm controller, you cannot directly access it.

You need to open a bash session in the running service by using the following command:

$ docker exec -it <docker service name> bash
#example
$ docker exec -it slurmctld bash
#or
$ docker exec -it cc-metric-store bash

Once you start a bash on any docker service, then you may execute any service related commands in that bash.

But for Cluster Cockpit development, you only need ports to access these docker services. You have to use localhost:<port> when trying to access any docker service. You may need to configure the cc-backend/config.json based on these docker services and ports.

Slurm setup in cc-docker

1. Slurm controller

Currently slurm controller is aware of the 1 node that we have setup in our mini cluster i.e. node01.

In order to execute slurm commands, you may need to bash into the slurmctld docker service.

docker exec -it slurmctld bash

Then you may be able to run slurm controller commands. A few examples without output are:

sinfo

or

squeue

or

scontrol show nodes

2. Slurm rest service

You do not need to bash into the slurmrestd service but can directly access the rest API via localhost:6820. A simple example on how to CURL to the slurm rest API is given in the curl_slurmrestd.sh.

You can directly use curl_slurmrestd.sh with a never expiring JWT token ( can be found in /data/slurm/secret/jwt_token.txt )

You may also use the never expiring token directly from the file for any of your custom CURL commands.

Known Issues

  • docker-compose installed on Ubuntu (18.04, 20.04) via apt-get can not correctly parse docker-compose.yml due to version differences. Install latest version of docker-compose from https://docs.docker.com/compose/install/ instead.
  • You need to ensure that no other web server is running on ports 8088 (cc-backend), 8080 (KeyCloak), 8084 (cc-metric-store), 4222 and 8222 (Nats). If one or more ports are already in use, you have to adapt the related config accordingly.
  • Existing VPN connections sometimes cause problems with docker. If docker-compose does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.

Docker services and restarting the services

You can find all the docker services in docker-compose.yml. Feel free to modify it.

Whenever you modify it, please use

docker compose down

in order to shut down all the services in all the VM’s (maininstance, nodeinstance, nodeinstance2) and then start all the services by using

docker compose up

TODO: Update job archive and all other metric data. The job archive with 1867 jobs originates from the second half of 2020. Roughly 2700 jobs from the first week of 2021 are loaded with data from InfluxDB. Some views of ClusterCockpit (e.g. the Users view) show the last week or month. To show some data there you have to set the filter to time periods with jobs (August 2020 to January 2021).

About

A configurable docker compose setup for development and testing of ClusterCockpit

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

cc-docker

This is a docker-compose setup which provides a quickly started environment for ClusterCockpit development and testing, using cc-backend. A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP, SLURM), or easily added by manual configuration (MariaDB).

It includes the following containers:

Service full namedocker service nameport
Slurm Controllerslurmctld6818
Slurm Databaseslurmdbd6817
Slurm Rest (JWT)slurmrestd6820
Slurm Workernode016818
NATS servicenats4222, 6222, 8222
cc-metric-storecc-metric-store8084
KeyCloakkeycloak8080
OpenLDAPopenldap389, 636

The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, and a LDAP user directory.

Prerequisites

For all the docker services to work correctly, you will need the following tools installed:

  1. docker and docker-compose
  2. golang (for compiling cc-metric-store)
  3. perl (for migrateTimestamp.pl) with Cpanel::JSON::XS, Data::Dumper, Time::Piece, Sort::Versions and File::Slurp perl modules.
  4. npm (for cc-backend)
  5. make (for building slurm base image)

It is also recommended to add docker service to sudo user group since the setupDev.sh script assumes sudo permissions for docker and docker-compose services.

You can use:

sudo groupadd docker
sudo usermod -aG docker $USER
# restart after adding your docker with your user to sudo group
sudo shutdown -r -t 0

Note: You can install all these dependencies via predefined installation steps in prerequisite_installation_script.sh.

If you are using different Linux flavors, you will have to adapt prerequisite_installation_script.sh as well as setupDev.sh.

Setup Procedure

  1. Clone cc-backend repository in chosen base folder: $> git clone https://github.com/ClusterCockpit/cc-backend.git

  2. Run the setup bash file: $> ./setupDev.sh: NOTICE The script will download files of a total size of 338MB (mostly for the cc-metric-store data).

  3. The setup-script launches the supporting container stack in the background automatically if everything went well. Run

./cc-backend/cc-backend -server -dev

to start cc-backend.

  1. By default, you can access cc-backend in your browser at http://localhost:8088 (port 8080 is taken by the KeyCloak container). You can shut down the cc-backend server by pressing CTRL-C, remember to also shut down all containers via $> docker-compose down afterwards.

  2. You can restart the containers with: $> docker-compose up -d.

Credentials for logging into clustercockpit

Credentials for the preconfigured demo user are:

  • User: demo
  • Password: demo

The LDAP user directory is defined in ./data/ldap/add_users.ldif. Every account's password equals its user name:

UserGroupRole in ClusterCockpit
ldapuseruser
ccuseruser
ccadmincc-adminuser, admin
ccsupportcc-supportuser
ccmanagercc-manageruser
ccapicc-apiuser

LDAP role sync

cc-backend can derive elevated roles from LDAP group membership via auth.ldap.role-filters in config.json. Each entry maps a role to an LDAP filter that is evaluated against the user entry; the preconfigured setup maps the cc-admin group to the admin role:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)"
}

The memberOf attribute is maintained automatically by the memberof overlay of the openldap image, which is configured for groupOfUniqueNames / uniqueMember — the group entries in the ldif use those classes accordingly.

LDAP is authoritative for every role listed in role-filters: a role is granted when the filter matches and revoked when it no longer does. Roles that are not listed are never touched. To exercise the other groups, add them as well:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)",
"support": "(memberOf=cn=cc-support,ou=groups,dc=example,dc=com)",
"manager": "(memberOf=cn=cc-manager,ou=groups,dc=example,dc=com)",
"api": "(memberOf=cn=cc-api,ou=groups,dc=example,dc=com)"
}

Roles are applied when the account is first synced (sync-user-on-login) and refreshed on every subsequent login (update-user-on-login), as well as by the periodic sync task (sync-interval).

Note: The ldif is only applied when the openldap container initialises its database. After changing it, recreate the container and its volumes with docker compose rm -sfv openldap, or load the changes into the running directory manually with ldapadd.

OIDC login via KeyCloak

The KeyCloak container imports the realm clustercockpit from ./keycloak/import/clustercockpit-realm.json on first start. It defines the confidential client cc-backend, the realm roles cc-admin, cc-support, cc-manager and cc-api, and these accounts (password equals user name):

UserRealm roleRole in ClusterCockpit
kcuseruser
kcadmincc-adminadmin
kcsupportcc-supportuser
kcmanagercc-manageruser
kcapicc-apiuser

The KeyCloak admin console is at http://localhost:8080 (admin / admin).

The auth.oidc.role-mapping section of config.json translates realm roles into ClusterCockpit roles. The preconfigured setup maps cc-admin to admin:

"oidc": {
"provider": "http://localhost:8080/realms/clustercockpit",
"client-id": "cc-backend",
"client-secret": "cc-backend-dev-secret",
"sync-user-on-login": true,
"update-user-on-login": true,
"role-mapping": {
"cc-admin": "admin"
}
}

Unlike the LDAP role filters, role-mapping is the sole source of roles for OIDC logins: a role in the token grants a ClusterCockpit role only if it is listed here, and unmapped roles are ignored — literal role names such as admin would also have to be mapped explicitly. Accounts without a mapped role get user. Add the remaining groups to exercise them:

"role-mapping": {
"cc-admin": "admin",
"cc-support": "support",
"cc-manager": "manager",
"cc-api": "api"
}

Roles are read from the realm_access.roles claim of the ID token. The built-in KeyCloak roles client scope only adds that claim to the access token, so the imported client carries its own realm roles in id token protocol mapper with id.token.claim enabled. Keep that mapper when editing the realm, otherwise every OIDC login falls back to the plain user role.

Note: cc-backend resolves the OIDC provider at startup and aborts if it is unreachable, so the KeyCloak container has to be up before starting the server. The realm is only imported while the KeyCloak database is empty — to re-import after editing the realm file, recreate KeyCloak and its database with docker compose rm -sf keycloak postgres.

Preconfigured setup between docker services and ClusterCockpit components

When you are done cloning the cc-backend repo and once you execute setupDev.sh file, it will copy a preconfigured config.json from misc/config.json and replace the cc-backend/config.json, which will be used by cc-backend, once you start the server. The preconfigured config.json attaches to:

1. OpenLDAP docker service on port 389

2. cc-metric-store docker service on port 8084

3. cc-slurm-adapter is running on slurmctld docker service

cc-metric-store also has a preconfigured config.json in cc-metric-store/config.json which attaches to NATS docker service on port 4222 and subscribes to topic 'hpc-nats'.

Basically, all the ClusterCockpit components and the docker services attach to each other like lego pieces.

Docker commands to access the services

Note: You need to be in cc-docker directory in order to execute any docker command

You can view all docker processes running on either of the VM instance by using this command:

docker ps

Now that you can see the docker services, and if you want to manually access the docker services, you have to run bash command in those running services.

Example: You want to run slurm commands like sinfo or squeue or scontrol on slurm controller, you cannot directly access it.

You need to open a bash session in the running service by using the following command:

$ docker exec -it <docker service name> bash
#example
$ docker exec -it slurmctld bash
#or
$ docker exec -it cc-metric-store bash

Once you start a bash on any docker service, then you may execute any service related commands in that bash.

But for Cluster Cockpit development, you only need ports to access these docker services. You have to use localhost:<port> when trying to access any docker service. You may need to configure the cc-backend/config.json based on these docker services and ports.

Slurm setup in cc-docker

1. Slurm controller

Currently slurm controller is aware of the 1 node that we have setup in our mini cluster i.e. node01.

In order to execute slurm commands, you may need to bash into the slurmctld docker service.

docker exec -it slurmctld bash

Then you may be able to run slurm controller commands. A few examples without output are:

sinfo

or

squeue

or

scontrol show nodes

2. Slurm rest service

You do not need to bash into the slurmrestd service but can directly access the rest API via localhost:6820. A simple example on how to CURL to the slurm rest API is given in the curl_slurmrestd.sh.

You can directly use curl_slurmrestd.sh with a never expiring JWT token ( can be found in /data/slurm/secret/jwt_token.txt )

You may also use the never expiring token directly from the file for any of your custom CURL commands.

Known Issues

  • docker-compose installed on Ubuntu (18.04, 20.04) via apt-get can not correctly parse docker-compose.yml due to version differences. Install latest version of docker-compose from https://docs.docker.com/compose/install/ instead.
  • You need to ensure that no other web server is running on ports 8088 (cc-backend), 8080 (KeyCloak), 8084 (cc-metric-store), 4222 and 8222 (Nats). If one or more ports are already in use, you have to adapt the related config accordingly.
  • Existing VPN connections sometimes cause problems with docker. If docker-compose does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.

Docker services and restarting the services

You can find all the docker services in docker-compose.yml. Feel free to modify it.

Whenever you modify it, please use

docker compose down

in order to shut down all the services in all the VM’s (maininstance, nodeinstance, nodeinstance2) and then start all the services by using

docker compose up

TODO: Update job archive and all other metric data. The job archive with 1867 jobs originates from the second half of 2020. Roughly 2700 jobs from the first week of 2021 are loaded with data from InfluxDB. Some views of ClusterCockpit (e.g. the Users view) show the last week or month. To show some data there you have to set the filter to time periods with jobs (August 2020 to January 2021).

About

A configurable docker compose setup for development and testing of ClusterCockpit

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

cc-docker

This is a docker-compose setup which provides a quickly started environment for ClusterCockpit development and testing, using cc-backend. A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP, SLURM), or easily added by manual configuration (MariaDB).

It includes the following containers:

Service full namedocker service nameport
Slurm Controllerslurmctld6818
Slurm Databaseslurmdbd6817
Slurm Rest (JWT)slurmrestd6820
Slurm Workernode016818
NATS servicenats4222, 6222, 8222
cc-metric-storecc-metric-store8084
KeyCloakkeycloak8080
OpenLDAPopenldap389, 636

The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, and a LDAP user directory.

Prerequisites

For all the docker services to work correctly, you will need the following tools installed:

  1. docker and docker-compose
  2. golang (for compiling cc-metric-store)
  3. perl (for migrateTimestamp.pl) with Cpanel::JSON::XS, Data::Dumper, Time::Piece, Sort::Versions and File::Slurp perl modules.
  4. npm (for cc-backend)
  5. make (for building slurm base image)

It is also recommended to add docker service to sudo user group since the setupDev.sh script assumes sudo permissions for docker and docker-compose services.

You can use:

sudo groupadd docker
sudo usermod -aG docker $USER
# restart after adding your docker with your user to sudo group
sudo shutdown -r -t 0

Note: You can install all these dependencies via predefined installation steps in prerequisite_installation_script.sh.

If you are using different Linux flavors, you will have to adapt prerequisite_installation_script.sh as well as setupDev.sh.

Setup Procedure

  1. Clone cc-backend repository in chosen base folder: $> git clone https://github.com/ClusterCockpit/cc-backend.git

  2. Run the setup bash file: $> ./setupDev.sh: NOTICE The script will download files of a total size of 338MB (mostly for the cc-metric-store data).

  3. The setup-script launches the supporting container stack in the background automatically if everything went well. Run

./cc-backend/cc-backend -server -dev

to start cc-backend.

  1. By default, you can access cc-backend in your browser at http://localhost:8088 (port 8080 is taken by the KeyCloak container). You can shut down the cc-backend server by pressing CTRL-C, remember to also shut down all containers via $> docker-compose down afterwards.

  2. You can restart the containers with: $> docker-compose up -d.

Credentials for logging into clustercockpit

Credentials for the preconfigured demo user are:

  • User: demo
  • Password: demo

The LDAP user directory is defined in ./data/ldap/add_users.ldif. Every account's password equals its user name:

UserGroupRole in ClusterCockpit
ldapuseruser
ccuseruser
ccadmincc-adminuser, admin
ccsupportcc-supportuser
ccmanagercc-manageruser
ccapicc-apiuser

LDAP role sync

cc-backend can derive elevated roles from LDAP group membership via auth.ldap.role-filters in config.json. Each entry maps a role to an LDAP filter that is evaluated against the user entry; the preconfigured setup maps the cc-admin group to the admin role:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)"
}

The memberOf attribute is maintained automatically by the memberof overlay of the openldap image, which is configured for groupOfUniqueNames / uniqueMember — the group entries in the ldif use those classes accordingly.

LDAP is authoritative for every role listed in role-filters: a role is granted when the filter matches and revoked when it no longer does. Roles that are not listed are never touched. To exercise the other groups, add them as well:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)",
"support": "(memberOf=cn=cc-support,ou=groups,dc=example,dc=com)",
"manager": "(memberOf=cn=cc-manager,ou=groups,dc=example,dc=com)",
"api": "(memberOf=cn=cc-api,ou=groups,dc=example,dc=com)"
}

Roles are applied when the account is first synced (sync-user-on-login) and refreshed on every subsequent login (update-user-on-login), as well as by the periodic sync task (sync-interval).

Note: The ldif is only applied when the openldap container initialises its database. After changing it, recreate the container and its volumes with docker compose rm -sfv openldap, or load the changes into the running directory manually with ldapadd.

OIDC login via KeyCloak

The KeyCloak container imports the realm clustercockpit from ./keycloak/import/clustercockpit-realm.json on first start. It defines the confidential client cc-backend, the realm roles cc-admin, cc-support, cc-manager and cc-api, and these accounts (password equals user name):

UserRealm roleRole in ClusterCockpit
kcuseruser
kcadmincc-adminadmin
kcsupportcc-supportuser
kcmanagercc-manageruser
kcapicc-apiuser

The KeyCloak admin console is at http://localhost:8080 (admin / admin).

The auth.oidc.role-mapping section of config.json translates realm roles into ClusterCockpit roles. The preconfigured setup maps cc-admin to admin:

"oidc": {
"provider": "http://localhost:8080/realms/clustercockpit",
"client-id": "cc-backend",
"client-secret": "cc-backend-dev-secret",
"sync-user-on-login": true,
"update-user-on-login": true,
"role-mapping": {
"cc-admin": "admin"
}
}

Unlike the LDAP role filters, role-mapping is the sole source of roles for OIDC logins: a role in the token grants a ClusterCockpit role only if it is listed here, and unmapped roles are ignored — literal role names such as admin would also have to be mapped explicitly. Accounts without a mapped role get user. Add the remaining groups to exercise them:

"role-mapping": {
"cc-admin": "admin",
"cc-support": "support",
"cc-manager": "manager",
"cc-api": "api"
}

Roles are read from the realm_access.roles claim of the ID token. The built-in KeyCloak roles client scope only adds that claim to the access token, so the imported client carries its own realm roles in id token protocol mapper with id.token.claim enabled. Keep that mapper when editing the realm, otherwise every OIDC login falls back to the plain user role.

Note: cc-backend resolves the OIDC provider at startup and aborts if it is unreachable, so the KeyCloak container has to be up before starting the server. The realm is only imported while the KeyCloak database is empty — to re-import after editing the realm file, recreate KeyCloak and its database with docker compose rm -sf keycloak postgres.

Preconfigured setup between docker services and ClusterCockpit components

When you are done cloning the cc-backend repo and once you execute setupDev.sh file, it will copy a preconfigured config.json from misc/config.json and replace the cc-backend/config.json, which will be used by cc-backend, once you start the server. The preconfigured config.json attaches to:

1. OpenLDAP docker service on port 389

2. cc-metric-store docker service on port 8084

3. cc-slurm-adapter is running on slurmctld docker service

cc-metric-store also has a preconfigured config.json in cc-metric-store/config.json which attaches to NATS docker service on port 4222 and subscribes to topic 'hpc-nats'.

Basically, all the ClusterCockpit components and the docker services attach to each other like lego pieces.

Docker commands to access the services

Note: You need to be in cc-docker directory in order to execute any docker command

You can view all docker processes running on either of the VM instance by using this command:

docker ps

Now that you can see the docker services, and if you want to manually access the docker services, you have to run bash command in those running services.

Example: You want to run slurm commands like sinfo or squeue or scontrol on slurm controller, you cannot directly access it.

You need to open a bash session in the running service by using the following command:

$ docker exec -it <docker service name> bash
#example
$ docker exec -it slurmctld bash
#or
$ docker exec -it cc-metric-store bash

Once you start a bash on any docker service, then you may execute any service related commands in that bash.

But for Cluster Cockpit development, you only need ports to access these docker services. You have to use localhost:<port> when trying to access any docker service. You may need to configure the cc-backend/config.json based on these docker services and ports.

Slurm setup in cc-docker

1. Slurm controller

Currently slurm controller is aware of the 1 node that we have setup in our mini cluster i.e. node01.

In order to execute slurm commands, you may need to bash into the slurmctld docker service.

docker exec -it slurmctld bash

Then you may be able to run slurm controller commands. A few examples without output are:

sinfo

or

squeue

or

scontrol show nodes

2. Slurm rest service

You do not need to bash into the slurmrestd service but can directly access the rest API via localhost:6820. A simple example on how to CURL to the slurm rest API is given in the curl_slurmrestd.sh.

You can directly use curl_slurmrestd.sh with a never expiring JWT token ( can be found in /data/slurm/secret/jwt_token.txt )

You may also use the never expiring token directly from the file for any of your custom CURL commands.

Known Issues

  • docker-compose installed on Ubuntu (18.04, 20.04) via apt-get can not correctly parse docker-compose.yml due to version differences. Install latest version of docker-compose from https://docs.docker.com/compose/install/ instead.
  • You need to ensure that no other web server is running on ports 8088 (cc-backend), 8080 (KeyCloak), 8084 (cc-metric-store), 4222 and 8222 (Nats). If one or more ports are already in use, you have to adapt the related config accordingly.
  • Existing VPN connections sometimes cause problems with docker. If docker-compose does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.

Docker services and restarting the services

You can find all the docker services in docker-compose.yml. Feel free to modify it.

Whenever you modify it, please use

docker compose down

in order to shut down all the services in all the VM’s (maininstance, nodeinstance, nodeinstance2) and then start all the services by using

docker compose up

TODO: Update job archive and all other metric data. The job archive with 1867 jobs originates from the second half of 2020. Roughly 2700 jobs from the first week of 2021 are loaded with data from InfluxDB. Some views of ClusterCockpit (e.g. the Users view) show the last week or month. To show some data there you have to set the filter to time periods with jobs (August 2020 to January 2021).

About

A configurable docker compose setup for development and testing of ClusterCockpit

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

cc-docker

This is a docker-compose setup which provides a quickly started environment for ClusterCockpit development and testing, using cc-backend. A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP, SLURM), or easily added by manual configuration (MariaDB).

It includes the following containers:

Service full namedocker service nameport
Slurm Controllerslurmctld6818
Slurm Databaseslurmdbd6817
Slurm Rest (JWT)slurmrestd6820
Slurm Workernode016818
NATS servicenats4222, 6222, 8222
cc-metric-storecc-metric-store8084
KeyCloakkeycloak8080
OpenLDAPopenldap389, 636

The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, and a LDAP user directory.

Prerequisites

For all the docker services to work correctly, you will need the following tools installed:

  1. docker and docker-compose
  2. golang (for compiling cc-metric-store)
  3. perl (for migrateTimestamp.pl) with Cpanel::JSON::XS, Data::Dumper, Time::Piece, Sort::Versions and File::Slurp perl modules.
  4. npm (for cc-backend)
  5. make (for building slurm base image)

It is also recommended to add docker service to sudo user group since the setupDev.sh script assumes sudo permissions for docker and docker-compose services.

You can use:

sudo groupadd docker
sudo usermod -aG docker $USER
# restart after adding your docker with your user to sudo group
sudo shutdown -r -t 0

Note: You can install all these dependencies via predefined installation steps in prerequisite_installation_script.sh.

If you are using different Linux flavors, you will have to adapt prerequisite_installation_script.sh as well as setupDev.sh.

Setup Procedure

  1. Clone cc-backend repository in chosen base folder: $> git clone https://github.com/ClusterCockpit/cc-backend.git

  2. Run the setup bash file: $> ./setupDev.sh: NOTICE The script will download files of a total size of 338MB (mostly for the cc-metric-store data).

  3. The setup-script launches the supporting container stack in the background automatically if everything went well. Run

./cc-backend/cc-backend -server -dev

to start cc-backend.

  1. By default, you can access cc-backend in your browser at http://localhost:8088 (port 8080 is taken by the KeyCloak container). You can shut down the cc-backend server by pressing CTRL-C, remember to also shut down all containers via $> docker-compose down afterwards.

  2. You can restart the containers with: $> docker-compose up -d.

Credentials for logging into clustercockpit

Credentials for the preconfigured demo user are:

  • User: demo
  • Password: demo

The LDAP user directory is defined in ./data/ldap/add_users.ldif. Every account's password equals its user name:

UserGroupRole in ClusterCockpit
ldapuseruser
ccuseruser
ccadmincc-adminuser, admin
ccsupportcc-supportuser
ccmanagercc-manageruser
ccapicc-apiuser

LDAP role sync

cc-backend can derive elevated roles from LDAP group membership via auth.ldap.role-filters in config.json. Each entry maps a role to an LDAP filter that is evaluated against the user entry; the preconfigured setup maps the cc-admin group to the admin role:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)"
}

The memberOf attribute is maintained automatically by the memberof overlay of the openldap image, which is configured for groupOfUniqueNames / uniqueMember — the group entries in the ldif use those classes accordingly.

LDAP is authoritative for every role listed in role-filters: a role is granted when the filter matches and revoked when it no longer does. Roles that are not listed are never touched. To exercise the other groups, add them as well:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)",
"support": "(memberOf=cn=cc-support,ou=groups,dc=example,dc=com)",
"manager": "(memberOf=cn=cc-manager,ou=groups,dc=example,dc=com)",
"api": "(memberOf=cn=cc-api,ou=groups,dc=example,dc=com)"
}

Roles are applied when the account is first synced (sync-user-on-login) and refreshed on every subsequent login (update-user-on-login), as well as by the periodic sync task (sync-interval).

Note: The ldif is only applied when the openldap container initialises its database. After changing it, recreate the container and its volumes with docker compose rm -sfv openldap, or load the changes into the running directory manually with ldapadd.

OIDC login via KeyCloak

The KeyCloak container imports the realm clustercockpit from ./keycloak/import/clustercockpit-realm.json on first start. It defines the confidential client cc-backend, the realm roles cc-admin, cc-support, cc-manager and cc-api, and these accounts (password equals user name):

UserRealm roleRole in ClusterCockpit
kcuseruser
kcadmincc-adminadmin
kcsupportcc-supportuser
kcmanagercc-manageruser
kcapicc-apiuser

The KeyCloak admin console is at http://localhost:8080 (admin / admin).

The auth.oidc.role-mapping section of config.json translates realm roles into ClusterCockpit roles. The preconfigured setup maps cc-admin to admin:

"oidc": {
"provider": "http://localhost:8080/realms/clustercockpit",
"client-id": "cc-backend",
"client-secret": "cc-backend-dev-secret",
"sync-user-on-login": true,
"update-user-on-login": true,
"role-mapping": {
"cc-admin": "admin"
}
}

Unlike the LDAP role filters, role-mapping is the sole source of roles for OIDC logins: a role in the token grants a ClusterCockpit role only if it is listed here, and unmapped roles are ignored — literal role names such as admin would also have to be mapped explicitly. Accounts without a mapped role get user. Add the remaining groups to exercise them:

"role-mapping": {
"cc-admin": "admin",
"cc-support": "support",
"cc-manager": "manager",
"cc-api": "api"
}

Roles are read from the realm_access.roles claim of the ID token. The built-in KeyCloak roles client scope only adds that claim to the access token, so the imported client carries its own realm roles in id token protocol mapper with id.token.claim enabled. Keep that mapper when editing the realm, otherwise every OIDC login falls back to the plain user role.

Note: cc-backend resolves the OIDC provider at startup and aborts if it is unreachable, so the KeyCloak container has to be up before starting the server. The realm is only imported while the KeyCloak database is empty — to re-import after editing the realm file, recreate KeyCloak and its database with docker compose rm -sf keycloak postgres.

Preconfigured setup between docker services and ClusterCockpit components

When you are done cloning the cc-backend repo and once you execute setupDev.sh file, it will copy a preconfigured config.json from misc/config.json and replace the cc-backend/config.json, which will be used by cc-backend, once you start the server. The preconfigured config.json attaches to:

1. OpenLDAP docker service on port 389

2. cc-metric-store docker service on port 8084

3. cc-slurm-adapter is running on slurmctld docker service

cc-metric-store also has a preconfigured config.json in cc-metric-store/config.json which attaches to NATS docker service on port 4222 and subscribes to topic 'hpc-nats'.

Basically, all the ClusterCockpit components and the docker services attach to each other like lego pieces.

Docker commands to access the services

Note: You need to be in cc-docker directory in order to execute any docker command

You can view all docker processes running on either of the VM instance by using this command:

docker ps

Now that you can see the docker services, and if you want to manually access the docker services, you have to run bash command in those running services.

Example: You want to run slurm commands like sinfo or squeue or scontrol on slurm controller, you cannot directly access it.

You need to open a bash session in the running service by using the following command:

$ docker exec -it <docker service name> bash
#example
$ docker exec -it slurmctld bash
#or
$ docker exec -it cc-metric-store bash

Once you start a bash on any docker service, then you may execute any service related commands in that bash.

But for Cluster Cockpit development, you only need ports to access these docker services. You have to use localhost:<port> when trying to access any docker service. You may need to configure the cc-backend/config.json based on these docker services and ports.

Slurm setup in cc-docker

1. Slurm controller

Currently slurm controller is aware of the 1 node that we have setup in our mini cluster i.e. node01.

In order to execute slurm commands, you may need to bash into the slurmctld docker service.

docker exec -it slurmctld bash

Then you may be able to run slurm controller commands. A few examples without output are:

sinfo

or

squeue

or

scontrol show nodes

2. Slurm rest service

You do not need to bash into the slurmrestd service but can directly access the rest API via localhost:6820. A simple example on how to CURL to the slurm rest API is given in the curl_slurmrestd.sh.

You can directly use curl_slurmrestd.sh with a never expiring JWT token ( can be found in /data/slurm/secret/jwt_token.txt )

You may also use the never expiring token directly from the file for any of your custom CURL commands.

Known Issues

  • docker-compose installed on Ubuntu (18.04, 20.04) via apt-get can not correctly parse docker-compose.yml due to version differences. Install latest version of docker-compose from https://docs.docker.com/compose/install/ instead.
  • You need to ensure that no other web server is running on ports 8088 (cc-backend), 8080 (KeyCloak), 8084 (cc-metric-store), 4222 and 8222 (Nats). If one or more ports are already in use, you have to adapt the related config accordingly.
  • Existing VPN connections sometimes cause problems with docker. If docker-compose does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.

Docker services and restarting the services

You can find all the docker services in docker-compose.yml. Feel free to modify it.

Whenever you modify it, please use

docker compose down

in order to shut down all the services in all the VM’s (maininstance, nodeinstance, nodeinstance2) and then start all the services by using

docker compose up

TODO: Update job archive and all other metric data. The job archive with 1867 jobs originates from the second half of 2020. Roughly 2700 jobs from the first week of 2021 are loaded with data from InfluxDB. Some views of ClusterCockpit (e.g. the Users view) show the last week or month. To show some data there you have to set the filter to time periods with jobs (August 2020 to January 2021).

About

A configurable docker compose setup for development and testing of ClusterCockpit

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

cc-docker

This is a docker-compose setup which provides a quickly started environment for ClusterCockpit development and testing, using cc-backend. A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP, SLURM), or easily added by manual configuration (MariaDB).

It includes the following containers:

Service full namedocker service nameport
Slurm Controllerslurmctld6818
Slurm Databaseslurmdbd6817
Slurm Rest (JWT)slurmrestd6820
Slurm Workernode016818
NATS servicenats4222, 6222, 8222
cc-metric-storecc-metric-store8084
KeyCloakkeycloak8080
OpenLDAPopenldap389, 636

The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, and a LDAP user directory.

Prerequisites

For all the docker services to work correctly, you will need the following tools installed:

  1. docker and docker-compose
  2. golang (for compiling cc-metric-store)
  3. perl (for migrateTimestamp.pl) with Cpanel::JSON::XS, Data::Dumper, Time::Piece, Sort::Versions and File::Slurp perl modules.
  4. npm (for cc-backend)
  5. make (for building slurm base image)

It is also recommended to add docker service to sudo user group since the setupDev.sh script assumes sudo permissions for docker and docker-compose services.

You can use:

sudo groupadd docker
sudo usermod -aG docker $USER
# restart after adding your docker with your user to sudo group
sudo shutdown -r -t 0

Note: You can install all these dependencies via predefined installation steps in prerequisite_installation_script.sh.

If you are using different Linux flavors, you will have to adapt prerequisite_installation_script.sh as well as setupDev.sh.

Setup Procedure

  1. Clone cc-backend repository in chosen base folder: $> git clone https://github.com/ClusterCockpit/cc-backend.git

  2. Run the setup bash file: $> ./setupDev.sh: NOTICE The script will download files of a total size of 338MB (mostly for the cc-metric-store data).

  3. The setup-script launches the supporting container stack in the background automatically if everything went well. Run

./cc-backend/cc-backend -server -dev

to start cc-backend.

  1. By default, you can access cc-backend in your browser at http://localhost:8088 (port 8080 is taken by the KeyCloak container). You can shut down the cc-backend server by pressing CTRL-C, remember to also shut down all containers via $> docker-compose down afterwards.

  2. You can restart the containers with: $> docker-compose up -d.

Credentials for logging into clustercockpit

Credentials for the preconfigured demo user are:

  • User: demo
  • Password: demo

The LDAP user directory is defined in ./data/ldap/add_users.ldif. Every account's password equals its user name:

UserGroupRole in ClusterCockpit
ldapuseruser
ccuseruser
ccadmincc-adminuser, admin
ccsupportcc-supportuser
ccmanagercc-manageruser
ccapicc-apiuser

LDAP role sync

cc-backend can derive elevated roles from LDAP group membership via auth.ldap.role-filters in config.json. Each entry maps a role to an LDAP filter that is evaluated against the user entry; the preconfigured setup maps the cc-admin group to the admin role:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)"
}

The memberOf attribute is maintained automatically by the memberof overlay of the openldap image, which is configured for groupOfUniqueNames / uniqueMember — the group entries in the ldif use those classes accordingly.

LDAP is authoritative for every role listed in role-filters: a role is granted when the filter matches and revoked when it no longer does. Roles that are not listed are never touched. To exercise the other groups, add them as well:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)",
"support": "(memberOf=cn=cc-support,ou=groups,dc=example,dc=com)",
"manager": "(memberOf=cn=cc-manager,ou=groups,dc=example,dc=com)",
"api": "(memberOf=cn=cc-api,ou=groups,dc=example,dc=com)"
}

Roles are applied when the account is first synced (sync-user-on-login) and refreshed on every subsequent login (update-user-on-login), as well as by the periodic sync task (sync-interval).

Note: The ldif is only applied when the openldap container initialises its database. After changing it, recreate the container and its volumes with docker compose rm -sfv openldap, or load the changes into the running directory manually with ldapadd.

OIDC login via KeyCloak

The KeyCloak container imports the realm clustercockpit from ./keycloak/import/clustercockpit-realm.json on first start. It defines the confidential client cc-backend, the realm roles cc-admin, cc-support, cc-manager and cc-api, and these accounts (password equals user name):

UserRealm roleRole in ClusterCockpit
kcuseruser
kcadmincc-adminadmin
kcsupportcc-supportuser
kcmanagercc-manageruser
kcapicc-apiuser

The KeyCloak admin console is at http://localhost:8080 (admin / admin).

The auth.oidc.role-mapping section of config.json translates realm roles into ClusterCockpit roles. The preconfigured setup maps cc-admin to admin:

"oidc": {
"provider": "http://localhost:8080/realms/clustercockpit",
"client-id": "cc-backend",
"client-secret": "cc-backend-dev-secret",
"sync-user-on-login": true,
"update-user-on-login": true,
"role-mapping": {
"cc-admin": "admin"
}
}

Unlike the LDAP role filters, role-mapping is the sole source of roles for OIDC logins: a role in the token grants a ClusterCockpit role only if it is listed here, and unmapped roles are ignored — literal role names such as admin would also have to be mapped explicitly. Accounts without a mapped role get user. Add the remaining groups to exercise them:

"role-mapping": {
"cc-admin": "admin",
"cc-support": "support",
"cc-manager": "manager",
"cc-api": "api"
}

Roles are read from the realm_access.roles claim of the ID token. The built-in KeyCloak roles client scope only adds that claim to the access token, so the imported client carries its own realm roles in id token protocol mapper with id.token.claim enabled. Keep that mapper when editing the realm, otherwise every OIDC login falls back to the plain user role.

Note: cc-backend resolves the OIDC provider at startup and aborts if it is unreachable, so the KeyCloak container has to be up before starting the server. The realm is only imported while the KeyCloak database is empty — to re-import after editing the realm file, recreate KeyCloak and its database with docker compose rm -sf keycloak postgres.

Preconfigured setup between docker services and ClusterCockpit components

When you are done cloning the cc-backend repo and once you execute setupDev.sh file, it will copy a preconfigured config.json from misc/config.json and replace the cc-backend/config.json, which will be used by cc-backend, once you start the server. The preconfigured config.json attaches to:

1. OpenLDAP docker service on port 389

2. cc-metric-store docker service on port 8084

3. cc-slurm-adapter is running on slurmctld docker service

cc-metric-store also has a preconfigured config.json in cc-metric-store/config.json which attaches to NATS docker service on port 4222 and subscribes to topic 'hpc-nats'.

Basically, all the ClusterCockpit components and the docker services attach to each other like lego pieces.

Docker commands to access the services

Note: You need to be in cc-docker directory in order to execute any docker command

You can view all docker processes running on either of the VM instance by using this command:

docker ps

Now that you can see the docker services, and if you want to manually access the docker services, you have to run bash command in those running services.

Example: You want to run slurm commands like sinfo or squeue or scontrol on slurm controller, you cannot directly access it.

You need to open a bash session in the running service by using the following command:

$ docker exec -it <docker service name> bash
#example
$ docker exec -it slurmctld bash
#or
$ docker exec -it cc-metric-store bash

Once you start a bash on any docker service, then you may execute any service related commands in that bash.

But for Cluster Cockpit development, you only need ports to access these docker services. You have to use localhost:<port> when trying to access any docker service. You may need to configure the cc-backend/config.json based on these docker services and ports.

Slurm setup in cc-docker

1. Slurm controller

Currently slurm controller is aware of the 1 node that we have setup in our mini cluster i.e. node01.

In order to execute slurm commands, you may need to bash into the slurmctld docker service.

docker exec -it slurmctld bash

Then you may be able to run slurm controller commands. A few examples without output are:

sinfo

or

squeue

or

scontrol show nodes

2. Slurm rest service

You do not need to bash into the slurmrestd service but can directly access the rest API via localhost:6820. A simple example on how to CURL to the slurm rest API is given in the curl_slurmrestd.sh.

You can directly use curl_slurmrestd.sh with a never expiring JWT token ( can be found in /data/slurm/secret/jwt_token.txt )

You may also use the never expiring token directly from the file for any of your custom CURL commands.

Known Issues

  • docker-compose installed on Ubuntu (18.04, 20.04) via apt-get can not correctly parse docker-compose.yml due to version differences. Install latest version of docker-compose from https://docs.docker.com/compose/install/ instead.
  • You need to ensure that no other web server is running on ports 8088 (cc-backend), 8080 (KeyCloak), 8084 (cc-metric-store), 4222 and 8222 (Nats). If one or more ports are already in use, you have to adapt the related config accordingly.
  • Existing VPN connections sometimes cause problems with docker. If docker-compose does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.

Docker services and restarting the services

You can find all the docker services in docker-compose.yml. Feel free to modify it.

Whenever you modify it, please use

docker compose down

in order to shut down all the services in all the VM’s (maininstance, nodeinstance, nodeinstance2) and then start all the services by using

docker compose up

TODO: Update job archive and all other metric data. The job archive with 1867 jobs originates from the second half of 2020. Roughly 2700 jobs from the first week of 2021 are loaded with data from InfluxDB. Some views of ClusterCockpit (e.g. the Users view) show the last week or month. To show some data there you have to set the filter to time periods with jobs (August 2020 to January 2021).

About

A configurable docker compose setup for development and testing of ClusterCockpit

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

cc-docker

This is a docker-compose setup which provides a quickly started environment for ClusterCockpit development and testing, using cc-backend. A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP, SLURM), or easily added by manual configuration (MariaDB).

It includes the following containers:

Service full namedocker service nameport
Slurm Controllerslurmctld6818
Slurm Databaseslurmdbd6817
Slurm Rest (JWT)slurmrestd6820
Slurm Workernode016818
NATS servicenats4222, 6222, 8222
cc-metric-storecc-metric-store8084
KeyCloakkeycloak8080
OpenLDAPopenldap389, 636

The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, and a LDAP user directory.

Prerequisites

For all the docker services to work correctly, you will need the following tools installed:

  1. docker and docker-compose
  2. golang (for compiling cc-metric-store)
  3. perl (for migrateTimestamp.pl) with Cpanel::JSON::XS, Data::Dumper, Time::Piece, Sort::Versions and File::Slurp perl modules.
  4. npm (for cc-backend)
  5. make (for building slurm base image)

It is also recommended to add docker service to sudo user group since the setupDev.sh script assumes sudo permissions for docker and docker-compose services.

You can use:

sudo groupadd docker
sudo usermod -aG docker $USER
# restart after adding your docker with your user to sudo group
sudo shutdown -r -t 0

Note: You can install all these dependencies via predefined installation steps in prerequisite_installation_script.sh.

If you are using different Linux flavors, you will have to adapt prerequisite_installation_script.sh as well as setupDev.sh.

Setup Procedure

  1. Clone cc-backend repository in chosen base folder: $> git clone https://github.com/ClusterCockpit/cc-backend.git

  2. Run the setup bash file: $> ./setupDev.sh: NOTICE The script will download files of a total size of 338MB (mostly for the cc-metric-store data).

  3. The setup-script launches the supporting container stack in the background automatically if everything went well. Run

./cc-backend/cc-backend -server -dev

to start cc-backend.

  1. By default, you can access cc-backend in your browser at http://localhost:8088 (port 8080 is taken by the KeyCloak container). You can shut down the cc-backend server by pressing CTRL-C, remember to also shut down all containers via $> docker-compose down afterwards.

  2. You can restart the containers with: $> docker-compose up -d.

Credentials for logging into clustercockpit

Credentials for the preconfigured demo user are:

  • User: demo
  • Password: demo

The LDAP user directory is defined in ./data/ldap/add_users.ldif. Every account's password equals its user name:

UserGroupRole in ClusterCockpit
ldapuseruser
ccuseruser
ccadmincc-adminuser, admin
ccsupportcc-supportuser
ccmanagercc-manageruser
ccapicc-apiuser

LDAP role sync

cc-backend can derive elevated roles from LDAP group membership via auth.ldap.role-filters in config.json. Each entry maps a role to an LDAP filter that is evaluated against the user entry; the preconfigured setup maps the cc-admin group to the admin role:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)"
}

The memberOf attribute is maintained automatically by the memberof overlay of the openldap image, which is configured for groupOfUniqueNames / uniqueMember — the group entries in the ldif use those classes accordingly.

LDAP is authoritative for every role listed in role-filters: a role is granted when the filter matches and revoked when it no longer does. Roles that are not listed are never touched. To exercise the other groups, add them as well:

"role-filters": {
"admin": "(memberOf=cn=cc-admin,ou=groups,dc=example,dc=com)",
"support": "(memberOf=cn=cc-support,ou=groups,dc=example,dc=com)",
"manager": "(memberOf=cn=cc-manager,ou=groups,dc=example,dc=com)",
"api": "(memberOf=cn=cc-api,ou=groups,dc=example,dc=com)"
}

Roles are applied when the account is first synced (sync-user-on-login) and refreshed on every subsequent login (update-user-on-login), as well as by the periodic sync task (sync-interval).

Note: The ldif is only applied when the openldap container initialises its database. After changing it, recreate the container and its volumes with docker compose rm -sfv openldap, or load the changes into the running directory manually with ldapadd.

OIDC login via KeyCloak

The KeyCloak container imports the realm clustercockpit from ./keycloak/import/clustercockpit-realm.json on first start. It defines the confidential client cc-backend, the realm roles cc-admin, cc-support, cc-manager and cc-api, and these accounts (password equals user name):

UserRealm roleRole in ClusterCockpit
kcuseruser
kcadmincc-adminadmin
kcsupportcc-supportuser
kcmanagercc-manageruser
kcapicc-apiuser

The KeyCloak admin console is at http://localhost:8080 (admin / admin).

The auth.oidc.role-mapping section of config.json translates realm roles into ClusterCockpit roles. The preconfigured setup maps cc-admin to admin:

"oidc": {
"provider": "http://localhost:8080/realms/clustercockpit",
"client-id": "cc-backend",
"client-secret": "cc-backend-dev-secret",
"sync-user-on-login": true,
"update-user-on-login": true,
"role-mapping": {
"cc-admin": "admin"
}
}

Unlike the LDAP role filters, role-mapping is the sole source of roles for OIDC logins: a role in the token grants a ClusterCockpit role only if it is listed here, and unmapped roles are ignored — literal role names such as admin would also have to be mapped explicitly. Accounts without a mapped role get user. Add the remaining groups to exercise them:

"role-mapping": {
"cc-admin": "admin",
"cc-support": "support",
"cc-manager": "manager",
"cc-api": "api"
}

Roles are read from the realm_access.roles claim of the ID token. The built-in KeyCloak roles client scope only adds that claim to the access token, so the imported client carries its own realm roles in id token protocol mapper with id.token.claim enabled. Keep that mapper when editing the realm, otherwise every OIDC login falls back to the plain user role.

Note: cc-backend resolves the OIDC provider at startup and aborts if it is unreachable, so the KeyCloak container has to be up before starting the server. The realm is only imported while the KeyCloak database is empty — to re-import after editing the realm file, recreate KeyCloak and its database with docker compose rm -sf keycloak postgres.

Preconfigured setup between docker services and ClusterCockpit components

When you are done cloning the cc-backend repo and once you execute setupDev.sh file, it will copy a preconfigured config.json from misc/config.json and replace the cc-backend/config.json, which will be used by cc-backend, once you start the server. The preconfigured config.json attaches to:

1. OpenLDAP docker service on port 389

2. cc-metric-store docker service on port 8084

3. cc-slurm-adapter is running on slurmctld docker service

cc-metric-store also has a preconfigured config.json in cc-metric-store/config.json which attaches to NATS docker service on port 4222 and subscribes to topic 'hpc-nats'.

Basically, all the ClusterCockpit components and the docker services attach to each other like lego pieces.

Docker commands to access the services

Note: You need to be in cc-docker directory in order to execute any docker command

You can view all docker processes running on either of the VM instance by using this command:

docker ps

Now that you can see the docker services, and if you want to manually access the docker services, you have to run bash command in those running services.

Example: You want to run slurm commands like sinfo or squeue or scontrol on slurm controller, you cannot directly access it.

You need to open a bash session in the running service by using the following command:

$ docker exec -it <docker service name> bash
#example
$ docker exec -it slurmctld bash
#or
$ docker exec -it cc-metric-store bash

Once you start a bash on any docker service, then you may execute any service related commands in that bash.

But for Cluster Cockpit development, you only need ports to access these docker services. You have to use localhost:<port> when trying to access any docker service. You may need to configure the cc-backend/config.json based on these docker services and ports.

Slurm setup in cc-docker

1. Slurm controller

Currently slurm controller is aware of the 1 node that we have setup in our mini cluster i.e. node01.

In order to execute slurm commands, you may need to bash into the slurmctld docker service.

docker exec -it slurmctld bash

Then you may be able to run slurm controller commands. A few examples without output are:

sinfo

or

squeue

or

scontrol show nodes

2. Slurm rest service

You do not need to bash into the slurmrestd service but can directly access the rest API via localhost:6820. A simple example on how to CURL to the slurm rest API is given in the curl_slurmrestd.sh.

You can directly use curl_slurmrestd.sh with a never expiring JWT token ( can be found in /data/slurm/secret/jwt_token.txt )

You may also use the never expiring token directly from the file for any of your custom CURL commands.

Known Issues

  • docker-compose installed on Ubuntu (18.04, 20.04) via apt-get can not correctly parse docker-compose.yml due to version differences. Install latest version of docker-compose from https://docs.docker.com/compose/install/ instead.
  • You need to ensure that no other web server is running on ports 8088 (cc-backend), 8080 (KeyCloak), 8084 (cc-metric-store), 4222 and 8222 (Nats). If one or more ports are already in use, you have to adapt the related config accordingly.
  • Existing VPN connections sometimes cause problems with docker. If docker-compose does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.

Docker services and restarting the services

You can find all the docker services in docker-compose.yml. Feel free to modify it.

Whenever you modify it, please use

docker compose down

in order to shut down all the services in all the VM’s (maininstance, nodeinstance, nodeinstance2) and then start all the services by using

docker compose up

TODO: Update job archive and all other metric data. The job archive with 1867 jobs originates from the second half of 2020. Roughly 2700 jobs from the first week of 2021 are loaded with data from InfluxDB. Some views of ClusterCockpit (e.g. the Users view) show the last week or month. To show some data there you have to set the filter to time periods with jobs (August 2020 to January 2021).

About

A configurable docker compose setup for development and testing of ClusterCockpit

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages