Hon*_*iao 5 java kubernetes apache-flink k3s k3d
我有一个简单的 Flink 流应用程序。在通过命令创建的集群中运行良好start-cluster.sh。
现在根据Flink 教程,我希望将其以应用程序模式原生部署在 macOS 上k3d创建的 Kubernetes 集群中。
\n首先,我通过创建一个集群k3d cluster create dev。
这是我的Dockerfile:
\nFROM flink\nRUN mkdir -p $FLINK_HOME/usrlib\nCOPY target/streaming-0.1.jar $FLINK_HOME/usrlib/streaming-0.1.jar\nRun Code Online (Sandbox Code Playgroud)\n我构建了它并将其推送到 Docker Hub。
\n我的集群名称是k3d-dev,所以我跑了
flink run-application \\\n --target kubernetes-application \\\n -Dkubernetes.cluster-id=k3d-dev \\\n -Dkubernetes.container.image=hongbomiao/my-flink-xxx:latest \\\n local:///opt/flink/usrlib/streaming-0.1.jar\n\nRun Code Online (Sandbox Code Playgroud)\n但是,我得到了错误:
\n The program finished with the following exception:\n\nio.fabric8.kubernetes.client.KubernetesClientException: JcaPEMKeyConverter is provided by BouncyCastle, an optional dependency. To use support for EC Keys you must explicitly add this dependency to classpath.\n at io.fabric8.kubernetes.client.internal.CertUtils.handleECKey(CertUtils.java:161)\n at io.fabric8.kubernetes.client.internal.CertUtils.loadKey(CertUtils.java:131)\n at io.fabric8.kubernetes.client.internal.CertUtils.createKeyStore(CertUtils.java:111)\n at io.fabric8.kubernetes.client.internal.CertUtils.createKeyStore(CertUtils.java:243)\n at io.fabric8.kubernetes.client.internal.SSLUtils.keyManagers(SSLUtils.java:128)\n at io.fabric8.kubernetes.client.internal.SSLUtils.keyManagers(SSLUtils.java:122)\n at io.fabric8.kubernetes.client.utils.HttpClientUtils.createHttpClient(HttpClientUtils.java:82)\n at io.fabric8.kubernetes.client.utils.HttpClientUtils.createHttpClient(HttpClientUtils.java:62)\n at io.fabric8.kubernetes.client.BaseClient.<init>(BaseClient.java:51)\n at io.fabric8.kubernetes.client.DefaultKubernetesClient.<init>(DefaultKubernetesClient.java:105)\n at org.apache.flink.kubernetes.kubeclient.FlinkKubeClientFactory.fromConfiguration(FlinkKubeClientFactory.java:102)\n at org.apache.flink.kubernetes.KubernetesClusterClientFactory.createClusterDescriptor(KubernetesClusterClientFactory.java:61)\n at org.apache.flink.kubernetes.KubernetesClusterClientFactory.createClusterDescriptor(KubernetesClusterClientFactory.java:39)\n at org.apache.flink.client.deployment.application.cli.ApplicationClusterDeployer.run(ApplicationClusterDeployer.java:63)\n at org.apache.flink.client.cli.CliFrontend.runApplication(CliFrontend.java:213)\n at org.apache.flink.client.cli.CliFrontend.parseAndRun(CliFrontend.java:1057)\n at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1132)\n at org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:28)\n at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1132)\nRun Code Online (Sandbox Code Playgroud)\n看完之后
\n我添加了
\n<dependency>\n <groupId>org.bouncycastle</groupId>\n <artifactId>bcpkix-jdk15on</artifactId>\n <version>1.69</version>\n</dependency>\n<dependency>\n <groupId>org.bouncycastle</groupId>\n <artifactId>bcprov-jdk15on</artifactId>\n <version>1.69</version>\n</dependency>\n<dependency>\n <groupId>org.bouncycastle</groupId>\n <artifactId>bcprov-ext-jdk15on</artifactId>\n <version>1.69</version>\n</dependency>\nRun Code Online (Sandbox Code Playgroud)\n到我的pom.xml文件。我再次构建并推送到 Docker Hub。
\n当我运行上面的 Flink 命令时,我仍然遇到同样的错误。任何想法?谢谢!
\n更新1:
\n除了上面的pom.xml更改之外,我还手动下载了这 3 个 jar 并将我的 Dockerfile 更改为
\nFROM flink\nCOPY lib/* $FLINK_HOME/lib\nRUN mkdir -p $FLINK_HOME/usrlib\nCOPY target/streaming-0.1.jar $FLINK_HOME/usrlib/streaming-0.1.jar\nRun Code Online (Sandbox Code Playgroud)\n并再次尝试,但仍然出现同样的错误。
\n我可以确认 3 个 jar 文件bcpkix-jdk15on-1.69.jar, bcprov-ext-jdk15on-1.69.jar,bcprov-jdk15on-1.69.jar位于 docker 镜像中:
\xe2\x9e\x9c docker run -it 6c48af48db55c334003a307d1ef7a5fc5181f389613284b66b5cb97588b9708d sh\n\n$ cd lib && ls\nbcpkix-jdk15on-1.69.jar flink-dist_2.12-1.13.2.jar flink-table_2.12-1.13.2.jar log4j-slf4j-impl-2.12.1.jar\nbcprov-ext-jdk15on-1.69.jar flink-json-1.13.2.jar log4j-1.2-api-2.12.1.jar\nbcprov-jdk15on-1.69.jar flink-shaded-zookeeper-3.4.14.jar log4j-api-2.12.1.jar\nflink-csv-1.13.2.jar flink-table-blink_2.12-1.13.2.jar log4j-core-2.12.1.jar\n$ cd ../usrlib && ls\nstreaming-0.1.jar\nRun Code Online (Sandbox Code Playgroud)\n更新2:
\n我尝试通过以下方式启动会话模式
\n/usr/local/Cellar/apache-flink/1.13.1/libexec/bin/kubernetes-session.sh\nRun Code Online (Sandbox Code Playgroud)\n但仍然遇到同样的错误。所以现在我可以确认,当我之前使用应用程序模式时,问题与我的 Docker 镜像无关。
\n~/.m2我的机器上有这些罐子:
我错过了其他罐子吗?
\n另外,我发现该错误仅发生在 k3d/k3s 创建的集群上,而不会发生在 minikube 上。
\n从以下位置下载最新版本的bcprov-jdk15on和bcpkix-jdk15onjar 文件
然后移动到您的 apache-flink 文件夹。就我而言,是
/usr/local/Cellar/apache-flink/{version}/libexec/lib
Run Code Online (Sandbox Code Playgroud)
那么你就可以出发了!
检查完代码后
第一个脚本指向第二个脚本,第二个脚本有
# ...
CC_CLASSPATH=`manglePathList $(constructFlinkClassPath):$INTERNAL_HADOOP_CLASSPATHS`
# ...
"$JAVA_RUN" $JVM_ARGS -classpath "$CC_CLASSPATH" $log_setting org.apache.flink.kubernetes.cli.KubernetesSessionCli "$@"
Run Code Online (Sandbox Code Playgroud)
我添加了echo $CC_CLASSPATH,并打印出了类路径。
就我而言,它位于/usr/local/Cellar/apache-flink/1.13.1/libexec/lib。
将bcprov-jdk15on-1.69.jar和bcpkix-jdk15on-1.69.jar放入上面的文件夹后,Flink 现在可以在会话和应用程序模式下部署到 k3s(k3d)。
| 归档时间: |
|
| 查看次数: |
4346 次 |
| 最近记录: |