I have a Kubernetes scenario where I will need to deploy 3 Redis servers (pods), and each needs to be exposed with a ClusterIP service. Something like;
- RedisClusterIP1 -> RedisPod1
- RedisClusterIP2 -> RedisPod2
- RedisClusterIP3 -> RedisPod3
I have deployment plan like below, but as you can see it is creating ClusterIP service manually, and binds single of them to all pods.
Is there any way to set a deployment plan, there it will create same amount of services with Pods?
I checked deployments and replica sets but could not figure out if there is something already exists.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redisharedis
spec:
replicas: 3
template:
metadata:
labels:
app: redisharedis
spec:
containers:
- name: redisharedis
image: aozdemir/redisharedis:v6
resources:
limits:
cpu: "1"
memory: "800Mi"
requests:
cpu: "0.1"
memory: "200Mi"
ports:
- containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
name: redisharedis-service
labels:
name: redisharedis-service
spec:
ports:
- port: 6379
targetPort: 6379
protocol: TCP
selector:
app: redisharedis
type: ClusterIP