Skip to content

Commit

Permalink
fix: refactor deployment templates to use common port definitions and…
Browse files Browse the repository at this point in the history
… update service account token settings

On-behalf-of: @SAP angel.kafazov@sap.com
Signed-off-by: Angel Kafazov <akafazov@cst-bg.net>
  • Loading branch information
akafazov committed Nov 25, 2024
1 parent 566ff49 commit 0e0b3ae
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 24 deletions.
7 changes: 1 addition & 6 deletions charts/account-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ spec:
name: manager
{{ include "common.security" . | nindent 10 }}
ports:
- containerPort: {{ .Values.metrics.port }}
name: metrics
protocol: TCP
- name: health-port
containerPort: {{ .Values.health.port }}
protocol: TCP
{{ include "common.PortsMetricsHealth" . | nindent 10 }}
{{- if .Values.webhooks.enabled }}
- name: webhook-port
containerPort: 9443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ operator match the snapshot:
- --leader-elect
- --log-level=warn
- --health-probe-bind-address=:8081
automountServiceAccountToken: true
automountServiceAccountToken: false
env:
- name: SUBROUTINES_NAMESPACE_ENABLED
value: "true"
Expand Down Expand Up @@ -675,7 +675,7 @@ operator match the snapshot (with kubeconfigSecret):
- --leader-elect
- --log-level=warn
- --health-probe-bind-address=:8081
automountServiceAccountToken: true
automountServiceAccountToken: false
env:
- name: SUBROUTINES_NAMESPACE_ENABLED
value: "true"
Expand Down Expand Up @@ -1063,7 +1063,7 @@ operator match the snapshot with webhook enabled:
- --leader-elect
- --log-level=warn
- --health-probe-bind-address=:8081
automountServiceAccountToken: true
automountServiceAccountToken: false
env:
- name: SUBROUTINES_NAMESPACE_ENABLED
value: "true"
Expand Down
5 changes: 5 additions & 0 deletions charts/account-operator/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ tests:
- it: operator match the snapshot with webhook enabled
set:
health:
port: 8081
liveness:
path: "/healthz"
# failureThreshold: 1
webhooks:
enabled: true
certDir: /certs
asserts:
- matchSnapshot: {}
- it: deployment with security context
template: deployment.yaml
set:
security:
mountServiceAccountToken: true
asserts:
- equal:
path: spec.template.spec.containers[0].securityContext
Expand Down
36 changes: 35 additions & 1 deletion charts/account-operator/values.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
image:
# @param image.name The image repository
name: ghcr.io/openmfp/account-operator
# @param image.tag The image tag
tag: latest

# @param imagePullSecret The secret used to pull the image
imagePullSecret: "github"

# @param crds.enabled Enable CRDs
crds:
enabled: true

# @param webhooks.enabled Enable webhooks
# @param webhooks.certDir The directory for webhook certificates
webhooks:
enabled: false
certDir: /certs
Expand Down Expand Up @@ -35,10 +41,19 @@ health:
# path: "/readyz"
# failureThreshold: 30


# The metrics configuration
## @param metrics.port The port for the metrics
metrics:
port: 8080

# The deployment configuration
## @param deployment.specTemplate.annotations The annotations to add to the deployment template
## @param deployment.specTemplate.labels The labels to add to the deployment template
## @param deployment.revisionHistoryLimit The number of old ReplicaSets to retain to allow rollback
## @param deployment.resources.limits.cpu The maximum amount of CPU the container is allowed to use
## @param deployment.resources.limits.memory The maximum amount of memory the container is allowed to use
## @param deployment.resources.requests.cpu The amount of CPU requested for the container
## @param deployment.resources.requests.memory The amount of memory requested for the container
deployment:
specTemplate:
annotations: {}
Expand All @@ -52,10 +67,23 @@ deployment:
cpu: 150m
memory: 128Mi

# The KCP configuration
## @param kcp.enabled Enable KCP
## @param kcp.virtualWorkspaceUrl The URL for the virtual workspace
kcp:
enabled: false
virtualWorkspaceUrl: ""

# The subroutines configuration
## @param subroutines.namespace.enabled Enable namespace subroutines
## @param subroutines.fga.enabled Enable FGA subroutines
## @param subroutines.fga.grpcAddr The gRPC address for FGA
## @param subroutines.fga.rootNamespace The root namespace for FGA
## @param subroutines.fga.objectType The object type for FGA
## @param subroutines.fga.parentRelation The parent relation for FGA
## @param subroutines.fga.creatorRelation The creator relation for FGA
## @param subroutines.extension.enabled Enable extension subroutines
## @param subroutines.extensionReady.enabled Enable extension ready subroutines
subroutines:
namespace:
enabled: true
Expand All @@ -71,5 +99,11 @@ subroutines:
extensionReady:
enabled: true

# @param kubeconfigSecret The secret for kubeconfig
kubeconfigSecret: ""
# @param logLevel The log level
logLevel: warn

## @param security.mountServiceAccountToken Mount the service account token
security:
mountServiceAccountToken: false

Check failure on line 109 in charts/account-operator/values.yaml

View workflow job for this annotation

GitHub Actions / pipeline / testChart / lint

109:34 [new-line-at-end-of-file] no new line character at the end of file

Check failure on line 109 in charts/account-operator/values.yaml

View workflow job for this annotation

GitHub Actions / pipeline / testChart / lint

109:34 [new-line-at-end-of-file] no new line character at the end of file

Check failure on line 109 in charts/account-operator/values.yaml

View workflow job for this annotation

GitHub Actions / pipeline / testChart / lint

109:34 [new-line-at-end-of-file] no new line character at the end of file
18 changes: 10 additions & 8 deletions charts/common/templates/_deploymentHelpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ ports:
- name: http
containerPort: {{ .Values.port | default 8080 }}
protocol: TCP
- name: metrics
containerPort: {{ .Values.metricsPort | default 2112 }}
protocol: TCP
- name: health-port
containerPort: {{ (.Values.health).port | default 3389 }}
protocol: TCP
{{ include "common.PortsMetricsHealth" | nindent 4 }}
{{- end}}

{{- define "common.technicalIssuers" }}
Expand Down Expand Up @@ -114,7 +109,7 @@ readinessProbe:
initialDelaySeconds: {{ ((.Values.health).readiness).initialDelaySeconds | default 45 }}
periodSeconds: {{ (.Values.health).periodSeconds | default 10 }}
{{- end }}
{{- define "common.security" }}
{{- define "common.security" -}}
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
Expand All @@ -126,7 +121,6 @@ automountServiceAccountToken: {{ not (eq (.Values.security).mountServiceAccountT
{{- define "common.terminationGracePeriodSeconds" -}}
{{ .Values.terminationGracePeriodSeconds | default 10 }}
{{- end }}

{{- define "common.imagePullPolicy" -}}
{{- if and .Values.global (.Values.global.imagePullPolicy) -}}
{{ .Values.global.imagePullPolicy }}
Expand All @@ -136,3 +130,11 @@ automountServiceAccountToken: {{ not (eq (.Values.security).mountServiceAccountT
Always
{{- end -}}
{{- end }}
{{- define "common.PortsMetricsHealth" -}}
- name: metrics
containerPort: {{ ((.Values).metrics).port | default 2112 }}
protocol: TCP
- name: health-port
containerPort: {{ (.Values.health).port | default 3389 }}
protocol: TCP
{{- end -}}
7 changes: 1 addition & 6 deletions charts/extension-manager-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ spec:
name: manager
{{ include "common.security" . | nindent 10 }}
ports:
- containerPort: {{ .Values.metrics.port }}
name: metrics
protocol: TCP
- name: health-port
containerPort: {{ .Values.health.port }}
protocol: TCP
{{ include "common.PortsMetricsHealth" . | nindent 10 }}
{{ include "common.operatorHealthAndReadyness" . | nindent 10 }}
resources:
limits:
Expand Down

0 comments on commit 0e0b3ae

Please sign in to comment.