gpt4 book ai didi

kubernetes - Kubernetes 中的 Pod 预设与 ConfigMap

转载 作者:行者123 更新时间:2023-12-02 12:01:21 24 4
gpt4 key购买 nike

两者似乎都达到了相同的效果 - 在构建时配置一个 pod。

谁能解释一下这两者有什么区别?
如果您认为这会让它更清楚,也许还会给出一个简单的 1 个用例示例。

最佳答案

Pod 预设比 configmaps/secrets 更具可扩展性和强大功能,可将公共(public)信息注入(inject) Pod。

一个 Kubernetes 集群可能包含数百个 Pod。其中许多 Pod 共享常见的结构,例如环境变量、ConfigMaps、Secrets 等。例如,在使用 MySQL 的微服务的情况下,我们需要将 MySQL 凭据作为 K8s Secrets 注入(inject)到 Pod 中。如果集群有 100 个微服务(并不少见),我们需要在所有 100 个 pod 的配置中添加以下部分。

这是非常低效且容易出错的。 Pod Preset 通过在多个 Pod 中注入(inject)公共(public)信息来帮助我们避免这种情况,以便我们将所有公共(public)信息放在一个地方。

    env:
- name: SECRET_USERNAME
valueFrom:
secretKeyRef:
name: mysecret
key: mysql-username
- name: SECRET_PASSWORD
valueFrom:
secretKeyRef:
name: mysecret
key: mysql-password

来自 pods 预设设计 doc .

Motivation:

Consuming a service involves more than just connectivity. In addition to coordinates to reach the service, credentials and non-secret configuration parameters are typically needed to use the service. The primitives for this already exist, but a gap exists where loose coupling is desired: it should be possible to inject pods with the information they need to use a service on a service-by-service basis, without the pod authors having to incorporate the information into every pod spec where it is needed.

Use Cases

  1. As a user, I want to be able to provision a new pod without needing to know the application configuration primitives the services my pod will consume.
  2. As a cluster admin, I want specific configuration items of a service to be withheld visibly from a developer deploying a service, but not to block the developer from shipping.
  3. As an app developer, I want to provision a Cloud Spanner instance and then access it from within my Kubernetes cluster.
  4. As an app developer, I want the Cloud Spanner provisioning process to configure my Kubernetes cluster so the endpoints and credentials for my Cloud Spanner instance are implicitly injected into Pods matching a label selector (without me having to modify the PodSpec to add the specific Configmap/Secret containing the endpoint/credential data).

关于kubernetes - Kubernetes 中的 Pod 预设与 ConfigMap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61577043/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com