kubefuse - a file-system for kubernetes

33
Bart Spaans @Work_of_Bart OpenCredo

Upload: bart-spaans

Post on 26-Jan-2017

412 views

Category:

Software


0 download

TRANSCRIPT

Bart Spaans@Work_of_Bart

OpenCredo

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Hello!

Lead consultant at OpenCredo

Doing infrastructure, automation, CI/CD, DevOps, ...

Semi-specialised in container based infrastructures

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

OpenCredo

High-end consultancy in London

Delivery of highly scalable systems

Early adopters of CloudFoundry, Docker, Mesos, Kubernetes, …

And also CQRS, Big Data, micro-services architectures, CI/CD, ...

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

The past year

● Kubernetes!● Kubernetes!● Kubernetes!● Kubernetes!● Kubernetes!

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

The next year (probably)

● Kubernetes!● Kubernetes!● Kubernetes!● Kubernetes!● Kubernetes!

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

What is Kubernetes anyway?

● A cluster manager inspired by Google’s Borg

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

What is a Cluster Manager anyway?

● A resource (CPU, Memory, Disk) aware scheduler● Control loops

For example:

deploy an application and give it two cores and four Gb of RAM, and make sure there are always ten copies running

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Why use one?

● Improved resource utilisation

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Why use one?

● Improved resource utilisation● Fault-tolerant

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Why use one?

● Improved resource utilisation● Fault tolerant● Homogenous

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Why use one?

● Improved resource utilisation● Fault tolerant● Homogenous● Enables automation

API

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Kubernetes

Master

Node Node Node

Master

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Key features

● Pods and services abstraction● Flat network● Load balancing and service discovery● Cloud integration● Industry backing

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Pods

● One abstraction above containers● We can group multiple containers together● They share the same IP and volumes● Like a pseudo virtual machine

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Replication Controllers

● Replicate pods ● Control loop ● Restart stopped pods

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Services

● Load balancer for pods● Service discovery for pods● Exposing pods outside the cluster

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Namespaces

● Logically group our resources in namespaces● To separate different teams, environments, organisations, …

● Nice, but slightly awkward tooling

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Kubectl

● We usually interact with Kubernetes using kubectl● A command line tool that consumes the REST API

For example:

kubectl get pods --namespace=dev

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

KubeFuse

● A file-system view of Kubernetes resources● Read/write pods, replication controllers, services, secrets, volumes, etc.

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Why?

● Less typing (+ tab completion)● Context in paths● Enables standard Linux tools (ls, cat, less, vim, find, ….)● Easy backups/exports● Continuous Deployment???

https://github.com/opencredo/kubefuse/

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Context in path

KubeFuse

cd ~/kubernetes/dev/pods

ls

cd my-pod

cat describe

Kubectl

kubectl get pods --namespace=dev

kubectl describe pod my-pod --

namespace=dev

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

The KubeFuse Model

A KubeFuse path can be broken down like this:

/namespace/resource_type/object_id/action

Examples:

/default/svc/nginx/json

/default/volumes/data/describe

/dev/pod/my-cheeky-app-buu43/logs

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Use case - Exploration

For example:

Listing pods, rcs, services, …

ls ~/kubernetes/default/pods

Listing all objects in the default namespace:

find ~/kubernetes/default -type d -mindepth 2

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Use case - Troubleshooting

For example:

Get logs from a graphite pod:

cat ~/kubernetes/default/pod/graphite-i3bb2/logs

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Use case - Quick tweaks

For example:

Update the number of DNS replicas:

vim ~/kubernetes/kube-system/rc/kube-dns-v11/yaml

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Use case - Backup

For example:

Export all services as YAML:

find ~/kubernetes/default/svc -name yaml | \

while read line ; do cat $line ; echo "----\n" ; done

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Use case - Continuous Delivery-ish

Coming soon!

Copy from one KubeFuse mount to the next:

cp ~/kubernetes-dev/default/pods/my-pod/json \

~/kubernetes-stage/default/pods/my-pod/json

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Use case - Griefing

Coming soon!

Recursively delete everything in your cluster!

rm -rf ~/kubernetes/default/

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

How does it work?

● KubeFuse is written in Python● Relies heavily on FUSE and kubectl ● FUSE gives us a way to implement a file system in user space● Kubectl gives us a the Kubernetes resources● KubeFuse translates between the two

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

How does it work?

Caching, dealing with concurrency, permissions, modification dates, ...

More implementation details on our website: https://opencredo.com/introducing-kubefuse-file-system-kubernetes/

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Testing

Using Myna to simulate kubectl in tests with fast feedback.

Heavily inspired by SpectoLabs’ Hoverfly, which simulates HTTP

Donated to SpectoLabs

https://github.com/SpectoLabs/myna

https://github.com/SpectoLabs/hoverfly

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Demo

Give me strength.

https://github.com/opencredo/kubefuse/

Bart Spaans@Work_of_Bart

https://github.com/opencredo/kubefuse/

Thanks!

Questions?

Suggestions?

Feature requests?

Version 0.6 out next week!