Skip to main content

Openshift cluster login on command line

Project description

logo

OCL (OpenShift Login)

PyPI PyPI platforms PyPI - License Release and Package Application

OCL does an automatic login to an OpenShift cluster. It fetches cluster information from app-interface and performs a login via Red Hat SSO.

Installation

You can install this tool from PyPI with pip:

python3 -m pip install openshift-cluster-login

or install it with uv:

uv tool install openshift-cluster-login

You can also use uv to run the tool without installing it:

uvx openshift-cluster-login

Usage

ocl

This spawns a new shell with the following environment variables are set:

  • KUBECONFIG - path to kubeconfig file
  • OCL_CLUSTER_NAME - cluster name
  • OCL_CLUSTER_CONSOLE - url to cluster console

Features

OCL currently provides the following features (get help with -h or --help):

  • OpenShift console login (oc login) via GitHub or Red Hat authentication
  • Get cluster and namespace information from app-interface or user-defined (OCL_USER_CLUSTERS)
  • Open the OpenShift console in the browser (--open-in-browser)
  • Star your most often used namespaces Ctrl+S in the UI
  • Shell completion (--install-completion, --show-completion)
  • Credentials via environment variables or shell command (e.g., 1password CLI)
  • Cache App-Interface queries (via GraphQL) for one week

Environment Variables

Variable Name Description Default
OCL_APP_INTERFACE_URL OCL_APP_INTERFACE_URL_COMMAND App-Interface URL
OCL_APP_INT_TOKEN OCL_APP_INT_TOKEN_COMMAND App-Interface authentication token [optional]
OCL_USER_CLUSTERS OCL_USER_CLUSTERS_COMMAND User defined clusters as json format (e.g. [{"name": "local-kind", "serverUrl": "https://localhost:6443", "consoleUrl": "not available}]) "[]"
OCL_CACHE_TIMEOUT_MINUTES GraphQL cache timeout in minutes 1 hour
OCL_HISTORY Enable/Disable the usage of the last selected namespace enabled
OCL_CSS_PATH Path to custom Textual CSS file

You can either set a variable, e.g. export OCL_GITHUB_USERNAME="mail@example.com" or retrieve it via a command, e.g. export OCL_GITHUB_USERNAME_COMMAND="op read op://Private/Github/username". If a variable is not set but needed, OCL will ask for it interactively.

App-Interface

OCL retrieves the cluster information from app-interface via GraphQL (OCL_APP_INTERFACE_URL) and caches them in your user cache directory (on MacOS, e.g., ~/Library/Caches/ocl/gql_cache/). Remove this directory to force a refresh.

Limitations

  • Kerberos authentication only
  • Works only with a Red Hat associate account

Development

Code style: black Checked with mypy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openshift_cluster_login-1.4.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openshift_cluster_login-1.4.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file openshift_cluster_login-1.4.0.tar.gz.

File metadata

  • Download URL: openshift_cluster_login-1.4.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for openshift_cluster_login-1.4.0.tar.gz
Algorithm Hash digest
SHA256 be60ea185aaa4852e55cc861d19fba6199129dd317e76bbe8698e1a5c50ac598
MD5 13e7386695cf51f2c99c8dd007047354
BLAKE2b-256 b06e677f315c6d4275d1319a3dc1b40dfab9c7feae7be7ac1d02e0ac4382bed3

See more details on using hashes here.

File details

Details for the file openshift_cluster_login-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: openshift_cluster_login-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for openshift_cluster_login-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc492937097f2c34b475c29f64e3b6986d57afd9b0d6c320c28a08a9fa3a0e59
MD5 5f3fbd5352078b8bfb848738050c35ca
BLAKE2b-256 b2134b08ebf2dfe5e86ecc1f324a226ec37be2a1f1b6bbc25b3a0be147d773bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page