O'Reilly logo
live online training icon Live Online training

Databases in Cloud Containers: MySQL, Docker, and Kubernetes

Stateful applications made easier

Topic: Web Ops & Performance
Patrick Galbraith

You are a database administrator, and you keep hearing about how useful containers are and how great Kubernetes is for running your applications. But despite your mastery of complex databases, you still experience apprehension at the thought of running a database on a new, unfamiliar platform.

Docker, and more so, Kubernetes has become incredibly popular. When Kubernetes first started being promoted, so much of what people knew about this new technology and the applications that seemed best suited to run stateless applications The very definition of Kubernetes pods in the manual states that they are immortal, which is not an attribute one would want to hear about being associated with a database, and there was this impression that Kubernetes wasn't suited for databases.

This course will allay your concerns and show you that quite the contrary, running MySQL, and stateful application on Kubernetes, is made easier by abstracting much of the day-to-day tasks into simple commands and a consistent view of your database cluster.

What you'll learn-and how you can apply it

  • How immutable infrastructure is the more contemporary, and improved pattern for devops as it uses containers to roll out changes so that you don't have to manage a server in an on-going manner
  • and How Kubernetes makes running MySQL easier as it abstracts away having to run tasks at a lower level such as bringing up a complex cluster and run backups and restorations with simple commands, as well be able to have consistent database access for your applications
  • The various Kubernetes MySQL Operators that are available
  • How to run the Oracle MySQL Kubernetes Operator
  • Bringing up a MySQL 8.0 InnoDB cluster using group replication
  • Running a backup and restore of your cluster
  • Running an application that uses the MySQL cluster you set up and having it automatically use DNS on your Kubernetes cluster
  • Simulating problems such as a table being dropped and how simple it is to restore your database

And you’ll be able to:

  • Debug your MySQL cluster running on Kubernetes
  • View logs for the various components of your MySQL cluster and operator components
  • Understand the basics of running MySQL and obtain an appreciation of how much easier running the MySQL Operator makes it
  • No longer be afraid of adopting a containerized MySQL setup

This training course is for you because...

  • You’re a database administrator who wants to understand how you can deploy MySQL on this new technology
  • You work with applications that use MySQL on bare metal or virtual machines and want to leverage new technology and better utilisation of computing resources than bare metal or virtual machines afford
  • You want to become a person familiar with-- if not an expert on-- Kubernetes and in particular, MySQL on Kubernetes
  • You want to evolve your systems from tools like Chef, Puppet, or Ansible to a pattern of immutable infrastructure


  • MySQL, or other RDBMS and applications that use databases
  • Basic UNIX system administration and DevOps knowledge
  • Concepts of virtualization and cloud computing
  • Familiarity with YAML syntax

Recommended preparation:

  • Read these selections from Kubernetes: Up and Running (book):
    • Chapter 2 “Creating and Running Containers” for familiarity with using Docker.
    • Chapters 3 “Deploying a Kubernetes Cluster” and 4 “Common kubectl Commands” for understanding how to get a cluster and how to run kubectl commands.
  • Read these selections from MySQL in a Nutshell, 2nd Edition (book):
    • Chapter 2 “Installing MySQL” for a clear understanding of the installation options for MySQL.
    • Chapter 3 “MySQL Basics” to be familiar with basic MySQL statements for working with data.

Recommended follow-up:

About your instructor

  • Patrick Galbraith has been involved in MySQL, Linux, and other Open Source (OSS) projects back to the early days of Slackware. He has worked for a broad spectrum of companies and in a wide array of roles throughout his career, including Slashdot, MySQL, Blue Gecko, Hewlett-Packard, and now Oracle, and has contributed to a number of Open Source projects such as MySQL, Drizzle, DBD:mysql, Kubernetes, Helm charts for MySQL and Galera.He is the author of two books, "Developing Web Applications with Apache, MySQL, memcached, and Perl" and "Expert PHP and MySQL" (both Wiley). In the past decade of his career, Patrick has had a focus on anything related to cloud computing, and in more recent years, containerization with emphasis on Kubernetes; this focus, like all his past endeavors, included participation in the associated OSS communities that continues to this day. Patrick has a long-standing interest in the effective marriage of stateful applications such as databases and Kubernetes with a bent toward MySQL. He has spoken at a number of conferences including last year at Kubecon in Austin, TX. The talk can be seen at: https://www.youtube.com/watch?v=J7h0F34iBx0.


The timeframes are only estimates and may vary according to how the class is progressing

What are containers, and how do I run MySQL on a container? (60 minutes)

  • Presentation: What containers are, the difference between containers and virtual machines
  • Discussion: How do I manually run MySQL in a docker container?
  • Presentation: How to run MySQL in a container. An introduction to how MySQL runs on a container and what arguments are passed, what volumes are specified, and how to use it.
  • Exercise: Run MySQL on a Docker container
  • Q&A
  • Break (5 minutes)

Running MySQL on Kubernetes (55 minutes)

  • Presentation: Describe how to run a simple MySQL pod on Kubernetes
  • Presentation: How to run a simple MySQL on Kubernetes using stateful sets
  • Exercise: Run a simple MySQL master->slave on Kubernetes using a stateful set
  • Q&A
  • Break (5 minutes)

Putting it together - the Oracle MySQL Kubernetes Operator (55 minutes)

  • Presentation: How to run the MySQL Operator, using block storage
  • Presentation: How to dig down into your Kubernetes cluster to view the state of the MySQL cluster
  • Exercise: Run the MySQL Operator, start a MySQL cluster, and connect an application to it

Final Q&A