StreamPark集成k8s运行Flink

也分享下自己踩的坑(第四步)

一、登录阿里云设置下docker的账号密码。

1.然后在有docekr的机器上登录。

阿里云登录

2.设置下命名空间(左侧)

二、在streampark中设置docker相关信息。

三、设置RBAC账号

kubectl create namespace streampark
kubectl -n streampark create serviceaccount flink-serviceaccount
kubectl -n streampark create clusterrolebinding flink-role-binding-flink --clusterrole=edit --serviceaccount=streampark:flink-serviceaccount

四、创建secret

kubectl create secret docker-registry streamparksecret \
--docker-server=registry.cn-hangzhou.aliyuncs.com \
--docker-username=xxxx\
--docker-password=xxxx -n streampark


kubectl patch serviceaccount flink-serviceaccount -p '{"imagePullSecrets": [{"name": "streamparksecret"}]}' -n  streampark

五、创建作业

六、 将checkpoint写入nfs中

6.1 ​​​​​​ NFS服务搭建与配置

6.2  StorageClass相关yaml

6.2.1  01_rbac.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: streampark
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: streampark
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: streampark
rules:
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: streampark
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: streampark
roleRef:
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io
6.2.2  02_nfs_client_provisioner.yaml
kind: Deployment
apiVersion: apps/v1
metadata:
  name: nfs-client-provisioner
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nfs-client-provisioner
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: quay.io/vbouchaud/nfs-client-provisioner:latest
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: fuseim.pri/ifs
            - name: NFS_SERVER
              value: 192.168.20.60
            - name: NFS_PATH
              value: /opt/flink
      volumes:
        - name: nfs-client-root
          nfs:
            server: 192.168.20.60
            path: /opt/flink

6.2.3 03_nfs-storage-class.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-nfs-storage
provisioner: fuseim.pri/ifs
parameters:
  archiveOnDelete: "false" 
6.2.4 04_nfs-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: flink-combined-claim
  annotations:
    volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Mi
6.2.5 Pod Template
apiVersion: v1
kind: Pod
metadata:
  name: flink-storage-pod
spec:
  containers:
  - name: flink-main-container
    volumeMounts:
    - name: flink-storage
      mountPath: /opt/flink/checkpoints
    - name: flink-storage
      mountPath: /opt/flink/savepoints
  volumes:
  - name: flink-storage
    persistentVolumeClaim:
      claimName: flink-combined-claim
		

6.3 查看目录是否有chekpoint

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值