安装规划
组件 | replicas |
---|---|
kudu-master | 3 |
kudu-tserver | 3 |
vi kudu-ns.yaml
apiVersion: v1
kind: Namespace
metadata:
name: apache-kudu
labels:
name: apache-kudu
kubectl apply -f kudu-ns.yaml
查看命名空间:
kubectl get ns
vi local-kudu-storage.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-kudu-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer # 绑定模式为等待消费者,即当Pod分配到节点后,进行与PV的绑定
kubectl apply -f local-kudu-storage.yaml
查看存储卷
kubectl get sc
kubectl label nodes node1 kudu-master-node=true
kubectl label nodes node2 kudu-master-node=true
kubectl label nodes node3 kudu-master-node=true
kubectl label nodes node1 kudu-tserver-node=true
kubectl label nodes node2 kudu-tserver-node=true
kubectl label nodes node3 kudu-tserver-node=true
查看 node
标签
kubectl get node --show-labels=true
预先创建好存储目录,在需要分配的 node
上,并授予权限:
mkdir -p {/opt/kudu/master-data,/opt/kudu/tserver-data} && chmod 777 {/opt/kudu/master-data,/opt/kudu/tserver-data}
vi local-kudu-pv-pvc.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-kudu-master-pv
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 5Gi
local:
path: /opt/kudu/master-data # 需要在指定的节点创建相应的目录
nodeAffinity: # 指定节点,对节点配置label
required:
nodeSelectorTerms:
- matchExpressions:
- key: kudu-master-node
operator: In
values:
- "true"
persistentVolumeReclaimPolicy: Retain # 回收策略为保留,不会删除数据,即当pod重新调度的时候,数据不会发生变化.
storageClassName: local-kudu-storage
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-kudu-master-pvc
namespace: apache-kudu
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-kudu-storage
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-kudu-tserver-pv
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 5Gi
local:
path: /opt/kudu/tserver-data # 需要在指定的节点创建相应的目录
nodeAffinity: # 指定节点,对节点配置label
required:
nodeSelectorTerms:
- matchExpressions:
- key: kudu-tserver-node
operator: In
values:
- "true"
persistentVolumeReclaimPolicy: Retain # 回收策略为保留,不会删除数据,即当pod重新调度的时候,数据不会发生变化.
storageClassName: local-kudu-storage
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-kudu-tserver-pvc
namespace: apache-kudu
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-kudu-storage
resources:
requests:
storage: 5Gi
kubectl apply -f local-kudu-pv-pvc.yaml
查看 PV:
kubectl get pv
查看 PVC :
kubectl get pvc -n apache-kudu
vi kudu-svc.yaml
# headless service for kudu masters
apiVersion: v1
kind: Service
metadata:
name: kudu-masters
namespace: apache-kudu
labels:
app: kudu-master
spec:
clusterIP: None
ports:
- name: ui
port: 8051
- name: rpc-port
port: 7051
selector:
app: kudu-master
---
# NodePort service for masters
apiVersion: v1
kind: Service
metadata:
name: kudu-master-ui
namespace: apache-kudu
labels:
app: kudu-master
spec:
clusterIP:
ports:
- name: ui
port: 8051
nodePort: 30051
targetPort: 8051
selector:
app: kudu-master
type: NodePort
target-port:
externalTrafficPolicy: Cluster # Local 只有所在node可以访问,Cluster 公平转发
---
# headless service for tservers
apiVersion: v1
kind: Service
metadata:
name: kudu-tservers
namespace: apache-kudu
labels:
app: kudu-tserver
spec:
clusterIP: None
ports:
- name: ui
port: 8050
- name: rpc-port
port: 7050
selector:
app: kudu-tserver
kubectl apply -f kudu-svc.yaml
查看创建的 service:
kubectl get svc -n apache-kudu
vi kudu-master-tserver-statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kudu-master
namespace: apache-kudu
labels:
app: kudu-master
spec:
serviceName: kudu-masters
podManagementPolicy: "Parallel"
replicas: 3
selector:
matchLabels:
app: kudu-master
template:
metadata:
labels:
app: kudu-master
spec:
containers:
- name: kudu-master
image: apache/kudu:1.15.0
imagePullPolicy: IfNotPresent
env:
- name: GET_HOSTS_FROM
value: dns
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: KUDU_MASTERS
value: "kudu-master-0.kudu-masters.apache-kudu.svc.cluster.local,kudu-master-1.kudu-masters.apache-kudu.svc.cluster.local,kudu-master-2.kudu-masters.apache-kudu.svc.cluster.local"
args: ["master"]
ports:
- containerPort: 8051
name: master-ui
- containerPort: 7051
name: master-rpc
volumeMounts:
- name: kudu-master-data
mountPath: /mnt/data0
- name: kudu-master-data
mountPath: /var/lib/kudu
volumes:
- name: kudu-master-data
persistentVolumeClaim:
claimName: local-kudu-master-pvc
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kudu-tserver
namespace: apache-kudu
labels:
app: kudu-tserver
spec:
serviceName: kudu-tservers
podManagementPolicy: "Parallel"
replicas: 3
selector:
matchLabels:
app: kudu-tserver
template:
metadata:
labels:
app: kudu-tserver
spec:
containers:
- name: kudu-tserver
image: apache/kudu:1.15.0
imagePullPolicy: IfNotPresent
env:
- name: GET_HOSTS_FROM
value: dns
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: KUDU_MASTERS
value: "kudu-master-0.kudu-masters.apache-kudu.svc.cluster.local,kudu-master-1.kudu-masters.apache-kudu.svc.cluster.local,kudu-master-2.kudu-masters.apache-kudu.svc.cluster.local"
args: ["tserver"]
ports:
- containerPort: 8050
name: tserver-ui
- containerPort: 7050
name: tserver-rpc
volumeMounts:
- name: kudu-tserver-data
mountPath: /mnt/data0
- name: kudu-tserver-data
mountPath: /var/lib/kudu
volumes:
- name: kudu-tserver-data
persistentVolumeClaim:
claimName: local-kudu-tserver-pvc
kubectl apply -f kudu-master-tserver-statefulset.yaml
查看 statefulset :
kubectl get statefulset -n apache-kudu
查看 pod:
kubectl get pods -n apache-kudu
http://nodel2:30051
查看 tserver 情况: