惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
Martin Fowler
Martin Fowler
B
Blog RSS Feed
D
DataBreaches.Net
L
LangChain Blog
月光博客
月光博客
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
美团技术团队
Jina AI
Jina AI
博客园 - 司徒正美
雷峰网
雷峰网
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
小众软件
小众软件
罗磊的独立博客
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta

Xinwei Xiong (cubxxw) - AI, Open Source & Nomad Blog

2026 June Thought Notes: The Pushing-Away Comes Be… | cubxxw Dissecting open-lovable: An App Generator That Tam… | cubxxw Ignite and Settle (Part 3): Anxious Attachment — W… | cubxxw Ignite and Settle (Part 2): Avoidant Attachment — … | cubxxw Ignite and Settle (Part 1): The Quality and Time o… | cubxxw The Super-Individual Stack: AI-Native Product Dire… | cubxxw Building a Production-Grade AI Agent System from S… | cubxxw Seen Clearly, Loved Deeply: Five Lenses on Love, a… | cubxxw Context Is Not Prompt: Why Context Engineering Is Becoming AI's New Foundation The Agent Engineering Map: Where Does That 98.4% o… | cubxxw April 2026 Thought Notes Agent Identity: From Locke to OpenClaw Maintaining Self-Worth in the Age of AI March 2026 Thought Notes Lhasa: Slow and Heavy Wandering & Growing: 2025-2026 Annual Review AI and Self-Identity: Who Am I in the AI Age February 2026 Thought Notes January 2026 Thought Notes December 2025 Thought Notes Japan Travel Notes — Learning to Be with Time Through Wood, Fire, and Gaps 2025 November Thought Notes October 2025 Thought Notes September 2025 Thought Notes 2025 August Thought Notes 2025 July Thought Notes 2025 June Thought Notes Metacognitive Transformation Review 2025 May Thought Notes 2025 April Thought Notes
Kubernetes Port Config via Config Files
Xinwei Xiong · 2023-09-18 · via Xinwei Xiong (cubxxw) - AI, Open Source & Nomad Blog

[Xinwei Xiong Me] · September 18, 2023

2 min · 402 words · EN |

Introduction

In the current module’s execution, numerous ports (ws, api, rpc, Prometheus) are passed directly. This approach can be cumbersome and doesn’t align with Kubernetes’ best practices where a pod typically exposes only one port (either 80 or 443). This proposal suggests transitioning to a configuration file-centric approach, while still retaining the capability to pass ports directly when needed.

Goals

  1. Simplify the port configuration for Kubernetes deployment.
  2. Prioritize port values passed as arguments over configuration file values.
  3. Provide flexibility to users who wish to use traditional port-based or environment variable-based deployments.

Proposed Solution

1. Configuration File

Instead of passing multiple ports directly, a configuration file will be introduced. By default, this file will contain predefined ports. This configuration file can be passed to the module using Kubernetes’ ConfigMap.

Example Configuration File:

ws_port: 3000
api_port: 3001
rpc_port: 3002
prometheus_port: 9090

2. Passing Ports Directly

While the configuration file approach is recommended for Kubernetes deployment, users can still pass the ports directly. If ports are passed as arguments, these values will override the values from the configuration file.

3. Environment Variable-based Deployment

For users who prefer source code deployment using environment variables, the module can be designed to read port values set as environment variables on a Linux system. If these environment variables are set, they will override the configuration file values but will have lower precedence than port values passed directly as arguments.

Example: If WS_PORT environment variable is set to 3005, it will override the ws_port value from the configuration file, unless ws_port is passed as an argument.

Implementation Steps

  1. Update Module to Read Configuration File: Modify the module to read port values from the provided configuration file.
  2. Argument-based Overrides: Implement logic to override configuration file port values if they are provided as arguments.
  3. Environment Variable-based Overrides: Implement logic to check for environment variables and use those values if set. Ensure that direct argument values have the highest priority.
  4. Documentation: Update documentation to provide clear instructions on the three methods of setting port values: configuration file, direct arguments, and environment variables.
  5. Testing: Thoroughly test the module in different scenarios:
    • Using only the configuration file.
    • Passing ports as arguments.
    • Setting environment variables.

Conclusion

Adopting a configuration file approach simplifies the deployment process, especially in Kubernetes environments. While the configuration file is prioritized for simplicity, the flexibility of passing ports directly or using environment variables ensures backward compatibility and caters to various user preferences.