mendhak / mendhak/docker-http-https-echo

Where are these ENVVARS coming from???

未关闭
#86 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Shell
星标
792
派生
152
平均合并
3 天 18 小时
30 天内合并 PR
3

描述

I've got a simple blue/green Kubernetes deployment using this container as described below:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: green-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: green-app
  template:
    metadata:
      labels:
        app: green-app
    spec:
      containers:
      - name: http-https-echo
        image: mendhak/http-https-echo
        ports:
        - containerPort: 8080
        env:
        - name: ECHO_INCLUDE_ENV_VARS
          value: "1"
        - name: APP_COLOR
          value: "GREEN"
---
apiVersion: v1
kind: Service
metadata:
  name: green-app
spec:
  selector:
    app: green-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: blue-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: blue-app
  template:
    metadata:
      labels:
        app: blue-app
    spec:
      containers:
      - name: http-https-echo
        image: mendhak/http-https-echo
        ports:
        - containerPort: 8080
        env:
        - name: ECHO_INCLUDE_ENV_VARS
          value: "1"
        - name: APP_COLOR
          value: "BLUE"
---
apiVersion: v1
kind: Service
metadata:
  name: blue-app
spec:
  selector:
    app: blue-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: color-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
#  tls:
#  - hosts:
#    - '*.com'
  rules:
  - http:
      paths:
      - path: /green
        pathType: Prefix
        backend:
          service:
            name: green-app
            port:
              number: 80
      - path: /blue
        pathType: Prefix
        backend:
          service:
            name: blue-app
            port:
              number: 80

Everything spins up and the /blue and /green endpoints work as they should.

But inside the blue are all of these environment variables referencing the green app (and vice versa)

/app $ env
KUBERNETES_PORT=tcp://172.20.0.1:443
GREEN_APP_PORT_80_TCP=tcp://172.20.144.83:80
KUBERNETES_SERVICE_PORT=443
NODE_VERSION=22.21.0
HOSTNAME=blue-app-64bd4f854f-x9v4j
YARN_VERSION=1.22.22
BLUE_APP_PORT_80_TCP=tcp://172.20.108.198:80
SHLVL=1
HOME=/home/node
ECHO_INCLUDE_ENV_VARS=1
GREEN_APP_SERVICE_HOST=172.20.144.83
BLUE_APP_SERVICE_HOST=172.20.108.198
TERM=xterm
KUBERNETES_PORT_443_TCP_ADDR=172.20.0.1
HTTP_PORT=8080
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GREEN_APP_PORT=tcp://172.20.144.83:80
KUBERNETES_PORT_443_TCP_PORT=443
GREEN_APP_SERVICE_PORT=80
KUBERNETES_PORT_443_TCP_PROTO=tcp
HTTPS_PORT=8443
BLUE_APP_PORT=tcp://172.20.108.198:80
BLUE_APP_SERVICE_PORT=80
APP_COLOR=BLUE
GREEN_APP_PORT_80_TCP_ADDR=172.20.144.83
KUBERNETES_SERVICE_PORT_HTTPS=443
GREEN_APP_PORT_80_TCP_PORT=80
KUBERNETES_PORT_443_TCP=tcp://172.20.0.1:443
BLUE_APP_PORT_80_TCP_ADDR=172.20.108.198
GREEN_APP_PORT_80_TCP_PROTO=tcp
KUBERNETES_SERVICE_HOST=172.20.0.1
PWD=/app
BLUE_APP_PORT_80_TCP_PORT=80
BLUE_APP_PORT_80_TCP_PROTO=tcp
/app $ 

How can a simple pod that only has 2 environment variables defined (APP_COLOR and ECHO_INCLUDE_ENV_VARS) pickup all of these other variables? Where are they coming from!??!

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Kubernetes Deployment 和 Service 清单以及 issue 中描述的容器行为开始。调查 Kubernetes 如何向 pod 暴露与 Service 相关的环境变量,然后检查 repository 是否记录或控制了这一行为。完成的标准是解释清楚来源,并确定所需的文档或代码更改。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, kubernetes
领域
infrastructure
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。