使用API:CreateApp
注意应用StateType=2,代表有状态应用。默认为无状态应用,即使用Deployment部署。
使用API:CreateDeployConfig
可以使用configmap存放zk的基本配置以及初始化配置脚本。注意所有的yaml配置需要Base64序列化后加入到参数中。
参考配置:
1、 configmap
kind ConfigMap metadata name zookeeper-config # namespace: kafka apiVersion v1 data init.sh - #!/bin/bash set -e set -x "$ID_OFFSET" && ID_OFFSET=1 -z export ZOO_MY_ID=$(($ HOSTNAME##*- + $ID_OFFSET)) echo "${ZOO_MY_ID:-1}" | tee $ZOO_DATA_DIR/myid cat $ EXTERNAL_CONF_PATH /zookeeper.properties > $ ZOO_CONF_DIR /zoo.cfg sed -i "s/server\.${ZOO_MY_ID}\=[a-z0-9.-]*/server.${ZOO_MY_ID}=0.0.0.0/" $ ZOO_CONF_DIR /zoo.cfg zookeeper.properties - tickTime=2000 dataDir=/data dataLogDir=/datalog clientPort=2181 maxClientCnxns=1 initLimit=5 syncLimit=2 autopurge.snapRetainCount=3 autopurge.purgeInterval=1 server.1=zk-0.zk-hs:2888:3888 server.2=zk-1.zk-hs:2888:3888 server.3=zk-2.zk-hs:2888:3888
2、statefulset
apiVersion apps/v1 kind StatefulSet metadata name zk spec selector matchLabels app zk serviceName zk-hs updateStrategy type RollingUpdate podManagementPolicy Parallel template metadata labels app zk spec affinity podAntiAffinity requiredDuringSchedulingIgnoredDuringExecution labelSelector matchExpressions key"app" operator In values zk topologyKey"kubernetes.io/hostname" containers name zookeeper imagePullPolicy IfNotPresent image"registry-vpc.cn-zhangjiakou.aliyuncs.com/zaide_demo/zookeeper:1.0.0" ports containerPort2181 name client containerPort2888 name server containerPort3888 name leader-election env name EXTERNAL_CONF_PATH value /external/bin readinessProbe exec command /bin/sh -c '[ "imok" = "$(echo ruok | nc -w 1 -q 1 127.0.0.1 2181)" ]' volumeMounts name datadir mountPath /var/lib/zookeeper name configmap mountPath /external/bin/ volumes name configmap configMap name zookeeper-config name datadir emptyDir
使用API:CreateEnvironment
注意:环境的实例个数注意和上面ConfigMap的配置保持一致。
使用API:CreateService
参考请求:
Action=CreateService& EnvId=xxxx& Headless=true& K8sServiceId=zk-hs& Name=zk-hs& PortMappings.1.Name=server& PortMappings.1.Port=2888& PortMappings.1.Protocol=TCP& PortMappings.1.TargetPort=2888& PortMappings.2.Name=leader-election& PortMappings.2.Port=3888& PortMappings.2.Protocol=TCP& PortMappings.2.TargetPort=3888& ServiceType=ClusterIP
使用API:DeployApp
也可以使用控制台进行部署(注意,暂时不支持yaml类型配置在控制台更新)
使用API:DescribeDeployOrderDetail, DescribePodLog, DescribePodEvents
可以在控制台找到刚才通过API提交的发布单,查看发布单结果,或者调用发布相关API确认结果。