Skip to content

Commit

Permalink
[Feature] Support kubernetes deployment via YAML files (apache#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
hdygxsj authored Jun 18, 2024
1 parent cf70ee6 commit 8f6d61a
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 2 deletions.
4 changes: 2 additions & 2 deletions paimon-web-server/src/main/bin/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#

# Set the FLINK_HOME directory to execute the flink command to submit the cdc job.
FLINK_HOME=
FLINK_HOME=${FLINK_HOME:-""}

# Set the ACTION_JAR_PATH to execute the paimon action job.
ACTION_JAR_PATH=
Expand All @@ -26,4 +26,4 @@ JVM_ARGS="-server"

JAVA_OPTS=${JAVA_OPTS:-"${JVM_ARGS}"}

JAVA_HOME=
JAVA_HOME=${JAVA_HOME:-/opt/java/openjdk}
125 changes: 125 additions & 0 deletions scripts/deploy/kubernetes/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
name: paimon-web-configmap
labels:
app: paimon-web
data:
application.yml: |-
server:
port: 10088
spring:
application:
name: Paimon-Web-UI
profiles:
active: dev-mysql
messages:
basename: i18n/messages
encoding: UTF-8
mvc:
pathmatch:
matching-strategy: ant_path_matcher
format:
date: yyyy-MM-dd HH:mm:ss # date format
time: HH:mm:ss # time format
date-time: yyyy-MM-dd HH:mm:ss # date-time format
jackson:
time-zone: GMT+8 # Time zone, default is GMT+8
date-format: yyyy-MM-dd HH:mm:ss # Date format, the default is yyyy-MM-dd HH:mm:ss
spring:
datasource:
url: jdbc:mysql://${MYSQL_ADDR:127.0.0.1:3306}/${MYSQL_DATABASE:paimon}?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:username}
password: ${MYSQL_PASSWORD:password}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
maximum-pool-size: 20
minimum-idle: 10
max-lifetime: 27000000
idle-timeout: 600000
connection-test-query: SELECT 1
mybatis-plus:
mapperLocations: classpath*:mapper/*Mapper.xml
global-config:
banner: false
db-config:
logic-delete-field: is_delete
configuration:
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
sa-token:
token-name: ${spring.application.name}
timeout: 2592000
active-timeout: -1
is-concurrent: true
is-share: true
token-style: uuid
is-log: false
is-print: false
is-read-cookie: true
is-write-header: true
is-read-header: true
is-read-body: true
management:
web:
exposure:
include: info,health
endpoint:
health:
show-details: when-authorized
health:
ldap:
enabled: false
log4j2-spring.xml: |-
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="OFF" monitorInterval="600">
<Properties>
<property name="LOG_PATH">./logs/</property>
<property name="LOG_FILE">paimon</property>
<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss z} %-5level %class{36}#%M:%L - %msg%xEx%n"/>
<property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%6p} %style{%5pid}{bright,magenta} --- [%15.15t] %style{%c{20}}{bright,cyan}: %m%n"/>
</Properties>
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="ACCEPT"/>
<PatternLayout>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
</PatternLayout>
</Console>
<RollingFile name="RollingFile" fileName="${LOG_PATH}/${LOG_FILE}.log"
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${LOG_FILE}-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<Pattern>${FILE_LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="100MB"/>
</Policies>
</RollingFile>
</appenders>
<loggers>
<root level="info">
<appender-ref ref="Console"/>
<!--<appender-ref ref="File"/>-->
<appender-ref ref="RollingFile"/>
</root>
</loggers>
</configuration>
87 changes: 87 additions & 0 deletions scripts/deploy/kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
name: paimon-web-deployment # Deployment name for Paimon Web UI
labels:
app: paimon-web # Label to categorize the Deployment

spec:
replicas: 1 # Number of desired replicas
selector: # Selector to match Pods controlled by this Deployment
matchLabels:
app: paimon-web

strategy:
type: RollingUpdate # Strategy for updating Pods
rollingUpdate:
maxSurge: 25% # Maximum surge of new Pods during update
maxUnavailable: 0 # Ensure no Pods are unavailable during update

template: # Pod template specification
metadata:
labels:
app: paimon-web # Pod labels to match Deployment selector

spec:
serviceAccountName: default # Use the default service account
containers:
- name: paimon-web-container # Name of the container
ports:
- containerPort: 10088 # Exposed port within the container
name: "port"

image: apache/paimon-webui:latest # Docker image to use
imagePullPolicy: IfNotPresent # Always pull the latest image

env: # Environment variables for container configuration
- name: MYSQL_HOST # MySQL host address
value: xxxxx
- name: MYSQL_USERNAME # MySQL username
value: xxxxx
- name: MYSQL_PASSWORD # MySQL password
value: xxxxx
- name: ACTION_JAR_PATH # Path to action JAR file
value: xxxxx
- name: FLINK_HOME # Home directory for Flink
value: xxxxx
- name: JAVA_HOME
value: java
livenessProbe: # Liveness probe to check container health
exec: # Command execution for probe
command: ["curl", "-s", "http://localhost:10088/actuator/health/liveness"]
initialDelaySeconds: 30 # Initial delay before probe starts
periodSeconds: 30 # How often to perform the probe
timeoutSeconds: 5 # Probe timeout
successThreshold: 1 # Minimum consecutive successes for healthy status
failureThreshold: 1 # Minimum consecutive failures for unhealthy status

readinessProbe: # Readiness probe to verify if Pod is ready to serve traffic
exec:
command: ["curl", "-s", "http://localhost:10088/actuator/health/readiness"]
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 1

volumeMounts: # Volume mounts for the container
- mountPath: /opt/paimon/config # Path where the volume is mounted inside the container
name: config-volume # Named volume
volumes:
- name: config-volume
configMap:
name: paimon-web-configmap

34 changes: 34 additions & 0 deletions scripts/deploy/kubernetes/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: paimon-web
labels:
app: paimon-web
annotations:
nginx.ingress.kubernetes.io/rewrite-target: / # Example annotation for path-based routing with Nginx Ingress Controller
spec:
ingressClassName: nginx # Your ingress class name
rules:
- host: paimonweb.k8s.io # Replace with your desired hostname
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: paimon-web-svc
port:
name: server
28 changes: 28 additions & 0 deletions scripts/deploy/kubernetes/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Service
metadata:
name: paimon-web-svc
labels:
app: paimon-web
spec:
type: ClusterIP
ports:
- port: 10088
targetPort: 10088
name: port
protocol: TCP
selector:
app: paimon-web

0 comments on commit 8f6d61a

Please sign in to comment.