Kubernetes Services Explorer

This is a simple Streamlit web app that allows you to explore the services running in a Kubernetes cluster. You can select a namespace and retrieve a list of services running in that namespace.

Requirements

To run this script, you will need:

  • Python 3
  • The streamlit and kubernetes Python packages
  • Access to a Kubernetes cluster

Installation

Before you can run the app, you'll need to install the necessary dependencies. You can do this using pip:

pip install streamlit kubernetes

Running the App

To run the app, simply execute the following command in your terminal:

streamlit run app.py

Replace app.py with the name of the Python file containing the code.

Once the app is running, you should see a web page that allows you to select a namespace and retrieve a list of services.

Code Explanation

The code is written in Python and uses the following libraries:

  • streamlit - for building the web app
  • kubernetes - for interacting with the Kubernetes API

The code does the following:

  1. Loads the Kubernetes configuration using config.load_kube_config()
  2. Creates a Kubernetes API client using client.CoreV1Api()
  3. Defines a function to list all services in a given namespace
  4. Defines a Streamlit web app that allows you to select a namespace and retrieve a list of services
  5. Runs the app using streamlit run app.py

The app works by allowing the user to select a namespace from a dropdown menu. If the user clicks the "List Services" button, the app retrieves a list of services running in the selected namespace using the list_services() function. The services are displayed in a table on the web page.

I hope this helps! Let me know if you have any further questions.

Here's an example README.md file for your Python script:

Acknowledgements

This script was created using the Kubernetes Python client library and the Streamlit Python package. Thank you to the developers of these packages for making this script possible.