Skip to content

Commit

Permalink
helm chart: Add service account support (#624)
Browse files Browse the repository at this point in the history
* helm: Add service account support in common services

1. Add service account creation support, disabled by default.

2. Add support of sharing the same service account by setting
   global.sharedSAName, disabled by default.

Signed-off-by: Lianhao Lu <[email protected]>

* helm: Add service account support in e2e charts

1. Add service account creation support, enabled by default.

2. Add support of sharing the same service account by setting
   global.sharedSAName, enabled by default.

Signed-off-by: Lianhao Lu <[email protected]>

---------

Signed-off-by: Lianhao Lu <[email protected]>
  • Loading branch information
lianhao authored Dec 10, 2024
1 parent 7219249 commit 9bb7c3a
Show file tree
Hide file tree
Showing 127 changed files with 1,219 additions and 86 deletions.
4 changes: 3 additions & 1 deletion helm-charts/agentqna/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "agentqna.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- if .Values.global.sharedSAName }}
{{- .Values.global.sharedSAName }}
{{- else if .Values.serviceAccount.create }}
{{- default (include "agentqna.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
Expand Down
1 change: 1 addition & 0 deletions helm-charts/agentqna/templates/crag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "agentqna.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand Down
1 change: 1 addition & 0 deletions helm-charts/agentqna/templates/docretriever.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "agentqna.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand Down
16 changes: 16 additions & 0 deletions helm-charts/agentqna/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "agentqna.serviceAccountName" . }}
labels:
{{- include "agentqna.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
24 changes: 24 additions & 0 deletions helm-charts/agentqna/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@

replicaCount: 1

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
Expand Down Expand Up @@ -102,6 +122,10 @@ global:
https_proxy: ""
no_proxy: ""
HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here"
# service account name to be shared with all parent/child charts.
# If set, it will overwrite serviceAccount.name.
# If set, and serviceAccount.create is false, it will assume this service account is already created by others.
sharedSAName: "agentqna"
# set modelUseHostPath or modelUsePVC to use model cache.
modelUseHostPath: ""
# modelUseHostPath: /mnt/opea-models
Expand Down
4 changes: 3 additions & 1 deletion helm-charts/audioqna/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "audioqna.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- if .Values.global.sharedSAName }}
{{- .Values.global.sharedSAName }}
{{- else if .Values.serviceAccount.create }}
{{- default (include "audioqna.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
Expand Down
1 change: 1 addition & 0 deletions helm-charts/audioqna/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "audioqna.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand Down
16 changes: 16 additions & 0 deletions helm-charts/audioqna/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "audioqna.serviceAccountName" . }}
labels:
{{- include "audioqna.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
38 changes: 31 additions & 7 deletions helm-charts/audioqna/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@ image:
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

port: 8888
service:
type: ClusterIP
port: 3008
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

nginx:
service:
type: NodePort
serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext:
readOnlyRootFilesystem: true
Expand All @@ -34,6 +45,15 @@ securityContext:
seccompProfile:
type: RuntimeDefault

port: 8888
service:
type: ClusterIP
port: 3008

nginx:
service:
type: NodePort

nodeSelector: {}

tolerations: []
Expand All @@ -57,6 +77,10 @@ global:
https_proxy: ""
no_proxy: ""
HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here"
# service account name to be shared with all parent/child charts.
# If set, it will overwrite serviceAccount.name.
# If set, and serviceAccount.create is false, it will assume this service account is already created by others.
sharedSAName: "audioqna"
# set modelUseHostPath or modelUsePVC to use model cache.
modelUseHostPath: ""
# modelUseHostPath: /mnt/opea-models
Expand Down
4 changes: 3 additions & 1 deletion helm-charts/chatqna/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "chatqna.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- if .Values.global.sharedSAName }}
{{- .Values.global.sharedSAName }}
{{- else if .Values.serviceAccount.create }}
{{- default (include "chatqna.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
Expand Down
1 change: 1 addition & 0 deletions helm-charts/chatqna/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "chatqna.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand Down
16 changes: 16 additions & 0 deletions helm-charts/chatqna/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "chatqna.serviceAccountName" . }}
labels:
{{- include "chatqna.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
40 changes: 32 additions & 8 deletions helm-charts/chatqna/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@ image:
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

port: 8888
service:
type: ClusterIP
port: 8888

nginx:
service:
type: NodePort
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext:
readOnlyRootFilesystem: true
Expand All @@ -34,6 +45,15 @@ securityContext:
seccompProfile:
type: RuntimeDefault

port: 8888
service:
type: ClusterIP
port: 8888

nginx:
service:
type: NodePort

nodeSelector: {}

tolerations: []
Expand Down Expand Up @@ -67,6 +87,10 @@ global:
https_proxy: ""
no_proxy: ""
HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here"
# service account name to be shared with all parent/child charts.
# If set, it will overwrite serviceAccount.name.
# If set, and serviceAccount.create is false, it will assume this service account is already created by others.
sharedSAName: "chatqna"
# set modelUseHostPath or modelUsePVC to use model cache.
modelUseHostPath: ""
# modelUseHostPath: /mnt/opea-models
Expand Down
4 changes: 3 additions & 1 deletion helm-charts/codegen/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "codegen.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- if .Values.global.sharedSAName }}
{{- .Values.global.sharedSAName }}
{{- else if .Values.serviceAccount.create }}
{{- default (include "codegen.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
Expand Down
1 change: 1 addition & 0 deletions helm-charts/codegen/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "codegen.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand Down
16 changes: 16 additions & 0 deletions helm-charts/codegen/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "codegen.serviceAccountName" . }}
labels:
{{- include "codegen.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
38 changes: 31 additions & 7 deletions helm-charts/codegen/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@ image:
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

port: 7778
service:
type: ClusterIP
port: 7778
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

nginx:
service:
type: NodePort
serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext:
readOnlyRootFilesystem: true
Expand All @@ -34,6 +45,15 @@ securityContext:
seccompProfile:
type: RuntimeDefault

port: 7778
service:
type: ClusterIP
port: 7778

nginx:
service:
type: NodePort

nodeSelector: {}

tolerations: []
Expand All @@ -56,6 +76,10 @@ global:
https_proxy: ""
no_proxy: ""
HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here"
# service account name to be shared with all parent/child charts.
# If set, it will overwrite serviceAccount.name.
# If set, and serviceAccount.create is false, it will assume this service account is already created by others.
sharedSAName: "codegen"
# set modelUseHostPath or modelUsePVC to use model cache.
modelUseHostPath: ""
# modelUseHostPath: /mnt/opea-models
Expand Down
4 changes: 3 additions & 1 deletion helm-charts/codetrans/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "codetrans.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- if .Values.global.sharedSAName }}
{{- .Values.global.sharedSAName }}
{{- else if .Values.serviceAccount.create }}
{{- default (include "codetrans.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
Expand Down
1 change: 1 addition & 0 deletions helm-charts/codetrans/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "codetrans.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand Down
Loading

0 comments on commit 9bb7c3a

Please sign in to comment.