Skip to content

Commit

Permalink
[Feature][Docs] Add start guide for docker and kubernetes (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
735140144 authored Jan 5, 2024
1 parent 3ad06a5 commit a4d1a4f
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/02-get-started/02-docker/01-build-docker-image.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
id: 'build-docker-image'
title: 'Build Docker Image'
---

## Build Docker Image
This document mainly introduces how to use Dockerfile to create a running image of DataVines, so that a DataVines Image can be quickly pulled to complete cluster creation in containerized orchestration tools or rapid testing processes.
## Prepare Dockerfile
The following points should be noted when writing Dockerfile:
>1. The basic parent image uses the official OpenJDK image certified by Docker Hub, with JDK version 1.8 used.
>2. The binary packages required for the application need to be packaged by oneself. Please refer to the [Deploy with Source Code] (/docs/02-get-started/01-build-from-source/03-package) 。
>3. When starting an application within Docker, use `start_container` parameter
>4. The construction platform should be consistent with the operation platform.
### Build Steps
* Write a Dockerfile file, which can be referenced as follows [Dockerfile](
https://raw.githubusercontent.com/datavane/datavines/dev/deploy/docker/Dockerfile),Can be downloaded through wget。
* Copy the packaged binary package to the directory where Dockerfile is located。
* Verify the consistency of binary package names in Dockerfile files。
* Pack and pack using the following command
```
docker build -t datavines:dev .
```

## Push images to DockerHub or private warehouse
Login to DockerHub account
```
docker login -u <username> <hubaddress>
```
Successful login will prompt a Success related prompt.

change the image tag
```
docker tag datavines:dev <hubaddress>/<namespace>/datavines:dev
```

push image to DockerHub
```
docker push <hubaddress>/<namespace>/datavines:dev
```
62 changes: 62 additions & 0 deletions docs/02-get-started/02-docker/02-deploy-docker-image.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
id: 'deploy-docker-image'
title: 'Run Docker Image'
---

## Description

This article will briefly describe how to quickly run Datavines using the 'Docker run' or 'Docker compile' commands.

## Environment

| software | Version |
|:--------------:|:--------------:|
| Docker | 20.0 and above |
| docker-compose | 2.10 and above |

## Method 1 (Recommended):docker-compose

### Preparation in advance

1.Download and modify[docker-compose.yaml](https://raw.githubusercontent.com/datavane/datavines/dev/deploy/compose/docker-compose.yaml)

* Modify the image version to a locally compiled version or a private repository image version

```
image: datavines:dev
```

* If there is a conflict between the external network segment and the internal network segment of the container, which means that the container can be accessed within the same network segment, but cannot be accessed across different network segments,Can modify the `network_mode` in the `docker-compose.yaml` file.。

```
networks:
datavines:
driver: bridge
ipam:
config:
- subnet: 172.18.0.0/24(Custom network segment)
```

2. Download environment configuration file[.env](https://raw.githubusercontent.com/datavane/datavines/dev/deploy/compose/.env)
3. Modify the configuration items in the `. env` file as follows:

```
# Database Connection
SPRING_DATASOURCE_URL=jdbc:mysql://127.0.0.1:3306/datavines?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
# User name
SPRING_DATASOURCE_USERNAME=root
```

### Quick Start

```
docker compose up -d
```

## Method 2 :docker run

The environmental parameters need to be passed in from the startup command, as shown below.

```
docker run -it -d --name datavines -p 5600:5600 --privileged=true --restart always -e SPRING_PROFILES_ACTIVE=mysql -e SPRING_DATASOURCE_URL=jdbc:mysql://127.0.0.1:3306/datavines?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8 -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=123456 -e SPRING_DATASOURCE_DRIVER-CLASS_NAME=com.mysql.cj.jdbc.Driver datavines:dev
```
3 changes: 3 additions & 0 deletions docs/02-get-started/02-docker/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"label": "Docker Deploy"
}
22 changes: 22 additions & 0 deletions docs/02-get-started/03-kubernetes-deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
id: 'kubernetes-deploy'
title: 'Kubernetes Deploy'
---

## Environmental Preparation
* Installation k8s
* Build datavines image
* Create or download the yml file for datavines on k8s
* https://raw.githubusercontent.com/datavane/datavines/dev/deploy/k8s/datavines.yaml

## Starting a cluster
Execute the following command by specifying the namespace.
```
kubectl apply -f datavines.yaml -n <namespace>
```

## Test and verify
Get the pod under the namespace and check if the datavines are running properly.
```
kubectl get pod -n <namespace>
```
4 changes: 4 additions & 0 deletions i18n/zh-CN/docusaurus-plugin-content-docs/current.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"message": "入门指南",
"description": "The label for category Get Started in sidebar tutorialSidebar"
},
"sidebar.tutorialSidebar.category.Docker Deploy": {
"message": "Docker部署",
"description": "The label for category Docker Deploy in sidebar tutorialSidebar"
},
"sidebar.tutorialSidebar.category.Integration": {
"message": "集成",
"description": "The label for category Integration in sidebar tutorialSidebar"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
id: 'build-docker-image'
title: '构建Docker镜像'
---

## 构建Docker Image
该文档主要介绍了如何通过 Dockerfile 来制作 DataVines 的运行镜像,以便于在容器化编排工具或者快速测试过程中可迅速拉取一个 Datavines Image 来完成集群的创建。

## 准备 Dockerfile
Dockerfile编写需注意以下几点:
>1. 基础父镜像选用经过 Docker-Hub 认证的 OpenJDK 官方镜像,版本用 JDK 1.8 版本。
>2. 应用所需二进制包需自行打包,参考 [用源码部署](/docs/02-get-started/01-build-from-source/03-package) 章节。
>3. 应用在Docker内启动时应使用 `start_container` 参数
>4. 构建平台应与运行平台保持一致。
### 构建步骤
* 编写 Dockerfile 文件,可参考如下[Dockerfile](
https://raw.githubusercontent.com/datavane/datavines/dev/deploy/docker/Dockerfile),可通过wget进行下载。
* 复制打包好的二进制包到 Dockerfile 所在目录。
* 校验 Dockerfile 文件中二进制包名一致性。
* 通过如下命令进行打包。
```
docker build -t datavines:dev .
```

## 推送镜像至 DockerHub 或私有仓库
登录 DockerHub 账号
```
docker login -u <username> <hubaddress>
```
登录成功会提示 Success 相关提示。

更改镜像标签
```
docker tag datavines:dev <hubaddress>/<namespace>/datavines:dev
```

推送镜像
```
docker push <hubaddress>/<namespace>/datavines:dev
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
id: 'deploy-docker-image'
title: '运行Docker镜像'
---

## 背景说明

本篇将简述如何通过`docker run``docker-compose`命令快速运行Datavines。

## 软件环境

| 软件 | 版本 |
|:--------------:|:--------:|
| Docker | 20.0及以上 |
| docker-compose | 2.10 及以上 |

## 方法一(推荐):docker-compose

### 前期准备

1.下载并修改[docker-compose.yaml](https://raw.githubusercontent.com/datavane/datavines/dev/deploy/compose/docker-compose.yaml)

* 修改镜像版本为本地编译版本或私仓镜像版本

```
image: datavines:dev
```

* 如出现外部网段与容器内部网段冲突,表现为容器同网段可访问,跨网段无法访问,可修改`docker-compose.yaml`文件中的`network_mode`

```
networks:
datavines:
driver: bridge
ipam:
config:
- subnet: 172.18.0.0/24(自定义网段)
```

2. 下载环境配置文件[.env](https://raw.githubusercontent.com/datavane/datavines/dev/deploy/compose/.env)
3. 修改`.env`文件中的配置项,参考如下:

```
# 数据库连接
SPRING_DATASOURCE_URL=jdbc:mysql://127.0.0.1:3306/datavines?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
# 数据库用户名
SPRING_DATASOURCE_USERNAME=root
```

### 快速启动

```
docker compose up -d
```

## 方法二:docker run
环境参数需从启动命令中传入,如下。
```
docker run -it -d --name datavines -p 5600:5600 --privileged=true --restart always -e SPRING_PROFILES_ACTIVE=mysql -e SPRING_DATASOURCE_URL=jdbc:mysql://127.0.0.1:3306/datavines?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8 -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=123456 -e SPRING_DATASOURCE_DRIVER-CLASS_NAME=com.mysql.cj.jdbc.Driver datavines:dev
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"label": "Docker Deploy"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
id: 'kubernetes-deploy'
title: 'Kubernetes部署'
---

## 环境准备
* 安装k8s
* 构建datavines镜像
* 创建或下载datavines on k8s的配置文件
* https://raw.githubusercontent.com/datavane/datavines/dev/deploy/k8s/datavines.yaml

## 部署
指定命名空间执行如下命令。
```
kubectl apply -f datavines.yaml -n <namespace>
```

## 验证
获取命名空间下的pod,查看datavines是否正常运行。
```
kubectl get pod -n <namespace>
```

0 comments on commit a4d1a4f

Please sign in to comment.