Skip to content

Commit

Permalink
[v14] teleport-kube-agent: Propagate resources to post-install and po…
Browse files Browse the repository at this point in the history
…st-delete Jobs (#47748)

* teleport-kube-agent: Propagate resources to post-install and post-delete Jobs (#47677)

* Update snapshots

* Update snapshots
  • Loading branch information
webvictim authored Nov 12, 2024
1 parent 882ee26 commit ce5c1b4
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/chart/teleport-kube-agent/templates/delete_hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,6 @@ spec:
{{- if .Values.securityContext }}
securityContext: {{- toYaml .Values.securityContext | nindent 10 }}
{{- end }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 10 }}
{{- end }}
3 changes: 3 additions & 0 deletions examples/chart/teleport-kube-agent/templates/hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,7 @@ spec:
{{- if .Values.securityContext }}
securityContext: {{- toYaml .Values.securityContext | nindent 10 }}
{{- end }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 10 }}
{{- end }}
{{- end}}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,41 @@ should set nodeSelector in post-delete hook:
gravitational.io/k8s-role: node
restartPolicy: OnFailure
serviceAccountName: RELEASE-NAME-delete-hook
should set resources in the Job's pod spec if resources is set in values:
1: |
containers:
- args:
- kube-state
- delete
command:
- teleport
env:
- name: KUBE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: RELEASE_NAME
value: RELEASE-NAME
image: public.ecr.aws/gravitational/teleport-distroless:14.3.33
imagePullPolicy: IfNotPresent
name: post-delete-job
resources:
limits:
cpu: 2
memory: 4Gi
requests:
cpu: 1
memory: 2Gi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 9807
restartPolicy: OnFailure
serviceAccountName: RELEASE-NAME-delete-hook
should set securityContext in post-delete hook:
1: |
containers:
Expand Down
32 changes: 32 additions & 0 deletions examples/chart/teleport-kube-agent/tests/job_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,35 @@ tests:
value:
app: RELEASE-NAME
testLabel: testValue

- it: should set resources in the Job's pod spec if resources is set in values
template: delete_hook.yaml
# documentIndex: 0=ServiceAccount 1=Role 2=RoleBinding 3=Job
documentIndex: 3
values:
- ../.lint/backwards-compatibility.yaml
set:
# These are just sample values to test the chart.
# They are not intended to be guidelines or suggestions for running teleport.
resources:
limits:
cpu: 2
memory: 4Gi
requests:
cpu: 1
memory: 2Gi
asserts:
- equal:
path: spec.template.spec.containers[0].resources.limits.cpu
value: 2
- equal:
path: spec.template.spec.containers[0].resources.limits.memory
value: 4Gi
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 1
- equal:
path: spec.template.spec.containers[0].resources.requests.memory
value: 2Gi
- matchSnapshot:
path: spec.template.spec

0 comments on commit ce5c1b4

Please sign in to comment.