You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kind: PersistentVolume # Create a PersistentVolume
3
3
metadata:
4
-
name: polling-app-mysql
4
+
name: mysql-pv
5
5
labels:
6
-
app: polling-app
6
+
type: local
7
7
spec:
8
-
ports:
9
-
- port: 3306
10
-
selector:
11
-
app: polling-app
12
-
tier: mysql
13
-
clusterIP: None
14
-
---
8
+
storageClassName: standard # The class of storage. A PV Claim requesting the same storageClass can be bound to this volume.
9
+
capacity:
10
+
storage: 250Mi
11
+
accessModes:
12
+
- ReadWriteOnce
13
+
hostPath: # hostPath PersistentVolume is used for development and testing. It uses a file/directory on the Node to emulate network-attached storage
14
+
path: "/mnt/data"
15
+
persistentVolumeReclaimPolicy: Retain # Retain the PersistentVolume even after PersistentVolumeClaim is deleted. The volume is considered “released”. But it is not yet available for another claim because the previous claimant’s data remains on the volume.
16
+
---
15
17
apiVersion: v1
16
-
kind: PersistentVolumeClaim
17
-
metadata:
18
+
kind: PersistentVolumeClaim# Create a PersistentVolumeClaim to request a PersistentVolume storage
19
+
metadata:# Claim name and labels
18
20
name: mysql-pv-claim
19
21
labels:
20
22
app: polling-app
21
-
spec:
23
+
spec: # Access mode and resource limits
24
+
storageClassName: standard # Request a certain storage class
22
25
accessModes:
23
-
- ReadWriteOnce
26
+
- ReadWriteOnce# ReadWriteOnce means the volume can be mounted as read-write by a single Node
24
27
resources:
25
28
requests:
26
29
storage: 250Mi
27
30
---
28
-
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
29
-
kind: Deployment
31
+
apiVersion: v1# API version
32
+
kind: Service # Type of kubernetes resource
30
33
metadata:
31
-
name: polling-app-mysql
32
-
labels:
34
+
name: polling-app-mysql # Name of the resource
35
+
labels: # Labels that will be applied to the resource
36
+
app: polling-app
37
+
spec:
38
+
ports:
39
+
- port: 3306
40
+
selector: # Selects any Pod with labels `app=polling-app,tier=mysql`
41
+
app: polling-app
42
+
tier: mysql
43
+
clusterIP: None
44
+
---
45
+
apiVersion: apps/v1
46
+
kind: Deployment # Type of the kubernetes resource
47
+
metadata:
48
+
name: polling-app-mysql # Name of the deployment
49
+
labels: # Labels applied to this deployment
33
50
app: polling-app
34
51
spec:
35
52
selector:
36
-
matchLabels:
53
+
matchLabels:# This deployment applies to the Pods matching the specified labels
37
54
app: polling-app
38
55
tier: mysql
39
56
strategy:
40
57
type: Recreate
41
-
template:
58
+
template:# Template for the Pods in this deployment
42
59
metadata:
43
-
labels:
60
+
labels:# Labels to be applied to the Pods in this deployment
44
61
app: polling-app
45
62
tier: mysql
46
-
spec:
63
+
spec:# The spec for the containers that will be run inside the Pods in this deployment
47
64
containers:
48
-
- image: mysql:5.6
65
+
- image: mysql:5.6# The container image
49
66
name: mysql
50
-
env:
51
-
- name: MYSQL_ROOT_PASSWORD
52
-
valueFrom:
67
+
env:# Environment variables passed to the container
68
+
- name: MYSQL_ROOT_PASSWORD
69
+
valueFrom:# Read environment variables from kubernetes secrets
53
70
secretKeyRef:
54
71
name: mysql-root-pass
55
72
key: password
56
73
- name: MYSQL_DATABASE
57
74
valueFrom:
58
75
secretKeyRef:
59
-
name: mysql-db
76
+
name: mysql-db-url
60
77
key: database
61
78
- name: MYSQL_USER
62
79
valueFrom:
63
80
secretKeyRef:
64
-
name: mysql-user
81
+
name: mysql-user-pass
65
82
key: username
66
83
- name: MYSQL_PASSWORD
67
84
valueFrom:
68
85
secretKeyRef:
69
-
name: mysql-pass
86
+
name: mysql-user-pass
70
87
key: password
71
88
ports:
72
-
- containerPort: 3306
89
+
- containerPort: 3306# The port that the container exposes
73
90
name: mysql
74
91
volumeMounts:
75
-
- name: mysql-persistent-storage
92
+
- name: mysql-persistent-storage# This name should match the name specified in `volumes.name`
76
93
mountPath: /var/lib/mysql
77
-
volumes:
94
+
volumes:# A PersistentVolume is mounted as a volume to the Pod
0 commit comments