
https://github.com/juicedata/juicefs/blob/main/docs/en/how_to_use_on_kubernetes.mdhttps://github.com/juicedata/juicefs-csi-driver/tree/master/examples/static-provisioning
#上一篇的Volumn$ ./juicefs format --storage hdfs --bucket 172.16.2.119:8020 redis://:123456@172.16.2.120:16379/2 mhdfs$ hadoop fs -ls jfs://test# 笔者上篇忘记说了,172.16.2.119,172.16.2.120,172.16.2.121是笔者的测试Hadoop集群。# 172.16.2.119:8020为Hdfs Active NameNode# HA配置为 --bucket=namenode1:port,namenode2:port.
首先安装JuiceFS K8S的驱动:(注意Docker的镜像配置,因为JuiceFS驱动镜像的TAG是latest,如果用阿里云的镜像,可能同步不及时。)
$ cat /etc/docker/daemon.json{"registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"],"insecure-registries":["172.16.2.66:5000"]}
#安装驱动$ kubectl apply -f https://raw.githubusercontent.com/juicedata/juicefs-csi-driver/master/deploy/k8s.yamlserviceaccount/juicefs-csi-controller-sa createdclusterrole.rbac.authorization.k8s.io/juicefs-external-provisioner-role createdclusterrolebinding.rbac.authorization.k8s.io/juicefs-csi-provisioner-binding createdstatefulset.apps/juicefs-csi-controller createddaemonset.apps/juicefs-csi-node createdcsidriver.storage.k8s.io/csi.juicefs.com created
$ mkdir static-provisioning$ cd static-provisioning$ cat > secrets.env << EOFname=mhdfsmetaurl=redis://:123456@172.16.2.120:16379/2access-key=hdfsstorage=hdfsbucket=172.16.2.119:8020EOF$ cat > kustomizeconfig.yaml << EOFnameReference:- kind: SecretfieldSpecs:- path: spec/csi/nodePublishSecretRef/namekind: PersistentVolumenamespace:- path: spec/csi/nodePublishSecretRef/namespacekind: PersistentVolumeEOF$ cat > resources.yaml << EOF---apiVersion: v1kind: PersistentVolumemetadata:name: juicefs-hdfs-1spec:capacity:storage: 1GivolumeMode: FilesystemaccessModes:- ReadWriteManypersistentVolumeReclaimPolicy: Retaincsi:driver: csi.juicefs.comvolumeHandle: hdfs-1fsType: juicefsnodePublishSecretRef:name: juicefs-hdfs-1namespace: default---apiVersion: v1kind: PersistentVolumeClaimmetadata:name: one-gb-fsnamespace: defaultspec:accessModes:- ReadWriteManyvolumeMode: FilesystemstorageClassName: ""resources:requests:storage: 1GiEOF$ cat > kustomization.yaml << EOFapiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationnamespace: defaultconfigurations:- kustomizeconfig.yamlresources:- resources.yamlsecretGenerator:- name: juicefs-hdfs-1env: secrets.envEOF# 创建persistentvolumeclaim,名为one-gb-fs$ kubectl apply -k .secret/juicefs-hdfs-1-mg2575m8hf createdpersistentvolume/juicefs-hdfs-1 createdpersistentvolumeclaim/one-gb-fs created
hadoop fs -ls jfs://test/mlsqldrwxr-xr-x - hdfs hdfs 4096 2021-03-06 18:47 jfs://test/mlsql/mlsqljardrwxr-xr-x - hdfs hdfs 4096 2021-03-06 23:43 jfs://test/mlsql/scriptdrwxr-xr-x - hdfs hdfs 4096 2021-03-06 18:43 jfs://test/mlsql/sparkconfhadoop fs -ls jfs://test/mlsql/mlsqljar-rw-r--r-- 1 hdfs hdfs 14822782 2021-03-06 18:44 jfs://test/mlsql/mlsqljar/juicefs-hadoop-0.11.0.jar-rw-r--r-- 1 hdfs hdfs 119974685 2021-03-06 18:44 jfs://test/mlsql/mlsqljar/streamingpro-mlsql-spark_3.0_2.12-2.1.0-SNAPSHOT.jarhadoop fs -ls jfs://test/mlsql/sparkconf-rw-r--r-- 1 hdfs hdfs 2544 2021-03-06 18:43 jfs://test/mlsql/sparkconf/log4j.propertieshadoop fs -ls jfs://test/mlsql/script-rw-r--r-- 1 hdfs hdfs 2471 2021-03-06 19:07 jfs://test/mlsql/script/mlsql-start.sh
cat > testp.yaml << EOFapiVersion: apps/v1kind: Deploymentmetadata:name: spark-hellonamespace: defaultspec:selector:matchLabels:app: spark-hellostrategy:rollingUpdate:maxUnavailable: 0type: RollingUpdatetemplate:metadata:labels:app: spark-hellospec:serviceAccountName: sparkcontainers:- name: spark-helloargs: [ "while true; do sleep 10000; done;" ]command:- /bin/sh- '-c'image: '172.16.2.66:5000/mlsql:3.0-j14-mlsql'imagePullPolicy: AlwayssecurityContext:runAsUser: 0volumeMounts:- name: juicefs-pvmountPath: /opt/mlsql/jarsubPath: mlsql/mlsqljar- name: juicefs-pvmountPath: /opt/spark/confsubPath: mlsql/sparkconf- name: juicefs-pvmountPath: /opt/mlsql/scriptsubPath: mlsql/scriptvolumes:- name: juicefs-pvpersistentVolumeClaim:claimName: one-gb-fsEOF
$ docker ps | grep hello132a130ce60b 172.16.2.66:5000/mlsql "/bin/sh -c 'while t…" 2 minutes ago Up 2 minutes k8s_spark-hello_spark-hello-56d64fff75-78bhq_default_26427172-85f4-47ce-84c6-a8e3f53f817e_0$ docker exec -it 132a130ce60b /bin/shsh-5.0# ls opt/mlsql/jar/juicefs-hadoop-0.11.0.jar streamingpro-mlsql-spark_3.0_2.12-2.1.0-SNAPSHOT.jarsh-5.0# ls opt/mlsql/script/mlsql-start-d.sh mlsql-start.shsh-5.0# ls opt/spark/conf/log4j.properties# 启动MLSQL服务来验证一下吧$ cd opt/mlsqlnohup sh script/mlsql-start.sh &
curl -XPOST hello.mlsql.com/run/script -d 'sql=select 1 a as t;'[{"a":1}]

图片素材1:水上威尼斯
图片素材2:互联网

喜欢就点击最上方的[ MLSQL之道 ]关注下吧!右下角还有在看哦!
源码地址:
https://github.com/latincross/mlsqlwechat
文章转载自MLSQL之道,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




