Update host:port in YAML service URLs by service name and Kubernetes cluster
Project description
Service-Lookup Utility
A Python-based tool for updating YAML configuration files with dynamic host and port information from Kubernetes clusters. This utility is designed to streamline service discovery and configuration management in microservice environments.
Table of Contents
Features
- Dynamic Service Discovery: Automatically discover services running in a Kubernetes cluster and update your YAML configuration files accordingly.
- Port Forwarding: Port forward Kubernetes services to your local machine for development and testing purposes.
- Custom Mappings: Use custom mappings to handle services with different names locally and in Kubernetes.
- Exclusion of Files: Specify paths to exclude from YAML updates.
- Setup Utility: Configure your environment with a simple setup command.
Requirements
- Python 3.7 or later
kubectlinstalled and configured- Access to a Kubernetes cluster
- uv
Installation from PyPI
Once the package is published on PyPI, you can install it using pip:
pip install service-lookup
Add to PATH
In order to be able to call service-lookup directly from any directory, you must add the Python scripts directory to your PATH environment variable.
The default location for Windows is <User_Directory>/AppData/Local/Programs/Python/<Python_Version>/Scripts.
Installation From Repository
-
Clone the Repository:
git clone https://github.com/iByteABit256/service-lookup.git cd service-lookup
-
Install Dependencies:
uv sync -
Add to pip modules (Optional)
pip install .
-
Ensure
kubectlis Installed: Make sure you havekubectlinstalled and configured to access your Kubernetes cluster. You should either have a.kubeconfigfile or run the setup command if you're using Lens.
Usage
To use the utility, run the main script with the desired options:
Basic Command
service-lookup --root /path/to/root --namespace your-namespace --services service1,service2 --exclude path/to/exclude
Setup Environment from Kubernetes Lens
To set up your environment based on your Lens configuration, run:
service-lookup --setup
With Mappings
If you have predefined mappings:
service-lookup --root /path/to/root --map service1=localhost:8080,service2=localhost:8081 --exclude path/to/exclude
Options
-r,--root: Root directory to search YAML files.-e,--exclude: Comma-separated list of paths to exclude.-m,--map: Comma-separated service=host:port pairs.-n,--namespace: Kubernetes namespace to discover services.-v,--services: Comma-separated list of service names to port forward.-f,--mapping-file: Path to JSON file with service mappings.-s,--setup: Run setup to configure KUBECONFIG.
Configuration
Service Mappings
Create a service_mappings.json file to map local service names to Kubernetes service names:
{
"local-service-a-name": "kubernetes-service-a-name",
"local-service-b-name": "kubernetes-service-b-name"
}
Exclusion Paths
Use the --exclude option to specify paths in the root directory that should be excluded from updates.
Contributing
All contributions are welcome! To contribute:
- Fork the repository on GitHub.
- Create a new branch for your feature or fix.
- Commit your changes and push your branch to GitHub.
- Submit a pull request for review.
License
This project is licensed under the GNU GPL-3.0 License. See the LICENSE file for more details.
Contact
For questions or feedback, please reach out via the project's GitHub issues page or contact the maintainer directly.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file service_lookup-0.2.1.tar.gz.
File metadata
- Download URL: service_lookup-0.2.1.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e9b34ce8d6f0ddf84f81cce47361626cb20c38f801070afc048d283dac04070
|
|
| MD5 |
6eed5cd895e154a88d95ea241d22dd81
|
|
| BLAKE2b-256 |
797fc5ff011383b06db968afebef72937a8d53e0fe701d39f73a9a8a2eef3a19
|
File details
Details for the file service_lookup-0.2.1-py3-none-any.whl.
File metadata
- Download URL: service_lookup-0.2.1-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d773b851a2d83514d8289c6ddda3346fd2d5fe2160617b4d44f8aac3903bdd67
|
|
| MD5 |
ecc276a2ad6df71968de3fce20bfa744
|
|
| BLAKE2b-256 |
6dd7fffd364f1d05705ef21147d3c2e7e4e40be398f92ac738e2ae3dcd5c6613
|