kubernetes - fikt.uklo.edu.mk · a service is a grouping of pods that are running on the cluster....

18
Kubernetes KSpresso 18/11/2016 Ilche Bedelovski, DevOps Engineer in Keitaro

Upload: others

Post on 19-Jul-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Kubernetes

KSpresso 18/11/2016

Ilche Bedelovski, DevOps Engineer in Keitaro

Page 2: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

2

Kubernetes Introduction

What is Kubernetes?

- Kubernetes is a platform for hosting Docker containers in a clustered environment with multiple Docker hosts.

- Provides container grouping, load balancing, scaling features- Project was started by Google

Page 3: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

What is a container?

● Lightweight Linux environment● Hermetically sealed, deployable application● Introspectable, runnable artifact● Recently popularized by Docker

3

Page 4: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

What is a cluster?

4

Page 5: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Kubernetes Architecture

5

Page 6: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Pod

Overview of a Pod?

A Kubernetes pod is a group of containers that are deployed together on the same host. If you frequently deploy single containers, you can generally replace the word "pod" with "container" and accurately understand the concept.

Pods operate at one level higher than individual containers because it's very common to have a group of containers work together to produce an artifact or process a set of work.

6

Pod

Page 7: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Shared Namespaces, Volumes and Secrets

● Shared Network - All containers share the same network namespace & port space. Communication over localhost is encouraged. Each container can also communicate with any other pod or service within the cluster.

● Shared Volumes - Volumes attached to the pod may be mounted inside of one or more containers.

● Shared Resources - Resource limits such as CPU and RAM are shared between all containers in the pod.

7

Pod

Page 8: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Sample pod manifest file in yaml

8

apiVersion: v1kind: Podmetadata: name: example-app labels: app: example-app version: v1 role=backendspec: containers: - name: java image: companyname/java ports: - containerPort: 443 volumeMounts: - mountPath: /volumes/logs name: logs - name: logger image: companyname/logger:v1.2.3 ports: - containerPort: 9999 volumeMounts: - mountPath: /logs name: logs - name: monitoring image: companyname/monitoring:v4.5.6 ports: - containerPort: 1234

Pod

Page 9: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Service

Overview of a service?

A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture.

Services provide important features that are standardized across the cluster: load-balancing, service discovery between applications, and features to support zero-downtime application deployments.

9

Service

Page 10: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

IP Address and Routing

A core design feature of Kubernetes is a routable IP address for every service and pod in the cluster. Assigning IPs this way eliminates port conflicts between applications across the cluster.

This allows any application team to bind to any port they require instead of reconfiguring databases or web servers to listen on non-standard ports.

Each service has a unique IP address and a DNS hostname.

10

Service

Page 11: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Load Balancing

● Services are automatically configured to load balance traffic to pods matching the label query. Session affinity can be configured to send traffic to pods by client IP.

11

Service

Page 12: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Sample HTTPS service

12

Service

kind: ServiceapiVersion: v1metadata: name: Frontend Servicespec: selector: app: webapp role: frontend ports: - name: https protocol: TCP port: 443 targetPort: 443

Page 13: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Replication Controller

Overview of ReplicationController

A replication controller is one of the features of Kubernetes that you'll interact with on a regular basis to launch one or more instances of your applications

Each replication controller has a desired state that is managed by the application deployer.

13

Replication Controller

Page 14: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

ReplicationController template

In Kubernetes, the base unit of deployment is a pod (intro to pods), which is a group of containers that work together and therefore are logically grouped. The replication controller stores a pod template in order to create new pods if needed.

14

Replication Controller

Page 15: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Sample ReplicationControllerapiVersion: v1kind: ReplicationControllermetadata: name: nginx-controllerspec: replicas: 2 selector: role: load-balancer template: metadata: labels: role: load-balancer spec: containers: - name: nginx image: coreos/nginx ports: - containerPort: 80

15

Replication Controller

Page 16: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Sample kubectl commands

● kubectl cluster-info● kubectl get namespaces, pods, services● kubectl create -f ./sample-rc.yaml● kubectl describe pod podname● kubectl logs podname

16

Page 17: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

Sample lab: Launching cluster in AWS and deploy sample service

17

Page 18: Kubernetes - fikt.uklo.edu.mk · A service is a grouping of pods that are running on the cluster. Kubernetes services can efficiently power a microservice architecture. Services provide

THANK YOU

Hangouts: [email protected]: @ibedelovski

GitHub: ilchebedelovski

Ilche Bedelovski