rancher / rke

Rancher Kubernetes Engine (RKE), an extremely simple, lightning fast Kubernetes distribution that runs entirely within containers.
Apache License 2.0
3.2k stars 580 forks source link

Forwardport: ingress should accept extra_env/extra_volumes #1776

Closed mrajashree closed 4 years ago

mrajashree commented 4 years ago

Forwardport: https://github.com/rancher/rke/issues/1104

deniseschannon commented 4 years ago

Available in RKE CLI v1.1.0-rc1.

soumyalj commented 4 years ago

Tested with rke version v1.1.0-rc1. Created 3 node cluster with the cluster.yml below:

auth:
  strategy: x509
nodes:
  - address: abcd
    user: root
    role: [etcd,controlplane,worker]
  - address: efgh
    user: root
    role: [etcd,controlplane,worker]
  - address: ijkl
    user: root
    role: [etcd,controlplane,worker]
ingress:
    provider: nginx
    extra_envs:
      - name: MYNODENAME
        valueFrom:
          fieldRef:
            fieldPath: spec.nodeName
      - name: testenvvar
        value: testvalue
    extra_volume_mounts:
      - mountPath: /data
        name: testvol
    extra_volumes:
      - emptyDir: {}
        name: testvol

Cluster came up successfully. rancher/nginx-ingress-controller pod was created successfully on each node. Exec'ed into each of the containers and verified that the volume mount /data exists. Write and read to the volume was successful.

env variables were also verifed

KUBERNETES_SERVICE_PORT=443
KUBERNETES_PORT=tcp://abcd:443
HOSTNAME=soumyanewrketest-01
LUA_PATH=/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua;/usr/local/lib/lua/?.lua;/etc/nginx/lua/?.lua;/etc/nginx/lua/vendor/?.lua;;
HOME=/var/www
DEFAULT_HTTP_BACKEND_SERVICE_HOST=abcd
TERM=xterm
POD_NAME=nginx-ingress-controller-l75ms
KUBERNETES_PORT_443_TCP_ADDR=10.43.0.1
DEFAULT_HTTP_BACKEND_PORT=tcp://abcd:80
DEFAULT_HTTP_BACKEND_SERVICE_PORT=80
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_PROTO=tcp
DEFAULT_HTTP_BACKEND_PORT_80_TCP_ADDR=abcd
DEFAULT_HTTP_BACKEND_PORT_80_TCP_PORT=80
DEFAULT_HTTP_BACKEND_PORT_80_TCP_PROTO=tcp
MYNODENAME=167.172.118.4
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT_443_TCP=tcp://abcd:443
POD_NAMESPACE=ingress-nginx
KUBERNETES_SERVICE_HOST=abcd
LUA_CPATH=/etc/nginx/lua/?.lua;/etc/nginx/lua/vendor/?.lua;/usr/local/openresty/site/lualib/?.so;/usr/local/openresty/lualib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;;
PWD=/etc/nginx
testenvvar=testvalue
DEFAULT_HTTP_BACKEND_PORT_80_TCP=tcp://abcd:80

This issue was also verified on rancher master-head with the same rke version vendored in.