Skip to content

Commit

Permalink
Merge pull request #1 from apitable/development
Browse files Browse the repository at this point in the history
chore: init apitabole enterprise
  • Loading branch information
paylm authored Sep 28, 2023
2 parents 71ba246 + 49318c6 commit e9c4c40
Show file tree
Hide file tree
Showing 350 changed files with 41,891 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

.env
.terraform
.terraform.lock.hcl
./examples/*/config-k8s/kubeconfig
./examples/*/terraform.*


.idea
*.iml
out
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

100 changes: 98 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,98 @@
# terraform-apitable-enterprise
A Terraform module to create apitable enterprise
# Apitable Enterprise modules

## Introduction
`APITable` Terraform Modulesis a set of Terraform modules for managing and deploying APITable resources. These modules are designed to simplify the process of creating and configuring APITable resources, provide reusable code blocks, and help you quickly set up and manage your APITable environment.


## Module List
The following APITable Terraform modules are available:

* Apitable-app:
* `web-server`: build supercharged, SEO-friendly, and extremely user-facing static website and web application by using NextJS
* `backend-server`: handles HTTP requests about nodes, users, organizations, etc. Code under Java Spring Boot Framework
* `room-server`: handles operations(OTJSON) of datasheets, communicates with Socket Server through gRPC, and also provides APIs for developers. Coding under TypeScript and NestJS framework.
+ `nest-server`: handles HTTP GET requests about datasheets, records, views, etc.
+ `socket-server`: establishes a long connection with clients through the WebSocket protocol, allowing for two-way communication and real-time collaboration, notifications, and other features.
* `openresty`: Popular open source gateways.

* Apitable-datacenter:
* `MySQL`: Mysql is a popular relational database management system, often used for back-end data storage of web applications.
* `Redis`: Redis is a fast in-memory data structure storage system commonly used for caching and message queues.
* `RabbitMQ`: RabbitMQ is an open source message queuing software used for asynchronous communication between applications.
* `Minio`: Minio is an open source object storage server that can be used to store and manage large amounts of data.

* Regcred: Acts on Docker registry, users download docker image authentication.

* Charts: Offline charts of the stable version, which includes core modules such as minio, mysql, rabbitmq and redis.




## Requiremnet
1. `kubconfig` certificate, which requires the following permissions
```
- configmap:*
- pv:*
- pvc:*
- service:*
- deployment:*
- ns: create, get, list, watch
- events: create, get, list,delete, watch
- secret: *
```

2. The cluster has installed the kubernetes-csi driver and obtained the `storageclass`.
3. Providers for Kubernetes and Helm, referring to the values in the examples.


## Usage
To use the APITable Terraform Modules, follow these steps:

1. Create a new directory in your Terraform project to store your APITable-related configuration files.
2. Create a `main.tf` file in that directory and reference the desired modules.
3. Configure the input variables for each module to meet your needs.
4. Run the `terraform init` command to initialize your Terraform environment.
5. Run the `terraform apply` command to create and configure your APITable resources.


## Example

Here's an example of using the APITable Terraform Modules to create an APITable application and database:

```hcl
module "apitable-enterprise" {
source = "apitable/enterprise/apitable"
version = "1.0.0"
namespace = "apitable-enterprise"
// Environmental variables, such as databases, storage, etc.
env = {
"PARAM1" = "xx1"
"PARAM2" = "xx2"
}
default_storage_class_name = "<your-storage-class-name>"
regcred = {
registry_server = "<your-registry-server>"
username = "<your-username>"
password = "<your-password>"
}
#Optional, refer https://apitable.getoutline.com/s/82e078fc-1a8d-4616-b69d-fcdbb18ef715/doc/image-version-inventory-J9TZe7ym8I to replace the image version
image_tags = {
backend_server = "latest-alpha"
room_server = "latest-alpha"
web_server = "latest-alpha"
#And others ..
}
}
```

## FAQ
### Q1: How to get regcred information?

A: Submit the [form](https://vika.cn/share/shrdm5smaJ9XsxSzdTJVw/fom8jGSU4RqAw3vXNs) to request a trial.

4 changes: 4 additions & 0 deletions charts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# Helm Charts 安装包


23 changes: 23 additions & 0 deletions charts/init-data/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
6 changes: 6 additions & 0 deletions charts/init-data/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: vika-init-data
description: vika-init-data
type: application
version: 0.1.29
appVersion: "0.15.0"
Empty file.
Empty file.
13 changes: 13 additions & 0 deletions charts/init-data/templates/_tplvalues.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Renders a value that contains template.
Usage:
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "common.tplvalues.render" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}
79 changes: 79 additions & 0 deletions charts/init-data/templates/init-data/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{{/*
Set redis host
*/}}
{{- define "redis.host" -}}
{{- if .Values.redis.enabled -}}
{{- .Values.redis.host }}
{{- end -}}
{{- end -}}

{{/*
Set redis port
*/}}
{{- define "redis.port" -}}
{{- if .Values.redis.enabled -}}
{{- .Values.redis.port }}
{{- end -}}
{{- end -}}

{{/*
Set mysql host
*/}}
{{- define "mysql.host" -}}
{{- if .Values.mysql.enabled -}}
{{- .Values.mysql.host }}
{{- end -}}
{{- end -}}

{{/*
Set mysql port
*/}}
{{- define "mysql.port" -}}
{{- if .Values.mysql.enabled -}}
{{- .Values.mysql.port }}
{{- end -}}
{{- end -}}

{{/*
Set mongo host
*/}}
{{- define "mongo.host" -}}
{{- if .Values.mongo.enabled -}}
{{- .Values.mongo.host }}
{{- end -}}
{{- end -}}

{{/*
Set mongo port
*/}}
{{- define "mongo.port" -}}
{{- if .Values.mongo.enabled -}}
{{- .Values.mongo.port }}
{{- end -}}
{{- end -}}

{{/*
Set minio host
*/}}
{{- define "minio.host" -}}
{{- if .Values.minio.enabled -}}
{{- .Values.minio.host }}
{{- end -}}
{{- end -}}

{{/*
Set minio port
*/}}
{{- define "minio.port" -}}
{{- if .Values.minio.enabled -}}
{{- .Values.minio.port }}
{{- end -}}
{{- end -}}


{{- define "imagePullSecret" }}
{{- with .Values.global.imageCredentials }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- end }}

17 changes: 17 additions & 0 deletions charts/init-data/templates/init-data/appdata-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: init-appdata-env
namespace: {{.Release.Namespace}}
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-delete-policy": "{{ if .Values.hooks.removeOnSuccess }}hook-succeeded,{{ end }}before-hook-creation"
"helm.sh/hook-weight": "-5"
data:
{{- range $key, $val := .Values.initAppData }}
{{ $key }}: {{ $val | quote }}
{{- end}}


81 changes: 81 additions & 0 deletions charts/init-data/templates/init-data/init-appdata.job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{{- if .Values.mysql.enabled -}}
---
apiVersion: batch/v1
kind: Job
metadata:
name: init-appdata
namespace: {{.Release.Namespace}}
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-delete-policy": "{{ if .Values.hooks.removeOnSuccess }}hook-succeeded,{{ end }}before-hook-creation"
"helm.sh/hook-weight": "30"
spec:
{{- if .Values.hooks.activeDeadlineSeconds }}
activeDeadlineSeconds: {{ .Values.hooks.activeDeadlineSeconds }}
{{- end}}
#completionMode: Indexed
ttlSecondsAfterFinished: 180
template:
spec:
{{- if .Values.container.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.container.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.hooks.initCheck.tolerations }}
tolerations:
{{ toYaml .Values.hooks.initCheck.tolerations | indent 8 }}
{{- end }}
containers:
- name: init-appdata
image: {{ .Values.images.initAppData }}
imagePullPolicy: IfNotPresent
env:
- name: MYSQL_HOST
value: {{.Values.mysql.host}}
- name: MYSQL_PORT
value: "{{.Values.mysql.port}}"
- name: MYSQL_USERNAME
value: {{.Values.mysql.username}}
- name: MYSQL_PASSWORD
value: {{.Values.mysql.password}}
- name: MYSQL_DATABASE
value: {{.Values.mysql.database}}
- name: DATABASE_TABLE_PREFIX
value: {{.Values.mysql.tablePrefix}}
- name: AWS_ENDPOINT
value: "{{.Values.minio.schema}}://{{.Values.minio.host}}:{{.Values.minio.port}}"
- name: AWS_ACCESS_KEY
value: {{.Values.minio.accessKey}}
- name: AWS_ACCESS_SECRET
value: {{.Values.minio.secretKey}}
- name: AWS_REGION
value: {{.Values.minio.region}}
- name: OSS_BUCKET_NAME
value: {{.Values.minio.bucket}}
- name: ASSETS_BUCKET
value: {{.Values.minio.bucket}}
- name: OSS_ENABLED
value: "true"
- name: LOADER_TEMPLATE_SPACE_ID
value: "spcNTxlv8Drra"
- name: LOADER_WIDGET_SPACE_ID
value: "spcNTxlv8Drra"
- name: SKIP_WIDGET_CENTER_LOADER
value: "{{.Values.initAppData.skipWidgetCenterLoader}}"
- name: INIT_TEST_ACCOUNT_ENABLED
value: "{{.Values.initAppData.init_test_account_enabled}}"
envFrom:
- configMapRef:
name: init-appdata-env
optional: false

resources:
{{ toYaml .Values.global.resources | indent 12 }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.global.imagePullSecrets | indent 8 }}
{{- end }}
restartPolicy: Never
backoffLimit: 10
{{- end }}
Loading

0 comments on commit e9c4c40

Please sign in to comment.