更新时间:2024-04-23 GMT+08:00
id-generator部署
配置zookeeper
在使用id-generator前,要先确保已经安装zookeeper,因为id-generator依赖zookeeper。
上传zookeeper的yaml文件到k8s宿主机
图1 启动
创建endpoint
# kubectl create -f .
图2 创建1
# kubectl get svc,ep -n applife
图3 创建2
导入镜像
上传distribute-id-generator.tar.gz到k8s宿主机,执行
# docker load -i distribute-id-generator.tar.gz
图4 执行
看到上面结果,表明镜像导入成功。
创建应用副本
通过k8s master或者华为云cce控制台导入yaml文件。
图5 导入yaml文件
# kubectl apply -f deepexi-daas-distribute-id-generator.yaml apiVersion: apps/v1 kind: Deployment metadata: name: deepexi-distribute-id-generator-deploy namespace: daas spec: replicas: 1 template: metadata: labels: app: deepexi-distribute-id-generator-deploy openkube.deepexi.cloud/logtype: java spec: containers: - name: deepexi-distribute-id-generator-deploy imagePullPolicy: Always image: swr.cn-south-1.myhuaweicloud.com/daas/distribute-id-generator:v2.7.x_20210817_arm64 command: ["/bin/sh"] args: ["-c","cd /home; java -Djava.security.egd=file:/dev/./urandom -Duser.timezone=Asia/Shanghai -XX:+HeapDumpOnOutOfMemoryError -jar ./demo.jar --leaf.snowflake.zk.address=zk1.applife --dubbo.registry.address=zookeeper://zk1.applife?backup=zk2.applife,zk3.applife --server.port=38103"] imagePullSecrets: - name: default-secret selector: matchLabels: app: deepexi-distribute-id-generator-deploy --- apiVersion: v1 kind: Service metadata: name: deepexi-distribute-id-generator-service namespace: daas spec: type: NodePort ports: - port: 38103 nodePort: 38103 targetPort: 38103 selector: app: deepexi-distribute-id-generator-deploy
验证
- 在k8s宿主机上,查看pod的地址,
类型为ClusterIp是不能通过外网访问的
# kubectl get svc -n daas
图6 查看pod的地址
- 在K8s宿主机上,执行:
# curl http://192.168.0.69:38103/distribute-id-generator/api/v1/snowflake/id/32
图7 执行
看到上面返回的结果,说明部署成功,否则检查一下zookeeper配置是否正确。
父主题: 实施步骤