I have deployed my Ni-Fi application using Kubernetes on-prem setup. Now the image which i am using to spin up the docker container is from docker private registry, which i can see when i deployed using Daemon sets service because my requirement is to spin up only one Pod per node and i don't want to replicate my pod if that is killed/terminated. having said that i want to listen this applications on some ports...so my questions are as below 1) How to open multiple ports for the application which are running on multiple nodes on single pod. 2) i have some configuration files which are in a shell script with environment variables defined within..how to inject this script on to my application which is already running.
Welcome on StackExchange @Ravikumar
Ad. 1 - How to open multiple ports for the application which are running on multiple nodes on single pod
- You need to define what ports are opened in your container inside of Pod spec. e.g:
apiVersion: v1 kind: Pod metadata: labels: app: example-app name: example-app namespace: default spec: containers: name: multi-port image: perl command: - perl - -Mbignum=bpi - -wle - print bpi(2000) ports: - containerPort: 8080 - containerPort: 8081
- Expose your workload externally using Service, e.g.
apiVersion: v1 kind: Service metadata: name: my-app-svc spec: selector: app: example-app ports: - name: http protocol: TCP port: 8080 targetPort: 8080 - name: monitoring protocol: TCP port: 8081 targetPort: 8081
From now on you can refer to your app, distributed over different nodes (Pod replicas) using service DNS name + Port: e.g. my-app-svc:8080 or my-app-svc:8081. Keep in mind this is a valid only within cluster, if your want to expose your app outside of Kubernetes cluster, check other option like ServiceType of LoadBalancer or NodePort, as described in official doc here.
Ad. 2 - For defining environment variables for Pod's container check in official doc here.