Openshift: Is it possible to make different pods of the same deployment to use different resources?

2/7/2020

In Openshift, say there are two pods of the same deployment in Test env. Is it possible to make one pod to use/connect to database1, make another pod to use/connect to dababase2 via label or configuration?

-- ITMan
deployment
kubernetes
label
openshift
pod

2 Answers

2/11/2020

I have created two diff pods with same code base or image containing same compiled code. Using spring profiling,passed two different arguments for connection to oracle database.

for example

enter image description here

enter image description here

-- deepak prajapati
Source: StackOverflow

2/8/2020

How about try to use StatefulSet for deploying each pod ? StatefulSet make each pod uses each PersistentVolume, so if you place each configuration file which is configured with other database connection data on each PersistentVolume, each pod can use other database each other. Because the pod can refer different config file.

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: app
spec:
  serviceName: "app"
  replicas: 2
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
      - name: app
        image: example.com/app:1.0
        ports:
        - containerPort: 8080
          name: web
        volumeMounts:
        - name: databaseconfig
          mountPath: /usr/local/databaseconfig
  volumeClaimTemplates:
  - metadata:
      name: databaseconfig
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 10Mi
-- Daein Park
Source: StackOverflow