diff --git a/.gitignore b/.gitignore index 100f3d09..3ef9826b 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,7 @@ coverage/ .nyc_output/ release/ + +# Builds + +build/charts/codepair/charts/ diff --git a/build/charts/codepair/.helmignore b/build/charts/codepair/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/build/charts/codepair/.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/build/charts/codepair/Chart.lock b/build/charts/codepair/Chart.lock new file mode 100644 index 00000000..bb75c5b9 --- /dev/null +++ b/build/charts/codepair/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: yorkie-mongodb + repository: https://yorkie-team.github.io/yorkie/helm-charts + version: 0.4.13 +digest: sha256:cc8f0136f05468ef7ad3b79470f59c47b0a2b82ee7826881c5b688f072b1033d +generated: "2025-05-05T15:58:01.457671+09:00" diff --git a/build/charts/codepair/Chart.yaml b/build/charts/codepair/Chart.yaml new file mode 100644 index 00000000..774442c9 --- /dev/null +++ b/build/charts/codepair/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: codepair +description: A Helm chart for CodePair, a collaborative coding platform built with Yorkie +type: application +icon: https://raw.githubusercontent.com/yorkie-team/yorkie-team.github.io/main/public/favicon-512x512.png +maintainers: + - name: krapie + email: krapi0314@gmail.com + +version: 0.1.0 +appVersion: "0.1.32" +kubeVersion: ">=1.23.0-0" + +dependencies: + - name: yorkie-mongodb + version: 0.4.13 + repository: https://yorkie-team.github.io/yorkie/helm-charts + condition: yorkie-mongodb.enabled + +keywords: + - codepair + - yorkie + - collaboration + - kubernetes diff --git a/build/charts/codepair/README.md b/build/charts/codepair/README.md new file mode 100644 index 00000000..7c22f055 --- /dev/null +++ b/build/charts/codepair/README.md @@ -0,0 +1,85 @@ +# CodePair Helm Chart + +Installs the CodePair application, a collaborative coding platform powered by Yorkie. + +## Prerequisites + +- Kubernetes 1.23+ +- Helm 3+ + +## Get Helm Repository Info + +```bash +# TODO(krapie): need to centralize the helm repo +helm repo add yorkie-team https://yorkie-team.github.io/yorkie/helm-charts +helm repo update +``` + +_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._ + +## Install Helm Chart + +```bash +# Create mongodb namespace if not already created +kubectl create namespace mongodb + +# Install codepair helm chart with default values +helm install codepair yorkie-team/codepair -n codepair --create-namespace +``` + +_See [configuration](#configuration) below for custom installation_ + +_See [`helm install`](https://helm.sh/docs/helm/helm_install/) for command documentation._ + +## Dependencies + +By default, this chart installs the following dependency: + +- [yorkie-mongodb](https://github.com/yorkie-team/yorkie/tree/main/charts/yorkie-mongodb) + +## Uninstall Helm Chart + +```bash +helm uninstall codepair +``` + +This removes all the Kubernetes components associated with the chart and deletes the release. + +_See [`helm uninstall`](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ + +## Upgrading Chart + +```bash +helm upgrade codepair yorkie-team/codepair +``` + +_See [`helm upgrade`](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ + +## Configuration + +See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments: + +```console +helm show values yorkie-team/codepair +``` + +### Key Parameters + +The following table lists the configurable parameters of the CodePair chart and their default values: + +| Parameter | Description | Default | +| --------- | ----------- | ------- | +| `codepair.image.repository` | CodePair image repository | `yorkieteam/codepair` | +| `codepair.image.tag` | CodePair image tag | `0.1.32` | +| `codepair.autoscaling.replicaCount` | Number of CodePair replicas | `1` | +| `codepair.env.databaseUrl` | MongoDB connection URI | `mongodb://mongodb.mongodb.svc.cluster.local:27017/codepair` | +| `codepair.env.githubClientId` | GitHub OAuth Client ID | `""` | +| `codepair.env.githubClientSecret` | GitHub OAuth Client Secret | `""` | +| `codepair.env.frontendBaseUrl` | Frontend application URL | `""` | +| `codepair.env.yorkieApiAddr` | Yorkie API address | `""` | +| `ingress.enabled` | Enable ingress | `true` | +| `ingress.className` | Ingress class name | `alb` | +| `ingress.hosts.apiHost` | Host name for API | `codepair-api.yorkie.dev` | +| `yorkie-mongodb.enabled` | Enable MongoDB dependency | `true` | + +You may also configure the MongoDB dependency. See the [yorkie-mongodb chart](https://github.com/yorkie-team/yorkie/tree/main/charts/yorkie-mongodb) for additional options. diff --git a/build/charts/codepair/templates/NOTES.txt b/build/charts/codepair/templates/NOTES.txt new file mode 100644 index 00000000..27f8c0df --- /dev/null +++ b/build/charts/codepair/templates/NOTES.txt @@ -0,0 +1,18 @@ +--- Install Complete --- +{{ .Release.Name }} successfully installed! + +CodePair application has been deployed to the {{ .Values.codepair.namespace }} namespace. + +{{- if .Values.ingress.hosts.enabled }} +Your application is available at: https://{{ .Values.ingress.hosts.apiHost }} +{{- else }} +To expose your service, you need to set up an Ingress or use port-forwarding: + + kubectl port-forward service/{{ .Values.codepair.name }} -n {{ .Values.codepair.namespace }} {{ .Values.codepair.ports.serverPort }}:{{ .Values.codepair.ports.serverPort }} + +Then access the application at: http://localhost:{{ .Values.codepair.ports.serverPort }} +{{- end }} + +To learn more about the release, try: + $ helm status {{ .Release.Name }} + $ helm get all {{ .Release.Name }} diff --git a/build/charts/codepair/templates/_helpers.tpl b/build/charts/codepair/templates/_helpers.tpl new file mode 100644 index 00000000..43b296ed --- /dev/null +++ b/build/charts/codepair/templates/_helpers.tpl @@ -0,0 +1,45 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "codepair.name" -}} +{{- default .Chart.Name .Values.codepair.name | 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). +*/}} +{{- define "codepair.fullname" -}} +{{- if .Values.codepair.name }} +{{- .Values.codepair.name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "codepair.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "codepair.labels" -}} +helm.sh/chart: {{ include "codepair.chart" . }} +{{ include "codepair.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "codepair.selectorLabels" -}} +app.kubernetes.io/name: {{ include "codepair.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/build/charts/codepair/templates/deployment.yaml b/build/charts/codepair/templates/deployment.yaml new file mode 100644 index 00000000..d9b85bf3 --- /dev/null +++ b/build/charts/codepair/templates/deployment.yaml @@ -0,0 +1,89 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.codepair.name }} + namespace: {{ .Values.codepair.namespace }} + labels: + app: {{ .Values.codepair.name }} + app.kubernetes.io/name: {{ .Values.codepair.name }} + app.kubernetes.io/instance: {{ .Values.codepair.name }} + app.kubernetes.io/version: {{ .Values.codepair.image.tag | default .Chart.AppVersion }} + app.kubernetes.io/component: server + app.kubernetes.io/part-of: {{ .Values.codepair.name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + version: {{ .Values.codepair.image.tag | default .Chart.AppVersion }} +spec: + {{ if not .Values.codepair.autoscaling.enabled }} + replicas: {{ .Values.codepair.autoscaling.replicaCount }} + {{ end }} + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: {{ .Values.codepair.name }} + template: + metadata: + labels: + app: {{ .Values.codepair.name }} + app.kubernetes.io/instance: {{ .Values.codepair.name }} + app.kubernetes.io/version: {{ .Values.codepair.image.tag | default .Chart.AppVersion }} + version: {{ .Values.codepair.image.tag | default .Chart.AppVersion }} + spec: + containers: + - name: {{ .Values.codepair.name }} + image: "{{ .Values.codepair.image.repository }}:{{ .Values.codepair.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.codepair.image.pullPolicy }} + env: + - name: DATABASE_URL + value: "{{ .Values.codepair.env.databaseUrl }}" + - name: GITHUB_CLIENT_ID + value: "{{ .Values.codepair.env.githubClientId }}" + - name: GITHUB_CLIENT_SECRET + value: "{{ .Values.codepair.env.githubClientSecret }}" + - name: GITHUB_CALLBACK_URL + value: "{{ .Values.codepair.env.githubCallbackUrl }}" + - name: GITHUB_AUTHORIZATION_URL + value: "{{ .Values.codepair.env.githubAuthorizationUrl }}" + - name: GITHUB_TOKEN_URL + value: "{{ .Values.codepair.env.githubTokenUrl }}" + - name: GITHUB_USER_PROFILE_URL + value: "{{ .Values.codepair.env.githubUserProfileUrl }}" + - name: JWT_ACCESS_TOKEN_SECRET + value: "{{ .Values.codepair.env.jwtAccessTokenSecret }}" + - name: JWT_ACCESS_TOKEN_EXPIRATION_TIME + value: "{{ .Values.codepair.env.jwtAccessTokenExpirationTime }}" + - name: JWT_REFRESH_TOKEN_SECRET + value: "{{ .Values.codepair.env.jwtRefreshTokenSecret }}" + - name: JWT_REFRESH_TOKEN_EXPIRATION_TIME + value: "{{ .Values.codepair.env.jwtRefreshTokenExpirationTime }}" + - name: FRONTEND_BASE_URL + value: "{{ .Values.codepair.env.frontendBaseUrl }}" + - name: YORKIE_API_ADDR + value: "{{ .Values.codepair.env.yorkieApiAddr }}" + - name: YORKIE_PROJECT_NAME + value: "{{ .Values.codepair.env.yorkieProjectName }}" + - name: YORKIE_PROJECT_SECRET_KEY + value: "{{ .Values.codepair.env.yorkieProjectSecretKey }}" + - name: YORKIE_INTELLIGENCE + value: "{{ .Values.codepair.env.yorkieIntelligence }}" + - name: OPENAI_API_KEY + value: "{{ .Values.codepair.env.openaiApiKey }}" + - name: LANGCHAIN_TRACING_V2 + value: "{{ .Values.codepair.env.langchainTracingV2 }}" + - name: LANGCHAIN_API_KEY + value: "{{ .Values.codepair.env.langchainApiKey }}" + - name: LANGCHAIN_PROJECT + value: "{{ .Values.codepair.env.langchainProject }}" + - name: FILE_UPLOAD + value: "{{ .Values.codepair.env.fileUpload }}" + - name: AWS_ACCESS_KEY_ID + value: "{{ .Values.codepair.env.awsAccessKeyId }}" + - name: AWS_SECRET_ACCESS_KEY + value: "{{ .Values.codepair.env.awsSecretAccessKey }}" + - name: AWS_REGION + value: "{{ .Values.codepair.env.awsRegion }}" + - name: BUCKET_NAME + value: "{{ .Values.codepair.env.bucketName }}" + ports: + - containerPort: {{ .Values.codepair.ports.serverPort }} + resources: + {{ toYaml .Values.codepair.resources | nindent 12 }} diff --git a/build/charts/codepair/templates/ingress.yaml b/build/charts/codepair/templates/ingress.yaml new file mode 100644 index 00000000..60fab3bf --- /dev/null +++ b/build/charts/codepair/templates/ingress.yaml @@ -0,0 +1,51 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + {{ if .Values.ingress.nginx.enabled }} + name: ingress-nginx + {{ else }} + name: {{ .Values.codepair.name }} + {{ end }} + namespace: {{ .Values.codepair.namespace }} + annotations: + {{ if .Values.ingress.awsAlb.enabled }} + alb.ingress.kubernetes.io/scheme: {{ .Values.ingress.awsAlb.scheme }} + # Set alb.ingress.kubernetes.io/certificate-arn annotation to TLS certificate's ARN issued by AWS ACM + alb.ingress.kubernetes.io/certificate-arn: {{ .Values.ingress.awsAlb.certArn }} + alb.ingress.kubernetes.io/listen-ports: {{ .Values.ingress.awsAlb.listenPorts }} + alb.ingress.kubernetes.io/backend-protocol: {{ .Values.ingress.awsAlb.backendProtocol }} + alb.ingress.kubernetes.io/backend-protocol-version: {{ .Values.ingress.awsAlb.backendProtocolVersion }} + alb.ingress.kubernetes.io/group.name: {{ .Values.ingress.awsAlb.groupName }} + alb.ingress.kubernetes.io/group.order: {{ .Values.ingress.awsAlb.groupOrder | quote }} + {{ end }} + {{ if .Values.ingress.ncpAlb.enabled }} + # Set alb.ingress.kubernetes.io/ssl-certificate-no annotation to TLS certificate's number issued by NCP + alb.ingress.kubernetes.io/ssl-certificate-no: "{{ .Values.ingress.ncpAlb.certNo }}" + alb.ingress.kubernetes.io/listen-ports: {{ .Values.ingress.ncpAlb.listenPorts }} + alb.ingress.kubernetes.io/ssl-redirect: {{ .Values.ingress.ncpAlb.sslRedirect }} + alb.ingress.kubernetes.io/backend-protocol: {{ .Values.ingress.ncpAlb.backendProtocol }} + alb.ingress.kubernetes.io/enable-http2: {{ .Values.ingress.ncpAlb.enableHttp2 }} + # Set alb.ingress.kubernetes.io/healthcheck-path annotation to health check path + alb.ingress.kubernetes.io/healthcheck-path: {{ .Values.ingress.ncpAlb.healthcheckPath }} + {{ end }} + {{ if .Values.ingress.nginx.enabled }} + nginx.ingress.kubernetes.io/rewrite-target: {{ .Values.ingress.nginx.rewriteTarget }} + kubernetes.io/ingress.class: "nginx" + {{ end }} +spec: + ingressClassName: {{ .Values.ingress.ingressClassName }} + rules: + {{ if .Values.ingress.hosts.enabled }} + - host: {{ .Values.ingress.hosts.apiHost }} + http: + {{ else }} + - http: + {{ end }} + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Values.codepair.name }} + port: + number: {{ .Values.codepair.ports.serverPort }} diff --git a/build/charts/codepair/templates/service.yaml b/build/charts/codepair/templates/service.yaml new file mode 100644 index 00000000..62cd23d5 --- /dev/null +++ b/build/charts/codepair/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.codepair.name }} + namespace: {{ .Values.codepair.namespace }} + labels: + app.kubernetes.io/name: {{ .Values.codepair.name }} + app.kubernetes.io/instance: {{ .Values.codepair.name }} + app.kubernetes.io/component: server + app.kubernetes.io/part-of: {{ .Values.codepair.name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: NodePort + ports: + - name: {{ .Values.codepair.name }}-server + port: {{ .Values.codepair.ports.serverPort }} + targetPort: {{ .Values.codepair.ports.serverPort }} + appProtocol: http + selector: + app.kubernetes.io/instance: {{ .Values.codepair.name }} diff --git a/build/charts/codepair/values.yaml b/build/charts/codepair/values.yaml new file mode 100644 index 00000000..6cb68580 --- /dev/null +++ b/build/charts/codepair/values.yaml @@ -0,0 +1,112 @@ +# Configuration for CodePair application +codepair: + name: codepair + namespace: codepair + + autoscaling: + enabled: false + replicaCount: 1 + + image: + repository: yorkieteam/codepair + pullPolicy: IfNotPresent + tag: "0.1.32" + + ports: + serverPort: 3000 + + env: + databaseUrl: "mongodb://mongodb.mongodb.svc.cluster.local:27017/codepair" + + # GitHub OAuth Settings + githubClientId: "" + githubClientSecret: "" + githubCallbackUrl: "" + githubAuthorizationUrl: "https://github.com/login/oauth/authorize" + githubTokenUrl: "https://github.com/login/oauth/access_token" + githubUserProfileUrl: "https://api.github.com/user" + + # JWT Settings + jwtAccessTokenSecret: "" + jwtAccessTokenExpirationTime: "86400" + jwtRefreshTokenSecret: "" + jwtRefreshTokenExpirationTime: "2592000" + + # Frontend and API URLs + frontendBaseUrl: "" + yorkieApiAddr: "" + + # Yorkie Project Settings + yorkieProjectName: "codepair" + yorkieProjectSecretKey: "" + + # AI/Intelligence Settings + yorkieIntelligence: "openai:gpt-4o-mini" + openaiApiKey: "" + + # LangChain Settings + langchainTracingV2: "true" + langchainApiKey: "" + langchainProject: "codepair-prod" + + # File Upload Settings + fileUpload: "s3" + awsAccessKeyId: "" + awsSecretAccessKey: "" + awsRegion: "ap-northeast-2" + bucketName: "yorkie-codepair" + + resources: {} + +# Configuration for ingress +ingress: + ingressClassName: nginx + ## Set to alb if you are using AWS, NCP ALB + # ingressClassName: alb + + hosts: + enabled: false + apiHost: "codepair-api.yorkie.dev" + + # AWS ALB configuration + awsAlb: + enabled: false + scheme: internet-facing + certArn: "arn:aws:acm:ap-northeast-2:123412341234:certificate/1234-1234-1234-1234-1234" + listenPorts: '[{"HTTPS": 443}]' + backendProtocol: HTTP + backendProtocolVersion: HTTP1 + groupName: "api.yorkie.dev" + groupOrder: "3" + + # NCP ALB configuration + ncpAlb: + enabled: false + certNo: "1234" + healthcheckPath: "/healthz" + listenPorts: '[{"HTTP": 80},{"HTTPS":443}]' + sslRedirect: "443" + backendProtocol: HTTP + enableHttp2: "true" + + # Nginx configuration + nginx: + enabled: true + rewriteTarget: "/" + +# Configuration for yorkie-mongodb +yorkie-mongodb: + name: mongodb + namespace: mongodb + port: 27017 + image: + registry: docker.io + repository: mongo + tag: "6.0" + persistence: + dataSize: 1Gi + configSize: 500Mi + storageClass: standard + sharded: + enabled: false + enabled: true