mysqldb_deployment.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Persistent volume for mysqldb
  16. kubernetes.core.k8s:
  17. state: present
  18. definition:
  19. apiVersion: v1
  20. kind: PersistentVolume
  21. metadata:
  22. name: "{{ mysql_pv_name }}"
  23. namespace: "{{ namespace }}"
  24. labels:
  25. type: local
  26. spec:
  27. storageClassName: manual
  28. capacity:
  29. storage: "{{ mysqldb_storage }}"
  30. accessModes:
  31. - ReadWriteOnce
  32. hostPath:
  33. path: "{{ mount_location + 'mysqldb' }}"
  34. - name: Persistent volume claim for mysqldb
  35. kubernetes.core.k8s:
  36. state: present
  37. definition:
  38. apiVersion: v1
  39. kind: PersistentVolumeClaim
  40. metadata:
  41. name: "{{ mysqldb_pvc_name }}"
  42. namespace: "{{ namespace }}"
  43. spec:
  44. storageClassName: manual
  45. accessModes:
  46. - ReadWriteOnce
  47. resources:
  48. requests:
  49. storage: "{{ mysqldb_storage }}"
  50. - name: mysqldb pod definition
  51. kubernetes.core.k8s:
  52. state: present
  53. definition:
  54. apiVersion: apps/v1
  55. kind: StatefulSet
  56. metadata:
  57. name: "{{ mysqldb_k8s_name }}"
  58. namespace: "{{ namespace }}"
  59. spec:
  60. selector:
  61. matchLabels:
  62. app: "{{ mysqldb_k8s_name }}"
  63. serviceName: "{{ mysqldb_k8s_name }}"
  64. replicas: "{{ statefulset_replicas }}"
  65. template:
  66. metadata:
  67. labels:
  68. app: "{{ mysqldb_k8s_name }}"
  69. spec:
  70. volumes:
  71. - name: telemetry-reference-tools
  72. hostPath:
  73. path: "{{ mount_location + idrac_telemetry_folder_name }}"
  74. type: Directory
  75. - name: mysqldb-pvc
  76. persistentVolumeClaim:
  77. claimName: "{{ mysqldb_pvc_name }}"
  78. containers:
  79. - name: mysqldb
  80. image: mysql:8.0
  81. imagePullPolicy: "IfNotPresent"
  82. volumeMounts:
  83. - mountPath: /go/src/github.com/telemetry-reference-tools
  84. name: telemetry-reference-tools
  85. - mountPath: /var/lib/mysql/
  86. name: mysqldb-pvc
  87. workingDir: /go/src/github.com/telemetry-reference-tools
  88. env:
  89. - name: MYSQL_DATABASE
  90. value: "{{ mysqldb_name }}"
  91. - name: MYSQL_USER
  92. valueFrom:
  93. secretKeyRef:
  94. name: "{{ secrets_name }}"
  95. key: sqldb_user
  96. - name: MYSQL_PASSWORD
  97. valueFrom:
  98. secretKeyRef:
  99. name: "{{ secrets_name }}"
  100. key: sqldb_password
  101. - name: MYSQL_ROOT_PASSWORD
  102. valueFrom:
  103. secretKeyRef:
  104. name: "{{ secrets_name }}"
  105. key: sqldb_root_password
  106. ports:
  107. - containerPort: "{{ mysqldb_container_port1 }}"
  108. - containerPort: "{{ mysqldb_container_port2 }}"
  109. - name: Service for mysqldb
  110. kubernetes.core.k8s:
  111. state: present
  112. definition:
  113. apiVersion: v1
  114. kind: Service
  115. metadata:
  116. name: "{{ mysqldb_k8s_name }}"
  117. namespace: "{{ namespace }}"
  118. labels:
  119. app: "{{ mysqldb_k8s_name }}"
  120. spec:
  121. type: ClusterIP
  122. ports:
  123. - name: mysqldb-http-port-1
  124. port: "{{ mysqldb_container_port1 }}"
  125. - name: mysqldb-http-port-2
  126. port: "{{ mysqldb_container_port2 }}"
  127. selector:
  128. app: "{{ mysqldb_k8s_name }}"