title: Can we create multiple instances of a Kubernetes cluster & access it through different external IPs?
body: <p>In Brief, I want to create multiple instances of a pod contains MongoDB &amp; Mongo-express containers which can be accessed through different external IPs. Even when we change anything from mongo-express GUI then the change should be reflected into that particular instance's Mongo database not others. That means, each instance should create a separate volume also.</p>
  <p>My current YAML code is below: (Now it creates a single instance only and can be access through the localhost)</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
  kind: ConfigMap
  metadata:
    name: mongodb-configmap
  data:
    database_url: mongodb-service
  ---
  apiVersion: apps/v1
  kind: StatefulSet
  metadata:
    name: mongodb-statefulset
  spec:
    serviceName: &quot;mongodb-service&quot;
    selector:
      matchLabels:
        app: mongodb
    template:
      metadata:
        labels:
          app: mongodb
      spec:
        containers:
        - name: mongodb
          image: mongo
          ports:
          - containerPort: 27017
          env:
            - name: MONGO_INITDB_ROOT_USERNAME
              value: &quot;admin&quot;
            - name: MONGO_INITDB_ROOT_PASSWORD
              value: &quot;pass&quot;
          volumeMounts:
          - name: mongo-initdb
            mountPath: /docker-entrypoint-initdb.d
        restartPolicy: Always
        volumes:
        - name: mongo-initdb
          configMap:
            name: mongo-initdb
  ---
  apiVersion: v1
  kind: Service
  metadata:
    name: mongodb-service
  spec:
    clusterIP: None
    selector:
      app: mongodb
    ports:
      - port: 27017
        targetPort: 27017
        protocol: TCP
  ---
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: mongo-express
    labels:
      app: mongo-express
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: mongo-express
    template:
      metadata:
        labels:
          app: mongo-express
      spec:
        hostname: mongo-express
        subdomain: mongodb-service
        containers:
        # Container for Mongo-Service
        - name: mongo-express
          image: mongo-express
          ports:
          - containerPort: 8081
          env:
            - name: ME_CONFIG_MONGODB_ADMINUSERNAME
              value: &quot;admin&quot;
            - name: ME_CONFIG_MONGODB_ADMINPASSWORD
              value: &quot;pass&quot;
            - name: ME_CONFIG_MONGODB_SERVER
              valueFrom: 
                configMapKeyRef:
                  name: mongodb-configmap
                  key: database_url
  ---
  apiVersion: v1
  kind: Service
  metadata:
    name: mongo-express-service
  spec:
    selector:
      app: mongo-express
    type: LoadBalancer
    ports:
      - port: 8081
        targetPort: 8081
        protocol: TCP
        name: port1
  </code></pre>