How should we configure the minikube for microservices

Viewed 68

I have 3 Node services and a React app. I want to run them in a Minikube environment. At the moment there is no API Gateway and the React app is communicating each services directly.
I have no idea about the followings.

  1. If I configure all these four instances as containers inside the Minikube, how the service URLs have to be configured in the React app.
  2. At the moment I'm using .env files for all the services and apps. If I want to use config maps, where do I need to mount the configs files? and will giving a mount path will enough or do I need to do any other configuration to enable the services/app to read the configs from mount path?
1 Answers

1 . You need to define service definition on minikube for all your microservices. Please read official documentation for kubernetes services. -- > https://kubernetes.io/docs/concepts/services-networking/service/

If you have 3 node application on your minikube you should define 3 different service. For example

Service 1 For Application 1 :

apiVersion: v1
kind: Service
metadata:
 name: ServiceA
spec:
  type: ClusterIP
  ports:
    - targetPort: 80
      port: 80

Service 2 For Application 2 :

apiVersion: v1
kind: Service
metadata:
 name: ServiceB
spec:
  type: ClusterIP
  ports:
    - targetPort: 80
      port: 80

Service 3 For Application 3 :

apiVersion: v1
kind: Service
metadata:
 name: ServiceC
spec:
  type: ClusterIP
  ports:
    - targetPort: 80
      port: 80

After apply your yml's you can see clusterIP's for all your application. Your application can communicate each other with their clusterIP's or their service name. Please check your applications clusterIP's with this command

kubectl get svc

http://ServiceA -- > http://ServiceB
http://ClusterIPA --> http://ClusterIPB
  1. If you want to use configmap you need to mount on your pod definition yaml. This is from official documentation example

config_map

pod_definition

Related