diff --git a/charts/ai-agent/.helmignore b/charts/ai-agent/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/ai-agent/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/ai-agent/Chart.yaml b/charts/ai-agent/Chart.yaml new file mode 100644 index 00000000..d69aa1b2 --- /dev/null +++ b/charts/ai-agent/Chart.yaml @@ -0,0 +1,13 @@ +apiVersion: v2 +appVersion: 0.0.1 +description: Devtron AI Agent Helm chart for Kubernetes +name: ai-agent +keywords: + - Devtron + - kubernetes + - devops + - genai + - ai + - ai-gent +type: application +version: 0.0.1 diff --git a/charts/ai-agent/templates/ai-agent-service-account.yaml b/charts/ai-agent/templates/ai-agent-service-account.yaml new file mode 100644 index 00000000..f47bc1a5 --- /dev/null +++ b/charts/ai-agent/templates/ai-agent-service-account.yaml @@ -0,0 +1,223 @@ +{{- if .Values.createServiceAccount }} +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ .Release.Name }}-ai-agent-cluster-role + namespace : {{ .Release.Namespace }} +rules: + {{- if .Values.customClusterRoleRules }} +{{ toYaml .Values.customClusterRoleRules | indent 2 }} + {{- end }} + - apiGroups: + - "storage.k8s.io" + resources: + - storageclasses + verbs: + - list + - get + - watch + - apiGroups: + - "metrics.k8s.io" + resources: + - pods + - nodes + verbs: + - get + - list + - apiGroups: + - "" + resources: + - configmaps + - daemonsets + - deployments + - events + - namespaces + - persistentvolumes + - persistentvolumeclaims + - pods + - pods/status + - pods/log + - replicasets + - replicationcontrollers + - services + - serviceaccounts + - endpoints + verbs: + - get + - list + - watch + + - apiGroups: + - "" + resources: + - nodes + verbs: + - get + - list + - watch + + - apiGroups: + - "apiregistration.k8s.io" + resources: + - apiservices + verbs: + - get + - list + + - apiGroups: + - "rbac.authorization.k8s.io" + resources: + - clusterroles + - clusterrolebindings + verbs: + - get + - list + - watch + - apiGroups: + - "autoscaling" + resources: + - horizontalpodautoscalers + verbs: + - get + - list + - watch + + - apiGroups: + - apps + resources: + - daemonsets + - deployments + - deployments/scale + - replicasets + - replicasets/scale + - statefulsets + verbs: + - get + - list + - watch + + - apiGroups: + - extensions + resources: + - daemonsets + - deployments + - deployments/scale + - ingresses + - replicasets + - replicasets/scale + - replicationcontrollers/scale + verbs: + - get + - list + - watch + + - apiGroups: + - batch + resources: + - cronjobs + - jobs + verbs: + - get + - list + - watch + + - apiGroups: + - "events.k8s.io" + resources: + - events + verbs: + - get + - list + + - apiGroups: + - networking.k8s.io + resources: + - ingresses + - networkpolicies + verbs: + - get + - list + - watch + - apiGroups: + - autoscaling + resources: + - horizontalpodautoscalers + verbs: + - get + - list + - apiGroups: + - "policy" + resources: + - poddisruptionbudgets + - podsecuritypolicies + verbs: + - get + - list + - apiGroups: + - rbac.authorization.k8s.io + resources: + - clusterroles + - clusterrolebindings + - roles + - rolebindings + verbs: + - get + - list + + # Prometheus CRDs + - apiGroups: + - monitoring.coreos.com + resources: + - alertmanagers + - alertmanagers/finalizers + - alertmanagers/status + - alertmanagerconfigs + - prometheuses + - prometheuses/finalizers + - prometheuses/status + - prometheusagents + - prometheusagents/finalizers + - prometheusagents/status + - thanosrulers + - thanosrulers/finalizers + - thanosrulers/status + - scrapeconfigs + - servicemonitors + - podmonitors + - probes + - prometheusrules + verbs: + - get + - list + - watch + +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Release.Name }}-ai-agent-service-account + namespace: {{ .Release.Namespace }} + {{- if .Values.serviceAccount.annotations }} + annotations: + {{- with .Values.serviceAccount.annotations }} + {{- toYaml . | nindent 4}} + {{- end }} + {{- end }} +{{- if .Values.serviceAccount.imagePullSecrets }} +imagePullSecrets: +{{- toYaml .Values.serviceAccount.imagePullSecrets | nindent 2}} +{{- end }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ .Release.Name }}-ai-agent-cluster-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ .Release.Name }}-ai-agent-cluster-role +subjects: + - kind: ServiceAccount + name: {{ .Release.Name }}-ai-agent-service-account + namespace: {{ .Release.Namespace }} +{{- end }} \ No newline at end of file diff --git a/charts/ai-agent/templates/deployment.yaml b/charts/ai-agent/templates/deployment.yaml new file mode 100644 index 00000000..942d4174 --- /dev/null +++ b/charts/ai-agent/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-ai-agent + namespace: {{ .Release.Namespace }} + labels: + app: ai-agent +spec: + replicas: 1 + selector: + matchLabels: + app: ai-agent + template: + metadata: + labels: + app: ai-agent + spec: + {{- if .Values.customServiceAccountName }} + serviceAccountName: {{ .Values.customServiceAccountName }} + {{ else }} + serviceAccountName: {{ .Release.Name }}-ai-agent-service-account + {{- end }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml .Values.imagePullSecrets | nindent 6 }} + {{- end }} + containers: + - name: ai-agent + image: "{{ .Values.registry }}/{{ .Values.image }}" + imagePullPolicy: Always + command: ["python3", "-u", "server.py"] + env: + - name: CUSTOM_TOOLSET_LOCATION + value: /etc/ai-agent/config/custom_toolset.yaml + - name: LOG_LEVEL + value: {{ .Values.logLevel }} + - name: ALLOWED_TOOLSETS + value: {{ .Values.allowedToolsets }} + {{ if .Values.certificate -}} + - name: CERTIFICATE + value: {{ .Values.certificate }} + {{- end }} + {{- if .Values.additionalEnvVars -}} + {{ toYaml .Values.additionalEnvVars | nindent 10 }} + {{- end }} + lifecycle: + preStop: + exec: + command: ["bash", "-c", "kill -SIGINT 1"] + volumeMounts: + - mountPath: /etc/ai-agent/config + name: custom-toolsets-configmap + subPath: custom_toolset.yaml + resources: + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + limits: + memory: {{ .Values.resources.limits.memory }} + {{ if .Values.resources.limits.cpu }}cpu: {{ .Values.resources.limits.cpu | quote }}{{ end }} + {{- if .Values.tolerations }} + tolerations: {{ toYaml .Values.tolerations | nindent 8 }} + {{- end }} + volumes: + - configMap: + name: custom-toolsets-configmap + optional: true + name: custom-toolsets-configmap \ No newline at end of file diff --git a/charts/ai-agent/templates/service.yaml b/charts/ai-agent/templates/service.yaml new file mode 100644 index 00000000..df3b7a7f --- /dev/null +++ b/charts/ai-agent/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-ai-agent + namespace: {{ .Release.Namespace }} + labels: + app: ai-agent +spec: + selector: + app: ai-agent + ports: + - name: http + protocol: TCP + port: 80 + targetPort: 5050 \ No newline at end of file diff --git a/charts/ai-agent/templates/toolset-config.yaml b/charts/ai-agent/templates/toolset-config.yaml new file mode 100644 index 00000000..cbdbf7ae --- /dev/null +++ b/charts/ai-agent/templates/toolset-config.yaml @@ -0,0 +1,11 @@ +{{- if gt (len .Values.toolsets) 0 }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: custom-toolsets-configmap + namespace: {{ .Release.Namespace }} +data: + custom_toolset.yaml: |- + toolsets: + {{ toYaml .Values.toolsets | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/charts/ai-agent/values.yaml b/charts/ai-agent/values.yaml new file mode 100644 index 00000000..4d4fdc12 --- /dev/null +++ b/charts/ai-agent/values.yaml @@ -0,0 +1,34 @@ +certificate: "" # base64 encoded +logLevel: INFO + +additionalEnvVars: [] +imagePullSecrets: [] + +allowedToolsets: "kubernetes/core,internet" + +image: ai-agent:0.0.1 +registry: quay.io/devtron + +enableAccountsCreate: true + +createServiceAccount: true +customServiceAccountName: "" + +customClusterRoleRules: [] + +postProcessingPrompt: "builtin://generic_post_processing.jinja2" + +tolerations: [] + +serviceAccount: + imagePullSecrets: [] + annotations: {} + +toolsets: [] + +resources: + requests: + cpu: 100m + memory: 1024Mi + limits: + memory: 1024Mi \ No newline at end of file