Skip to content

Commit feae33e

Browse files
author
waleed
committed
improvement(helm): enhance copilot chart with HA support and validation
1 parent 19ede0c commit feae33e

6 files changed

Lines changed: 87 additions & 3 deletions

File tree

helm/sim/examples/values-copilot.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ copilot:
3838
SIM_BASE_URL: "https://sim.example.com" # Base URL for Sim deployment
3939
SIM_AGENT_API_KEY: "" # Must match SIM-side COPILOT_API_KEY
4040
REDIS_URL: "redis://default:password@redis:6379"
41+
# Optional configuration
42+
LOG_LEVEL: "info"
43+
CORS_ALLOWED_ORIGINS: "https://sim.example.com"
44+
OTEL_EXPORTER_OTLP_ENDPOINT: ""
4145

4246
# Create a Secret from the values above. Set create=false to reference an existing secret instead.
4347
secret:

helm/sim/templates/_helpers.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ Validate Copilot configuration
355355
{{- fail "Set at least one of copilot.server.env.OPENAI_API_KEY_1 or copilot.server.env.ANTHROPIC_API_KEY_1" -}}
356356
{{- end -}}
357357
{{- end -}}
358-
{{- if not .Values.copilot.postgresql.enabled -}}
358+
{{- if .Values.copilot.postgresql.enabled -}}
359+
{{- if or (not .Values.copilot.postgresql.auth.password) (eq .Values.copilot.postgresql.auth.password "") -}}
360+
{{- fail "copilot.postgresql.auth.password is required when copilot.postgresql.enabled=true" -}}
361+
{{- end -}}
362+
{{- else -}}
359363
{{- if and (or (not .Values.copilot.database.existingSecretName) (eq .Values.copilot.database.existingSecretName "")) (or (not .Values.copilot.database.url) (eq .Values.copilot.database.url "")) -}}
360364
{{- fail "Provide copilot.database.existingSecretName or copilot.database.url when copilot.postgresql.enabled=false" -}}
361365
{{- end -}}

helm/sim/templates/job-copilot-migrations.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
app.kubernetes.io/component: copilot-migrations
1010
annotations:
1111
"helm.sh/hook": post-install,post-upgrade
12-
"helm.sh/hook-weight": "1"
12+
"helm.sh/hook-weight": "-5"
1313
"helm.sh/hook-delete-policy": before-hook-creation
1414
spec:
1515
backoffLimit: {{ .Values.copilot.migrations.backoffLimit }}

helm/sim/templates/poddisruptionbudget.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,32 @@ spec:
5050
{{- include "sim.realtime.selectorLabels" $ | nindent 6 }}
5151
{{- end }}
5252
{{- end }}
53+
{{- if and .Values.copilot.enabled .Values.copilot.server.podDisruptionBudget.enabled }}
54+
{{- with .Values.copilot.server.podDisruptionBudget }}
55+
---
56+
apiVersion: policy/v1
57+
kind: PodDisruptionBudget
58+
metadata:
59+
name: {{ include "sim.fullname" $ }}-copilot-pdb
60+
namespace: {{ $.Release.Namespace }}
61+
labels:
62+
{{- include "sim.labels" $ | nindent 4 }}
63+
app.kubernetes.io/component: copilot
64+
spec:
65+
{{- if .minAvailable }}
66+
minAvailable: {{ .minAvailable }}
67+
{{- else if .maxUnavailable }}
68+
maxUnavailable: {{ .maxUnavailable }}
69+
{{- else }}
70+
maxUnavailable: 1
71+
{{- end }}
72+
{{- if .unhealthyPodEvictionPolicy }}
73+
unhealthyPodEvictionPolicy: {{ .unhealthyPodEvictionPolicy }}
74+
{{- end }}
75+
selector:
76+
matchLabels:
77+
app.kubernetes.io/name: {{ include "sim.name" $ }}
78+
app.kubernetes.io/instance: {{ $.Release.Name }}
79+
app.kubernetes.io/component: copilot
80+
{{- end }}
81+
{{- end }}

helm/sim/values.schema.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,23 @@
726726
"port": { "type": "integer" },
727727
"targetPort": { "type": "integer" }
728728
}
729+
},
730+
"podDisruptionBudget": {
731+
"type": "object",
732+
"properties": {
733+
"enabled": {
734+
"type": "boolean",
735+
"description": "Enable PodDisruptionBudget for Copilot server"
736+
},
737+
"minAvailable": {
738+
"type": "integer",
739+
"description": "Minimum number of available pods"
740+
},
741+
"maxUnavailable": {
742+
"type": "integer",
743+
"description": "Maximum number of unavailable pods"
744+
}
745+
}
729746
}
730747
}
731748
},
@@ -836,6 +853,27 @@
836853
}
837854
}
838855
},
856+
"copilot": {
857+
"type": "object",
858+
"properties": {
859+
"host": {
860+
"type": "string",
861+
"format": "hostname",
862+
"description": "Copilot service hostname"
863+
},
864+
"paths": {
865+
"type": "array",
866+
"items": {
867+
"type": "object",
868+
"properties": {
869+
"path": { "type": "string" },
870+
"pathType": { "type": "string" }
871+
}
872+
},
873+
"description": "Ingress paths for Copilot service"
874+
}
875+
}
876+
},
839877
"tls": {
840878
"type": "object",
841879
"properties": {

helm/sim/values.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,10 @@ copilot:
798798
SIM_BASE_URL: ""
799799
SIM_AGENT_API_KEY: ""
800800
REDIS_URL: ""
801+
# Optional configuration
802+
LOG_LEVEL: "info"
803+
CORS_ALLOWED_ORIGINS: ""
804+
OTEL_EXPORTER_OTLP_ENDPOINT: ""
801805

802806
# Optional: additional static environment variables
803807
extraEnv: []
@@ -835,7 +839,12 @@ copilot:
835839
periodSeconds: 30
836840
timeoutSeconds: 5
837841
failureThreshold: 3
838-
842+
843+
# Pod Disruption Budget for high availability
844+
podDisruptionBudget:
845+
enabled: false
846+
minAvailable: 1
847+
839848
# PostgreSQL database for copilot (separate from main Sim database)
840849
postgresql:
841850
# Enable/disable internal PostgreSQL for copilot

0 commit comments

Comments
 (0)