mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-05 04:15:08 -05:00
Compare commits
25 Commits
fix/copilo
...
aarushikan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa7026c575 | ||
|
|
564a4a033a | ||
|
|
fe15f31851 | ||
|
|
f4fa63bc4e | ||
|
|
8ad15bd3c3 | ||
|
|
cd9c85aabb | ||
|
|
d3425fe05e | ||
|
|
fda82b580e | ||
|
|
5c14546578 | ||
|
|
eeb74219f4 | ||
|
|
2c564e2a4a | ||
|
|
55d2de15d9 | ||
|
|
0929162854 | ||
|
|
4ec90ffed9 | ||
|
|
539cf5de4f | ||
|
|
650ffa50c3 | ||
|
|
b0373d4925 | ||
|
|
8a0d3c0878 | ||
|
|
e87f40a234 | ||
|
|
bcfb2d4cdd | ||
|
|
d12f620468 | ||
|
|
ed85473102 | ||
|
|
b809aa49d1 | ||
|
|
465b67eb67 | ||
|
|
e60e977681 |
23
.github/workflows/autogpt-infra-ci.yml
vendored
23
.github/workflows/autogpt-infra-ci.yml
vendored
@@ -23,6 +23,9 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: TFLint
|
||||
uses: pauloconnor/tflint-action@v0.0.2
|
||||
env:
|
||||
@@ -31,3 +34,23 @@ jobs:
|
||||
tflint_path: terraform/
|
||||
tflint_recurse: true
|
||||
tflint_changed_only: false
|
||||
|
||||
- name: Set up Helm
|
||||
uses: azure/setup-helm@v4.2.0
|
||||
with:
|
||||
version: v3.14.4
|
||||
|
||||
- name: Set up chart-testing
|
||||
uses: helm/chart-testing-action@v2.6.0
|
||||
|
||||
- name: Run chart-testing (list-changed)
|
||||
id: list-changed
|
||||
run: |
|
||||
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
|
||||
if [[ -n "$changed" ]]; then
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Run chart-testing (lint)
|
||||
if: steps.list-changed.outputs.changed == 'true'
|
||||
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
|
||||
@@ -15,7 +15,6 @@ from fastapi import (
|
||||
)
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
import autogpt_server.server.ws_api
|
||||
from autogpt_server.data import block, db
|
||||
@@ -34,7 +33,6 @@ from autogpt_server.server.model import (
|
||||
SetGraphActiveVersion,
|
||||
WsMessage,
|
||||
)
|
||||
from autogpt_server.util.data import get_frontend_path
|
||||
from autogpt_server.util.lock import KeyedMutex
|
||||
from autogpt_server.util.service import AppService, expose, get_service_client
|
||||
from autogpt_server.util.settings import Settings
|
||||
@@ -190,12 +188,6 @@ class AgentServer(AppService):
|
||||
|
||||
app.add_exception_handler(500, self.handle_internal_error) # type: ignore
|
||||
|
||||
app.mount(
|
||||
path="/frontend",
|
||||
app=StaticFiles(directory=get_frontend_path(), html=True),
|
||||
name="example_files",
|
||||
)
|
||||
|
||||
app.include_router(router)
|
||||
|
||||
@app.websocket("/ws")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from abc import abstractmethod
|
||||
@@ -16,6 +17,8 @@ logger = logging.getLogger(__name__)
|
||||
conn_retry = retry(stop=stop_after_delay(5), wait=wait_exponential(multiplier=0.1))
|
||||
T = TypeVar("T")
|
||||
|
||||
host = os.environ.get("PYRO_HOST", "localhost")
|
||||
|
||||
|
||||
def expose(func: Callable) -> Callable:
|
||||
def wrapper(*args, **kwargs):
|
||||
@@ -33,7 +36,7 @@ class PyroNameServer(AppProcess):
|
||||
def run(self):
|
||||
try:
|
||||
print("Starting NameServer loop")
|
||||
nameserver.start_ns_loop()
|
||||
nameserver.start_ns_loop(host=host, port=9090)
|
||||
except KeyboardInterrupt:
|
||||
print("Shutting down NameServer")
|
||||
|
||||
@@ -77,8 +80,8 @@ class AppService(AppProcess):
|
||||
|
||||
@conn_retry
|
||||
def __start_pyro(self):
|
||||
daemon = pyro.Daemon()
|
||||
ns = pyro.locate_ns()
|
||||
daemon = pyro.Daemon(host=host)
|
||||
ns = pyro.locate_ns(host=host, port=9090)
|
||||
uri = daemon.register(self)
|
||||
ns.register(self.service_name, uri)
|
||||
logger.warning(f"Service [{self.service_name}] Ready. Object URI = {uri}")
|
||||
|
||||
23
rnd/infra/helm/autogpt-server/.helmignore
Normal file
23
rnd/infra/helm/autogpt-server/.helmignore
Normal file
@@ -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/
|
||||
10
rnd/infra/helm/autogpt-server/Chart.yaml
Normal file
10
rnd/infra/helm/autogpt-server/Chart.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: v2
|
||||
name: autogpt-server
|
||||
description: A Helm chart for AutoGPT on Kubernetes
|
||||
|
||||
type: application
|
||||
|
||||
|
||||
version: 0.1.0
|
||||
|
||||
appVersion: "1.0.0"
|
||||
22
rnd/infra/helm/autogpt-server/templates/NOTES.txt
Normal file
22
rnd/infra/helm/autogpt-server/templates/NOTES.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
1. Get the application URL by running these commands:
|
||||
{{- if .Values.ingress.enabled }}
|
||||
{{- range $host := .Values.ingress.hosts }}
|
||||
{{- range .paths }}
|
||||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if contains "NodePort" .Values.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "autogpt-server.fullname" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo http://$NODE_IP:$NODE_PORT
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "autogpt-server.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "autogpt-server.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "autogpt-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
|
||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
|
||||
{{- end }}
|
||||
62
rnd/infra/helm/autogpt-server/templates/_helpers.tpl
Normal file
62
rnd/infra/helm/autogpt-server/templates/_helpers.tpl
Normal file
@@ -0,0 +1,62 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "autogpt-server.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "autogpt-server.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "autogpt-server.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "autogpt-server.labels" -}}
|
||||
helm.sh/chart: {{ include "autogpt-server.chart" . }}
|
||||
{{ include "autogpt-server.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "autogpt-server.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "autogpt-server.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "autogpt-server.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "autogpt-server.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
10
rnd/infra/helm/autogpt-server/templates/configmap.yaml
Normal file
10
rnd/infra/helm/autogpt-server/templates/configmap.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "autogpt-server.fullname" . }}-config
|
||||
labels:
|
||||
{{- include "autogpt-server.labels" . | nindent 4 }}
|
||||
data:
|
||||
{{- range $key, $value := .Values.env }}
|
||||
{{ $key }}: {{ $value | quote }}
|
||||
{{- end }}
|
||||
80
rnd/infra/helm/autogpt-server/templates/deployment.yaml
Normal file
80
rnd/infra/helm/autogpt-server/templates/deployment.yaml
Normal file
@@ -0,0 +1,80 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "autogpt-server.fullname" . }}
|
||||
labels:
|
||||
{{- include "autogpt-server.labels" . | nindent 4 }}
|
||||
spec:
|
||||
{{- if not .Values.autoscaling.enabled }}
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "autogpt-server.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "autogpt-server.labels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "autogpt-server.serviceAccountName" . }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: {{ include "autogpt-server.fullname" . }}-config
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.service.port }}
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
{{- toYaml .Values.livenessProbe | nindent 12 }}
|
||||
readinessProbe:
|
||||
{{- toYaml .Values.readinessProbe | nindent 12 }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- with .Values.volumeMounts }}
|
||||
volumeMounts:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
- name: cloud-sql-proxy
|
||||
image: "{{ .Values.cloudSqlProxy.image.repository }}:{{ .Values.cloudSqlProxy.image.tag }}"
|
||||
args:
|
||||
- "--structured-logs"
|
||||
{{- if .Values.cloudSqlProxy.usePrivateIp }}
|
||||
- "--private-ip"
|
||||
{{- end }}
|
||||
- "--port={{ .Values.cloudSqlProxy.port }}"
|
||||
- "{{ .Values.cloudSqlProxy.instanceConnectionName }}"
|
||||
{{- with .Values.volumes }}
|
||||
volumes:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
32
rnd/infra/helm/autogpt-server/templates/hpa.yaml
Normal file
32
rnd/infra/helm/autogpt-server/templates/hpa.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
{{- if .Values.autoscaling.enabled }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ include "autogpt-server.fullname" . }}
|
||||
labels:
|
||||
{{- include "autogpt-server.labels" . | nindent 4 }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ include "autogpt-server.fullname" . }}
|
||||
minReplicas: {{ .Values.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
61
rnd/infra/helm/autogpt-server/templates/ingress.yaml
Normal file
61
rnd/infra/helm/autogpt-server/templates/ingress.yaml
Normal file
@@ -0,0 +1,61 @@
|
||||
{{- if .Values.ingress.enabled -}}
|
||||
{{- $fullName := include "autogpt-server.fullname" . -}}
|
||||
{{- $svcPort := .Values.service.port -}}
|
||||
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
|
||||
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
|
||||
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
{{- else -}}
|
||||
apiVersion: extensions/v1beta1
|
||||
{{- end }}
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $fullName }}
|
||||
labels:
|
||||
{{- include "autogpt-server.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- end }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
|
||||
pathType: {{ .pathType }}
|
||||
{{- end }}
|
||||
backend:
|
||||
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
|
||||
service:
|
||||
name: {{ $fullName }}
|
||||
port:
|
||||
number: {{ $svcPort }}
|
||||
{{- else }}
|
||||
serviceName: {{ $fullName }}
|
||||
servicePort: {{ $svcPort }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
7
rnd/infra/helm/autogpt-server/templates/managedcert.yaml
Normal file
7
rnd/infra/helm/autogpt-server/templates/managedcert.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: networking.gke.io/v1
|
||||
kind: ManagedCertificate
|
||||
metadata:
|
||||
name: {{ include "autogpt-server.fullname" . }}-cert
|
||||
spec:
|
||||
domains:
|
||||
- {{ .Values.domain }}
|
||||
19
rnd/infra/helm/autogpt-server/templates/service.yaml
Normal file
19
rnd/infra/helm/autogpt-server/templates/service.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "autogpt-server.fullname" . }}
|
||||
labels:
|
||||
{{- include "autogpt-server.labels" . | nindent 4 }}
|
||||
{{- with .Values.service.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "autogpt-server.selectorLabels" . | nindent 4 }}
|
||||
13
rnd/infra/helm/autogpt-server/templates/serviceaccount.yaml
Normal file
13
rnd/infra/helm/autogpt-server/templates/serviceaccount.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "autogpt-server.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "autogpt-server.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ include "autogpt-server.fullname" . }}-test-connection"
|
||||
labels:
|
||||
{{- include "autogpt-server.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
spec:
|
||||
containers:
|
||||
- name: wget
|
||||
image: busybox
|
||||
command: ['wget']
|
||||
args: ['{{ include "autogpt-server.fullname" . }}:{{ .Values.service.port }}']
|
||||
restartPolicy: Never
|
||||
83
rnd/infra/helm/autogpt-server/values.dev.yaml
Normal file
83
rnd/infra/helm/autogpt-server/values.dev.yaml
Normal file
@@ -0,0 +1,83 @@
|
||||
# dev values, overwrite base values as needed.
|
||||
|
||||
image:
|
||||
repository: us-east1-docker.pkg.dev/agpt-dev/agpt-server-dev/agpt-server-dev
|
||||
pullPolicy: Always
|
||||
tag: "latest"
|
||||
|
||||
serviceAccount:
|
||||
annotations:
|
||||
iam.gke.io/gcp-service-account: "dev-agpt-server-sa@agpt-dev.iam.gserviceaccount.com"
|
||||
name: "dev-agpt-server-sa"
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 8000
|
||||
targetPort: 8000
|
||||
annotations:
|
||||
cloud.google.com/neg: '{"ingress": true}'
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: "gce"
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: gce
|
||||
kubernetes.io/ingress.global-static-ip-name: "agpt-dev-agpt-server-ip"
|
||||
networking.gke.io/managed-certificates: "autogpt-server-cert"
|
||||
kubernetes.io/ingress.allow-http: "true"
|
||||
hosts:
|
||||
- host: dev-server.agpt.co
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: autogpt-server
|
||||
port: 8000
|
||||
defaultBackend:
|
||||
service:
|
||||
name: autogpt-server
|
||||
port:
|
||||
number: 8000
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /docs
|
||||
port: 8000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 6
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /docs
|
||||
port: 8000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 6
|
||||
|
||||
domain: "dev-server.agpt.co"
|
||||
|
||||
cloudSqlProxy:
|
||||
image:
|
||||
repository: gcr.io/cloud-sql-connectors/cloud-sql-proxy
|
||||
tag: 2.11.4
|
||||
instanceConnectionName: "agpt-dev:us-central1:agpt-server-dev"
|
||||
port: 5432
|
||||
resources:
|
||||
requests:
|
||||
memory: "2Gi"
|
||||
cpu: "1"
|
||||
|
||||
env:
|
||||
APP_ENV: "dev"
|
||||
PYRO_HOST: "0.0.0.0"
|
||||
87
rnd/infra/helm/autogpt-server/values.yaml
Normal file
87
rnd/infra/helm/autogpt-server/values.yaml
Normal file
@@ -0,0 +1,87 @@
|
||||
# base values, environment specific variables should be specified/overwritten in environment values
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: us-east1-docker.pkg.dev/agpt-dev/agpt-server-dev/agpt-server-dev
|
||||
pullPolicy: IfNotPresent
|
||||
tag: "latest"
|
||||
|
||||
imagePullSecrets: []
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
serviceAccount:
|
||||
create: true
|
||||
automount: true
|
||||
annotations: {}
|
||||
name: ""
|
||||
|
||||
podAnnotations: {}
|
||||
podLabels: {}
|
||||
|
||||
podSecurityContext: {}
|
||||
|
||||
securityContext: {}
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
className: ""
|
||||
annotations: {}
|
||||
hosts:
|
||||
- host: chart-example.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: ImplementationSpecific
|
||||
tls: []
|
||||
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
|
||||
autoscaling:
|
||||
enabled: false
|
||||
minReplicas: 1
|
||||
maxReplicas: 100
|
||||
targetMemoryUtilizationPercentage: 80
|
||||
|
||||
volumes: []
|
||||
|
||||
volumeMounts: []
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
domain: ""
|
||||
|
||||
cloudSqlProxy:
|
||||
image:
|
||||
repository: gcr.io/cloud-sql-connectors/cloud-sql-proxy
|
||||
tag: 2.11.4
|
||||
instanceConnectionName: ""
|
||||
port: 5432
|
||||
resources:
|
||||
requests:
|
||||
memory: "2Gi"
|
||||
cpu: "1"
|
||||
@@ -10,3 +10,46 @@ node_pool_name = "dev-main-pool"
|
||||
machine_type = "e2-medium"
|
||||
disk_size_gb = 100
|
||||
static_ip_names = ["agpt-server-ip", "agpt-builder-ip", "auth-ip"]
|
||||
|
||||
|
||||
service_accounts = {
|
||||
"dev-agpt-server-sa" = {
|
||||
display_name = "AutoGPT Dev Server Account"
|
||||
description = "Service account for agpt dev server"
|
||||
}
|
||||
}
|
||||
|
||||
workload_identity_bindings = {
|
||||
"dev-agpt-server-workload-identity" = {
|
||||
service_account_name = "dev-agpt-server-sa"
|
||||
namespace = "dev-agpt"
|
||||
ksa_name = "dev-agpt-server-sa"
|
||||
}
|
||||
}
|
||||
|
||||
role_bindings = {
|
||||
"roles/container.developer" = [
|
||||
"serviceAccount:dev-agpt-server-sa@agpt-dev.iam.gserviceaccount.com"
|
||||
],
|
||||
"roles/cloudsql.client" = [
|
||||
"serviceAccount:dev-agpt-server-sa@agpt-dev.iam.gserviceaccount.com"
|
||||
],
|
||||
"roles/cloudsql.editor" = [
|
||||
"serviceAccount:dev-agpt-server-sa@agpt-dev.iam.gserviceaccount.com"
|
||||
],
|
||||
"roles/cloudsql.instanceUser" = [
|
||||
"serviceAccount:dev-agpt-server-sa@agpt-dev.iam.gserviceaccount.com"
|
||||
],
|
||||
"roles/iam.workloadIdentityUser" = [
|
||||
"serviceAccount:dev-agpt-server-sa@agpt-dev.iam.gserviceaccount.com"
|
||||
]
|
||||
"roles/compute.networkUser" = [
|
||||
"serviceAccount:dev-agpt-server-sa@agpt-dev.iam.gserviceaccount.com"
|
||||
],
|
||||
"roles/container.hostServiceAgentUser" = [
|
||||
"serviceAccount:dev-agpt-server-sa@agpt-dev.iam.gserviceaccount.com"
|
||||
]
|
||||
}
|
||||
|
||||
pods_ip_cidr_range = "10.1.0.0/16"
|
||||
services_ip_cidr_range = "10.2.0.0/20"
|
||||
@@ -6,10 +6,12 @@ terraform {
|
||||
version = "~> 4.0"
|
||||
}
|
||||
}
|
||||
|
||||
backend "gcs" {
|
||||
bucket = "agpt-dev-terraform"
|
||||
prefix = "terraform/state"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
provider "google" {
|
||||
@@ -28,11 +30,13 @@ module "static_ips" {
|
||||
module "networking" {
|
||||
source = "./modules/networking"
|
||||
|
||||
project_id = var.project_id
|
||||
region = var.region
|
||||
network_name = var.network_name
|
||||
subnet_name = var.subnet_name
|
||||
subnet_cidr = var.subnet_cidr
|
||||
project_id = var.project_id
|
||||
region = var.region
|
||||
network_name = var.network_name
|
||||
subnet_name = var.subnet_name
|
||||
subnet_cidr = var.subnet_cidr
|
||||
pods_ip_cidr_range = var.pods_ip_cidr_range
|
||||
services_ip_cidr_range = var.services_ip_cidr_range
|
||||
}
|
||||
|
||||
module "gke_cluster" {
|
||||
@@ -49,3 +53,12 @@ module "gke_cluster" {
|
||||
subnetwork = module.networking.subnet_self_link
|
||||
enable_autopilot = var.enable_autopilot
|
||||
}
|
||||
|
||||
module "iam" {
|
||||
source = "./modules/iam"
|
||||
|
||||
project_id = var.project_id
|
||||
service_accounts = var.service_accounts
|
||||
workload_identity_bindings = var.workload_identity_bindings
|
||||
role_bindings = var.role_bindings
|
||||
}
|
||||
@@ -2,6 +2,11 @@ resource "google_container_cluster" "primary" {
|
||||
name = var.cluster_name
|
||||
location = var.zone
|
||||
|
||||
workload_identity_config {
|
||||
workload_pool = "${var.project_id}.svc.id.goog"
|
||||
}
|
||||
|
||||
|
||||
dynamic "node_pool" {
|
||||
for_each = var.enable_autopilot ? [] : [1]
|
||||
content {
|
||||
@@ -11,11 +16,20 @@ resource "google_container_cluster" "primary" {
|
||||
node_config {
|
||||
machine_type = var.machine_type
|
||||
disk_size_gb = var.disk_size_gb
|
||||
|
||||
workload_metadata_config {
|
||||
mode = "GKE_METADATA"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network = var.network
|
||||
subnetwork = var.subnetwork
|
||||
|
||||
ip_allocation_policy {
|
||||
cluster_secondary_range_name = "pods"
|
||||
services_secondary_range_name = "services"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
26
rnd/infra/terraform/modules/iam/main.tf
Normal file
26
rnd/infra/terraform/modules/iam/main.tf
Normal file
@@ -0,0 +1,26 @@
|
||||
resource "google_service_account" "service_accounts" {
|
||||
for_each = var.service_accounts
|
||||
account_id = each.key
|
||||
display_name = each.value.display_name
|
||||
description = each.value.description
|
||||
}
|
||||
|
||||
# IAM policy binding for Workload Identity
|
||||
resource "google_service_account_iam_binding" "workload_identity_binding" {
|
||||
for_each = var.workload_identity_bindings
|
||||
service_account_id = google_service_account.service_accounts[each.value.service_account_name].name
|
||||
role = "roles/iam.workloadIdentityUser"
|
||||
|
||||
members = [
|
||||
"serviceAccount:${var.project_id}.svc.id.goog[${each.value.namespace}/${each.value.ksa_name}]"
|
||||
]
|
||||
}
|
||||
|
||||
# Role bindings grouped by role
|
||||
resource "google_project_iam_binding" "role_bindings" {
|
||||
for_each = var.role_bindings
|
||||
project = var.project_id
|
||||
role = each.key
|
||||
|
||||
members = each.value
|
||||
}
|
||||
4
rnd/infra/terraform/modules/iam/outputs.tf
Normal file
4
rnd/infra/terraform/modules/iam/outputs.tf
Normal file
@@ -0,0 +1,4 @@
|
||||
output "service_account_emails" {
|
||||
description = "The emails of the created service accounts"
|
||||
value = { for k, v in google_service_account.service_accounts : k => v.email }
|
||||
}
|
||||
29
rnd/infra/terraform/modules/iam/variables.tf
Normal file
29
rnd/infra/terraform/modules/iam/variables.tf
Normal file
@@ -0,0 +1,29 @@
|
||||
variable "project_id" {
|
||||
description = "The ID of the project"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "service_accounts" {
|
||||
description = "Map of service accounts to create"
|
||||
type = map(object({
|
||||
display_name = string
|
||||
description = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "workload_identity_bindings" {
|
||||
description = "Map of Workload Identity bindings to create"
|
||||
type = map(object({
|
||||
service_account_name = string
|
||||
namespace = string
|
||||
ksa_name = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "role_bindings" {
|
||||
description = "Map of roles to list of members"
|
||||
type = map(list(string))
|
||||
default = {}
|
||||
}
|
||||
@@ -8,5 +8,15 @@ resource "google_compute_subnetwork" "subnet" {
|
||||
ip_cidr_range = var.subnet_cidr
|
||||
region = var.region
|
||||
network = google_compute_network.vpc_network.self_link
|
||||
|
||||
secondary_ip_range {
|
||||
range_name = "pods"
|
||||
ip_cidr_range = var.pods_ip_cidr_range
|
||||
}
|
||||
|
||||
secondary_ip_range {
|
||||
range_name = "services"
|
||||
ip_cidr_range = var.services_ip_cidr_range
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,4 +18,12 @@ variable "subnet_cidr" {
|
||||
description = "The CIDR range for the subnet"
|
||||
}
|
||||
|
||||
variable "pods_ip_cidr_range" {
|
||||
description = "The IP address range for pods"
|
||||
default = "10.1.0.0/16"
|
||||
}
|
||||
|
||||
variable "services_ip_cidr_range" {
|
||||
description = "The IP address range for services"
|
||||
default = "10.2.0.0/20"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
resource "google_compute_address" "static_ip" {
|
||||
resource "google_compute_global_address" "static_ip" {
|
||||
count = length(var.ip_names)
|
||||
name = "${var.project_id}-${var.ip_names[count.index]}"
|
||||
region = var.region
|
||||
address_type = "EXTERNAL"
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
output "ip_addresses" {
|
||||
description = "Map of created static IP addresses"
|
||||
value = { for i, ip in google_compute_address.static_ip : var.ip_names[i] => ip.address }
|
||||
value = { for i, ip in google_compute_global_address.static_ip : var.ip_names[i] => ip.address }
|
||||
}
|
||||
|
||||
output "ip_names" {
|
||||
description = "List of full names of the created static IP addresses"
|
||||
value = google_compute_address.static_ip[*].name
|
||||
value = google_compute_global_address.static_ip[*].name
|
||||
}
|
||||
@@ -74,3 +74,40 @@ variable "static_ip_names" {
|
||||
type = list(string)
|
||||
default = ["ip-1", "ip-2", "ip-3"]
|
||||
}
|
||||
|
||||
variable "service_accounts" {
|
||||
description = "Map of service accounts to create"
|
||||
type = map(object({
|
||||
display_name = string
|
||||
description = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "workload_identity_bindings" {
|
||||
description = "Map of Workload Identity bindings to create"
|
||||
type = map(object({
|
||||
service_account_name = string
|
||||
namespace = string
|
||||
ksa_name = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "role_bindings" {
|
||||
description = "Map of roles to list of members"
|
||||
type = map(list(string))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "pods_ip_cidr_range" {
|
||||
description = "The IP address range for pods"
|
||||
type = string
|
||||
default = "10.1.0.0/16"
|
||||
}
|
||||
|
||||
variable "services_ip_cidr_range" {
|
||||
description = "The IP address range for services"
|
||||
type = string
|
||||
default = "10.2.0.0/20"
|
||||
}
|
||||
Reference in New Issue
Block a user