Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Kubernetes - An Introduction to the Open Source Container Orchestration Platform Cork Open Technologies Michael J. O’Sullivan - @mjjosullivan 17th April 2018
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Before we start... Beware...shipping analogies ahoy!
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Kubernetes - what is it? Kubernetes is an open-source system for automating deployment, scaling, and management of container- ized applications. ▶ Abbreviated as K8S or Kube for short. ▶ Kubernetes is Greek for helmsman or pilot. ▶ Originally developed by Google based on the internal Borg cluster management system, and made available as version 1.0 in 2015. ▶ Now open-source and managed under the Cloud Native Computing Foundation (CNCF). ▶ It is not a container-engine itself - it uses various other container-engines, notably Docker. ▶ Can create Resources (objects) either via CLI (kubectl) or via YAML/JSON files.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Kubernetes - why would I use it? As an orchestration platform, K8S provides features to make the management, maintenance, and life-cycle of containers easier than using a containers-engine alone. ▶ Horizontal scaling of applications accross containers. ▶ Self-healing by redeploying containers that have crashed. ▶ Automated rollout of container updates, and rollbacks if failures detected. ▶ Provides for service discovery across applications with cluster DNS names and IP addresses, and load balancing capabilities with these.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...but what about Docker Swarm? ▶ Both have their pros and cons as a choice of orchestration platform... ▶ Docker Swarm is seen as a simpler platform - provides compatibility with existing Docker APIs, and Docker Compose. ▶ Docker is not strictly open source... ▶ K8S is considered to be more flexible, with more features and multi container-engine support, but is seen as more complex. ▶ K8S backing from hosted platforms such as Google Cloud Platform, and the experience of Google running containers, and it’s open source nature, all contribute to its popularity.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clusters Containerised-applications are deployed with K8S into highly available Clusters. ▶ Clusters run over several computers called Worker Nodes, that are connected to work as a single unit. ▶ Containerised applications are automatically distributed among the Worker Nodes at deploy time. ▶ A Master Node manages the cluster - coordinating scheduling, scaling, and rolling updates.
Master and Worker Nodes . . . . . . . . . . . . . . . . . . . .
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deployments To run a containerised-application in a cluster, a Deployment configuration is used. ▶ The Deployment describes how K8S should create and update application instances. ▶ The K8S Master uses this to schedule the instances onto the Worker Nodes.
Creating a Deployment . . . . . . . . . . . . . . . . . . . .
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pods A Pod is an abstraction that represents a group of one or more application containers and shared resources. ▶ Pods are the atomic unit on the Kubernetes platform for scheduling in a Cluster. ▶ Deployments create Pods, with containers running inside those Pods. ▶ The Pods are scheduled on the Worker Nodes, and remain on their assigned Nodes until termination. ▶ Worker Nodes can run several Pods.
Deployments create Pods . . . . . . . . . . . . . . . . . . . .
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ConfigMaps ConfigMaps decouple configuration from images for container portability... apiVersion: v1 data: game.properties: | enemies=aliens lives=3 enemies.cheat=true enemies.cheat.level=noGoodRotten secret.code.passphrase=UUDDLRLRBABAS secret.code.allowed=true secret.code.lives=30 ui.properties: | color.good=purple color.bad=yellow allow.textmode=true how.nice.to.look=fairlyNice kind: ConfigMap metadata: creationTimestamp: 2016-02-18T18:52:05Z name: game-config namespace: default resourceVersion: "516" selfLink: /api/v1/namespaces/default/configmaps/game-config uid: b4952dc3-d670-11e5-8cd0-68f728db1985
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Secrets A Secret is an object that contains a small amount of sensitive data such as a password, a token, or a key. ▶ Saving credentials in a Secret rather than a Pod provides more control over how it is used, and reduces the risk of accidental exposure. ▶ A secret can be used with a Pod in two ways: as files in a mounted Volume, or used by kubelet when pulling images for the Pod.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Describing Secrets $ kubectl get secrets NAME TYPE DATA AGE db-user-pass Opaque 2 51s $ kubectl describe secrets/db-user-pass Name: db-user-pass Namespace: default Labels: <none> Annotations: <none> Type: Opaque Data ==== password.txt: 12 bytes username.txt: 5 bytes
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Secrets in a Pod apiVersion: v1 kind: Pod metadata: name: secret-env-pod spec: containers: - name: mycontainer image: redis env: - name: SECRET_USERNAME valueFrom: secretKeyRef: name: mysecret key: username - name: SECRET_PASSWORD valueFrom: secretKeyRef: name: mysecret key: password restartPolicy: Never
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Worker Nodes The Worker Node above is running several Pods - each Pod runs one or more Containers, and encapsulates resources such as storage volumes. ▶ Each Pod has a Cluster IP address. ▶ Docker-engine is installed and running as the container-engine on the Node. ▶ A kubelet agent is also running on the Node - this is used to talk to the Master Node.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cluster Storage There are persistent and non-persistent methods for storing data in clusters. ▶ Data can be either stored in the container, or mounted into the container from the Worker Node - this data is non-persistent. ▶ To store persistent data, network file storage (NFS) should be used. ▶ To attach an NFS volume to a Pod, a Persistent Volume Claim (PVC) is specified as part of the Deployment. ▶ A PVC will attach a Persistent Volume (PV) to the cluster, which can be mounted to any Pod.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Services A Service is a logical set of Pods and a policy to access them - they are used to expose your pods to access from outside the cluster
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Services ▶ Cluster IP: Default option. The Service uses an internal IP only accessible within the cluster. ▶ NodePort: A Service is accessed using the IP address of the Worker Node. ▶ LoadBalancer: A Service is accessed using an external LoadBalancer with a seperate extermal IP address. ▶ ExternalName: A Service is accessed using an a name defined in a CNAME record in DNS.
Creating Services . . . . . . . . . . . . . . . . . . . .
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ingress An Ingress is an API object that manages external access to the services in a cluster, typically via HTTP. Ingress can provide load balancing, SSL termination, and name-based virtual hosting. ▶ The Ingress Object contains rules to specify how external inbound traffic can reach services using URLs. ▶ These rules are defined in an Ingress Resource. ▶ The Ingress Resource is provided to the Ingress Controller, which uses a LoadBalancer to manage incoming traffic against the rules. ▶ Essentially an easy way of combining services exposed via a LoadBalancer, and path matching against URLs for different services!
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ingress Resource apiVersion: extensions/v1beta1 kind: Ingress metadata: name: test annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: foo.bar.com http: paths: - path: /foo backend: serviceName: s1 servicePort: 80 - path: /bar backend: serviceName: s2 servicePort: 80
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Labels Labels are key:value pairs that can be applied to objects to provide logical groupings - labels are then used with selectors to apply logical operations.
Using Labels . . . . . . . . . . . . . . . . . . . .
K8S Architecture The architecture can be viewed in two parts: components that run on a Master Node, and those that run on the Worker Nodes (minions). . . . . . . . . . . . . . . . . . . . .
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K8S Architecture - Master Nodes ▶ Kube Controller Manager: Runs common controllers for Nodes, Routes, Services, and Volumes. ▶ Cloud Controller Manager: Runs separate processes for KCM controllers that contain cloud-vendor specific implementations. ▶ kube-apiserver: K8S brain - hub of communications between Masters and Workers. Also receives kubectl commands. ▶ etcd: A key:value database that stores all the information for current and desired state of clusters. ▶ kube-scheduler: Based on workload, schedules upon which Worker Nodes that Pods should run.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K8S Architecture - Worker Nodes ▶ kubelet: Effectively the K8S agent running on each node, for communication with the apiserver on the Master - implements Node and Pod APIs, and initialises a Worker. ▶ kube-proxy: A network proxy that is used to implement service backends in K8S, providing appropriate traffic routing to virtual-IPs of backend services via iptables configurations. ▶ Docker: Out of the box, docker-engine is running as the container engine implementation.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Helm The package manager for Kubernetes...
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Helm - what is it? Helm helps you manage Kubernetes applications — Helm Charts helps you define, install, and upgrade even the most complex Kubernetes application. ▶ A Helm Chart is in effect a package of different Kubernetes objects (deployments, services, routes, etc.) that can deploy an entire software stack into a cluster with one command. ▶ Developers can write Helm Charts, version them, and then publish them to a repository for sharing with the wider community. ▶ Developers install a Helm Client onto the local machine, and use it to install a Tiller into the target cluster - Tiller both installs and manages Charts in your cluster as Releases.
Helm: Installing and Deploying helm init configures the CLI, and installs Tiller into the cluster. Helm has not only created the Deployment, but also a ConfigMap and two Services! . . . . . . . . . . . . . . . . . . . .
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Istio An open platform to connect, manage, and secure microservices. A Google - IBM collaborative project.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Istio - what is it? Istio can be used to overlay useful networking fea- tures on top of services deployed with Kubernetes using a service mesh. ▶ It enables load balancing, service-to-service authentication and monitoring without any changes required to the service code. ▶ Istio is built upon the Envoy proxy to mediate traffic between different services. ▶ A sidecar container is deployed into each Pod in the Cluster, and any ingress/egress traffic for the Pod is routed through this sidecar into the service mesh.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Architecture ▶ Pilot: Provides service-discovery, traffic management and routing between sidecars within the Cluster. ▶ Mixer: Responsible for enforcing access control policies over the service mesh, and reporting telemetry metrics. ▶ Istio-Auth: Provides service-to-service and end-user authentication with mutual TLS using built-in identity and credential management.
Kubernetes - An Introduction to the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The End Thank you! Acknowledgements: Alan Panayotov Ruairi Hayes Kubernetes: https://kubernetes.io/ K8S vs. Docker Swarm: https://nickjanetakis.com/blog/ docker-swarm-vs-kubernetes-which-one-should-you-learn Helm: https://helm.sh Helm Minecraft Chart: https://github.com/ kubernetes/charts/tree/master/stable/minecraft Istio: https://istio.io/ Cork Open Technologies Meetup: https://www.meetup.com/Cork-OpenTechnology/ Cork Open Technologies Twitter: https://twitter.com/CorkOpenTech

Kubernetes: An Introduction to the Open Source Container Orchestration Platform

  • 1.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Kubernetes - An Introduction to the Open Source Container Orchestration Platform Cork Open Technologies Michael J. O’Sullivan - @mjjosullivan 17th April 2018
  • 2.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Before we start... Beware...shipping analogies ahoy!
  • 3.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Kubernetes - what is it? Kubernetes is an open-source system for automating deployment, scaling, and management of container- ized applications. ▶ Abbreviated as K8S or Kube for short. ▶ Kubernetes is Greek for helmsman or pilot. ▶ Originally developed by Google based on the internal Borg cluster management system, and made available as version 1.0 in 2015. ▶ Now open-source and managed under the Cloud Native Computing Foundation (CNCF). ▶ It is not a container-engine itself - it uses various other container-engines, notably Docker. ▶ Can create Resources (objects) either via CLI (kubectl) or via YAML/JSON files.
  • 4.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Kubernetes - why would I use it? As an orchestration platform, K8S provides features to make the management, maintenance, and life-cycle of containers easier than using a containers-engine alone. ▶ Horizontal scaling of applications accross containers. ▶ Self-healing by redeploying containers that have crashed. ▶ Automated rollout of container updates, and rollbacks if failures detected. ▶ Provides for service discovery across applications with cluster DNS names and IP addresses, and load balancing capabilities with these.
  • 5.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...but what about Docker Swarm? ▶ Both have their pros and cons as a choice of orchestration platform... ▶ Docker Swarm is seen as a simpler platform - provides compatibility with existing Docker APIs, and Docker Compose. ▶ Docker is not strictly open source... ▶ K8S is considered to be more flexible, with more features and multi container-engine support, but is seen as more complex. ▶ K8S backing from hosted platforms such as Google Cloud Platform, and the experience of Google running containers, and it’s open source nature, all contribute to its popularity.
  • 6.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clusters Containerised-applications are deployed with K8S into highly available Clusters. ▶ Clusters run over several computers called Worker Nodes, that are connected to work as a single unit. ▶ Containerised applications are automatically distributed among the Worker Nodes at deploy time. ▶ A Master Node manages the cluster - coordinating scheduling, scaling, and rolling updates.
  • 7.
    Master and WorkerNodes . . . . . . . . . . . . . . . . . . . .
  • 8.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deployments To run a containerised-application in a cluster, a Deployment configuration is used. ▶ The Deployment describes how K8S should create and update application instances. ▶ The K8S Master uses this to schedule the instances onto the Worker Nodes.
  • 9.
    Creating a Deployment .. . . . . . . . . . . . . . . . . . .
  • 10.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pods A Pod is an abstraction that represents a group of one or more application containers and shared resources. ▶ Pods are the atomic unit on the Kubernetes platform for scheduling in a Cluster. ▶ Deployments create Pods, with containers running inside those Pods. ▶ The Pods are scheduled on the Worker Nodes, and remain on their assigned Nodes until termination. ▶ Worker Nodes can run several Pods.
  • 11.
    Deployments create Pods .. . . . . . . . . . . . . . . . . . .
  • 12.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ConfigMaps ConfigMaps decouple configuration from images for container portability... apiVersion: v1 data: game.properties: | enemies=aliens lives=3 enemies.cheat=true enemies.cheat.level=noGoodRotten secret.code.passphrase=UUDDLRLRBABAS secret.code.allowed=true secret.code.lives=30 ui.properties: | color.good=purple color.bad=yellow allow.textmode=true how.nice.to.look=fairlyNice kind: ConfigMap metadata: creationTimestamp: 2016-02-18T18:52:05Z name: game-config namespace: default resourceVersion: "516" selfLink: /api/v1/namespaces/default/configmaps/game-config uid: b4952dc3-d670-11e5-8cd0-68f728db1985
  • 13.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Secrets A Secret is an object that contains a small amount of sensitive data such as a password, a token, or a key. ▶ Saving credentials in a Secret rather than a Pod provides more control over how it is used, and reduces the risk of accidental exposure. ▶ A secret can be used with a Pod in two ways: as files in a mounted Volume, or used by kubelet when pulling images for the Pod.
  • 14.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Describing Secrets $ kubectl get secrets NAME TYPE DATA AGE db-user-pass Opaque 2 51s $ kubectl describe secrets/db-user-pass Name: db-user-pass Namespace: default Labels: <none> Annotations: <none> Type: Opaque Data ==== password.txt: 12 bytes username.txt: 5 bytes
  • 15.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Secrets in a Pod apiVersion: v1 kind: Pod metadata: name: secret-env-pod spec: containers: - name: mycontainer image: redis env: - name: SECRET_USERNAME valueFrom: secretKeyRef: name: mysecret key: username - name: SECRET_PASSWORD valueFrom: secretKeyRef: name: mysecret key: password restartPolicy: Never
  • 16.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Worker Nodes The Worker Node above is running several Pods - each Pod runs one or more Containers, and encapsulates resources such as storage volumes. ▶ Each Pod has a Cluster IP address. ▶ Docker-engine is installed and running as the container-engine on the Node. ▶ A kubelet agent is also running on the Node - this is used to talk to the Master Node.
  • 17.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cluster Storage There are persistent and non-persistent methods for storing data in clusters. ▶ Data can be either stored in the container, or mounted into the container from the Worker Node - this data is non-persistent. ▶ To store persistent data, network file storage (NFS) should be used. ▶ To attach an NFS volume to a Pod, a Persistent Volume Claim (PVC) is specified as part of the Deployment. ▶ A PVC will attach a Persistent Volume (PV) to the cluster, which can be mounted to any Pod.
  • 18.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Services A Service is a logical set of Pods and a policy to access them - they are used to expose your pods to access from outside the cluster
  • 19.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Services ▶ Cluster IP: Default option. The Service uses an internal IP only accessible within the cluster. ▶ NodePort: A Service is accessed using the IP address of the Worker Node. ▶ LoadBalancer: A Service is accessed using an external LoadBalancer with a seperate extermal IP address. ▶ ExternalName: A Service is accessed using an a name defined in a CNAME record in DNS.
  • 20.
    Creating Services . .. . . . . . . . . . . . . . . . . .
  • 21.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ingress An Ingress is an API object that manages external access to the services in a cluster, typically via HTTP. Ingress can provide load balancing, SSL termination, and name-based virtual hosting. ▶ The Ingress Object contains rules to specify how external inbound traffic can reach services using URLs. ▶ These rules are defined in an Ingress Resource. ▶ The Ingress Resource is provided to the Ingress Controller, which uses a LoadBalancer to manage incoming traffic against the rules. ▶ Essentially an easy way of combining services exposed via a LoadBalancer, and path matching against URLs for different services!
  • 22.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ingress Resource apiVersion: extensions/v1beta1 kind: Ingress metadata: name: test annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: foo.bar.com http: paths: - path: /foo backend: serviceName: s1 servicePort: 80 - path: /bar backend: serviceName: s2 servicePort: 80
  • 23.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Labels Labels are key:value pairs that can be applied to objects to provide logical groupings - labels are then used with selectors to apply logical operations.
  • 24.
    Using Labels . .. . . . . . . . . . . . . . . . . .
  • 25.
    K8S Architecture The architecturecan be viewed in two parts: components that run on a Master Node, and those that run on the Worker Nodes (minions). . . . . . . . . . . . . . . . . . . . .
  • 26.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K8S Architecture - Master Nodes ▶ Kube Controller Manager: Runs common controllers for Nodes, Routes, Services, and Volumes. ▶ Cloud Controller Manager: Runs separate processes for KCM controllers that contain cloud-vendor specific implementations. ▶ kube-apiserver: K8S brain - hub of communications between Masters and Workers. Also receives kubectl commands. ▶ etcd: A key:value database that stores all the information for current and desired state of clusters. ▶ kube-scheduler: Based on workload, schedules upon which Worker Nodes that Pods should run.
  • 27.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K8S Architecture - Worker Nodes ▶ kubelet: Effectively the K8S agent running on each node, for communication with the apiserver on the Master - implements Node and Pod APIs, and initialises a Worker. ▶ kube-proxy: A network proxy that is used to implement service backends in K8S, providing appropriate traffic routing to virtual-IPs of backend services via iptables configurations. ▶ Docker: Out of the box, docker-engine is running as the container engine implementation.
  • 28.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Helm The package manager for Kubernetes...
  • 29.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Helm - what is it? Helm helps you manage Kubernetes applications — Helm Charts helps you define, install, and upgrade even the most complex Kubernetes application. ▶ A Helm Chart is in effect a package of different Kubernetes objects (deployments, services, routes, etc.) that can deploy an entire software stack into a cluster with one command. ▶ Developers can write Helm Charts, version them, and then publish them to a repository for sharing with the wider community. ▶ Developers install a Helm Client onto the local machine, and use it to install a Tiller into the target cluster - Tiller both installs and manages Charts in your cluster as Releases.
  • 30.
    Helm: Installing andDeploying helm init configures the CLI, and installs Tiller into the cluster. Helm has not only created the Deployment, but also a ConfigMap and two Services! . . . . . . . . . . . . . . . . . . . .
  • 31.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Istio An open platform to connect, manage, and secure microservices. A Google - IBM collaborative project.
  • 32.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Istio - what is it? Istio can be used to overlay useful networking fea- tures on top of services deployed with Kubernetes using a service mesh. ▶ It enables load balancing, service-to-service authentication and monitoring without any changes required to the service code. ▶ Istio is built upon the Envoy proxy to mediate traffic between different services. ▶ A sidecar container is deployed into each Pod in the Cluster, and any ingress/egress traffic for the Pod is routed through this sidecar into the service mesh.
  • 33.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Architecture ▶ Pilot: Provides service-discovery, traffic management and routing between sidecars within the Cluster. ▶ Mixer: Responsible for enforcing access control policies over the service mesh, and reporting telemetry metrics. ▶ Istio-Auth: Provides service-to-service and end-user authentication with mutual TLS using built-in identity and credential management.
  • 34.
    Kubernetes - An Introductionto the Open Source Container Orchestration Platform Michael J. O’Sullivan - @mjjosullivan Introduction Kubernetes: What and Why Clusters Structure Nodes Deployments Pods Configurations and Secrets Worker Node Structure Storage Services Labels Architecture Helm What is it? Installing and Deploying Istio What is it? Installation and Use Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The End Thank you! Acknowledgements: Alan Panayotov Ruairi Hayes Kubernetes: https://kubernetes.io/ K8S vs. Docker Swarm: https://nickjanetakis.com/blog/ docker-swarm-vs-kubernetes-which-one-should-you-learn Helm: https://helm.sh Helm Minecraft Chart: https://github.com/ kubernetes/charts/tree/master/stable/minecraft Istio: https://istio.io/ Cork Open Technologies Meetup: https://www.meetup.com/Cork-OpenTechnology/ Cork Open Technologies Twitter: https://twitter.com/CorkOpenTech