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.
To run this script, you will need:
- Python 3
- The
streamlit
andkubernetes
Python packages - Access to a Kubernetes cluster
Before you can run the app, you'll need to install the necessary dependencies. You can do this using pip:
pip install streamlit kubernetes
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.
The code is written in Python and uses the following libraries:
streamlit
- for building the web appkubernetes
- for interacting with the Kubernetes API
The code does the following:
- Loads the Kubernetes configuration using
config.load_kube_config()
- Creates a Kubernetes API client using
client.CoreV1Api()
- Defines a function to list all services in a given namespace
- Defines a Streamlit web app that allows you to select a namespace and retrieve a list of services
- 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:
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.