Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat(chart): Add labels.common helm value to easily put labels on all resources #91

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}
{{- end }}

{{- define "renderLabels" -}}
{{- range $key, $value := . -}}
{{ $key }}: {{ $value }}
{{- end -}}
{{- end -}}
29 changes: 16 additions & 13 deletions chart/templates/ad-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ limitations under the License.
apiVersion: v1
kind: Service
metadata:
name: unguard-{{.Values.adService.name}}
name: unguard-{{ .Values.adService.name }}
labels:
app.kubernetes.io/name: {{.Values.adService.name}}
app.kubernetes.io/name: {{ .Values.adService.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 4 }}
spec:
type: {{ .Values.adService.service.type }}
selector:
app.kubernetes.io/name: {{.Values.adService.name}}
app.kubernetes.io/name: {{ .Values.adService.name }}
app.kubernetes.io/part-of: unguard
ports:
{{- .Values.adService.service.ports | toYaml | nindent 4 }}
Expand All @@ -32,29 +33,31 @@ spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: unguard-{{.Values.adService.name}}
name: unguard-{{ .Values.adService.name }}
labels:
app.kubernetes.io/name: {{.Values.adService.name}}
app.kubernetes.io/name: {{ .Values.adService.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{.Values.adService.name}}
app.kubernetes.io/name: {{ .Values.adService.name }}
app.kubernetes.io/part-of: unguard
strategy:
type: {{.Values.adService.deployment.strategy.type}}
type: {{ .Values.adService.deployment.strategy.type }}
template:
metadata:
labels:
app.kubernetes.io/name: {{.Values.adService.name}}
app.kubernetes.io/name: {{ .Values.adService.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 8 }}
spec:
containers:
- name: {{.Values.adService.name}}
image: {{.Values.adService.deployment.container.image.repository}}:{{.Values.adService.deployment.container.image.tag}}
imagePullPolicy: {{.Values.adService.deployment.container.image.pullPolicy}}
- name: {{ .Values.adService.name }}
image: {{ .Values.adService.deployment.container.image.repository }}:{{ .Values.adService.deployment.container.image.tag }}
imagePullPolicy: {{ .Values.adService.deployment.container.image.pullPolicy }}
ports:
- containerPort: {{.Values.adService.deployment.container.ports.containerPort}}
- containerPort: {{ .Values.adService.deployment.container.ports.containerPort }}
env:
- name: ASPNETCORE_ENVIRONMENT
value: {{ quote .Values.adService.deployment.container.env.ASPNETCORE_ENVIRONMENT }}
Expand All @@ -65,7 +68,7 @@ spec:
- name: USER_AUTH_SERVICE_ADDRESS
value: {{ quote .Values.adService.deployment.container.env.USER_AUTH_SERVICE_ADDRESS }}
- name: JAEGER_SERVICE_NAME
value: {{quote (printf "unguard-%s" .Values.adService.name) }}
value: {{ quote (printf "unguard-%s" .Values.adService.name) }}
- name: JAEGER_AGENT_HOST
value: {{ quote (printf "%s-%s" .Values.jaeger.name .Values.adService.deployment.container.env.JAEGER_AGENT_HOST) }}
- name: JAEGER_SAMPLER_TYPE
Expand Down
31 changes: 17 additions & 14 deletions chart/templates/envoy-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ limitations under the License.
apiVersion: v1
kind: Service
metadata:
name: unguard-{{.Values.envoyProxy.name}}
name: unguard-{{ .Values.envoyProxy.name }}
labels:
app.kubernetes.io/name: {{.Values.envoyProxy.name}}
app.kubernetes.io/name: {{ .Values.envoyProxy.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 4 }}
spec:
{{if .Values.aws.enabled}}
{{ if .Values.aws.enabled }}
type: NodePort
{{else}}
{{ else }}
type: {{ .Values.envoyProxy.service.type }}
{{end}}
{{ end }}
selector:
app.kubernetes.io/name: {{.Values.envoyProxy.name}}
app.kubernetes.io/name: {{ .Values.envoyProxy.name }}
app.kubernetes.io/part-of: unguard
ports:
{{- .Values.envoyProxy.service.ports | toYaml | nindent 4 }}
Expand All @@ -37,26 +38,28 @@ spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: unguard-{{.Values.envoyProxy.name}}
name: unguard-{{ .Values.envoyProxy.name }}
labels:
app.kubernetes.io/name: {{.Values.envoyProxy.name}}
app.kubernetes.io/name: {{ .Values.envoyProxy.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{.Values.envoyProxy.name}}
app.kubernetes.io/name: {{ .Values.envoyProxy.name }}
app.kubernetes.io/part-of: unguard
strategy:
type: {{.Values.envoyProxy.deployment.strategy.type}}
type: {{ .Values.envoyProxy.deployment.strategy.type }}
template:
metadata:
labels:
app.kubernetes.io/name: {{.Values.envoyProxy.name}}
app.kubernetes.io/name: {{ .Values.envoyProxy.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 8 }}
spec:
containers:
- name: {{.Values.envoyProxy.name}}
image: {{.Values.envoyProxy.deployment.container.image.repository}}:{{.Values.envoyProxy.deployment.container.image.tag}}
imagePullPolicy: {{.Values.envoyProxy.deployment.container.image.pullPolicy}}
- name: {{ .Values.envoyProxy.name }}
image: {{ .Values.envoyProxy.deployment.container.image.repository }}:{{ .Values.envoyProxy.deployment.container.image.tag }}
imagePullPolicy: {{ .Values.envoyProxy.deployment.container.image.pullPolicy }}
ports:
{{- .Values.envoyProxy.deployment.container.ports | toYaml | nindent 12 }}
29 changes: 16 additions & 13 deletions chart/templates/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ limitations under the License.
apiVersion: v1
kind: Service
metadata:
name: unguard-{{.Values.frontend.name}}
name: unguard-{{ .Values.frontend.name }}
labels:
app.kubernetes.io/name: {{.Values.frontend.name}}
app.kubernetes.io/name: {{ .Values.frontend.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 4 }}
spec:
type: {{ .Values.frontend.service.type }}
selector:
app.kubernetes.io/name: {{.Values.frontend.name}}
app.kubernetes.io/name: {{ .Values.frontend.name }}
app.kubernetes.io/part-of: unguard
ports:
{{- .Values.frontend.service.ports | toYaml | nindent 4 }}
Expand All @@ -33,29 +34,31 @@ spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: unguard-{{.Values.frontend.name}}
name: unguard-{{ .Values.frontend.name }}
labels:
app.kubernetes.io/name: {{.Values.frontend.name}}
app.kubernetes.io/name: {{ .Values.frontend.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{.Values.frontend.name}}
app.kubernetes.io/name: {{ .Values.frontend.name }}
app.kubernetes.io/part-of: unguard
strategy:
type: {{.Values.frontend.deployment.strategy.type}}
type: {{ .Values.frontend.deployment.strategy.type }}
template:
metadata:
labels:
app.kubernetes.io/name: {{.Values.frontend.name}}
app.kubernetes.io/name: {{ .Values.frontend.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 8 }}
spec:
containers:
- name: {{.Values.frontend.name}}
image: {{.Values.frontend.deployment.container.image.repository}}:{{.Values.frontend.deployment.container.image.tag}}
imagePullPolicy: {{.Values.frontend.deployment.container.image.pullPolicy}}
- name: {{ .Values.frontend.name }}
image: {{ .Values.frontend.deployment.container.image.repository }}:{{ .Values.frontend.deployment.container.image.tag }}
imagePullPolicy: {{ .Values.frontend.deployment.container.image.pullPolicy }}
ports:
- containerPort: {{.Values.frontend.deployment.container.ports.containerPort}}
- containerPort: {{ .Values.frontend.deployment.container.ports.containerPort }}
env:
- name: MICROBLOG_SERVICE_ADDRESS
value: {{ quote .Values.frontend.deployment.container.env.MICROBLOG_SERVICE_ADDRESS }}
Expand Down Expand Up @@ -84,7 +87,7 @@ spec:
- name: STATUS_SERVICE_BASE_PATH
value: {{ quote .Values.frontend.deployment.container.env.STATUS_SERVICE_BASE_PATH }}
- name: JAEGER_SERVICE_NAME
value: {{quote (printf "unguard-%s" .Values.frontend.name) }}
value: {{ quote (printf "unguard-%s" .Values.frontend.name) }}
- name: JAEGER_AGENT_HOST
value: {{ quote (printf "%s-%s" .Values.jaeger.name .Values.frontend.deployment.container.env.JAEGER_AGENT_HOST) }}
- name: JAEGER_SAMPLER_TYPE
Expand Down
23 changes: 12 additions & 11 deletions chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@ limitations under the License.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: unguard-{{.Values.ingress.name}}
name: unguard-{{ .Values.ingress.name }}
labels:
app.kubernetes.io/name: {{.Values.ingress.name}}
app.kubernetes.io/name: {{ .Values.ingress.name }}
app.kubernetes.io/part-of: unguard
{{if .Values.aws.enabled}}
{{ include "renderLabels" .Values.labels.common | indent 4 }}
{{ if .Values.aws.enabled }}
annotations:
{{- .Values.aws.ingress.annotations | toYaml | nindent 4 }}
{{end}}
{{ end }}
spec:
rules:
{{if .Values.localDev.enabled}}
{{ if .Values.localDev.enabled }}
- host: unguard.kube
{{end}}
{{if .Values.localDev.enabled}}
{{ end }}
{{ if .Values.localDev.enabled }}
http:
{{end}}
{{if .Values.aws.enabled}}
{{ end }}
{{ if .Values.aws.enabled }}
- http:
{{end}}
{{ end }}
paths:
- path: /healthz
pathType: Prefix
Expand All @@ -51,4 +52,4 @@ spec:
name: unguard-envoy-proxy
port:
number: 8080
{{end}}
{{ end }}
33 changes: 18 additions & 15 deletions chart/templates/like-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ limitations under the License.
apiVersion: v1
kind: Service
metadata:
name: unguard-{{.Values.likeService.name}}
name: unguard-{{ .Values.likeService.name }}
labels:
app.kubernetes.io/name: {{.Values.likeService.name}}
app.kubernetes.io/name: {{ .Values.likeService.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 4 }}
spec:
type: {{ .Values.likeService.service.type }}
selector:
app.kubernetes.io/name: {{.Values.likeService.name}}
app.kubernetes.io/name: {{ .Values.likeService.name }}
app.kubernetes.io/part-of: unguard
ports:
{{- .Values.likeService.service.ports | toYaml | nindent 4 }}
Expand All @@ -32,29 +33,31 @@ spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: unguard-{{.Values.likeService.name}}
name: unguard-{{ .Values.likeService.name }}
labels:
app.kubernetes.io/name: {{.Values.likeService.name}}
app.kubernetes.io/name: {{ .Values.likeService.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{.Values.likeService.name}}
app.kubernetes.io/name: {{ .Values.likeService.name }}
app.kubernetes.io/part-of: unguard
strategy:
type: {{.Values.likeService.deployment.strategy.type}}
type: {{ .Values.likeService.deployment.strategy.type }}
template:
metadata:
labels:
app.kubernetes.io/name: {{.Values.likeService.name}}
app.kubernetes.io/name: {{ .Values.likeService.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 8 }}
spec:
containers:
- name: {{.Values.likeService.name}}
image: {{.Values.likeService.deployment.container.image.repository}}:{{.Values.likeService.deployment.container.image.tag}}
imagePullPolicy: {{.Values.likeService.deployment.container.image.pullPolicy}}
- name: {{ .Values.likeService.name }}
image: {{ .Values.likeService.deployment.container.image.repository }}:{{ .Values.likeService.deployment.container.image.tag }}
imagePullPolicy: {{ .Values.likeService.deployment.container.image.pullPolicy }}
ports:
- containerPort: {{.Values.likeService.deployment.container.ports.containerPort}}
- containerPort: {{ .Values.likeService.deployment.container.ports.containerPort }}
env:
- name: SERVER_PORT
value: {{ quote .Values.likeService.deployment.container.env.SERVER_PORT }}
Expand All @@ -68,8 +71,8 @@ spec:
name: {{ tpl .Values.likeService.deployment.container.env.MARIADB_PASSWORD.secretKeyRef.name . }}
key: {{ tpl .Values.likeService.deployment.container.env.MARIADB_PASSWORD.secretKeyRef.key . }}
- name: JAEGER_SERVICE_NAME
value: {{quote (printf "unguard-%s" .Values.likeService.name) }}
{{if .Values.tracing.enabled}}
value: {{ quote (printf "unguard-%s" .Values.likeService.name) }}
{{ if .Values.tracing.enabled }}
- name: JAEGER_COLLECTOR_HOST
value: {{ quote (printf "%s-%s" .Values.jaeger.name .Values.likeService.deployment.container.env.JAEGER_COLLECTOR_HOST) }}
- name: JAEGER_PORT
Expand All @@ -78,4 +81,4 @@ spec:
value: {{ quote .Values.likeService.deployment.container.env.SERVICE_NAME }}
- name: JAEGER_DISABLED
value: {{ quote .Values.likeService.deployment.container.env.JAEGER_DISABLED }}
{{end}}
{{ end }}
26 changes: 14 additions & 12 deletions chart/templates/malicious-load-generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,35 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{if .Values.maliciousLoadGenerator.enabled}}
{{ if .Values.maliciousLoadGenerator.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: unguard-{{.Values.maliciousLoadGenerator.name}}
name: unguard-{{ .Values.maliciousLoadGenerator.name }}
labels:
app.kubernetes.io/name: {{.Values.maliciousLoadGenerator.name}}
app.kubernetes.io/name: {{ .Values.maliciousLoadGenerator.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{.Values.maliciousLoadGenerator.name}}
app.kubernetes.io/name: {{ .Values.maliciousLoadGenerator.name }}
app.kubernetes.io/part-of: unguard
strategy:
type: {{.Values.maliciousLoadGenerator.deployment.strategy.type}}
type: {{ .Values.maliciousLoadGenerator.deployment.strategy.type }}
template:
metadata:
labels:
app.kubernetes.io/name: {{.Values.maliciousLoadGenerator.name}}
app.kubernetes.io/name: {{ .Values.maliciousLoadGenerator.name }}
app.kubernetes.io/part-of: unguard
{{ include "renderLabels" .Values.labels.common | indent 8 }}
spec:
terminationGracePeriodSeconds: {{.Values.maliciousLoadGenerator.deployment.terminationGracePeriodSeconds}}
restartPolicy: {{.Values.maliciousLoadGenerator.deployment.restartPolicy}}
terminationGracePeriodSeconds: {{ .Values.maliciousLoadGenerator.deployment.terminationGracePeriodSeconds }}
restartPolicy: {{ .Values.maliciousLoadGenerator.deployment.restartPolicy }}
containers:
- name: {{.Values.maliciousLoadGenerator.name}}
image: {{.Values.maliciousLoadGenerator.deployment.container.image.repository}}:{{.Values.maliciousLoadGenerator.deployment.container.image.tag}}
imagePullPolicy: {{.Values.maliciousLoadGenerator.deployment.container.image.pullPolicy}}
- name: {{ .Values.maliciousLoadGenerator.name }}
image: {{ .Values.maliciousLoadGenerator.deployment.container.image.repository }}:{{ .Values.maliciousLoadGenerator.deployment.container.image.tag }}
imagePullPolicy: {{ .Values.maliciousLoadGenerator.deployment.container.image.pullPolicy }}
env: # could add here run time as well
- name: FRONTEND_ADDR
value: {{ quote .Values.maliciousLoadGenerator.deployment.container.env.FRONTEND_ADDR }}
Expand All @@ -53,4 +55,4 @@ spec:
command: [ "/bin/sh", "-c" ]
# TODO: #22 Replace this endpoint with a proper health check endpoint
args: [ 'while [ $(curl -ksw "%{http_code}" "http://unguard-frontend:80/ui/img/logo.svg" -o /dev/null) -ne 200 ]; do sleep 5; echo "health check failed . Waiting for the service..."; done' ]
{{end}}
{{ end }}
Loading
Loading