Learn how to get Kubernetes up and running on Google Cloud Platform with GKE. Go over why you should use Kubernetes, and why using a managed service like GKE is important. After that we will go over how to deploy both simple and advanced applications to your cluster.
3. Agenda
● Cover the basic Kubernetes nomenclature and concepts
● Create a cluster on GKE
● Deploy a simple app on GKE
● Deploy WordPress on GKE
4. What is Kubernetes?
● Open source system of managing containerized
applications
● Developed by Google after 15 years of running
containers in production
● Scalable - add as many servers to the cluster
● Portable - run on bare metal, private or public
clouds
5. Why use Kubernetes
Enterprises
● Run on bare metal for max performance
● Vendor neutral infrastructure
● Multi Cloud
● Variable capacity
● Multi tenancy
● Possibly use spot instances for temp
workloads
SMBs & Startups
● Streamline devops and production
engineering workflows
● Multi tenancy
● Infrastructure can grow with needs
● Modular (only scale what you need to)
● GKE: Committed Use Discounts
6. Why use GKE
● Installing Kubernetes is complex
● Fully managed by Google SREs
● Auto scale
● Auto upgrade
● Container Optimized OS
● GPUs!
● Integrated Logging/Monitoring (via Stackdriver)
● FREE!
8. Kubernetes Master & Nodes
● Master coordinates the cluster
● Nodes run the processes
● GKE manages the Kubernetes Master with regional replication
9. Kubernetes Deployment
● Deployment instructs Kubernetes how to create and update instances of
your application.
● Master schedules applications to run on nodes
11. Pods
● Group of one or more containers with shared resources
○ Network (unique IP)
○ Storage
12. Service
● Defines how pods communicate (i.e. a microservice)
○ Pod-to-pod communication within a cluster
○ Communication outside the cluster (i.e. a website)
■ ClusterIP
■ Nodeport
■ LoadBalancer
■ ExternalName
15. Kubernetes Infrastructure as Code
All Kubectl commands can be stored as code (YAML) and deployed to the
cluster.
1. For volume claims $kubectl apply -f [file_name].yaml
2. For depoyments & services $kubectl create -f [file_name].yaml
16. Step 1: Create PersistentVolumes and
PersistentVolumeClaims
● PresistentVolumeClaim is a request for storage
● If no volume exists, one is dynamically provisioned
● GKE creates PersistentVolumes backed by persistent disks
$ kubectl apply -f mysql-volumeclaim.yaml
$ kubectl apply -f wordpress-volumeclaim.yaml
17. Step 2: Deploy MySQL
● Create secret - $ kubectl create secret generic mysql --from-
literal=password=YOUR_PASSWORD
● Deploy Service - $ kubectl create -f mysql.yaml
● Confirm pod is running - $ kubectl get pod -l app=mysql
● Deploy MySQL Service - $ kubectl create -f mysql-service.yaml
● Confirm service is created - $ kubectl get service mysql
18. Step 3: Deploy WordPress
● Deploy manifest file $ kubectl create -f wordpress.yaml
● Confirm pod is running $ kubectl get pod -l app=wordpress
● Expose WordPress Service $ kubectl create -f wordpress-service.yaml
● Get service external IP $ kubectl get svc -l app=wordpress
● Access your site!
20. Resources
● Kubernetes.io
● Udacity - Scalable Microservices with Kubernetes (free course by Google)
● Kubernetes the Hard Way by Kacey Hightower
● Minikube
● Kubernetes Slack