Kubernetes provides rock-solid APIs for building and running your distributed systems. Pods, Services and ReplicationControllers provide trustworthy and scalable abstractions that make solving real-world infrastructure problems simpler. But that doesn’t mean interacting with those low-level primitives will be the only option for developers and operators.
Sched Link: http://sched.co/67dA
21. $ kubectl controls the Kubernetes cluster manager.
Find more information at https://github.com/kubernetes/kubernetes.
Usage:
kubectl [flags]
kubectl [command]
Available Commands:
get Display one or many resources
describe Show details of a specific resource or group of
resources
create Create a resource by filename or stdin
replace Replace a resource by filename or stdin.
patch Update field(s) of a resource by stdin.
delete Delete resources by filenames, stdin, resources and
names, or by resources and label selector.
edit Edit a resource on the server
A universal interface for actions on a Kubernetes cluster
Gareth Rushgrove
24. template:
metadata:
labels:
app: guestbook
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v4
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
# If your cluster config does not include a dns service,
then to
A data format describing desired state
Gareth Rushgrove
28. Code plus data has
advantages over data alone
Gareth Rushgrove
29. The language to represent the data should
be a simple, data-only format such as JSON
or YAML, and programmatic modification of
this data should be done in a real
programming language
Gareth Rushgrove
Borg, Omega, and Kubernetes, ACM Queue,Volume 14, issue 1 http://queue.acm.org/detail.cfm?id=2898444
“
31. So why are so many people
hand writing YAML?
Gareth Rushgrove
32. Changes with kubectle patch diverge from the model
$ kubectl patch --help
Update field(s) of a resource using strategic merge patch
JSON and YAML formats are accepted.
Usage:
kubectl patch (-f FILENAME | TYPE NAME) -p PATCH [flags]
Examples:
# Partially update a node using strategic merge patch
kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'
Gareth Rushgrove
33. $ kubectl apply --help
Apply a configuration to a resource by filename or stdin.
JSON and YAML formats are accepted.
Usage:
kubectl apply -f FILENAME [flags]
Examples:
# Apply the configuration in pod.json to a pod.
$ kubectl apply -f ./pod.json
And kubectl apply requires the full object serialisation
Gareth Rushgrove
38. kubectl get pod mypod -o yaml
| sed 's/(image: myimage):.*$/1:v4/'
| kubectl replace -f -
This is from the official kubectl help. It pipes to sed.
Gareth Rushgrove
43. $ puppet apply examples/init.pp --test
Info: Loading facts
Notice: Compiled catalog for gareths in environment production in
1.24 seconds
Info: Applying configuration version '1453298602'
Info: Checking if sample-pod exists
Info: Creating kubernetes_pod sample-pod
Notice: /Stage[main]/Main/Kubernetes_pod[sample-pod]/ensure:
created
Notice: Applied catalog in 0.23 seconds
Running without that Pod already existing will create it
Gareth Rushgrove
44. Running a second time, nothing changes because
the Pod already existsGareth Rushgrove
$ puppet apply examples/init.pp --test
Info: Loading facts
Notice: Compiled catalog for garethr in environment production in
1.33 seconds
Info: Applying configuration version '1453298688'
Info: Checking if sample-pod exists
Notice: Applied catalog in 0.15 seconds
52. Gareth Rushgrove
Deis is an open source PaaS that provides a Heroku-
inspired workflow, using Kubernetes under the hoodGareth Rushgrove
53. Interactive CLI to login
Gareth Rushgrove
$ deis login http://deis.example.com
username: deis
password:
Logged in as deis
54. Create configs locally with the CLI
Gareth Rushgrove
$ deis create
Creating application... done, created boring-huntress
Git remote deis added
55. $ git push deis master
Counting objects: 95, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (52/52), done.
Writing objects: 100% (95/95), 20.24 KiB | 0 bytes/s, done.
Total 95 (delta 41), reused 85 (delta 37)
-----> Ruby app detected
-----> Compiling Ruby/Rack
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using 1.5.2
Running: bundle install --without development:test --path
vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from http://rubygems.org/..........
Fetching additional metadata from http://rubygems.org/..
Using bundler (1.5.2)
Installing tilt (1.3.6)
Installing rack (1.5.2)
The switch to Git for deployment
Gareth Rushgrove
56. Set config using CLI
Gareth Rushgrove
$ deis config:set FOO=1 BAR=baz && deis config:pull
$ cat .env
FOO=1
BAR=baz
$ echo "TIDE=high" >> .env
$ deis config:push
Creating config... done, v4
=== yuppie-earthman
DEIS_APP: yuppie-earthman
FOO: 1
BAR: baz
TIDE: high
57. $ deis scale web=8
Scaling processes... but first, coffee!
done in 20s
=== boring-huntress Processes
--- web:
web.1 up (v2)
web.2 up (v2)
web.3 up (v2)
web.4 up (v2)
web.5 up (v2)
web.6 up (v2)
web.7 up (v2)
web.8 up (v2)
Scale using the CLI
Gareth Rushgrove
70. name: jenkins
home: https://jenkins-ci.org/
version: 0.2.0
description: The leading open-source continuous integration
server.
maintainers:
- Matt Fisher <mfisher@deis.com>
details:
Jenkins is the leading open-source continuous integration
server.
Chart.yaml metadata format
Gareth Rushgrove
77. "type": "integer",
"format": "int32",
"description": "The port on each node on which this service
is exposed when type=NodePort or LoadBalancer. Usually assigned
by the system. If specified, it will be allocated to the service
if unused or else creation of the service will fail. Default is
to auto-allocate a port if the ServiceType of this Service
requires one. More info: http://releases.k8s.io/HEAD/docs/user-
guide/services.md#type--nodeport"
}
}
},
"v1.ServiceStatus": {
"id": "v1.ServiceStatus",
"description": "ServiceStatus represents the current status
of a service.",
"properties": {
"loadBalancer": {
"$ref": "v1.LoadBalancerStatus",
"description": "LoadBalancer contains the current status of
the load-balancer, if one is present."
The Kubernetes API spec is ~14,000 lines of JSON
Gareth Rushgrove