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

Post on 19-Jul-2020

7 views 0 download

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

Kubernetes

KSpresso 18/11/2016

Ilche Bedelovski, DevOps Engineer in Keitaro

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

What is a container?

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

3

What is a cluster?

4

Kubernetes Architecture

5

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

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

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

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

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

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

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

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

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

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

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

Sample lab: Launching cluster in AWS and deploy sample service

17

THANK YOU

Hangouts: ilche.bedelovski@gmail.comTwitter: @ibedelovski

GitHub: ilchebedelovski

Ilche Bedelovski