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

[Application] Support existing ServiceAccount name #144

Merged
merged 4 commits into from
Aug 30, 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
1 change: 1 addition & 0 deletions .github/workflows/conf/ct-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ all: true
debug: true
check-version-increment: true
helm-extra-args: '--timeout 120s'
namespace: test
11 changes: 6 additions & 5 deletions .github/workflows/pr-chart-lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ jobs:
echo "matrix<<EOF"
echo '{ "include": ['
[[ "${{ steps.changed-files.outputs.any_changed }}" == 'false' ]] && echo '{ "name": "lint" },'
echo '{ "name": "k8s-1.30", "kindest_image": "kindest/node:v1.30.0" },'
echo '{ "name": "k8s-1.29", "kindest_image": "kindest/node:v1.29.4" },'
echo '{ "name": "k8s-1.28", "kindest_image": "kindest/node:v1.28.9" },'
echo '{ "name": "k8s-1.27", "kindest_image": "kindest/node:v1.27.13" },'
echo '{ "name": "k8s-1.31", "kindest_image": "kindest/node:v1.31.0" },'
echo '{ "name": "k8s-1.30", "kindest_image": "kindest/node:v1.30.4" },'
echo '{ "name": "k8s-1.29", "kindest_image": "kindest/node:v1.29.8" },'
echo '{ "name": "k8s-1.28", "kindest_image": "kindest/node:v1.28.13" },'
echo '{ "name": "k8s-1.27", "kindest_image": "kindest/node:v1.27.16" },'
echo '{ "name": "k8s-1.26", "kindest_image": "kindest/node:v1.26.15" },'
echo '{ "name": "k8s-1.25", "kindest_image": "kindest/node:v1.25.16" }'
echo '] }'
Expand All @@ -60,7 +61,7 @@ jobs:
if: ${{ needs.prep_job.outputs.has_changes == 'true' }}
env:
# see https://github.com/kubernetes-sigs/kind/releases
kind_version: v0.23.0
kind_version: v0.24.0
strategy:
matrix: ${{ fromJson(needs.prep_job.outputs.matrix) }}
name: ${{ matrix.name }}
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/scripts/chart-test-prep/preconditions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ apiVersion: v1
kind: Namespace
metadata:
name: flux-system
---
apiVersion: v1
kind: Namespace
metadata:
name: test
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: name-me-butterfly
namespace: test
34 changes: 17 additions & 17 deletions chart-tests/application/ci/test-additional-port-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ resources:
limits:
cpu: 100m
memory: 100Mi
spec:
values:
container:
port: 8000
service:
port: 8000
backendConfig:
enabled: true
securityPolicyName: uri-path-policy
additionalPorts:
- name: https
protocol: TCP
containerPort: 8081
servicePort: 81
- name: grpc
protocol: TCP
containerPort: 8082
container:
port: 8000
service:
port: 8000
backendConfig:
enabled: true
securityPolicyName: uri-path-policy
configuration:
HTTP_PORT: 8000
additionalPorts:
- name: https
protocol: TCP
containerPort: 8081
servicePort: 81
- name: grpc
protocol: TCP
containerPort: 8082
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
requests:
cpu: 10m
memory: 50Mi
limits:
cpu: 100m
memory: 100Mi
serviceAccount:
existingServiceAccountName: name-me-butterfly
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ autoscaling:

image:
repository: quay.io/heubeck/examiner
tag: 1.13.1
tag: 1.13.3
pullPolicy: IfNotPresent

# ImagePolicy and check period for automated updates
Expand Down
4 changes: 2 additions & 2 deletions chart-tests/application/ci/test-sidecar-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sidecars:
- name: sidekick
image:
repository: quay.io/heubeck/examiner
tag: 1.13.1
tag: 1.13.3
env:
ECHO_VALUE: yehaaa
QUARKUS_HTTP_PORT: 9090
Expand All @@ -31,7 +31,7 @@ sidecars:
- name: kickback
image:
repository: quay.io/heubeck/examiner
tag: 1.13.1
tag: 1.13.3
env:
ECHO_VALUE: wohooo
QUARKUS_HTTP_PORT: 7070
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sidecars:
- name: sidekick
image:
repository: quay.io/heubeck/examiner
tag: 1.13.1
tag: 1.13.3
env:
ECHO_VALUE: yehaaa
QUARKUS_HTTP_PORT: 9090
Expand All @@ -34,7 +34,7 @@ sidecars:
- name: kickback
image:
repository: quay.io/heubeck/examiner
tag: 1.13.1
tag: 1.13.3
env:
ECHO_VALUE: wohooo
QUARKUS_HTTP_PORT: 7070
Expand Down
2 changes: 1 addition & 1 deletion charts/application/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ maintainers:
- name: MediaMarktSaturn
url: https://github.com/MediaMarktSaturn
appVersion: 1.0.0
version: 1.23.0
version: 1.24.0
2 changes: 1 addition & 1 deletion charts/application/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Generic application chart with common requirements of a typical workload.
| readinessProbe.failureThreshold | int | `3` | |
| readinessProbe.timeoutSeconds | int | `5` | |
| image.repository | string | `"quay.io/heubeck/examiner"` | |
| image.tag | string | `"1.13.1"` | |
| image.tag | string | `"1.13.3"` | |
| image.digest | string | `nil` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.tagSemverRange | string | `nil` | |
Expand Down
11 changes: 11 additions & 0 deletions charts/application/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ Selector labels
{{ include "commonLabels" . }}
{{ include "selectorLabels" . }}
{{- end -}}

{{/*
ServiceAccount name
*/}}
{{- define "serviceAccountName" -}}
{{- if .Values.serviceAccount.existingServiceAccountName -}}
{{- .Values.serviceAccount.existingServiceAccountName | quote -}}
{{- else -}}
{{- .Release.Name -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/application/templates/_podTemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ metadata:
{{- end }}
{{- end }}
spec:
serviceAccountName: {{ .Release.Name }}
serviceAccountName: {{ include "serviceAccountName" . }}
{{- if .Values.podSecurityContext }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 4 }}
Expand Down
4 changes: 3 additions & 1 deletion charts/application/templates/k8s-service-account.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{{- if not .Values.serviceAccount.existingServiceAccountName }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}
name: {{ include "serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "labels" . | nindent 4 }}
Expand All @@ -10,3 +11,4 @@ metadata:
iam.gke.io/gcp-service-account: {{ .Values.serviceAccount.workloadIdentityServiceAccount }}
{{- end }}
automountServiceAccountToken: {{ or .Values.serviceAccount.automountServiceAccountToken (not (empty .Values.serviceAccount.rbac)) }}
{{- end }}
14 changes: 11 additions & 3 deletions charts/application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ readinessProbe:

image:
repository: quay.io/heubeck/examiner
tag: 1.13.1
tag: 1.13.3
# When image.digest is set the image.tag, imagepolicy and imagerepository is ignored
# e.g. "sha256:b187aed68cc8c75f475efe8aebcc61fc7ca0c5adc2d2c5b8318997c3edc8d32f"
digest:
Expand Down Expand Up @@ -150,6 +150,14 @@ encryptedSecret:
mountPath:

serviceAccount:
# giving an `existingServiceAccountName` will map that one instead of creating a new one; the refered SA must already exist
## you may want to manual set:
## ```
## nodeSelector:
## iam.gke.io/gke-metadata-server-enabled: "true"
## ```
## if using workload identity with your own SA (done automatically when using `workloadIdentityServiceAccount` for automatically created SA)
existingServiceAccountName:
# service account email address for use with workload identity, see https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity
workloadIdentityServiceAccount:
# secret containing a 'key.json' of the GCP service account key to be used by this app
Expand Down Expand Up @@ -268,7 +276,7 @@ prepJob:
command: []
# key/value pairs that will be bound as env
configuration: {}
# pre-existing service account to be used
# pre-existing service account to be used (as automatically created one does not exist yet on-install of helm release)
serviceAccountName:
resources: {}
# requests:
Expand Down Expand Up @@ -311,7 +319,7 @@ sidecars: []
# - name: sqlproxy
# image:
# repository: quay.io/heubeck/examiner
# tag: 1.13.1
# tag: 1.13.3
# args: []
# env: {}
# configEnvFrom: []
Expand Down
Loading