Leanpub Header

Skip to main content

DevOps Katas

Hands-On DevOps

DevOps Katas: Hands-On DevOps is about three of the most important DevOps tools: Docker, Git, and Jenkins. You'll learn by doing with each set of exercises.

Minimum price

$19.99

$24.99

You pay

$24.99

Author earns

$19.99
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
143
Readers
About

About

About the Book

DevOps Katas: Hands-On DevOps is a collection of practical exercises that will teach you how to use three of the most important DevOps tools: Docker, Git, and Jenkins. Each set of katas will introduce you to the tool and its usage. The katas build on each other, so that after you're finished, you will have created a complete Continuous Integration / Continuous Delivery pipeline.

Many technical books are "walls of text," heavy on theory with exercises sprinkled throughout. Not so with DevOps Katas! Quite the opposite. DevOps Katas teaches by doing.

The katas in DevOps Katas are based on Code Katas, which in turn are inspired by the katas of martial arts: short, quick-to-practice exercises designed to be practiced regularly. Katas are broken into steps, each with a few commands. You'll execute the commands first, then learn what you did and why.

All of the software you'll need to practice DevOps Katas is free. It's also provided to you in the form of a free Learning Virtual Machine, available for download at www.devopskatas.com. The LVM is pre-loaded with everything you need. All you have to do is download and install Virtualbox. No installing, no configuring, just kata practice.

Author

About the Author

Dave Swersky

Dave Swersky is a 20+ year veteran of the IT industry. He's an experienced software developer and TOGAF-certified Enterprise Architect.

Dave has focused on DevOps for over three years, as a central part of his work as an Architect and software developer. He has worked with major banks, energy companies, consulting firms, and the US Government on DevOps strategies and transformations.

Contents

Table of Contents

Acknowledgements

Chapter 1: Introduction to DevOps

  1. What is DevOps?
  2. Culture
  3. Process
  4. Technology
  5. DevOps Automation

Chapter 2: Getting Started With DevOps Katas

  1. Introduction: Practice First
  2. What is a Kata?
  3. Kata Formatting and Conventions
  4. Kata Practice Guidelines
  5. Kata Practice Pages
  6. Kata Practice Calendar
  7. Kata Practice Tools
  8. Setting up the DevOps Katas Learning Virtual Machine
  9. Step 1: Install Virtualbox
  10. Step 2: Download the LVM Image
  11. Step 3: Import the LVM Image
  12. Step 4: Run the LVM
  13. Sample Kata
  14. Step 1: Create a Directory
  15. $ mkdir firstkata
  16. Step 2: Change to the firstkata Directory
  17. $ cd firstkata
  18. Step 3: Create a File
  19. $ touch firstkata.txt
  20. Step 4: List the files in the firstkata directory
  21. $ ls
  22. Step 5: Edit the file with the text editor
  23. $ gedit firstkata.txt &
  24. Step 6: Enter text into the file and save

Chapter 3: Containers and Docker

  1. 1995 - 2002: Advent of the Internet
  2. 2002: Virtualization
  3. 2008: Containers
  4. 2013: Docker
  5. Containers and DevOps
  6. Automation
  7. Reliability
  8. Portability
  9. Scalability
  10. Isolation
  11. Docker and DevOps Katas

Chapter 4: Docker Katas

  1. Docker Kata 1: The Basic Commands
  2. Step 1: Running Your First Container
  3. $ docker container run hello-world
  4. Step 2: Listing Containers
  5. $ docker container ls
  6. $ docker container ls -a
  7. Step 3: Listing Images
  8. $ docker image ls
  9. Step 4: Running a Named Container
  10. $ docker container run --name my_container hello-world
  11. $ docker container ls -a
  12. $ docker container inspect my_container
  13. Step 5: Run a Container in Interactive Mode
  14. $ docker container run -it ubuntu bash
  15. $ ls
  16. $ ls /bin
  17. $ exit
  18. Step 6: Remove all Containers and Images
  19. $ docker container rm $(docker container ls -a -q)
  20. $ docker container ls -a
  21. $ docker image rm $(docker image ls -aq)
  22. Docker Kata 2: Disconnected Containers
  23. Step 1: Run a “Disconnected” Container
  24. $ docker container ls
  25. $ docker container logs $(docker container ls -q)
  26. $ docker container stop $(docker container ls -q)
  27. Step 2: Execute Commands on a Running Container
  28. $ docker container run -d --name webserver nginx
  29. $ docker container exec webserver ls
  30. $ docker container exec webserver ip addr
  31. $ docker container exec webserver ip addr | grep inet
  32. Step 3: Connecting Interactively to a Running Container
  33. $ docker container exec -it webserver bash
  34. $ ls
  35. $ exit
  36. Docker Kata 3: Container Volumes and Filesystem
  37. Step 1: Container Filesystem Changes
  38. $ docker container stop $(docker container ls -q)
  39. $ docker container rm $(docker container ls -aq)
  40. $ docker container run -it ubuntu bash
  41. $ ls
  42. $ echo "file1text" > file1.txt
  43. $ ls
  44. $ exit
  45. $ docker container run -it ubuntu bash
  46. $ ls
  47. $ exit
  48. Step 2: Run a Container With a Named Volume
  49. $ docker container run -d --name web -v=myVolume:/webapp nginx
  50. $ docker container ls
  51. $ docker container exec web ls
  52. $ docker volume ls
  53. Step 3: Share a Volume Between Containers
  54. $ docker container run -d --name web2 -v myVolume:/webapp nginx
  55. $ docker container exec web ls webapp
  56. $ docker container exec web2 ls webapp
  57. Step 4: Run a Container With a Host-Mounted Volume
  58. $ mkdir dockervolume
  59. $ cd dockervolume
  60. $ echo file1text > file1.txt
  61. $ echo file2text > file2.txt
  62. $ ls
  63. $ cd ..
  64. $ docker container exec web3 ls /hostmounted
  65. Docker Kata 4: Running a Web Server in a Container
  66. Step 1: Run a Web Server
  67. $ docker container stop $(docker container ls -q)
  68. $ docker container rm $(docker container ls -aq)
  69. $ docker container run -d -p 80:80 --name webserver nginx
  70. $ curl localhost
  71. Open Firefox and go to http://localhost
  72. Step 2: Run a Second Webserver on a Different Port
  73. $ docker container run -d -p 81:80 --name webserver2 nginx
  74. $ curl localhost:81
  75. Docker Kata 5: Docker Networking
  76. Step 1: List All Networks
  77. $ docker network ls
  78. Step 2: Ping Between Containers
  79. $ docker container run -d --name web1 nginx
  80. $ docker container run -d --name web2 nginx
  81. $ docker container exec web1 ping -w3 $(docker inspect -f '{{ .NetworkSettings.IPAddress}}' web2)
  82. $ docker container exec web2 ping -w3 $(docker inspect -f '{{ .NetworkSettings.IPAddress}}' web1)
  83. $ docker container exec web1 ping -w3 web2
  84. Step 3: Create a User-Defined Network
  85. $ docker network create mynet
  86. $ docker network inspect mynet
  87. Step 4: Run Containers on a User-Defined Network
  88. $ docker container run -d --net=mynet --name web1 nginx
  89. $ docker container run -d --net=mynet --name web2 nginx
  90. $ docker network inspect mynet
  91. $ docker container exec web1 ping -w3 web2
  92. Docker Kata 6: Creating Docker Images
  93. Step 1: Creating an Image From a Modified Container
  94. $ mkdir dockerimage
  95. $ cd dockerimage
  96. $ cp ../index.html .
  97. $ ls
  98. $ docker container run --name web -d -p 80:80 nginx
  99. $ docker container cp index.html web:/usr/share/nginx/html/index.html
  100. $ curl localhost
  101. $ docker container ls
  102. $ docker container commit web kataimage_nginx
  103. $ docker image ls
  104. $ docker container run -d -p 81:80 kataimage_nginx
  105. $ curl localhost:81
  106. Step 2: Create an Image with a Dockerfile
  107. $ gedit Dockerfile &
  108. $ docker image build -t katadockerfile_image .
  109. $ docker image ls
  110. $ docker container run -d -p 80:80 katadockerfile_image
  111. $ curl localhost

Chatper 5: Source Control Management and Git

  1. Source Control Tools
  2. Centralized Version Control Systems (CVCS)
  3. Distributed Version Control Systems (DVCS)
  4. Introducing Git
  5. Anatomy of a Git Repository
  6. Sharing Code With Git
  7. Merging and Branching in Git
  8. Git Workflows
  9. Git Tools
  10. Git Uses

Chapter 6: Git Katas

  1. Git Kata 1: New Local Repository
  2. Step 1: Initialize a New Repository
  3. $ git init
  4. $ git status
  5. Step 2: Stage Changes to a Repository
  6. $ git add storelist.txt
  7. $ git status
  8. Step 3: Commit Changes to a Repository
  9. $ git status
  10. Step 4: Making and Committing Changes to a File
  11. $ git status
  12. $ git commit -a -m “Reordered list”
  13. $ git status
  14. $ git commit -a -m "Another reorder"
  15. $ git status
  16. Git Kata 2: Branches
  17. Step 1: Listing and Creating Branches
  18. $ git branch
  19. $ git branch newbranch
  20. $ git branch
  21. Step 2: Switching Between Branches
  22. $ git checkout newbranch
  23. $ git branch
  24. $ git status
  25. Step 3: Committing to a Branch
  26. $ git commit -a -m “First line last”
  27. $ git checkout master
  28. Git Kata 3: Merging
  29. Step 1: Merge Changes Between Branches
  30. $ git merge newbranch
  31. Step 2: Merging Branches With Divergent Histories
  32. $ git commit -a -m “Loving yogurt”
  33. $ git checkout newbranch
  34. $ git commit -a -m “Lowfat milk”
  35. $ git checkout master
  36. $ git diff newbranch
  37. Git Kata 4: Merge Conflicts
  38. Step 1: Modify the File in the master Branch
  39. $ git commit -a -m “I want Ripple Chips”
  40. Step 2: Modify the File in newbranch
  41. $ git checkout newbranch
  42. $ git commit -a -m “Barbecue for me”
  43. $ git checkout master
  44. $ git diff newbranch
  45. Step 3: Merge and Resolve Conflicts
  46. $ git merge newbranch
  47. $ git commit -a -m “Ripple and barbecue, everyone is happy!”
  48. $ git log --graph --pretty=oneline
  49. Git Kata 5: Run a Git Server
  50. Step 1: Install Gogs
  51. Step 2: Create Admin Account
  52. Step 3: Create a Repository
  53. Step 4: Add Users
  54. Step 5: Set Repository Permissions
  55. Git Kata 6: Remote Repositories
  56. Step 1: Initialize a New Repository
  57. $ git status
  58. $ git commit -a -m “Initial Commit”
  59. Step 2: Add a Remote Repository
  60. $ git remote add origin http://localhost:3000/devops/web-storelist.git
  61. $ git remote -v
  62. Step 3: Push Commits to a Remote Repository
  63. $ git status
  64. Git Kata 7: Collaboration
  65. Step 1: Clone and Configure the Repository
  66. $ cd carrie.coder
  67. Step 2: Make Changes as Ken and Push
  68. $ firefox storelist.htm &
  69. $ gedit storelist.htm &
  70. $ git status
  71. $ git commit -a -m “Adding items”
  72. Step 3: Make Changes as Carrie and Push
  73. $ gedit storelist.htm &
  74. $ git commit -a -m “Adding some items, list is out of order”
  75. $ git status
  76. $ git pull
  77. $ git commit -a -m “Combining our lists”
  78. $ git push -u origin master
  79. Step 4: Final Edits as Ken
  80. $ git pull
  81. $ git status
  82. $ git commit -a -m “Reordered the list, time for a trip!”
  83. $ git push -u origin master
  84. Git Kata 8: Repository Forking and Pull Requests
  85. Step 1: Create Cody’s Account in Gogs
  86. Step 2: Transfer the web-storelist Repository to Cody
  87. Step 3: Log in as Ken and Create a Fork
  88. Step 4: Review the Pull Request as Cody and Accept

Chapter 7: Continuous Integration and Jenkins

  1. Continuous Integration
  2. Introducing Jenkins

Chapter 8: Jenkins Katas

  1. Jenkins Kata 1: Setup
  2. Step 1: Get the Administrator Key
  3. Step 2: Install Jenkins
  4. Step 3: Create Administrative User
  5. Step 4: Start the Gogs Git Server
  6. Jenkins Kata 2: Create A Job
  7. Step 1: Create a New Job
  8. Step 2: Set up Source Control Parameters
  9. Step 3: Run the Job
  10. Jenkins Kata 3: Build Steps
  11. Step 1: Add a Build Step
  12. Step 2: Build Step Result Codes
  13. Jenkins Kata 4: Automated Testing
  14. Step 1: Add a Build Step to Run the Test
  15. python3 tests/listvalidator.py
  16. Step 2: Make the Test Fail
  17. $ cd ~/dk/cody.coder
  18. $ gedit storelist.htm &
  19. $ git commit -a -m "Adding an invalid item"
  20. $ git push origin master
  21. Step 3: Fix the Code
  22. $ git revert HEAD
  23. $ git push origin master
  24. Jenkins Kata 5: Integrate Git With Jenkins
  25. Step 1: Install the Gogs Webhook Plugin
  26. Step 2: Configure A Build Trigger
  27. Step 3: Configure the Webhook in Gogs
  28. Step 4: Test the Trigger
  29. Step 5: Trigger a Job With a Push
  30. $ cd /home/devops/dk/cody.coder
  31. $ gedit storelist.htm &
  32. $ git commit -a -m "Need more stuff"
  33. $ git push origin master
  34. Jenkins Kata 6: Docker Container Build Step
  35. Step 1: Add a Dockerfile
  36. $ gedit Dockerfile &
  37. $ docker build -t storelist_image .
  38. $ docker container run -d -p 80:80 storelist_image
  39. $ curl localhost
  40. $ git add Dockerfile
  41. $ git commit -a -m "Adding Dockerfile"
  42. $ git push origin master (username: cody.coder | password: katas)
  43. Step 2: Install the Docker Plugin
  44. Step 3: Run a Private Docker Registry
  45. $ docker container run -d -p 5000:5000 --name registry registry:2
  46. Step 4: Add a Docker Build Step
  47. $ curl -X GET http://localhost:5000/v2/dk/storelist/tags/list
  48. $ docker container run -d -p 81:80 localhost:5000/dk/storelist
  49. Jenkins Kata 7: Deploying Containers
  50. Step 1: Add the Build Pipeline Plugin
  51. Step 2: Define A DEV Environment Deployment Job
  52. $ docker container ls
  53. http://dev.storelist.com/storelist.htm
  54. Step 3: Configure the DEV Deployment Job Trigger
  55. $ cd ~/dk/web-storelist
  56. $ gedit storelist.htm &
  57. $ git status
  58. $ git commit -a -m "Added another item"
  59. $ git push origin master (username: cody.coder | password: katas)
  60. Step 4: Define A QA Environment Deployment Job
  61. Step 5: Define a Production Deployment Job
  62. $ docker container ls
  63. Step 6: Add a Pipeline View

DevOps Katas Practice Pages

  1. Docker Katas Practice Pages
  2. Docker Kata 1: The Basic Commands
  3. Docker Kata 2: Disconnected Containers
  4. Docker Kata 3: Container Volumes and Filesystem
  5. Docker Kata 4: Running a Web Server in a Container
  6. Docker Kata 5: Docker Networking
  7. Docker Kata 6: Creating Docker Images
  8. Git Katas Practice Pages
  9. Git Kata 1: New Local Repository
  10. Git Kata 2: Branches
  11. Git Kata 3: Merging
  12. Git Kata 4: Merge Conflicts
  13. Git Kata 5: Run a Git Server
  14. Git Kata 6: Remote Repositories
  15. Git Kata 7: Collaboration
  16. Git Kata 8: Repository Forking and Pull Requests
  17. Jenkins Katas Practice Pages
  18. Jenkins Kata 1: Setup
  19. Jenkins Kata 2: Create a Job
  20. Jenkins Kata 3: Build Steps
  21. Jenkins Kata 4: Automated Testing
  22. Jenkins Kata 5: Integrate Git With Jenkins
  23. Jenkins Kata 6: Docker Container Build Step
  24. Jenkins Kata 7: Deploying Containers

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub