How to pass windows mount points as environment variable for kubernetes


#1

Hi All,

We are using Rancher 2.x with kube config, deploying .ner microservices to Rancher 2.x having kube config.

One of the micro services having windows mount point, we are deploying linux containers, how can I windows mount point as enviroment variable in our deployment.yaml file.


#2

Are you trying to mount a windows path into the containers?

If you are just passing the path as an env in the the deployment file it should look like the following:

...
spec:
  containers:
  - name: mycontainer
      env:
      - name: MYPATH
        value: /path/to/my/mount
...

#3

Hi,

Thanks for your kind reply, yes trying to map windows mount point into containers.

Need your suggestions, in our deployment yaml file, container port is
containerPort: 5880, service target port is 5880, ingress service port is 80, but our load balancer listen on 443 . Do I need to change the container port and service target port to load balancer listener port.

Kindly advise me.


#4

Your container port does not need to match the ingress service port. When you define the ingress object for your service you just need to identify which port the ingress will direct to.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        backend:
          serviceName: test
          servicePort: 5880

Here is the link to the Ingress docs if you want to read more


#5

Hi Chris,

Thank you very much.

Regards,
Dhruva


#6

Happy to help


#7

Chris,

This is our ingress, kindly validate, if we want the service port to be changed to 443, need to change service port from 80 to 443, please correct me if I am wrong

Actual configuration:

Listener ports: 80, 443

Members ports: 80

Actual mapping:

Listener : Member

80 : 80

443 : 80

depolyment yaml file.

apiVersion: v1
kind: Service
metadata:
name: eol
namespace: deol
labels:
app: eol
spec:
ports:

  • port: 80
    targetPort: 5303
    protocol: TCP
    type: ClusterIP
    selector:
    app: eol

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: eol
namespace: eol
annotations:
kubernetes.io/ingress.class: nginx
ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:

  • host: ${HOST}
    http:
    paths:
    • path: /eol/
      backend:
      serviceName: eol
      servicePort: 80

Kindly advise me


#8

For the service you can just use 5303 as the port, you don’t need use port 80 in this case unless you want to. You don’t need to worry about matching what the ingress controller is exposing (80/443).

Then your ingress servicePort should point to whatever port the service is being exposed at as you did in you in your example.


#9

Just an FYI @Dhruva_Kumar if you put your code into mark down code blocks, it will make it much easier to look at and review. To do so, you wrap your code with 3 back ticks (```)
It would turn this:
apiVersion: v1
kind: Service
metadata:
name: eol
namespace: deol

into this:

apiVersion: v1
kind: Service
metadata:
  name: eol
  namespace: deol

#10

@macintoshprime, thank you very much


#11

@mrbobbytables, thank you very much