# Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- - name: Persistent volume for mysqldb kubernetes.core.k8s: state: present definition: apiVersion: v1 kind: PersistentVolume metadata: name: "{{ mysql_pv_name }}" namespace: "{{ namespace }}" labels: type: local spec: storageClassName: manual capacity: storage: "{{ mysqldb_storage }}" accessModes: - ReadWriteOnce hostPath: path: "{{ mount_location + 'mysqldb' }}" - name: Persistent volume claim for mysqldb kubernetes.core.k8s: state: present definition: apiVersion: v1 kind: PersistentVolumeClaim metadata: name: "{{ mysqldb_pvc_name }}" namespace: "{{ namespace }}" spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: "{{ mysqldb_storage }}" - name: mysqldb pod definition kubernetes.core.k8s: state: present definition: apiVersion: apps/v1 kind: StatefulSet metadata: name: "{{ mysqldb_k8s_name }}" namespace: "{{ namespace }}" spec: selector: matchLabels: app: "{{ mysqldb_k8s_name }}" serviceName: "{{ mysqldb_k8s_name }}" replicas: "{{ statefulset_replicas }}" template: metadata: labels: app: "{{ mysqldb_k8s_name }}" spec: volumes: - name: telemetry-reference-tools hostPath: path: "{{ mount_location + idrac_telemetry_folder_name }}" type: Directory - name: mysqldb-pvc persistentVolumeClaim: claimName: "{{ mysqldb_pvc_name }}" containers: - name: mysqldb image: mysql:8.0 imagePullPolicy: "IfNotPresent" volumeMounts: - mountPath: /go/src/github.com/telemetry-reference-tools name: telemetry-reference-tools - mountPath: /var/lib/mysql/ name: mysqldb-pvc workingDir: /go/src/github.com/telemetry-reference-tools env: - name: MYSQL_DATABASE value: "{{ mysqldb_name }}" - name: MYSQL_USER valueFrom: secretKeyRef: name: "{{ secrets_name }}" key: sqldb_user - name: MYSQL_PASSWORD valueFrom: secretKeyRef: name: "{{ secrets_name }}" key: sqldb_password - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name: "{{ secrets_name }}" key: sqldb_root_password ports: - containerPort: "{{ mysqldb_container_port1 }}" - containerPort: "{{ mysqldb_container_port2 }}" - name: Service for mysqldb kubernetes.core.k8s: state: present definition: apiVersion: v1 kind: Service metadata: name: "{{ mysqldb_k8s_name }}" namespace: "{{ namespace }}" labels: app: "{{ mysqldb_k8s_name }}" spec: type: ClusterIP ports: - name: mysqldb-http-port-1 port: "{{ mysqldb_container_port1 }}" - name: mysqldb-http-port-2 port: "{{ mysqldb_container_port2 }}" selector: app: "{{ mysqldb_k8s_name }}"