Creating a database service

Now that we have created a persistent volume claim, we can define the database service. We will define the database service within a new file called k8s/db/deployment.yaml in the todobackend repository, where we create a service and deployment definition:

apiVersion: v1kind: Servicemetadata:  name: todobackend-dbspec:  selector:    app: todobackend-db  clusterIP: None   ports:  - protocol: TCP    port: 3306---apiVersion: apps/v1kind: Deploymentmetadata:  name: todobackend-db  labels:    app: todobackend-dbspec:  selector:    matchLabels:      app: todobackend-db  template:    metadata:      labels:        app: todobackend-db    spec:      volumes:      - name: data        persistentVolumeClaim:          claimName: todobackend-data      containers:      - name: db        image: mysql:5.7 livenessProbe: ...

Get Docker on Amazon Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.