OpToolKit是客户成功产品团队出的一款运维工具箱产品,目标是方便交付或者有需要的同事调试、运维、提高效率。降低使用先知过程中到处找工具,写脚本的现状。
功能列表
本工具箱支持的工具如下
常用工具: vim net-tools dnsutils tcpdump strace telnet curl wget dig gcc unzip
数据库客户端: mysql rtidb
其他客户端: hadoop kafka spark
本工具箱支持的内置命令如下
pmysql: 自动连接先知内部的mysql数据库
pspark: 自动执行一个spark-submit命令提交默认的任务
phadoop ls: 列出当前环境连接的所有Hadoop集群
phadoop ch [Hadoop集群名称]: 改变当前使用的Hadoop集群
pls: 列出当前所有模块
pexec [模块名称]: 自动进入模块的pod, 如果模块有多个pod, 则进入其中一个pod
plogs [模块名称] [倒数第n行]: 查看模块的日志,第二个参数可选
kcp [kafka服务的地址:端口] [TOPIC]: kafka产生数据
kcc [kafka服务的地址:端口] [TOPIC]: kafka消费数据
开始使用
首先准备一个yml文件,文件名随意
deploy.yaml文件如下
apiVersion: v1
kind: List
items:
- apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: op-toolkit
name: op-toolkit
namespace: ##prophet##
spec:
replicas: 1
selector:
matchLabels:
app: op-toolkit
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
app: op-toolkit
spec:
nodeSelector:
prophet.4paradigm.com/system: "true"
containers:
- image: ##image##
imagePullPolicy: Always
name: app
resources:
limits:
cpu: 2
memory: 2048Mi
requests:
cpu: 1
memory: 1024Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
env:
- name: TZ
value: "Asia/Shanghai"
dnsPolicy: ClusterFirst
serviceAccountName: op-toolkit
imagePullSecrets:
- name: docker-secret
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: op-toolkit
namespace: ##prophet##
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
namespace: ##prophet##
name: op-toolkit
rules:
- apiGroups:
- "*"
resources:
- namespaces
- pods
- deployments
- pods/log
- pods/exec
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
namespace: ##prophet##
name: op-toolkit
subjects:
- kind: ServiceAccount
name: op-toolkit
namespace: ##prophet##
roleRef:
kind: ClusterRole
name: op-toolkit
apiGroup: rbac.authorization.k8s.io
替换两个变量
sed -i "s/##prophet##/370cdh/" demo-optool.yml (370cdh是你想部署的环境的namespace)
sed -i "s/##image##/docker.4pd.io/env/master/prophet/app/optoolkit.tar:pipe-26489-commit-f09b751f/" demo-optool.yml (docker.4pd.io/env/master/prophet/app/optoolkit.tar:pipe-26489-commit-f09b751f/ 是镜像地址)
使用kubectl命令部署
kubectl create -f deploy.yaml
OpToolKit容器就启动起来了
使用示例:
phadoop ls
hadoop fs ls /
phadoop ch leap7
kafka
spark
pmysql
rtidb
pls
pexec telamon
plogs telamon 2