From 8f6d61abe9ac8f44f32c8232405c564f48039e23 Mon Sep 17 00:00:00 2001 From: yangyang zhong <35210666+hdygxsj@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:06:13 +0800 Subject: [PATCH] [Feature] Support kubernetes deployment via YAML files (#401) --- paimon-web-server/src/main/bin/env.sh | 4 +- scripts/deploy/kubernetes/configmap.yaml | 125 ++++++++++++++++++++++ scripts/deploy/kubernetes/deployment.yaml | 87 +++++++++++++++ scripts/deploy/kubernetes/ingress.yaml | 34 ++++++ scripts/deploy/kubernetes/service.yaml | 28 +++++ 5 files changed, 276 insertions(+), 2 deletions(-) create mode 100644 scripts/deploy/kubernetes/configmap.yaml create mode 100644 scripts/deploy/kubernetes/deployment.yaml create mode 100644 scripts/deploy/kubernetes/ingress.yaml create mode 100644 scripts/deploy/kubernetes/service.yaml diff --git a/paimon-web-server/src/main/bin/env.sh b/paimon-web-server/src/main/bin/env.sh index 1419a8688..da7a989a8 100644 --- a/paimon-web-server/src/main/bin/env.sh +++ b/paimon-web-server/src/main/bin/env.sh @@ -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= @@ -26,4 +26,4 @@ JVM_ARGS="-server" JAVA_OPTS=${JAVA_OPTS:-"${JVM_ARGS}"} -JAVA_HOME= \ No newline at end of file +JAVA_HOME=${JAVA_HOME:-/opt/java/openjdk} \ No newline at end of file diff --git a/scripts/deploy/kubernetes/configmap.yaml b/scripts/deploy/kubernetes/configmap.yaml new file mode 100644 index 000000000..f341bd846 --- /dev/null +++ b/scripts/deploy/kubernetes/configmap.yaml @@ -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: |- + + + + ./logs/ + paimon + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${FILE_LOG_PATTERN} + + + + + + + + + + + + + + + + + + + diff --git a/scripts/deploy/kubernetes/deployment.yaml b/scripts/deploy/kubernetes/deployment.yaml new file mode 100644 index 000000000..a7f4f32ce --- /dev/null +++ b/scripts/deploy/kubernetes/deployment.yaml @@ -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 + diff --git a/scripts/deploy/kubernetes/ingress.yaml b/scripts/deploy/kubernetes/ingress.yaml new file mode 100644 index 000000000..bf82ac20f --- /dev/null +++ b/scripts/deploy/kubernetes/ingress.yaml @@ -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 diff --git a/scripts/deploy/kubernetes/service.yaml b/scripts/deploy/kubernetes/service.yaml new file mode 100644 index 000000000..815a8fe53 --- /dev/null +++ b/scripts/deploy/kubernetes/service.yaml @@ -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 \ No newline at end of file