Building a Kubernetes Cluster with Ansible. Patrick Galbraith, ATG Cloud Computing Expo, NYC, May 2016



Similar documents
Docker : devops, shared registries, HPC and emerging use cases. François Moreews & Olivier Sallou

Platform as a Service and Container Clouds

Cisco Application-Centric Infrastructure (ACI) and Linux Containers

Kubernetes-Murano Integration in Mirantis OpenStack 7.0

Containerization and the PaaS Cloud

Do Containers fully 'contain' security issues? A closer look at Docker and Warden. By Farshad Abasi,

The Virtualization Practice

Linux A first-class citizen in Windows Azure. Bruno Terkaly bterkaly@microsoft.com Principal Software Engineer Mobile/Cloud/Startup/Enterprise

Jenkins Slave Cloud with Apache Mesos. Klaus Azesberger Reinhard Kiesswetter Infonova GmbH

RED HAT CONTAINER STRATEGY

Intro to Docker and Containers

Container Clusters on OpenStack

Use Cases for Docker in Enterprise Linux Environment CloudOpen North America, 2014 Linda Wang Sr. Software Engineering Manager Red Hat, Inc.

ISLET: Jon Schipp, Ohio Linux Fest An Attempt to Improve Linux-based Software Training

Private Cloud Management

ABRAHAM ARCHITECTURE OF A CLOUD SERVICE USING PYTHON TECHNOLOGIES

Cloud Security with Stackato

Stackato PaaS Architecture: How it works and why.

DevOps with Containers. for Microservices

An Analysis of Container-based Platforms for NFV

Linstantiation of applications. Docker accelerate

A lap around Team Foundation Server 2015 en Visual Studio 2015

Copyright. Robert Sandoval

Managing Kubernetes and OpenShift with ManageIQ. Alissa Bonas, Dublin 2015

Operating Systems Virtualization mechanisms

The Bro Network Security Monitor

Containerisation and the PaaS Cloud

STRATEGIC WHITE PAPER. The next step in server virtualization: How containers are changing the cloud and application landscape

Docker on OpenStack. August Author : Nitin Agarwal nitinagarwal3006@gmail.com. Supervisor(s) : Belmiro Moreira

Sacha Dubois RED HAT TRENDS AND TECHNOLOGY PATH TO AN OPEN HYBRID CLOUD AND DEVELOPER AGILITY. Solution Architect Infrastructure

Continuous Integration using Docker & Jenkins

Ansible in Depth WHITEPAPER. ansible.com

w w w. u l t i m u m t e c h n o l o g i e s. c o m Infrastructure-as-a-Service on the OpenStack platform

DevOps. Josh Preston Solutions Architect Stardate

OpenStack Introduction. November 4, 2015

Cloud Simulator for Scalability Testing

Best Practices for Python in the Cloud: Lessons

Ryu SDN Framework What weʼ ve learned Where weʼ ll go

The Software Container pattern

Building Docker Cloud Services with Virtuozzo

Devops n the Operating System! John Willis Director of Ecosystem Development! Docker, Inc.

A Complete Open Cloud Storage, Virt, IaaS, PaaS. Dave Neary Open Source and Standards, Red Hat

Deploying complex applications to Google Cloud. Olia Kerzhner

The Definitive Guide To Docker Containers

Distributed Scheduling with Apache Mesos in the Cloud. PhillyETE - April, 2015 Diptanu Gon

On- Prem MongoDB- as- a- Service Powered by the CumuLogic DBaaS Platform

HP OO 10.X - SiteScope Monitoring Templates

The State of Containers and the Docker Ecosystem: Anna Gerber

WHITEPAPER INTRODUCTION TO CONTAINER SECURITY. Introduction to Container Security

Building a Continuous Integration Pipeline with Docker

Timofey Turenko. Kirill Krinkin St-Petersburg Electrotechnical University

Why Does CA Platform Use OpenShift?

Platform Architecture & Integration with OpenShift

Utilizing Ansible to Manage a Highly Available MySQL Environment

How Bigtop Leveraged Docker for Build Automation and One-Click Hadoop Provisioning

Our Puppet Story. Martin Schütte. May

Managing your Red Hat Enterprise Linux guests with RHN Satellite

Sistemi Operativi e Reti. Cloud Computing

Type-C Ubuntu Product & Strategy Canonical Ltd.

KVM, OpenStack, and the Open Cloud

Why the Datacenter needs an Operating System. Dr. Bernd Mathiske Senior Software Architect Mesosphere

}w!"#$%&'()+,-./012345<ya

Example of Standard API

Savanna Hadoop on. OpenStack. Savanna Technical Lead

Cloud Computing. A new kind of developers? Presentation by. Nick Barcet nick.barcet@canonical.com

Cross-Platform ASP.NET 5 For the Cloud. Anthony Sneed

Docker on AWS. Running Containers in the Cloud. Brandon Chavis Solutions Architect Thomas Jones Solutions Architect. April 2015

Introduction to OpenStack

Solution for private cloud computing

Agenda. Begining Research Project. Our problems. λ The End is not near...

DevOps Patterns for Software Orchestration on Public and Private Clouds

Cloud Operating Systems for Servers

IaaS Cloud Architectures: Virtualized Data Centers to Federated Cloud Infrastructures

Solution for private cloud computing

The Future of Virtualization & SDDC. Anil Vasudeva President & Chief Analyst IMEX Research.com

IBM Bluemix, the digital innovation platform

Release Notes for Fuel and Fuel Web Version 3.0.1

Cloud.com CloudStack Community Edition 2.1 Beta Installation Guide

Open Source Cloud Computing Management with OpenNebula

The Cloud to the rescue!

Assignment # 1 (Cloud Computing Security)

OpenShift Dedicated 3.1 Architecture

Ansible. Configuration management tool and ad hoc solution. Marcel Nijenhof

Getting Started Using Project Photon on VMware Fusion/Workstation

Who s me? Zequi Vázquez DevOps & Backend PhD student Hacking & Security Rock n Roll (electric guitarist) Videogames Books

CI Pipeline with Docker

Cloudera Enterprise Reference Architecture for Google Cloud Platform Deployments

Cloud Computing #8 - Datacenter OS. Johan Eker

Cloud Storage in a PaaS World

W H I T E P A P E R. Best Practices for Building Virtual Appliances

Migration and Building of Data Centers in IBM SoftLayer with the RackWare Management Module

KVM, OpenStack, and the Open Cloud

virtualization.info Review Center SWsoft Virtuozzo (for Windows) //

Last time. Today. IaaS Providers. Amazon Web Services, overview

Data Centers and Cloud Computing

Whither Enterprise Cloud Platform Linux, Docker and more Loo Chia Zyn Head of Sales Consulting, Japan & Asia Pacific Oracle Linux & Oracle VM

Automating Big Data Benchmarking for Different Architectures with ALOJA

Docker for Sysadmins: what's in it for me?

Openshift for Continuous Integration

Getting Started with Google Cloud Platform

Transcription:

Building a Kubernetes Cluster with Ansible Patrick Galbraith, ATG Cloud Computing Expo, NYC, May 2016

HPE ATG HPE's (HP Enterprise) Advanced Technology Group for Open Source and Cloud embraces a vision that is two steps ahead of today's solutions. We use this vision to drive product adoption and incubate technologies to advance HPE. Through Open Source initiatives we foster collaboration across HPE and beyond. 2

About the speaker Patrick Galbraith HP Advanced Technology Group Has worked at Blue Gecko, MySQL AB, Classmates, Slashdot, Cobalt Group, US Navy, K-mart MySQL projects: memcached UDFs, DBD::mysql, federated storage engine Family Outdoors 3

Purpose of this talk why are you here? Docker Containers vs. Virtualization Simple Docker usage Clustered Docker Kubernetes Understand what Kubernetes is How to set up Kubernetes Ansible What is Ansible? How can Ansible build Kubernetes? 4

What are containers? Operating-system-level isolation Encapsulated, hermetically sealed applications Portable. And did I mention, portable?! Small footprint of container images Fast to launch! Use of host OS and Kernel Execution consists of time to startup application in question LXC, Docker, Solaris Zones, BSD Jails, Parallels Virtuozzo, OpenVZ, 5

VM vs. Containers VM Containers Mysql Bins/ Libs Gues t OS Mysql Bins/ Libs Gues t OS Hypervisor Host OS App Bins/ Libs Gues t OS M y s q l M y s q l M y s q l Bins/Libs A p p Host OS Server A p p Bins/Libs A p p D o c k e r Server

What is Docker? Set of tools for managing containers Command line tool that doubles as a daemon Kernel namespaces the core ingredient to containers working PID IPC uts (what will be seen by a group of processes) Mount Network User Cgroups (control groups) -- limit, account and isolate resource usage (CPU, memory, disk I/O, etc.) of process groups Originally used lxc, now defaults to Libcontainer but meant for any containerization mechanism Much more light weight than VMs Encapsulated application containers in a relatively isolated but lightweight operating environment Written in Go 7

Docker common terms and usage Dockerfile EXPOSE ports Entrypoints and CMD docker build docker push docker run docker inspect docker exec docker commit 8

Dockerfile https://github.com/capttofu/percona_xtradb_cluster_docker 9

Running a docker container $ docker run \ --name mybox \ -e MYSQL_ROOT_PASSWORD=secret \ -d \ mysql/mysql-server --log-bin --server-id=100$ $ cat minimal.cnf [mysqld] user=mysql log-bin=mysql-bin server-id=100 $ docker run \ --name mybox \ -e MYSQL_ROOT_PASSWORD=secret \ -d --hostname mybox \ -v $PWD/minimal.cnf:/etc/my.cnf mysql/mysql-server 10

Clustered Docker Kubernetes -- http://kubernetes.io CoreOS -- https://coreos.com/ Mesos + Marathon -- http://mesos.apache.org/ Apache project, Zookeeper, etc Project Atomic -- http://www.projectatomic.io/-- RH/Fedora/Centos designed for ru Docker Openstack -- https://wiki.openstack.org/wiki/docker Hypervisor Driver for O Swarm/Compose/Machine RancherOS http://rancher.com/rancher-os Minimalist Linux, Docker daemon runs Flocker -- https://clusterhq.com Spotify Helios -- https://github.com/spotify/helios -- Zookeeper Deis (http://deis.io) Maestro (https://github.com/toscanini/maestro) Shipyard (http://shipyard-project.com) others to come! 11

Kubernetes Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications Designed on the same principles that allows Google to run billions of containers a week Borg paper: https://research.google.com/pubs/pub43438.html Scale without increasing your ops team. Lean Portable will run cloud, bare metal, hybrid, etc Extensible using modular design allowing for plug-ability and hooks Automatic inpacking ensures container placement per resource requirements Self-healing auto-placement, auto-restart, auto-replication Batch execution can manage batch in CI workloads Google engineering bring good work to the Open-source world 12

Kubernetes concepts Pod Group of closely-related containers on the same host Service Virtual abstraction Basic load-balancer Single consistent access point to a pod Replication controller Defines pods to be horizontally scaled Uses a label query for identifying what containers to run Maintains specified number of replicas of a particular thing to run Dynamic resizing Label Key/value tag to mark work units a part of group Management and action targeting Definition file YAML/json describing a pod, service, or replication controller 13

Kubernetes pod 14

Kubernetes Master kube-apiserver API Server (RESTful) primary management for cluster reconciles etcd entries with deployed containers kube-controller-manager Controller Manager Server Handle replication processes defined by replication tasks Writes details to etcd Monitors changes and implements procedure to reflect the change kube-scheduler -- Scheduler Server Assigns workloads to specific minions in cluster taking into account service s operating requirements and infrastructure environment kube-register -- Register Server 15

Kubernetes minion kubelet Communicates with the master, relaying information to/from Reads and updates etcd Takes a set of PodSpecs and ensures that the containers described in those PodSpecs are running and healthy. Receives work in a manifest that defines the workload and operating parameters. Assumes responsibility for the state of work on minion kube-proxy Ensures network environment is accessible but isolated. Makes services available externally by forwarding requests to containers. Can perform rudimentary load balancing. 16

Kubernetes Basic Setup 17

Kubernetes diagram 18

Kubernetes usage Pod configuration file YAML or JSON Service configuration file Replication controller configuration file export KUBERNETES_API=http://kube-master:8080 kubectl create f mysql_master.json kubectl create f mysql_master_service.json 19

How can I run Kubernetes? https://github.com/capttofu/vagrant-kubernetes-cluster.git (this talk!) https://github.com/samsung-ag/kraken.git http://kubernetes.io/docs/hellonode/ https://github.com/pires/kubernetes-vagrant-coreos-cluster https://github.com/thenewnormal/kube-solo-osx 20

Other deployment Strategies for Kubernetes Helm -- http://helm.sh/ -- Package Manager for k8s Deis v2 Builds, deploys, 12-factor PaaS Kupak RedSpread KPM 21

More info, projects A curated list for awesome kubernetes sources -- https://github.com/ramitsurana/awesome-kubernetes 22

How do I build Kubernetes? Basic control plane Docker Flannel Set up containerized apt-repository Set up private docker registry Install master components: api server, controller manager, scheduler Start master components Install minion components: kubelet and kube-proxy Start up minion components 23

Ansible Automation Engine Application deployment, configuration management, provisioning, orchestration Agentless / SSH connections Push model programs (modules) pushed to nodes and executed over SSH Copies files to remote location being configured, executes, wipes Inventory described and managed in a text file Inventory can be static or dynamic Playbooks: the Ansible orchestration language YAML file, designed to be human readable 24

Ansible: Inventory file [southwest:children] arizona new-mexico [arizona] phoenix tuscon [new-mexico] albuquerque santa-fe List of hosts being managed Grouped into categories (master/minion, regions, type) Hierarchical 25

Ansible: Inventory file [kubernetes] [kubernetes:children] kubernetes-master kubernetes-minions [kubernetes-master] kubernetes-master-001 [kubernetes-minions] kubernetes-minion 000 kubernetes-minion-001 kubernetes-minion-002 26

Ansible: Playbook, example top level --- - hosts: "{{ target default( kubernetes') }} roles: - common - docker-registry - docker-private-registry - hosts: "{{ target default( kubernetes-master') }} roles: - kuberneter-master Language of Configuration, deployment and orchestration Describe configuration you want to enforce Contains "plays" (steps of process being executed) Map to specific groups of hosts Include roles (pre-packaged units of work) 27

Ansible: Playbook - name: Install the apt key for ubuntu apt_key: id=7f0ceb10 keyserver="keyserver.ubuntu.com" state=present - name: Install the repository for Ubuntu mongodb apt_repository: repo="deb http://repo.mongodb.org/apt/{{ ansible_os_family lower }} {{ debian_version.stdout }}/mongodb-org/3.0 main" state=present - name: pre-create ntp group, system group: name=ntp system=yes state=present - name: pre-create ntp user, system user: name=ntp group=ntp system=yes state=present - name: install NTP apt: name=ntp state=present update_cache=yes notify: restart ntp - name: install various packages apt: name={{ item }} state=present update_cache=yes with_items: common_packages when: ansible_os_family == "Debian" 28

Ansible modules Module library Usually Written in Python Use a common API for returning json to Ansible to indicate failure or success For just about everything you would need! Divided into core and extras 29

Using Ansible to build Kubernetes Roles: (https://github.com/kubernetes-cluster-automation) docker-apt-repository docker-registry docker-private-registry etcd flanneld kubernetes-master kubernetes-minion 30

Docker Registry setup Two containers Docker registry, uses volume for images Docker registry proxy (nginx) Linked to docker-registry container for certs and.htpasswd Generation and setup of self-signed SSL cert Generation and setup of htpassword Set up Docker on all hosts /etc/docker/certs.d for all hosts Set up of /root/.docker/config.json to automatically be logged in for all hosts 31

Etcd and flannel Install etcd and flannel apt packages Generate systemd unit files Configure etcd cluster Modify docker systemd unit file to use flannel Start up flannel and restart docker End of a run, flannel network is set up and containers on all machines can ping each other 32

Kubernetes kubernetes-master Install apt package Generate systemd unit files Start api server, controller manager, and scheduler kubernetes-minion Install apt package Generate systemd unit files Start kubelete and kube-proxy Load SkyDNS pod and service files 33

Ansible set up of Kubernetes Ansible host docker-apt-repo docker-registry* etcd flanneld kubernetes-master kubernetes-minion r e g i s t r y master etcd controller scheduler api server a p t r e p o Flannel network minion minion minion etcd etcd etcd kubelet kubelet kubelet kube-proxy kube-proxy kube-proxy 34

Using Kubernetes https://github.com/kubernetes/kubernetes/tree/master/examples/mysql-galera 35

Galera replication on Kubernetes https://github.com/kubernetes/kubernetes/tree/master/examples/mysql-galera 36

Galera on Kubernetes 37

Galera on Kubernetes Process pxc_node1 od and service file pxc_node2 po and service file pxc_node3 pod and service file kubectl Api server pxc_cluster Service file pxc_node1 pod pxc_node2 pod pxc_node3 pod pxc container pxc container pxc container minion minion minion pxc_node1 service pxc_node2 service pxc_cluster service pxc_node3 service 38

Thank you! Questions? 39

Demo https://www.youtube.com/watch?v=vyxwlyjmkha 40