Move file path and Add flink sql gateway document
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | 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).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.labels" -}}
|
||||
helm.sh/chart: {{ include "flink-sql-gateway.chart" . }}
|
||||
{{ include "flink-sql-gateway.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- with .Values.global.labels }}
|
||||
{{ toYaml . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "flink-sql-gateway.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.serviceAccountName" -}}
|
||||
{{- if .Values.rbac.create }}
|
||||
{{- default (include "flink-sql-gateway.fullname" .) .Values.rbac.serviceAccountName }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.rbac.serviceAccountName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create namespace name
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.namespace" -}}
|
||||
{{- default .Values.global.namespace .Release.Namespace }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create image name
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.image" -}}
|
||||
{{- printf "%s:%s" .Values.global.image.repository .Values.global.image.tag }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Session Cluster labels
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.sessionCluster.labels" -}}
|
||||
{{ include "flink-sql-gateway.labels" . }}
|
||||
app: {{ .Values.sessionCluster.name }}
|
||||
component: flink-session-cluster
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
SQL Gateway labels
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.sqlGateway.labels" -}}
|
||||
{{ include "flink-sql-gateway.labels" . }}
|
||||
app: {{ .Values.sqlGateway.name }}
|
||||
component: flink-sql-gateway
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
SQL Client labels
|
||||
*/}}
|
||||
{{- define "flink-sql-gateway.sqlClient.labels" -}}
|
||||
{{ include "flink-sql-gateway.labels" . }}
|
||||
app: {{ .Values.sqlClient.name }}
|
||||
component: flink-sql-client
|
||||
{{- end }}
|
||||
@@ -0,0 +1,148 @@
|
||||
---
|
||||
# ConfigMap for SQL Gateway Configuration
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: sql-gateway-config
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.labels" . | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
sql-gateway-defaults.yaml: |
|
||||
# SQL Gateway Configuration
|
||||
sql-gateway:
|
||||
endpoint:
|
||||
rest:
|
||||
address: {{ .Values.sqlGateway.config.endpoint.rest.address }}
|
||||
port: {{ .Values.sqlGateway.config.endpoint.rest.port }}
|
||||
bind-address: {{ .Values.sqlGateway.config.endpoint.rest.bindAddress }}
|
||||
session:
|
||||
max-num: {{ .Values.sqlGateway.config.session.maxNum }}
|
||||
idle-timeout: {{ .Values.sqlGateway.config.session.idleTimeout }}
|
||||
check-interval: {{ .Values.sqlGateway.config.session.checkInterval }}
|
||||
plan-cache:
|
||||
enabled: {{ .Values.sqlGateway.config.session.planCache.enabled }}
|
||||
max-size: {{ .Values.sqlGateway.config.session.planCache.maxSize }}
|
||||
ttl: {{ .Values.sqlGateway.config.session.planCache.ttl }}
|
||||
{{- if .Values.sqlClient.enabled }}
|
||||
---
|
||||
# ConfigMap with sample SQL scripts
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: sql-test-scripts
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.labels" . | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
01-create-tables.sql: |
|
||||
-- Example SQL script for creating tables
|
||||
-- This is a template - modify according to your data sources
|
||||
|
||||
-- Example: Create source table (replace with your connector)
|
||||
CREATE TABLE source_table (
|
||||
id STRING,
|
||||
message STRING,
|
||||
timestamp_field TIMESTAMP(3),
|
||||
WATERMARK FOR timestamp_field AS timestamp_field - INTERVAL '5' SECOND
|
||||
) WITH (
|
||||
'connector' = 'your-connector', -- e.g., 'kafka', 'filesystem', etc.
|
||||
-- Add your connector-specific properties here
|
||||
'format' = 'json'
|
||||
);
|
||||
|
||||
-- Example: Create sink table (replace with your connector)
|
||||
CREATE TABLE sink_table (
|
||||
id STRING,
|
||||
processed_message STRING,
|
||||
original_timestamp TIMESTAMP(3),
|
||||
processing_time TIMESTAMP(3)
|
||||
) WITH (
|
||||
'connector' = 'your-connector', -- e.g., 'kafka', 'filesystem', etc.
|
||||
-- Add your connector-specific properties here
|
||||
'format' = 'json'
|
||||
);
|
||||
|
||||
02-simple-query.sql: |
|
||||
-- Simple filtering and transformation query
|
||||
INSERT INTO sink_table
|
||||
SELECT
|
||||
id,
|
||||
CONCAT('Processed: ', message) as processed_message,
|
||||
timestamp_field as original_timestamp,
|
||||
CURRENT_TIMESTAMP as processing_time
|
||||
FROM source_table
|
||||
WHERE LENGTH(message) > 5;
|
||||
|
||||
03-windowed-aggregation.sql: |
|
||||
-- Windowed aggregation example
|
||||
SELECT
|
||||
TUMBLE_START(timestamp_field, INTERVAL '1' MINUTE) as window_start,
|
||||
TUMBLE_END(timestamp_field, INTERVAL '1' MINUTE) as window_end,
|
||||
COUNT(*) as message_count,
|
||||
COUNT(DISTINCT id) as unique_ids
|
||||
FROM source_table
|
||||
GROUP BY TUMBLE(timestamp_field, INTERVAL '1' MINUTE);
|
||||
|
||||
test-data-generator.sql: |
|
||||
-- Generate test data (for manual testing)
|
||||
-- This would typically be done by external producer
|
||||
-- Example JSON format for input data:
|
||||
-- {"id": "msg001", "message": "Hello World", "timestamp_field": "2024-12-10T10:00:00.000Z"}
|
||||
-- {"id": "msg002", "message": "Test Message", "timestamp_field": "2024-12-10T10:01:00.000Z"}
|
||||
|
||||
README.md: |
|
||||
# Flink SQL Client Usage
|
||||
|
||||
## Connect to SQL Gateway with Remote Cluster
|
||||
```bash
|
||||
# Connect to SQL Gateway and specify remote cluster
|
||||
kubectl exec -it {{ .Values.sqlClient.name }} -n {{ include "flink-sql-gateway.namespace" . }} -- /opt/flink/bin/sql-client.sh gateway \
|
||||
--endpoint http://{{ .Values.sqlGateway.name }}:{{ .Values.sqlGateway.port }} \
|
||||
-Dexecution.target=remote \
|
||||
-Drest.address={{ .Values.sessionCluster.name }}-rest \
|
||||
-Drest.port=8081
|
||||
```
|
||||
|
||||
## Alternative: Set execution config in SQL
|
||||
```bash
|
||||
# Connect to SQL Gateway
|
||||
kubectl exec -it {{ .Values.sqlClient.name }} -n {{ include "flink-sql-gateway.namespace" . }} -- /opt/flink/bin/sql-client.sh gateway --endpoint http://{{ .Values.sqlGateway.name }}:{{ .Values.sqlGateway.port }}
|
||||
|
||||
# Then in SQL Client, set execution config:
|
||||
SET 'execution.target' = 'remote';
|
||||
SET 'rest.address' = '{{ .Values.sessionCluster.name }}-rest';
|
||||
SET 'rest.port' = '8081';
|
||||
```
|
||||
|
||||
## Run SQL Scripts
|
||||
```bash
|
||||
# Inside the SQL Client container
|
||||
kubectl exec -it {{ .Values.sqlClient.name }} -n {{ include "flink-sql-gateway.namespace" . }} -- bash
|
||||
|
||||
# View available scripts
|
||||
ls /opt/sql-scripts/
|
||||
|
||||
# Execute SQL file with remote cluster config
|
||||
/opt/flink/bin/sql-client.sh gateway \
|
||||
--endpoint http://{{ .Values.sqlGateway.name }}:{{ .Values.sqlGateway.port }} \
|
||||
-Dexecution.target=remote \
|
||||
-Drest.address={{ .Values.sessionCluster.name }}-rest \
|
||||
-Drest.port=8081 \
|
||||
-f /opt/sql-scripts/01-create-tables.sql
|
||||
```
|
||||
|
||||
## Test Data
|
||||
Send JSON messages to your input source:
|
||||
```json
|
||||
{"id": "msg001", "message": "Hello World", "timestamp_field": "2024-12-10T10:00:00.000Z"}
|
||||
```
|
||||
{{- end }}
|
||||
@@ -0,0 +1,67 @@
|
||||
{{- if .Values.sessionCluster.enabled }}
|
||||
---
|
||||
# Flink Session Cluster (for SQL Gateway to connect to)
|
||||
apiVersion: flink.apache.org/v1beta1
|
||||
kind: FlinkDeployment
|
||||
metadata:
|
||||
name: {{ .Values.sessionCluster.name }}
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.sessionCluster.labels" . | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
image: {{ include "flink-sql-gateway.image" . }}
|
||||
flinkVersion: {{ .Values.sessionCluster.flinkVersion }}
|
||||
flinkConfiguration:
|
||||
{{- toYaml .Values.sessionCluster.flinkConfiguration | nindent 4 }}
|
||||
serviceAccount: {{ include "flink-sql-gateway.serviceAccountName" . }}
|
||||
jobManager:
|
||||
resource:
|
||||
memory: {{ .Values.sessionCluster.jobManager.resources.memory }}
|
||||
cpu: {{ .Values.sessionCluster.jobManager.resources.cpu }}
|
||||
replicas: {{ .Values.sessionCluster.jobManager.replicas }}
|
||||
taskManager:
|
||||
resource:
|
||||
memory: {{ .Values.sessionCluster.taskManager.resources.memory }}
|
||||
cpu: {{ .Values.sessionCluster.taskManager.resources.cpu }}
|
||||
replicas: {{ .Values.sessionCluster.taskManager.replicas }}
|
||||
podTemplate:
|
||||
spec:
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.podSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: flink-main-container
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.sessionCluster.env }}
|
||||
env:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.sessionCluster.volumeMounts }}
|
||||
volumeMounts:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.sessionCluster.volumes }}
|
||||
volumes:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,173 @@
|
||||
{{- if .Values.sqlGateway.enabled }}
|
||||
---
|
||||
# SQL Gateway Deployment (separate from Flink cluster)
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Values.sqlGateway.name }}
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.sqlGateway.labels" . | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
replicas: {{ .Values.sqlGateway.replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Values.sqlGateway.name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ .Values.sqlGateway.name }}
|
||||
{{- include "flink-sql-gateway.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "flink-sql-gateway.serviceAccountName" . }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.podSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: sql-gateway
|
||||
image: {{ include "flink-sql-gateway.image" . }}
|
||||
imagePullPolicy: {{ .Values.global.image.pullPolicy }}
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
command: ["/bin/bash"]
|
||||
args:
|
||||
- -c
|
||||
- |
|
||||
# Wait for Flink session cluster to be ready with timeout
|
||||
echo "Waiting for Flink session cluster..."
|
||||
TIMEOUT=300 # 5 minutes
|
||||
ELAPSED=0
|
||||
INTERVAL=5
|
||||
|
||||
while [ $ELAPSED -lt $TIMEOUT ]; do
|
||||
if curl -f --connect-timeout 5 --max-time 10 http://{{ .Values.sessionCluster.name }}-rest:8081/v1/overview >/dev/null 2>&1; then
|
||||
echo "Flink session cluster is ready!"
|
||||
break
|
||||
fi
|
||||
echo "Waiting for Flink cluster... (${ELAPSED}s/${TIMEOUT}s)"
|
||||
sleep $INTERVAL
|
||||
ELAPSED=$((ELAPSED + INTERVAL))
|
||||
done
|
||||
|
||||
if [ $ELAPSED -ge $TIMEOUT ]; then
|
||||
echo "ERROR: Timeout waiting for Flink session cluster"
|
||||
echo "Checking cluster status..."
|
||||
kubectl get pods -n {{ include "flink-sql-gateway.namespace" . }} -l app={{ .Values.sessionCluster.name }} || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Flink cluster is ready. Starting SQL Gateway..."
|
||||
|
||||
# Create flink configuration with environment variable substitution
|
||||
cat > /opt/flink/conf/config.yaml << EOF
|
||||
# Remote Flink Cluster Configuration
|
||||
rest.bind-address: 0.0.0.0
|
||||
rest.address: {{ .Values.sessionCluster.name }}-rest
|
||||
rest.port: 8081
|
||||
jobmanager.rpc.address: {{ .Values.sessionCluster.name }}
|
||||
jobmanager.rpc.port: 6123
|
||||
|
||||
# Session Cluster at Kubernetes
|
||||
execution.target: kubernetes-session
|
||||
kubernetes.namespace: {{ .Release.Namespace }}
|
||||
kubernetes.cluster-id: {{ .Values.sessionCluster.name }}
|
||||
|
||||
# SQL Gateway Configuration
|
||||
sql-gateway.endpoint.rest.address: 0.0.0.0
|
||||
sql-gateway.endpoint.rest.port: {{ .Values.sqlGateway.port }}
|
||||
|
||||
# Table/SQL Configuration
|
||||
table.exec.source.idle-timeout: 30s
|
||||
table.exec.resource.default-parallelism: 1
|
||||
|
||||
# Additional Flink Configuration from values
|
||||
{{- with .Values.sqlGateway.flinkConfiguration }}
|
||||
{{- range $key, $value := . }}
|
||||
{{ $key }}: {{ $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
EOF
|
||||
|
||||
# Start SQL Gateway
|
||||
/opt/flink/bin/sql-gateway.sh start
|
||||
|
||||
echo "SQL Gateway started successfully"
|
||||
|
||||
# Wait for log file to be created and then tail it
|
||||
LOG_FILE=""
|
||||
for i in {1..30}; do
|
||||
LOG_FILE=$(find /opt/flink/log -name "flink--sql-gateway-*.log" 2>/dev/null | head -1)
|
||||
if [ -n "$LOG_FILE" ]; then
|
||||
echo "Found log file: $LOG_FILE"
|
||||
break
|
||||
fi
|
||||
echo "Waiting for log file to be created... ($i/30)"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [ -n "$LOG_FILE" ]; then
|
||||
echo "Tailing SQL Gateway log file..."
|
||||
tail -f "$LOG_FILE"
|
||||
else
|
||||
echo "Log file not found, keeping container alive..."
|
||||
# Keep container running without tailing logs
|
||||
while true; do
|
||||
echo "SQL Gateway is running on port {{ .Values.sqlGateway.port }}"
|
||||
sleep 60
|
||||
done
|
||||
fi
|
||||
env:
|
||||
- name: FLINK_CONF_DIR
|
||||
value: "/opt/flink/conf"
|
||||
{{- with .Values.sqlGateway.env }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: rest
|
||||
containerPort: {{ .Values.sqlGateway.port }}
|
||||
protocol: TCP
|
||||
volumeMounts:
|
||||
{{- with .Values.sqlGateway.volumeMounts }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
- name: sql-gateway-config
|
||||
mountPath: /opt/flink/conf/sql-gateway-defaults.yaml
|
||||
subPath: sql-gateway-defaults.yaml
|
||||
readOnly: true
|
||||
resources:
|
||||
{{- toYaml .Values.sqlGateway.resources | nindent 12 }}
|
||||
{{- with .Values.sqlGateway.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.sqlGateway.readinessProbe }}
|
||||
readinessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
{{- with .Values.sqlGateway.volumes }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
- name: sql-gateway-config
|
||||
configMap:
|
||||
name: sql-gateway-config
|
||||
{{- end }}
|
||||
@@ -0,0 +1,96 @@
|
||||
{{- if .Values.sqlGateway.enabled }}
|
||||
---
|
||||
# Hadoop Configuration ConfigMap for SQL Gateway
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: hadoop-config-{{ .Values.sessionCluster.name }}
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.sqlGateway.labels" . | nindent 4 }}
|
||||
data:
|
||||
core-site.xml: |
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property>
|
||||
<name>fs.defaultFS</name>
|
||||
<value>hdfs://localhost:9000</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>hadoop.tmp.dir</name>
|
||||
<value>/tmp/hadoop</value>
|
||||
</property>
|
||||
|
||||
<!-- S3A Configuration -->
|
||||
<property>
|
||||
<name>fs.s3a.impl</name>
|
||||
<value>org.apache.hadoop.fs.s3a.S3AFileSystem</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.aws.credentials.provider</name>
|
||||
<value>org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.access.key</name>
|
||||
<value>${AWS_ACCESS_KEY_ID}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.secret.key</name>
|
||||
<value>${AWS_SECRET_ACCESS_KEY}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.endpoint</name>
|
||||
<value>${S3_ENDPOINT}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.path.style.access</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.connection.ssl.enabled</name>
|
||||
<value>false</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.fast.upload</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.multipart.size</name>
|
||||
<value>67108864</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>fs.s3a.multipart.threshold</name>
|
||||
<value>134217728</value>
|
||||
</property>
|
||||
</configuration>
|
||||
|
||||
hdfs-site.xml: |
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property>
|
||||
<name>dfs.replication</name>
|
||||
<value>1</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>dfs.namenode.name.dir</name>
|
||||
<value>/tmp/hadoop/namenode</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>dfs.datanode.data.dir</name>
|
||||
<value>/tmp/hadoop/datanode</value>
|
||||
</property>
|
||||
</configuration>
|
||||
|
||||
yarn-site.xml: |
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property>
|
||||
<name>yarn.nodemanager.aux-services</name>
|
||||
<value>mapreduce_shuffle</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.resourcemanager.hostname</name>
|
||||
<value>localhost</value>
|
||||
</property>
|
||||
</configuration>
|
||||
{{- end }}
|
||||
@@ -0,0 +1,49 @@
|
||||
{{- if .Values.rbac.create }}
|
||||
---
|
||||
# ServiceAccount for Flink SQL Gateway
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "flink-sql-gateway.serviceAccountName" . }}
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.labels" . | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
---
|
||||
# ClusterRole for Flink SQL Gateway
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: {{ include "flink-sql-gateway.fullname" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["pods", "services", "endpoints", "persistentvolumeclaims", "events", "configmaps", "secrets"]
|
||||
verbs: ["*"]
|
||||
- apiGroups: ["apps"]
|
||||
resources: ["deployments", "replicasets"]
|
||||
verbs: ["*"]
|
||||
- apiGroups: ["flink.apache.org"]
|
||||
resources: ["flinkdeployments", "flinksessionjobs"]
|
||||
verbs: ["*"]
|
||||
---
|
||||
# ClusterRoleBinding for Flink SQL Gateway
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: {{ include "flink-sql-gateway.fullname" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.labels" . | nindent 4 }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: {{ include "flink-sql-gateway.fullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "flink-sql-gateway.serviceAccountName" . }}
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,71 @@
|
||||
{{- if .Values.sqlGateway.enabled }}
|
||||
---
|
||||
# Service for SQL Gateway
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Values.sqlGateway.name }}
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.sqlGateway.labels" . | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.services.sqlGateway.type }}
|
||||
ports:
|
||||
- name: rest
|
||||
port: {{ .Values.services.sqlGateway.port }}
|
||||
targetPort: {{ .Values.services.sqlGateway.targetPort }}
|
||||
protocol: TCP
|
||||
selector:
|
||||
app: {{ .Values.sqlGateway.name }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .Values.ingress.enabled }}
|
||||
---
|
||||
# Ingress for SQL Gateway
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "flink-sql-gateway.fullname" . }}
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.ingress.className }}
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- end }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
{{- if .pathType }}
|
||||
pathType: {{ .pathType }}
|
||||
{{- end }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ $.Values.sqlGateway.name }}
|
||||
port:
|
||||
number: {{ $.Values.services.sqlGateway.port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,92 @@
|
||||
{{- if .Values.sqlClient.enabled }}
|
||||
---
|
||||
# SQL Client Deployment for interactive SQL queries
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Values.sqlClient.name }}
|
||||
namespace: {{ include "flink-sql-gateway.namespace" . }}
|
||||
labels:
|
||||
{{- include "flink-sql-gateway.sqlClient.labels" . | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Values.sqlClient.name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ .Values.sqlClient.name }}
|
||||
{{- include "flink-sql-gateway.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "flink-sql-gateway.serviceAccountName" . }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.podSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: sql-client
|
||||
image: {{ include "flink-sql-gateway.image" . }}
|
||||
imagePullPolicy: {{ .Values.global.image.pullPolicy }}
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
command: ["/bin/bash"]
|
||||
args:
|
||||
- -c
|
||||
- |
|
||||
echo "Flink SQL Client Ready"
|
||||
echo "Connect to SQL Gateway: {{ .Values.sqlGateway.name }}:{{ .Values.sqlGateway.port }}"
|
||||
echo "Usage: /opt/flink/bin/sql-client.sh gateway --endpoint http://{{ .Values.sqlGateway.name }}:{{ .Values.sqlGateway.port }}"
|
||||
|
||||
# Wait for SQL Gateway to be ready
|
||||
echo "Waiting for SQL Gateway..."
|
||||
until curl -f http://{{ .Values.sqlGateway.name }}:{{ .Values.sqlGateway.port }}/v1/info; do
|
||||
echo "Waiting for SQL Gateway..."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
echo "SQL Gateway is ready!"
|
||||
echo "You can now connect using:"
|
||||
echo "/opt/flink/bin/sql-client.sh gateway --endpoint http://{{ .Values.sqlGateway.name }}:{{ .Values.sqlGateway.port }}"
|
||||
|
||||
# Keep container running
|
||||
tail -f /dev/null
|
||||
{{- with .Values.sqlClient.env }}
|
||||
env:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- with .Values.sqlClient.volumeMounts }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
- name: sql-scripts
|
||||
mountPath: /opt/sql-scripts
|
||||
readOnly: true
|
||||
resources:
|
||||
{{- toYaml .Values.sqlClient.resources | nindent 12 }}
|
||||
volumes:
|
||||
{{- with .Values.sqlClient.volumes }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
- name: sql-scripts
|
||||
configMap:
|
||||
name: sql-test-scripts
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user