1. apiVersion: v1
    2. kind: Service
    3. metadata:
    4. name: zk-hs
    5. namespace: ur-test
    6. labels:
    7. app: zk
    8. spec:
    9. ports:
    10. - port: 2888
    11. name: server
    12. - port: 3888
    13. name: leader-election
    14. clusterIP: None
    15. selector:
    16. app: zk
    17. ---
    18. apiVersion: v1
    19. kind: Service
    20. metadata:
    21. name: zk-cs
    22. namespace: ur-test
    23. labels:
    24. app: zk
    25. spec:
    26. type: ClusterIP
    27. ports:
    28. - port: 2181
    29. targetPort: 2181
    30. name: client
    31. selector:
    32. app: zk
    33. ---
    34. apiVersion: policy/v1beta1
    35. kind: PodDisruptionBudget
    36. metadata:
    37. name: zk-pdb
    38. namespace: ur-test
    39. spec:
    40. selector:
    41. matchLabels:
    42. app: zk
    43. maxUnavailable: 1
    44. ---
    45. apiVersion: apps/v1
    46. kind: StatefulSet
    47. metadata:
    48. name: zookeeper
    49. namespace: ur-test
    50. spec:
    51. serviceName: zk-hs
    52. replicas: 3
    53. selector:
    54. matchLabels:
    55. app: zk
    56. template:
    57. metadata:
    58. labels:
    59. app: zk
    60. spec:
    61. affinity:
    62. podAntiAffinity:
    63. requiredDuringSchedulingIgnoredDuringExecution:
    64. - labelSelector:
    65. matchExpressions:
    66. - key: "app"
    67. operator: In
    68. values:
    69. - zk
    70. topologyKey: "kubernetes.io/hostname"
    71. containers:
    72. - name: zookeeper
    73. imagePullPolicy: Always
    74. image: 192.168.13.79:6278/middleware/zookeeper:v3.4.10
    75. resources:
    76. requests:
    77. memory: "1Gi"
    78. cpu: "0.5"
    79. ports:
    80. - containerPort: 2181
    81. name: client
    82. - containerPort: 2888
    83. name: server
    84. - containerPort: 3888
    85. name: leader-election
    86. command:
    87. - sh
    88. - -c
    89. - "start-zookeeper \
    90. --servers=3 \
    91. --data_dir=/var/lib/zookeeper/data \
    92. --data_log_dir=/var/lib/zookeeper/data/log \
    93. --conf_dir=/opt/zookeeper/conf \
    94. --client_port=2181 \
    95. --election_port=3888 \
    96. --server_port=2888 \
    97. --tick_time=2000 \
    98. --init_limit=10 \
    99. --sync_limit=5 \
    100. --heap=512M \
    101. --max_client_cnxns=60 \
    102. --snap_retain_count=3 \
    103. --purge_interval=12 \
    104. --max_session_timeout=40000 \
    105. --min_session_timeout=4000 \
    106. --log_level=INFO"
    107. readinessProbe:
    108. exec:
    109. command:
    110. - sh
    111. - -c
    112. - "zookeeper-ready 2181"
    113. initialDelaySeconds: 10
    114. timeoutSeconds: 5
    115. livenessProbe:
    116. exec:
    117. command:
    118. - sh
    119. - -c
    120. - "zookeeper-ready 2181"
    121. initialDelaySeconds: 10
    122. timeoutSeconds: 5
    123. volumeMounts:
    124. - name: zkdata
    125. mountPath: /var/lib/zookeeper
    126. volumeClaimTemplates:
    127. - metadata:
    128. name: zkdata
    129. spec:
    130. accessModes: [ "ReadWriteOnce" ]
    131. resources:
    132. requests:
    133. storage: 1Gi