Skip to content

Commit

Permalink
Merge pull request #297 from montageofzyy/master
Browse files Browse the repository at this point in the history
hotelReservation: add label for backend services and support annotations
  • Loading branch information
cdelimitrou authored Nov 29, 2023
2 parents 45176d2 + dac716f commit bcaeae4
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ container:
name: hotel-reserv-profile
ports:
- containerPort: 8081
environments:
logLevel: INFO
jaegerSampleRatio: 1

configMaps:
- name: service-config.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ container:
name: hotel-reserv-rate
ports:
- containerPort: 8084
environments:
logLevel: INFO
jaegerSampleRatio: 1

configMaps:
- name: service-config.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,31 @@ kind: Deployment
metadata:
labels:
{{- include "hotel-reservation.labels" . | nindent 4 }}
{{- include "hotel-reservation.backendLabels" . | nindent 4 }}
service: {{ .Values.name }}-{{ $rangeItem }}-{{ include "hotel-reservation.fullname" . }}
name: {{ .Values.name }}-{{ $rangeItem }}-{{ include "hotel-reservation.fullname" . }}
spec:
replicas: {{ .Values.replicas | default .Values.global.replicas }}
selector:
matchLabels:
{{- include "hotel-reservation.selectorLabels" . | nindent 6 }}
{{- include "hotel-reservation.backendLabels" . | nindent 6 }}
service: {{ .Values.name }}-{{ $rangeItem }}-{{ include "hotel-reservation.fullname" . }}
app: {{ .Values.name }}-{{ $rangeItem }}-{{ include "hotel-reservation.fullname" . }}
template:
metadata:
labels:
{{- include "hotel-reservation.labels" . | nindent 8 }}
{{- include "hotel-reservation.backendLabels" . | nindent 8 }}
service: {{ .Values.name }}-{{ $rangeItem }}-{{ include "hotel-reservation.fullname" . }}
app: {{ .Values.name }}-{{ $rangeItem }}-{{ include "hotel-reservation.fullname" . }}
{{- if hasKey $.Values "annotations" }}
annotations:
{{ tpl $.Values.annotations . | nindent 8 | trim }}
{{- else if hasKey $.Values.global "annotations" }}
annotations:
{{ tpl $.Values.global.annotations . | nindent 8 | trim }}
{{- end }}
spec:
containers:
{{- with .Values.container }}
Expand All @@ -50,7 +60,7 @@ spec:
{{- if .args}}
args:
{{- range $arg := .args}}
- {{ $arg }}
- {{ $arg | quote }}
{{- end -}}
{{- end }}
{{- if .resources }}
Expand All @@ -64,9 +74,9 @@ spec:
{{- if hasKey .Values "topologySpreadConstraints" }}
topologySpreadConstraints:
{{ tpl .Values.topologySpreadConstraints . | nindent 6 | trim }}
{{- else if hasKey $.Values.global "topologySpreadConstraints" }}
{{- else if hasKey $.Values.global.memcached "topologySpreadConstraints" }}
topologySpreadConstraints:
{{ tpl $.Values.global.topologySpreadConstraints . | nindent 6 | trim }}
{{ tpl $.Values.global.memcached.topologySpreadConstraints . | nindent 6 | trim }}
{{- end }}
hostname: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
restartPolicy: {{ .Values.restartPolicy | default .Values.global.restartPolicy}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,31 @@ kind: Deployment
metadata:
labels:
{{- include "hotel-reservation.labels" . | nindent 4 }}
{{- include "hotel-reservation.backendLabels" . | nindent 4 }}
service: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
name: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
spec:
replicas: {{ .Values.replicas | default .Values.global.replicas }}
selector:
matchLabels:
{{- include "hotel-reservation.selectorLabels" . | nindent 6 }}
{{- include "hotel-reservation.backendLabels" . | nindent 6 }}
service: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
app: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
template:
metadata:
labels:
{{- include "hotel-reservation.labels" . | nindent 8 }}
{{- include "hotel-reservation.backendLabels" . | nindent 8 }}
service: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
app: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
{{- if hasKey $.Values "annotations" }}
annotations:
{{ tpl $.Values.annotations . | nindent 8 | trim }}
{{- else if hasKey $.Values.global "annotations" }}
annotations:
{{ tpl $.Values.global.annotations . | nindent 8 | trim }}
{{- end }}
spec:
containers:
{{- with .Values.container }}
Expand Down Expand Up @@ -61,9 +71,9 @@ spec:
{{- if hasKey .Values "topologySpreadConstraints" }}
topologySpreadConstraints:
{{ tpl .Values.topologySpreadConstraints . | nindent 6 | trim }}
{{- else if hasKey $.Values.global "topologySpreadConstraints" }}
{{- else if hasKey $.Values.global.mongodb "topologySpreadConstraints" }}
topologySpreadConstraints:
{{ tpl $.Values.global.topologySpreadConstraints . | nindent 6 | trim }}
{{ tpl $.Values.global.mongodb.topologySpreadConstraints . | nindent 6 | trim }}
{{- end }}
hostname: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
restartPolicy: {{ .Values.restartPolicy | default .Values.global.restartPolicy}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ spec:
{{- include "hotel-reservation.labels" . | nindent 8 }}
service: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
app: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}
{{- if hasKey $.Values "annotations" }}
annotations:
{{ tpl $.Values.annotations . | nindent 8 | trim }}
{{- else if hasKey $.Values.global "annotations" }}
annotations:
{{ tpl $.Values.global.annotations . | nindent 8 | trim }}
{{- end }}
spec:
containers:
{{- with .Values.container }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{{- define "hotelreservation.templates.basePersistentVolumeClaim" }}
{{- if .Values.global.mongodb.persistentVolume.pvprovisioner.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.name }}-{{ include "hotel-reservation.fullname" . }}-pvc
spec:
{{- if .Values.global.mongodb.persistentVolume.pvprovisioner.enabled }}
{{- if .Values.global.mongodb.persistentVolume.pvprovisioner.storageClassName }}
storageClassName: {{ .Values.global.mongodb.persistentVolume.pvprovisioner.storageClassName }}
{{- end }}
{{- end }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.global.mongodb.persistentVolume.size }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,10 @@ Usage:
{{- end }}
{{- join "," $addrlist | toJson }}
{{- end }}

{{/*
Backend labels
*/}}
{{- define "hotel-reservation.backendLabels" -}}
backend: {{ .Chart.Name | regexFind "[^-]*" }}
{{- end }}

0 comments on commit bcaeae4

Please sign in to comment.