Acknowledgements
Chapter 1: Introduction to DevOps
- What is DevOps?
- Culture
- Process
- Technology
- DevOps Automation
Chapter 2: Getting Started With DevOps Katas
- Introduction: Practice First
- What is a Kata?
- Kata Formatting and Conventions
- Kata Practice Guidelines
- Kata Practice Pages
- Kata Practice Calendar
- Kata Practice Tools
- Setting up the DevOps Katas Learning Virtual Machine
- Step 1: Install Virtualbox
- Step 2: Download the LVM Image
- Step 3: Import the LVM Image
- Step 4: Run the LVM
- Sample Kata
- Step 1: Create a Directory
$ mkdir firstkata- Step 2: Change to the
firstkataDirectory $ cd firstkata- Step 3: Create a File
$ touch firstkata.txt- Step 4: List the files in the
firstkatadirectory $ ls- Step 5: Edit the file with the text editor
$ gedit firstkata.txt &- Step 6: Enter text into the file and save
Chapter 3: Containers and Docker
- 1995 - 2002: Advent of the Internet
- 2002: Virtualization
- 2008: Containers
- 2013: Docker
- Containers and DevOps
- Automation
- Reliability
- Portability
- Scalability
- Isolation
- Docker and DevOps Katas
Chapter 4: Docker Katas
- Docker Kata 1: The Basic Commands
- Step 1: Running Your First Container
$ docker container run hello-world- Step 2: Listing Containers
$ docker container ls$ docker container ls -a- Step 3: Listing Images
$ docker image ls- Step 4: Running a Named Container
$ docker container run --name my_container hello-world$ docker container ls -a$ docker container inspect my_container- Step 5: Run a Container in Interactive Mode
$ docker container run -it ubuntu bash$ ls$ ls /bin$ exit- Step 6: Remove all Containers and Images
$ docker container rm $(docker container ls -a -q)$ docker container ls -a$ docker image rm $(docker image ls -aq)- Docker Kata 2: Disconnected Containers
- Step 1: Run a “Disconnected” Container
$ docker container ls$ docker container logs $(docker container ls -q)$ docker container stop $(docker container ls -q)- Step 2: Execute Commands on a Running Container
$ docker container run -d --name webserver nginx$ docker container exec webserver ls$ docker container exec webserver ip addr$ docker container exec webserver ip addr | grep inet- Step 3: Connecting Interactively to a Running Container
$ docker container exec -it webserver bash$ ls$ exit- Docker Kata 3: Container Volumes and Filesystem
- Step 1: Container Filesystem Changes
$ docker container stop $(docker container ls -q)$ docker container rm $(docker container ls -aq)$ docker container run -it ubuntu bash$ ls$ echo "file1text" > file1.txt$ ls$ exit$ docker container run -it ubuntu bash$ ls$ exit- Step 2: Run a Container With a Named Volume
$ docker container run -d --name web -v=myVolume:/webapp nginx$ docker container ls$ docker container exec web ls$ docker volume ls- Step 3: Share a Volume Between Containers
$ docker container run -d --name web2 -v myVolume:/webapp nginx$ docker container exec web ls webapp$ docker container exec web2 ls webapp- Step 4: Run a Container With a Host-Mounted Volume
$ mkdir dockervolume$ cd dockervolume$ echo file1text > file1.txt$ echo file2text > file2.txt$ ls$ cd ..$ docker container exec web3 ls /hostmounted- Docker Kata 4: Running a Web Server in a Container
- Step 1: Run a Web Server
$ docker container stop $(docker container ls -q)$ docker container rm $(docker container ls -aq)$ docker container run -d -p 80:80 --name webserver nginx$ curl localhostOpen Firefox and go to http://localhost- Step 2: Run a Second Webserver on a Different Port
$ docker container run -d -p 81:80 --name webserver2 nginx$ curl localhost:81- Docker Kata 5: Docker Networking
- Step 1: List All Networks
$ docker network ls- Step 2: Ping Between Containers
$ docker container run -d --name web1 nginx$ docker container run -d --name web2 nginx$ docker container exec web1 ping -w3 $(docker inspect -f '{{ .NetworkSettings.IPAddress}}' web2)$ docker container exec web2 ping -w3 $(docker inspect -f '{{ .NetworkSettings.IPAddress}}' web1)$ docker container exec web1 ping -w3 web2- Step 3: Create a User-Defined Network
$ docker network create mynet$ docker network inspect mynet- Step 4: Run Containers on a User-Defined Network
$ docker container run -d --net=mynet --name web1 nginx$ docker container run -d --net=mynet --name web2 nginx$ docker network inspect mynet$ docker container exec web1 ping -w3 web2- Docker Kata 6: Creating Docker Images
- Step 1: Creating an Image From a Modified Container
$ mkdir dockerimage$ cd dockerimage$ cp ../index.html .$ ls$ docker container run --name web -d -p 80:80 nginx$ docker container cp index.html web:/usr/share/nginx/html/index.html$ curl localhost$ docker container ls$ docker container commit web kataimage_nginx$ docker image ls$ docker container run -d -p 81:80 kataimage_nginx$ curl localhost:81- Step 2: Create an Image with a Dockerfile
$ gedit Dockerfile &$ docker image build -t katadockerfile_image .$ docker image ls$ docker container run -d -p 80:80 katadockerfile_image$ curl localhost
Chatper 5: Source Control Management and Git
- Source Control Tools
- Centralized Version Control Systems (CVCS)
- Distributed Version Control Systems (DVCS)
- Introducing Git
- Anatomy of a Git Repository
- Sharing Code With Git
- Merging and Branching in Git
- Git Workflows
- Git Tools
- Git Uses
Chapter 6: Git Katas
- Git Kata 1: New Local Repository
- Step 1: Initialize a New Repository
$ git init$ git status- Step 2: Stage Changes to a Repository
$ git add storelist.txt$ git status- Step 3: Commit Changes to a Repository
$ git status- Step 4: Making and Committing Changes to a File
$ git status$ git commit -a -m “Reordered list”$ git status$ git commit -a -m "Another reorder"$ git status- Git Kata 2: Branches
- Step 1: Listing and Creating Branches
$ git branch$ git branch newbranch$ git branch- Step 2: Switching Between Branches
$ git checkout newbranch$ git branch$ git status- Step 3: Committing to a Branch
$ git commit -a -m “First line last”$ git checkout master- Git Kata 3: Merging
- Step 1: Merge Changes Between Branches
$ git merge newbranch- Step 2: Merging Branches With Divergent Histories
$ git commit -a -m “Loving yogurt”$ git checkout newbranch$ git commit -a -m “Lowfat milk”$ git checkout master$ git diff newbranch- Git Kata 4: Merge Conflicts
- Step 1: Modify the File in the
masterBranch $ git commit -a -m “I want Ripple Chips”- Step 2: Modify the File in
newbranch $ git checkout newbranch$ git commit -a -m “Barbecue for me”$ git checkout master$ git diff newbranch- Step 3: Merge and Resolve Conflicts
$ git merge newbranch$ git commit -a -m “Ripple and barbecue, everyone is happy!”$ git log --graph --pretty=oneline- Git Kata 5: Run a Git Server
- Step 1: Install Gogs
- Step 2: Create Admin Account
- Step 3: Create a Repository
- Step 4: Add Users
- Step 5: Set Repository Permissions
- Git Kata 6: Remote Repositories
- Step 1: Initialize a New Repository
$ git status$ git commit -a -m “Initial Commit”- Step 2: Add a Remote Repository
$ git remote add origin http://localhost:3000/devops/web-storelist.git$ git remote -v- Step 3: Push Commits to a Remote Repository
$ git status- Git Kata 7: Collaboration
- Step 1: Clone and Configure the Repository
$ cd carrie.coder- Step 2: Make Changes as Ken and Push
$ firefox storelist.htm &$ gedit storelist.htm &$ git status$ git commit -a -m “Adding items”- Step 3: Make Changes as Carrie and Push
$ gedit storelist.htm &$ git commit -a -m “Adding some items, list is out of order”$ git status$ git pull$ git commit -a -m “Combining our lists”$ git push -u origin master- Step 4: Final Edits as Ken
$ git pull$ git status$ git commit -a -m “Reordered the list, time for a trip!”$ git push -u origin master- Git Kata 8: Repository Forking and Pull Requests
- Step 1: Create Cody’s Account in Gogs
- Step 2: Transfer the
web-storelistRepository to Cody - Step 3: Log in as Ken and Create a Fork
- Step 4: Review the Pull Request as Cody and Accept
Chapter 7: Continuous Integration and Jenkins
- Continuous Integration
- Introducing Jenkins
Chapter 8: Jenkins Katas
- Jenkins Kata 1: Setup
- Step 1: Get the Administrator Key
- Step 2: Install Jenkins
- Step 3: Create Administrative User
- Step 4: Start the Gogs Git Server
- Jenkins Kata 2: Create A Job
- Step 1: Create a New Job
- Step 2: Set up Source Control Parameters
- Step 3: Run the Job
- Jenkins Kata 3: Build Steps
- Step 1: Add a Build Step
- Step 2: Build Step Result Codes
- Jenkins Kata 4: Automated Testing
- Step 1: Add a Build Step to Run the Test
python3 tests/listvalidator.py- Step 2: Make the Test Fail
$ cd ~/dk/cody.coder$ gedit storelist.htm &$ git commit -a -m "Adding an invalid item"$ git push origin master- Step 3: Fix the Code
$ git revert HEAD$ git push origin master- Jenkins Kata 5: Integrate Git With Jenkins
- Step 1: Install the Gogs Webhook Plugin
- Step 2: Configure A Build Trigger
- Step 3: Configure the Webhook in Gogs
- Step 4: Test the Trigger
- Step 5: Trigger a Job With a Push
$ cd /home/devops/dk/cody.coder$ gedit storelist.htm &$ git commit -a -m "Need more stuff"$ git push origin master- Jenkins Kata 6: Docker Container Build Step
- Step 1: Add a Dockerfile
$ gedit Dockerfile &$ docker build -t storelist_image .$ docker container run -d -p 80:80 storelist_image$ curl localhost$ git add Dockerfile$ git commit -a -m "Adding Dockerfile"$ git push origin master(username: cody.coder | password: katas)- Step 2: Install the Docker Plugin
- Step 3: Run a Private Docker Registry
$ docker container run -d -p 5000:5000 --name registry registry:2- Step 4: Add a Docker Build Step
$ curl -X GET http://localhost:5000/v2/dk/storelist/tags/list$ docker container run -d -p 81:80 localhost:5000/dk/storelist- Jenkins Kata 7: Deploying Containers
- Step 1: Add the Build Pipeline Plugin
- Step 2: Define A DEV Environment Deployment Job
$ docker container lshttp://dev.storelist.com/storelist.htm- Step 3: Configure the DEV Deployment Job Trigger
$ cd ~/dk/web-storelist$ gedit storelist.htm &$ git status$ git commit -a -m "Added another item"$ git push origin master(username: cody.coder | password: katas)- Step 4: Define A QA Environment Deployment Job
- Step 5: Define a Production Deployment Job
$ docker container ls- Step 6: Add a Pipeline View
DevOps Katas Practice Pages
- Docker Katas Practice Pages
- Docker Kata 1: The Basic Commands
- Docker Kata 2: Disconnected Containers
- Docker Kata 3: Container Volumes and Filesystem
- Docker Kata 4: Running a Web Server in a Container
- Docker Kata 5: Docker Networking
- Docker Kata 6: Creating Docker Images
- Git Katas Practice Pages
- Git Kata 1: New Local Repository
- Git Kata 2: Branches
- Git Kata 3: Merging
- Git Kata 4: Merge Conflicts
- Git Kata 5: Run a Git Server
- Git Kata 6: Remote Repositories
- Git Kata 7: Collaboration
- Git Kata 8: Repository Forking and Pull Requests
- Jenkins Katas Practice Pages
- Jenkins Kata 1: Setup
- Jenkins Kata 2: Create a Job
- Jenkins Kata 3: Build Steps
- Jenkins Kata 4: Automated Testing
- Jenkins Kata 5: Integrate Git With Jenkins
- Jenkins Kata 6: Docker Container Build Step
- Jenkins Kata 7: Deploying Containers