Reader small image

You're reading from  Kubernetes Design Patterns and Extensions

Product typeBook
Published inSep 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781789619270
Edition1st Edition
Languages
Right arrow
Author (1)
Onur Yılmaz
Onur Yılmaz
author image
Onur Yılmaz

Onur Ylmaz is a senior software engineer in a multinational enterprise software company. He is a certified Kubernetes administrator (CKA) and works on Kubernetes and cloud management systems. He is a keen supporter of cutting-edge technologies including Docker, Kubernetes, and cloud-native applications. He has one master's and two bachelor's degrees in the engineering field.
Read more about Onur Yılmaz

Right arrow

Solutions

This section contains the worked-out answers for the activities present in each lesson. Note that in case of descriptive questions, your answers might not match the ones provided in this section completely. As long as the essence of the answers remain the same, you can consider them correct.

Chapter 1: Kubernetes Design Patterns

Following are the activity solutions for this chapter.

Activity: Running a Web Server with Synchronization

In the sidecar.yaml file, pod definition with two containers, namely server and sync, is provided. In the server container, httpd serves the source volume on port 80. In the sync container, git runs with every 30 seconds to synchronize the source volume. These two containers work independently; however, they are sharing the source volume to achieve file synchronization:

apiVersion: v1
kind: Pod
metadata:
name: sidecar
spec:
containers:
...
volumes:
- emptyDir: {}
name: source

Follow these steps to get the solution:

  1. Create the pod with the following command:
 kubectl apply...

Chapter 2: Kubernetes Client Libraries

Following are the activity solutions for this chapter.

Activity: Using the Kubernetes Go Client inside the Cluster

  1. Create a deployment with the Docker image of the example client from the previous exercise:
kubectl run go-client --image=onuryilmaz/k8s-clientexample:go
  1. Wait until the pod is running by using the following command:
kubectl get pods -w
  1. Get the logs of the deployment pod with the following command:
kubectl logs $(kubectl get pods --selector run=go-client -o jsonpath="{.items[0].metadata.name}")
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Kubernetes Design Patterns and Extensions
Published in: Sep 2018Publisher: PacktISBN-13: 9781789619270
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Onur Yılmaz

Onur Ylmaz is a senior software engineer in a multinational enterprise software company. He is a certified Kubernetes administrator (CKA) and works on Kubernetes and cloud management systems. He is a keen supporter of cutting-edge technologies including Docker, Kubernetes, and cloud-native applications. He has one master's and two bachelor's degrees in the engineering field.
Read more about Onur Yılmaz