Artun Duman
03/29/2023, 6:40 PMkubectl create clusterrolebinding flink-role-binding-default --clusterrole=edit --serviceaccount=default:default
$FLINK_PATH/bin/kubernetes-session.sh -Dkubernetes.cluster-id=flink-session-cluster -Dkubernetes.rest-service.exposed.type=LoadBalancer -Dkubernetes.namespace=default -Drest.address=0.0.0.0
This works fine and creates the cluster on minikube, I can access it if I do minikube tunnel to access the UI. At this point my services look like this:
β kg svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
flink-session-cluster ClusterIP None <none> 6123/TCP,6124/TCP 5s
flink-session-cluster-rest LoadBalancer 10.100.202.72 127.0.0.1 8081:32409/TCP 5s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 4d18h
I then create the SQL Gateway with the below yaml file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: sql-gateway
spec:
replicas: 1
selector:
matchLabels:
app: sql-gateway
template:
metadata:
labels:
app: sql-gateway
spec:
containers:
- name: sql-gateway
image: flink:1.17.0
ports:
- containerPort: 8083
command: ["/bin/sh", "-c"]
args:
- "/opt/flink/bin/sql-gateway.sh start-foreground"
volumeMounts:
- name: flink-conf
mountPath: /opt/flink/conf/flink-conf.yaml
volumes:
- name: flink-conf
hostPath:
path: /host/flink-refinery/k8s/conf/flink-conf.yaml # minikube stuff
type: File
---
apiVersion: v1
kind: Service
metadata:
name: sql-gateway
spec:
selector:
app: sql-gateway
ports:
- name: sql-gateway
port: 8083
targetPort: 8083
type: ClusterIP
And my flink-conf.yaml is
jobmanager.rpc.address: flink-session-cluster
jobmanager.rpc.port: 6123
rest.address: flink-session-cluster-rest
rest.port: 8081
sql-gateway.endpoint.rest.address: 0.0.0.0
sql-gateway.endpoint.rest.port: 8083
sql-gateway.endpoint.type: rest
I can confirm from the logs that this config is picked up.
2023-03-29 18:33:38,431 INFO org.apache.flink.configuration.GlobalConfiguration [] - Loading configuration property: rest.port, 8081
2023-03-29 18:33:38,431 INFO org.apache.flink.configuration.GlobalConfiguration [] - Loading configuration property: sql-gateway.endpoint.rest.address, sql-gateway
2023-03-29 18:33:38,431 INFO org.apache.flink.configuration.GlobalConfiguration [] - Loading configuration property: sql-gateway.endpoint.type, rest
2023-03-29 18:33:38,431 INFO org.apache.flink.configuration.GlobalConfiguration [] - Loading configuration property: jobmanager.rpc.address, flink-session-cluster
2023-03-29 18:33:38,431 INFO org.apache.flink.configuration.GlobalConfiguration [] - Loading configuration property: sql-gateway.endpoint.rest.port, 8083
2023-03-29 18:33:38,432 INFO org.apache.flink.configuration.GlobalConfiguration [] - Loading configuration property: rest.address, flink-session-cluster-rest
2023-03-29 18:33:38,432 INFO org.apache.flink.configuration.GlobalConfiguration [] - Loading configuration property: jobmanager.rpc.port, 6123
When I create a new Flink pod and run the sql client, however, I get an error from SQL Gateway. These are my pods and services at this point:
β kg po
NAME READY STATUS RESTARTS AGE
flink-session-cluster-758bc469cc-lgpps 1/1 Running 0 10m
sql-client-74f44556cf-ls24w 1/1 Running 0 2m29s
sql-gateway-7758c8fdf9-nldvt 1/1 Running 0 2m29s
β kg svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
flink-session-cluster ClusterIP None <none> 6123/TCP,6124/TCP 10m
flink-session-cluster-rest LoadBalancer 10.100.202.72 127.0.0.1 8081:32409/TCP 10m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 4d18h
sql-gateway ClusterIP 10.103.121.161 <none> 8083/TCP 2m30s
And I use sql-client pod to connect to the gateway like this:
β kubectl exec -i -t sql-client-74f44556cf-ls24w -- /bin/bash
root@sql-client-74f44556cf-5tv5d:/opt/flink# ./bin/sql-client.sh gateway -e sql-gateway:8083
# At this point I get "Session <id> is opened, and the number..." from SQL Gateway logs, so I can connect to the gateway
Flink SQL> SELECT
> name,
> COUNT(*) AS cnt
> FROM
> (VALUES ('Bob'), ('Alice'), ('Greg'), ('Bob')) AS NameTable(name)
> GROUP BY name;
As soon as I run that test SQL command, I get this error from the gateway's logs:
2023-03-29 18:32:28,748 WARN org.apache.flink.client.program.rest.RestClusterClient [] - Attempt to submit job 'collect' (ccaafce00ee8c95e4b5c037774d885e1) to '<http://0.0.0.0:8081>' has failed.
java.util.concurrent.CompletionException: org.apache.flink.shaded.netty4.io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /0.0.0.0:8081
at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) ~[?:?]
at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) ~[?:?]
at java.util.concurrent.CompletableFuture$UniCompose.tryFire(Unknown Source) ~[?:?]
at java.util.concurrent.CompletableFuture.postComplete(Unknown Source) ~[?:?]
at java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source) ~[?:?]
at org.apache.flink.runtime.rest.RestClient.lambda$submitRequest$1(RestClient.java:480) ~[flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:609) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:321) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:337) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) [flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [flink-dist-1.17.0.jar:1.17.0]
at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: org.apache.flink.shaded.netty4.io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /0.0.0.0:8081
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[?:?]
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source) ~[?:?]
at org.apache.flink.shaded.netty4.io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337) ~[flink-dist-1.17.0.jar:1.17.0]
at org.apache.flink.shaded.netty4.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) ~[flink-dist-1.17.0.jar:1.17.0]
Now I am extremely confused, why it's trying to connect to 0.0.0.0:8081 ? I remember I got this to work at some point, but I'm not sure what was different since I was just quickly experimenting.. If anyone has any pointers, I'd really appreciate it! Thanks!Artun Duman
03/29/2023, 8:51 PMsql-gateway on the same pod as the job manager? Is that the assumption?Rajat Ahuja
07/04/2023, 9:08 PMArtun Duman
07/04/2023, 11:53 PMPedro H S Teixeira
07/05/2023, 7:49 PMspec:
containers:
- name: flink-sql-gateway
image: flink:1.17.1-scala_2.12-java11
command: ["/bin/sh"]
args: ["-c", "/docker-entrypoint.sh /opt/flink/bin/sql-gateway.sh start-foreground -Dsql-gateway.endpoint.rest.address=0.0.0.0 -Djobmanager.rpc.address=flink-deployment -Dtaskmanager.host=flink-deployment -Drest.address=flink-deployment"]
ports:
- containerPort: 8083
gateway responds fine to GET /v1/info but when trying to send a query via sql-client, it hangs + timeout and gateway logs I am seeing similar exception Connection refused: localhost/127.0.0.1:8081
I am guessing that the CLI -D are not working (maybe default values from conf are being prioritized) or there is another property that needs to be setPedro H S Teixeira
07/05/2023, 8:18 PMcontainers:
- name: flink-sql-gateway
image: flink:1.17.1-scala_2.12-java11
env:
- name: JOB_MANAGER_RPC_ADDRESS
value: flink-deployment
command: ["/bin/sh"]
args: ["-c", "/docker-entrypoint.sh /opt/flink/bin/sql-gateway.sh start-foreground -Dsql-gateway.endpoint.rest.address=0.0.0.0"]
ports:
- containerPort: 8083
but not sure what rest.address in the sql gateway should be, if ok 0.0.0.0 or if this is another remote servicePedro H S Teixeira
07/05/2023, 8:52 PM./bin/sql-client.sh gateway --endpoint <http://sql.flink.minikube>
I had to type
SET rest.address=flink-deployment;
or running with the -Drest.address :
./bin/sql-client.sh gateway --endpoint <http://sql.flink.minikube> -Drest.address=flink-deployment
so that it would work. It seems the client is sending the params from its context, which is is then used by the gateway.
Flink SQL> SELECT
> name,
> COUNT(*) AS cnt
> FROM
> (VALUES ('Bob'), ('Alice'), ('Greg'), ('Bob')) AS NameTable(name)
> GROUP BY name;
+-------+-----+
| name | cnt |
+-------+-----+
| Alice | 1 |
| Bob | 2 |
| Greg | 1 |
+-------+-----+
3 rows in setRajat Ahuja
07/05/2023, 9:32 PMRajat Ahuja
07/05/2023, 9:32 PM[ERROR] Could not execute SQL statement. Reason:
org.apache.flink.runtime.rest.util.RestClientException: 413 Request Entity Too Large. Try to raise [rest.client.max-content-length]