Reputation: 34071
I am pretty newbie in Helm and would like to know, if it is allowed to have multi services in service.yaml file like:
apiVersion: v1
kind: Service
metadata:
name: {{ include "keycloak.fullname" . }}
labels:
{{- include "keycloak.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "keycloak.selectorLabels" . | nindent 4 }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "keycloak.fullname" . }}
labels:
{{- include "keycloak.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "keycloak.selectorLabels" . | nindent 4 }}
Upvotes: 1
Views: 3027
Reputation: 51
You can have multiple services defined in one file by using a List kind
apiVersion: v1
items:
- apiVersion: v1
kind: Service
metadata:
name: {{ .Values.appName }}{{ .Values.nameSuffix }}
namespace: {{ .Values.projectNamespace }}
labels:
app: {{ .Values.appName }}
owner: {{ .Values.ownerName }}
project: {{ .Values.projectName }}
spec:
ports:
- name: 8082-tcp
port: 8082
protocol: TCP
targetPort: 8082
selector:
deploymentconfig: {{ .Values.appName }}{{ .Values.nameSuffix }}
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
- apiVersion: v1
kind: Service
metadata:
name: {{ .Values.appName }}
namespace: {{ .Values.projectNamespace }}
labels:
app: {{ .Values.appName }}
owner: {{ .Values.ownerName }}
project: {{ .Values.projectName }}
spec:
ports:
- name: 8082-tcp
port: 8082
protocol: TCP
targetPort: 8082
selector:
deploymentconfig: {{ .Values.appName }}{{ .Values.nameSuffix }}
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
kind: List
metadata:
resourceVersion: ""
selfLink: ""
Upvotes: 0
Reputation: 3380
Yes it is, are you facing any issue?
A cleaner way is to use two different files service-a.yaml and service-b.yaml
Note: Better not to have both the services with the same name.
Upvotes: 1