Smaine Kahlouch
DevOps @Morea
Project motivations
What is kubernetes ?
Architecture
Work units
Networking
Deploying a cluster
Installing new services
Heroku is the current hosting platform
Better cost-control
Internalize operations for a better service delivery
Performances fine-tunning
I'll assume you already know the basics of Docker and Ansible
I'll try to Focus on Ansible but ...
Current version v1.2
Docker : A Container system which runs on a dedicated network
Kubelet : Is responsible for the communication with the master server
A colocated group of containers (one-to-many) with shared resources. e.g. network, volumes.
It can be viewed as a "logical host".
An interface to a group of containers, which acts as load-balancer and provides an abstraction layer - no need to worry about containers location.
Declarative way to describe the desired state of the application (pods, replica sets).
Volumes used to store the config files to be used within the pods.
A custom volumes to store passwords, keys etc.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx
labels:
k8s-app: nginx
kubernetes.io/cluster-service: "true"
spec:
replicas: 3
selector:
matchLabels:
k8s-app: nginx
template:
metadata:
labels:
k8s-app: nginx
kubernetes.io/cluster-service: "true"
spec:
containers:
- name: nginx
image: nginx
resources:
limits:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 80
kubectl create -f nginx-rc.yaml
Calico is a layer 3 approach to virtual networking.
• The config is saved into an etcd storage
• The routes are distrubuted using BGP
• Distributed ACL's policy
• allows communication between pods/services
• common ip troubleshooting tools (ping, traceroute, netcat ...)
The Github organization has two main projects :
Currently supported OS : Debian, Ubuntu, CentOS/RHEL, CoreOS
Download and install binaries
Configure every components (Docker, etcd, dnsmasq...)
Choose the network plugin:
Flannel, Calico or Weave
---
- hosts: k8s-cluster
roles:
- { role: adduser, tags: adduser }
- { role: download, tags: download }
- { role: kubernetes/preinstall, tags: preinstall }
- { role: etcd, tags: etcd }
- { role: docker, tags: docker, when: ansible_os_family != "CoreOS" }
- { role: kubernetes/node, tags: node }
- { role: network_plugin, tags: network }
- hosts: kube-master
roles:
- { role: kubernetes/master, tags: master }
- hosts: k8s-cluster
roles:
- { role: dnsmasq, tags: dnsmasq }
ansible-playbook -i inventory/inventory.cfg -u root cluster.yml
node1 ansible_ssh_host=95.54.0.12 # ip=10.3.0.1
node2 ansible_ssh_host=95.54.0.13 # ip=10.3.0.2
node3 ansible_ssh_host=95.54.0.14 # ip=10.3.0.3
node4 ansible_ssh_host=95.54.0.15 # ip=10.3.0.4
node5 ansible_ssh_host=95.54.0.16 # ip=10.3.0.5
node6 ansible_ssh_host=95.54.0.17 # ip=10.3.0.6
[kube-master]
node1
node2
[etcd]
node1
node2
node3
[kube-node]
node2
node3
node4
node5
node6
[k8s-cluster:children]
kube-node
kube-master
bin_dir: /usr/local/bin
local_release_dir: "/tmp/releases"
kube_cert_group: kube-cert
kube_log_level: 2
kube_users:
kube:
pass: changeme
role: admin
cluster_name: cluster.local
kube_network_plugin: calico
kube_service_addresses: 10.233.0.0/18
kube_pods_subnet: 10.233.64.0/18
kube_network_node_prefix: 24
peer_with_router: false
kube_apiserver_ip: "{{ kube_service_addresses|ipaddr('net')|ipaddr(1)|ipaddr('address') }}"
kube_apiserver_port: 443 # (https)
kube_apiserver_insecure_port: 8080 # (http)
upstream_dns_servers:
- 8.8.8.8
- 4.4.8.8
dns_setup: true
dns_domain: "{{ cluster_name }}"
dns_server: "{{ kube_service_addresses|ipaddr('net')|ipaddr(2)|ipaddr('address') }}"
Outdated, to be done with
https://github.com/kubespray/kpm
Kubernetes documentation :
http://kubernetes.io/v1.1/index.html
kubespray repositories :
kubespray tests :
ProjectCalico website :
By Smaine Kahlouch
Install a kubernetes cluster and deploy new applications.