Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Getting Started with Kubernetes, - Third Edition

You're reading from  Getting Started with Kubernetes, - Third Edition

Product type Book
Published in Oct 2018
Publisher Packt
ISBN-13 9781788994729
Pages 470 pages
Edition 3rd Edition
Languages
Concepts
Authors (2):
Jonathan Baier Jonathan Baier
Profile icon Jonathan Baier
Jesse White Jesse White
Profile icon Jesse White
View More author details

Table of Contents (23) Chapters

Title Page
Dedication
Packt Upsell
Contributors
Preface
1. Introduction to Kubernetes 2. Building a Foundation with Core Kubernetes Constructs 3. Working with Networking, Load Balancers, and Ingress 4. Implementing Reliable Container-Native Applications 5. Exploring Kubernetes Storage Concepts 6. Application Updates, Gradual Rollouts, and Autoscaling 7. Designing for Continuous Integration and Delivery 8. Monitoring and Logging 9. Operating Systems, Platforms, and Cloud and Local Providers 10. Designing for High Availability and Scalability 11. Kubernetes SIGs, Incubation Projects, and the CNCF 12. Cluster Federation and Multi-Tenancy 13. Cluster Authentication, Authorization, and Container Security 14. Hardening Kubernetes 15. Kubernetes Infrastructure Management 1. Assessments 2. Other Books You May Enjoy Index

Application autoscaling


A recent feature addition to Kubernetes is that of the Horizontal Pod Autoscaler. This resource type is really useful as it gives us a way to automatically set thresholds for scaling our application. Currently, that support is only for CPU, but there is alpha support for custom application metrics as well. 

Let's use the node-js-scaleReplicationController from the beginning of the chapter and add an autoscaling component. Before we start, let's make sure we are scaled back down to one replica using the following command:

$ kubectl scale --replicas=1 rc/node-js-scale

Now, we can create a Horizontal Pod Autoscaler, node-js-scale-hpa.yaml with the following hpa definition:

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: node-js-scale
spec:
  minReplicas: 1
  maxReplicas: 3
  scaleTargetRef:
    apiVersion: v1
    kind: ReplicationController
    name: node-js-scale
  targetCPUUtilizationPercentage: 20

Go ahead and create this with thekubectl create...

lock icon The rest of the chapter is locked
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.
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 €14.99/month. Cancel anytime}