-
Notifications
You must be signed in to change notification settings - Fork 14
ROSAENG-130 | feat: add support for AWS podidentity #67
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,10 +37,20 @@ spec: | |
| - name: db-migrate | ||
| image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
| imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
| command: ["/app/hyperfleet-api", "migrate"] | ||
| command: | ||
| - /app/hyperfleet-api | ||
| - migrate | ||
| {{- if and .Values.database.external.enabled .Values.database.external.usePodIdentity }} | ||
| - --db-host-file={{ .Values.database.external.secretMountPath }}/db.host | ||
| - --db-port-file={{ .Values.database.external.secretMountPath }}/db.port | ||
| - --db-name-file={{ .Values.database.external.secretMountPath }}/db.name | ||
| - --db-user-file={{ .Values.database.external.secretMountPath }}/db.user | ||
| - --db-password-file={{ .Values.database.external.secretMountPath }}/db.password | ||
| - --db-sslmode={{ .Values.database.external.sslMode | default "require" }} | ||
| {{- end }} | ||
| volumeMounts: | ||
| - name: secrets | ||
| mountPath: /build/secrets | ||
| mountPath: {{ if and .Values.database.external.enabled .Values.database.external.usePodIdentity }}{{ .Values.database.external.secretMountPath }}{{ else }}/build/secrets{{ end }} | ||
| readOnly: true | ||
| {{- end }} | ||
| containers: | ||
|
|
@@ -55,6 +65,14 @@ spec: | |
| - --api-server-bindaddress={{ .Values.server.bindAddress | default ":8000" }} | ||
| - --health-server-bindaddress={{ .Values.server.healthBindAddress | default ":8080" }} | ||
| - --metrics-server-bindaddress={{ .Values.server.metricsBindAddress | default ":9090" }} | ||
| {{- if and .Values.database.external.enabled .Values.database.external.usePodIdentity }} | ||
| - --db-host-file={{ .Values.database.external.secretMountPath }}/db.host | ||
| - --db-port-file={{ .Values.database.external.secretMountPath }}/db.port | ||
| - --db-name-file={{ .Values.database.external.secretMountPath }}/db.name | ||
| - --db-user-file={{ .Values.database.external.secretMountPath }}/db.user | ||
| - --db-password-file={{ .Values.database.external.secretMountPath }}/db.password | ||
| - --db-sslmode={{ .Values.database.external.sslMode | default "require" }} | ||
| {{- end }} | ||
| ports: | ||
| - name: http | ||
| containerPort: 8000 | ||
|
|
@@ -113,7 +131,7 @@ spec: | |
| mountPath: /tmp | ||
| {{- if or .Values.database.external.enabled .Values.database.postgresql.enabled }} | ||
| - name: secrets | ||
| mountPath: /build/secrets | ||
| mountPath: {{ if and .Values.database.external.enabled .Values.database.external.usePodIdentity }}{{ .Values.database.external.secretMountPath }}{{ else }}/build/secrets{{ end }} | ||
| readOnly: true | ||
| {{- end }} | ||
| {{- if .Values.extraVolumeMounts }} | ||
|
|
@@ -124,13 +142,21 @@ spec: | |
| emptyDir: {} | ||
| {{- if or .Values.database.external.enabled .Values.database.postgresql.enabled }} | ||
| - name: secrets | ||
| {{- if and .Values.database.external.enabled .Values.database.external.usePodIdentity }} | ||
| csi: | ||
| driver: secrets-store.csi.k8s.io | ||
| readOnly: true | ||
| volumeAttributes: | ||
| secretProviderClass: {{ ternary (printf "%s-db-secrets" (include "hyperfleet-api.fullname" .)) .Values.database.external.secretProviderClass .Values.database.external.createSecretProviderClass | quote }} | ||
| {{- else }} | ||
|
Comment on lines
+145
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a render-time guard for empty At Line 150, if 🔧 Proposed fix - name: secrets
{{- if and .Values.database.external.enabled .Values.database.external.usePodIdentity }}
+ {{- $spcName := ternary (printf "%s-db-secrets" (include "hyperfleet-api.fullname" .)) .Values.database.external.secretProviderClass .Values.database.external.createSecretProviderClass }}
+ {{- if empty $spcName }}
+ {{- fail "database.external.secretProviderClass is required when usePodIdentity=true and createSecretProviderClass=false" }}
+ {{- end }}
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
- secretProviderClass: {{ ternary (printf "%s-db-secrets" (include "hyperfleet-api.fullname" .)) .Values.database.external.secretProviderClass .Values.database.external.createSecretProviderClass | quote }}
+ secretProviderClass: {{ $spcName | quote }}
{{- else }}🤖 Prompt for AI Agents
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🧠 Learnings used |
||
| secret: | ||
| {{- if .Values.database.external.enabled }} | ||
| secretName: {{ .Values.database.external.secretName }} | ||
| {{- else }} | ||
| secretName: {{ include "hyperfleet-api.fullname" . }}-db-secrets | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .Values.extraVolumes }} | ||
| {{- toYaml .Values.extraVolumes | nindent 6 }} | ||
| {{- end }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||||||||||||||||||||||||||||||||||||||
| {{- if and .Values.database.external.enabled .Values.database.external.usePodIdentity .Values.database.external.createSecretProviderClass }} | ||||||||||||||||||||||||||||||||||||||||||
| apiVersion: secrets-store.csi.x-k8s.io/v1 | ||||||||||||||||||||||||||||||||||||||||||
| kind: SecretProviderClass | ||||||||||||||||||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||||||||||||||||||
| name: {{ include "hyperfleet-api.fullname" . }}-db-secrets | ||||||||||||||||||||||||||||||||||||||||||
| namespace: {{ .Release.Namespace }} | ||||||||||||||||||||||||||||||||||||||||||
| labels: | ||||||||||||||||||||||||||||||||||||||||||
| {{- include "hyperfleet-api.labels" . | nindent 4 }} | ||||||||||||||||||||||||||||||||||||||||||
| spec: | ||||||||||||||||||||||||||||||||||||||||||
| provider: aws | ||||||||||||||||||||||||||||||||||||||||||
| parameters: | ||||||||||||||||||||||||||||||||||||||||||
| usePodIdentity: "true" | ||||||||||||||||||||||||||||||||||||||||||
| region: {{ .Values.database.external.aws.region | quote }} | ||||||||||||||||||||||||||||||||||||||||||
| objects: | | ||||||||||||||||||||||||||||||||||||||||||
| - objectName: {{ .Values.database.external.aws.secretName | quote }} | ||||||||||||||||||||||||||||||||||||||||||
| objectType: "secretsmanager" | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fail fast when AWS SecretProviderClass inputs are empty. At Line 13 and Line 15, empty 🔧 Proposed fix {{- if and .Values.database.external.enabled .Values.database.external.usePodIdentity .Values.database.external.createSecretProviderClass }}
+{{- $awsRegion := required "database.external.aws.region is required when createSecretProviderClass=true" .Values.database.external.aws.region }}
+{{- $awsSecretName := required "database.external.aws.secretName is required when createSecretProviderClass=true" .Values.database.external.aws.secretName }}
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
@@
spec:
provider: aws
parameters:
usePodIdentity: "true"
- region: {{ .Values.database.external.aws.region | quote }}
+ region: {{ $awsRegion | quote }}
objects: |
- - objectName: {{ .Values.database.external.aws.secretName | quote }}
+ - objectName: {{ $awsSecretName | quote }}
objectType: "secretsmanager"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
{{- if and .Values.database.external.enabled .Values.database.external.usePodIdentity .Values.database.external.createSecretProviderClass }}
{{- $awsRegion := required "database.external.aws.region is required when createSecretProviderClass=true" .Values.database.external.aws.region }}
{{- $awsSecretName := required "database.external.aws.secretName is required when createSecretProviderClass=true" .Values.database.external.aws.secretName }}
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: {{ include "hyperfleet-api.fullname" . }}-db-secrets
namespace: {{ .Release.Namespace }}
labels:
{{- include "hyperfleet-api.labels" . | nindent 4 }}
spec:
provider: aws
parameters:
usePodIdentity: "true"
region: {{ $awsRegion | quote }}
objects: |
- objectName: {{ $awsSecretName | quote }}
objectType: "secretsmanager"Using 🧠 Learnings used |
||||||||||||||||||||||||||||||||||||||||||
| jmesPath: | ||||||||||||||||||||||||||||||||||||||||||
| - path: "username" | ||||||||||||||||||||||||||||||||||||||||||
| objectAlias: "db.user" | ||||||||||||||||||||||||||||||||||||||||||
| - path: "password" | ||||||||||||||||||||||||||||||||||||||||||
| objectAlias: "db.password" | ||||||||||||||||||||||||||||||||||||||||||
| - path: "host" | ||||||||||||||||||||||||||||||||||||||||||
| objectAlias: "db.host" | ||||||||||||||||||||||||||||||||||||||||||
| - path: "port" | ||||||||||||||||||||||||||||||||||||||||||
| objectAlias: "db.port" | ||||||||||||||||||||||||||||||||||||||||||
| - path: "database" | ||||||||||||||||||||||||||||||||||||||||||
| objectAlias: "db.name" | ||||||||||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.