Skip to main content

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
  • kubectl installed 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

Installation From Repository

  1. Clone the Repository:

    git clone https://github.com/iByteABit256/service-lookup.git
    cd service-lookup
    
  2. Install Dependencies:

    uv sync
    
  3. Ensure kubectl is Installed: Make sure you have kubectl installed and configured to access your Kubernetes cluster.

Usage

To use the utility, run the main script with the desired options:

Basic Command

python main.py --root /path/to/root --namespace your-namespace --services service1,service2 --exclude path/to/exclude

Setup Environment

To set up your environment for Kubernetes configuration, use:

python main.py --setup

With Mapping

If you have predefined mappings:

python main.py --map service1=localhost:8080,service2=localhost:8081

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:

  1. Fork the repository on GitHub.
  2. Create a new branch for your feature or fix.
  3. Commit your changes and push your branch to GitHub.
  4. 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


Download files

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

Source Distribution

service_lookup-0.1.1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

service_lookup-0.1.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file service_lookup-0.1.1.tar.gz.

File metadata

  • Download URL: service_lookup-0.1.1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for service_lookup-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bd18d5bdccfb0b4da059ef3174e3c8a18262ec5d0e4b3755bbc11e3678e3bcbb
MD5 b3c3324f9c4fb3a495345e1936ad5547
BLAKE2b-256 d8a2a56f8b0760ad3f0e46fbc8fbc687a14b05d5f7ca23fbf7c0110dccc162a5

See more details on using hashes here.

File details

Details for the file service_lookup-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for service_lookup-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 606a38e0147d33672d85557e038646c8de09ba151d67dcad354577a3a1725348
MD5 f530d8a9c7a4458483e5fc0d1e8c6695
BLAKE2b-256 c9ee542e5f529adfb1f0a1deaf5e1875d4c5c8745a53dc9d2de9e1ef73b88c11

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