也分享下自己踩的坑(第四步)
一、登录阿里云设置下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