Latest Socket ResearchMalicious Chrome Extension Performs Hidden Affiliate Hijacking.Details
Socket
Book a DemoInstallSign in
Socket

gke-log-tools

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gke-log-tools

[Protected] GKE Log Management Tools with GCS Archive Access

pipPyPI
Version
1.0.9
Maintainers
1

"""

GKE Log Tools

Log management tools for GKE with GCS archive access and signed URL generation.

Installation

pip install gke-log-tools

Quick Start

from gke_log_tools import generate_signed_url_for_log, list_archived_logs_for_deployment

# Generate signed URL for archived log
url_result = generate_signed_url_for_log(
    namespace="prod-app",
    deployment_name="app",
    environment="prod",
    log_date="2025-08-15",
    cluster="main-cluster",
    project="my-project"
)

print(f"Download URL: {url_result['signed_url']}")
print(f"Expires in: {url_result['expires_in']}")

# List available archived logs
logs_list = list_archived_logs_for_deployment(
    namespace="prod-app",
    deployment_name="app",
    environment="prod",
    cluster="main-cluster",
    project="my-project"
)

for log in logs_list['log_files']:
    print(f"{log['filename']} - {log['size_mb']} MB")

Features

  • Generate signed URLs for GCS archived logs
  • List available files from GCS bucket
  • Thread-safe credential management
  • Automatic token refresh for signing
  • Fixes SignatureDoesNotMatch errors

Usage Examples

Archived Logs from GCS

from gke_log_tools import generate_signed_url_for_log

result = generate_signed_url_for_log(
    namespace="abcv",
    deployment_name="app",
    environment="prod",
    log_date="2025-08-15",
    cluster="cluster-1",
    project="project-1"
)

if result['success']:
    # Use signed URL to download log
    import requests
    response = requests.get(result['signed_url'])
    log_content = response.text

Recent Logs from NFS

from gke_log_tools import fetch_recent_log_from_nfs_sync

result = fetch_recent_log_from_nfs_sync(
    namespace="prod-app",
    deployment_name="app",
    log_date="2025-12-10",  # Within last 6 days
    cluster="main",
    project="my-project"
)

if result['success']:
    print(f"Log URL: {result['signed_url']}")

List All Archived Logs

from gke_log_tools import list_archived_logs_for_deployment

result = list_archived_logs_for_deployment(
    namespace="prod-app",
    deployment_name="app",
    environment="prod",
    cluster="main",
    project="my-project",
    max_results=100
)

for log in result['log_files']:
    print(f"{log['log_date']}: {log['filename']} ({log['size_mb']} MB)")

Configuration

Environment setup for NFS access:

# For NFS mappings
export NFS_MAPPINGS_CSV=nfs_mappings.csv

NFS mappings CSV format:

host_url,vm_name,vm_zone,vm_project,nfs_path
www.example.com,nfs-vm-1,us-central1-a,my-project,/mnt/nfs/logs

GCS Bucket Structure

Expected GCS log archive structure:

bucket_name/
├── {namespace}/
│   └── {deployment}/
│       └── {environment}/
│           └── logs/
│               ├── file_name.log.2025-08-15
│               ├── file_name.log.2025-08-14
│               └── ...

Requirements

  • google-cloud-storage>=2.10.0
  • google-auth>=2.23.0

License

MIT License """

Keywords

gke

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts