Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanj/7a7189c5e329071fc2f798b5ab78875b to your computer and use it in GitHub Desktop.
Save ryanj/7a7189c5e329071fc2f798b5ab78875b to your computer and use it in GitHub Desktop.
"Kubernetes Extensibility with the Operator Pattern" at OSCON's Open Container Day 2017/05/09 http://bit.ly/oscon-operators
<section>
<section data-markdown>
# Extensible Kubernetes
with the
# Operator Pattern
at
## OSCON's Open Container Day
[May 9th, 2017](https://conferences.oreilly.com/oscon/oscon-tx/public/schedule/full/open-container-day)
[bit.ly/oscon-operators](http://bit.ly/oscon-operators)
</section>
<section data-state='blackout' data-background-color="#000000" id='by-ryanj'>
<p>presented by <a href="http://twitter.com/ryanj/">@ryanj</a>, Developer Advocate at CoreOS</p>
<p><a href="http://twitter.com/ryanj/"><img alt="ryanj" src="http://ryanjarvinen.com/images/ryanj-mestrefungo-com.gif" style="width:50%"/></p>
</section>
<section id='coreos' data-markdown>
![CoreOS Logo](http://i.imgur.com/DRm4KEq.png "")
Helping *Secure the Internet* by keeping your Container Linux hosts secure, up-to-date, and ready for the challenges of a modern world
</section>
</section>
<section>
<!--
<section id='introduction' data-markdown>
## 1. Introduction
</section>
<section id='survey'>
<h3>Intro Survey / Who are you?</h3>
<ol>
<li class='fragment'>do you have any experience using containers?</li>
<li class='fragment'>have you ever used Container Linux?</li>
<li class='fragment'>do you consider yourself to be proficient with kubernetes and the <code>kubectl</code> cli tool?</li>
<li class='fragment'>can you confidently define the term "K8s operator"?</li>
<li class='fragment'>do you have any hands-on experience using operators?</li>
<li class='fragment'>do you know what it takes to build an operator?</li>
<li class='fragment'>have you ever written a kubernetes operator?</li>
</ol>
</section>
-->
<section id='overview'>
<h2>Overview</h2>
<ol>
<li class='fragment'><a href="#/introduction">Introduction</a>
<!--
<ul>
<li><a href="#/workshop-setup">Workshop Setup</a></li>
</ul>
-->
<ul>
<li><a href="#/why-k8s">Why Kubernetes?</a></li>
<li><a href="#/what-is-an-SRE">What is an SRE?</a></li>
</ul>
</li>
<li class='fragment'><a href="#/k8s-operators">Kubernetes Operators</a>
<ul>
<li><a href="#/what-are-operators">What are operators made of?</a></li>
<li><a href="#/operator-examples">Operator Examples</a></li>
</ul>
</li>
<li class='fragment'><a href="#/operator-challenges">Operator Challenges</a>
<ul>
<li><a href="#/basic-challenge">Basic Challenge: deploy and use an operator</a></li>
<li><a href="#/advanced-challenge">Advanced Challenge: learn to write your own</a></li>
</ul>
</li>
</ol>
</section>
</section>
<!--
<section>
<section id='workshop-setup' data-markdown>
## Workshop Setup
bring a laptop with the following:
1. [kubectl](#/kubectl)
2. [minikube](#/minikube)
3. additional tooling for advanced users (optional)
</section>
<section id='kubectl'>
<h3>install kubectl</h3>
<p>linux amd64:</p>
<pre><code contenteditable>curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
</code></pre>
<p>osx amd64:</p>
<pre><code contenteditable>curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
</code></pre>
<p>To verify <code>kubectl</code> availability:</p>
<pre><code contenteditable>kubectl version</code></pre>
<p><a href="https://kubernetes.io/docs/tasks/kubectl/install/">official <code>kubectl</code> setup notes</a></p>
</section>
<section id='minikube'>
<h3>install minikube</h3>
<p>linux amd64:</p>
<pre><code contenteditable>curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.18.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/</code></pre>
<p>osx amd64:</p>
<pre><code contenteditable>curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.18.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
</code></pre>
<p>to verify <code>minikube</code> availability:</p>
<pre><code contenteditable>minikube start</code></pre>
<p><a href="https://github.com/kubernetes/minikube/releases">official <code>minikube</code> setup notes</a></p>
</section>
<section id='minikube-virt'>
<h4>minikube troubleshooting</h4>
<p>If your minikube environment does not boot correctly:</p>
<ol>
<li>Minikube requires an OS virtualization back-end</li>
<li>Most OSes include some support for virtualization</li>
<li>You can use the <a href="https://github.com/kubernetes/minikube#quickstart"><code>--vm-driver</code></a> flag to select a specific virt provider</li>
</ol>
<pre><code contenteditable>minikube start --vm-driver=virtualbox</code></pre>
<p>Check the project <a href="https://github.com/kubernetes/minikube#requirements"><code>README</code></a> for more information about <a href="https://github.com/kubernetes/minikube#requirements">supported virtualization options</a></p>
</section>
<section id='minikube-rkt'>
<h5><b>ADVANCED CHALLENGE OPTION</b></h5>
<h3>rkt-powered minikube (optional)</h3>
<p>To start <code>minikube</code> with <code>rkt</code> enabled, try:</p>
<pre><code contenteditable>minikube start --network-plugin=cni --container-runtime=rkt</code></pre>
<p>to verify:</p>
<pre><code contenteditable>minikube ssh
docker ps # expect no containers here
rkt list # list running containers</code></pre>
</section>
<section id='docker'>
<h5><b>ADVANCED CHALLENGE OPTION</b></h5>
<h3>install docker (optional)</h3>
<p>Download and install binary from <a href="https://store.docker.com/search?offering=community&type=edition">"the docker store"</a></p>
<p>Or, use a package manager to install:</p>
<pre><code contenteditable>brew install docker</code></pre>
<p>To verify <code>docker</code> availability:</p>
<pre><code contenteditable>docker version</code></pre>
<p>To <a href="https://github.com/kubernetes/minikube#reusing-the-docker-daemon">reference minikube's docker daemon from your host</a>, run:</p>
<pre><code contenteditable>eval $(minikube docker-env)</code></pre>
</section>
<section id='go'>
<h5><b>ADVANCED CHALLENGE OPTION</b></h5>
<h3>install go (optional)</h3>
<p>Download and install binary from <a href="https://golang.org/doc/install">golang.org</a></p>
<p>Or, use a package manager to install:</p>
<pre><code contenteditable>brew install go
export GOPATH=$HOME/src/go
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin</code></pre>
<p>To verify <code>go</code> availability:</p>
<pre><code contenteditable>go version</code></pre>
</section>
<section id='ready' data-markdown>
# *Ready?*
</section>
</section>
-->
<section>
<section id='why-k8s'>
<h3>Why Kubernetes?</h3>
<p><img src="https://pbs.twimg.com/profile_images/511909265720614913/21_d3cvM.png" alt="kubernetes" style='width:30%;'></p>
</section>
<section id='k8s-is'>
<h3>Kubernetes is...</h3>
<ol>
<li class='fragment'>The best way to manage distributed solutions at scale, based on years of industry expertise (Google-scale experience)</li>
<li class='fragment'>An extensible modeling language with a huge community following</li>
</ol>
</section>
<section id="what-is-an-SRE">
<h3>What is an SRE?</h3>
<p><a href="https://landing.google.com/sre/book.html"><img src="https://landing.google.com/sre/images/book-2x.png" alt="Site Reliability Engineering" style="width: 25%;"></a></p>
<p><i>"how Google runs production systems"</i></p>
<ol>
<li><a href="https://landing.google.com/sre/book.html">Google's SRE book - free to read online</a></li>
<li><a href="https://medium.com/@jerub/googles-approach-4bcdc0533c0a">SRE blog post series on Medium</a></li>
</ol>
</section>
</section>
<section>
<section id='k8s-operators' data-markdown>
## Kubernetes Operators
</section>
<section id='what-are-operators'>
<h3>What are Operators?</h3>
<p class='fragment'>Kube Operators establish a pattern for introducing higher-order interfaces that represent the logical domain expertise (and perhaps the ideal product output) of a Kubernetes SRE</p>
<p class='fragment'><a href="https://coreos.com/blog/introducing-operators.html">blog post: "Introducing Operators"</a></p>
</section>
<section id='k8s-extensibility' data-markdown>
### Extensible Kubernetes
1. k8s is a modeling language for architecting distrubuted solutions
2. It includes an extensible collection of primitives to build with
3. all platform state is stored in etcd
</section>
<section id='k8s-primitives' data-markdown>
### 5 Basic K8s Object Primitives
* nodes
* pods
* deployments
* replicaSets
* services
aka [resource types](https://kubernetes.io/docs/user-guide/kubectl-cheatsheet/#resource-types), aka [objects](https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/)
</section>
<section id='k8s-controllers' data-markdown>
### K8s Controllers
Controllers work to regulate the declarative nature of the platform state, reconsiling imbalances via a basic control loop
https://kubernetes.io/docs/admin/kube-controller-manager/
Kubernetes allows you to introduce your own custom controllers!
demo: show creation of a deployment, resizing, auto-recovery
</section>
<section id='k8s-tpr' data-markdown>
### Third Party Resources (TPRs)
TPRs allow you to establish new k8s primitives, extending the capabilities of the platform by allowing you to add your own terminology to the modeling language
https://kubernetes.io/docs/user-guide/thirdpartyresources/
</section>
<section id='best-practices' data-markdown>
### Best Practices for Writing Operators
https://coreos.com/blog/introducing-operators.html#how-can-you-create-an-operator
</section>
</section>
<section>
<section id='operator-examples' data-markdown>
## Operator Examples
</section>
<section id='etcd' data-markdown>
### Etcd
blog post: https://coreos.com/blog/introducing-the-etcd-operator.html
sources: https://github.com/coreos/etcd-operator
demo video: https://www.youtube.com/watch?v=n4GYyo1V3wY
</section>
<section id='prometheus' data-markdown>
### Prometheus
blog post: https://coreos.com/blog/the-prometheus-operator.html
sources: https://github.com/coreos/prometheus-operator
demo video: https://www.youtube.com/watch?v=GYSKEd9FePk
</section>
<section id='kube-cert-manager' data-markdown>
### Kube Cert Manager
https://github.com/kelseyhightower/kube-cert-manager
</section>
<section id='rook' data-markdown>
### Rook (Storage)
https://rook.io/
</section>
<section id='elasticsearch' data-markdown>
### Elastic Search
https://github.com/upmc-enterprises/elasticsearch-operator
</section>
<section id='postgres' data-markdown>
### PostgreSQL
Postgres Operator from CrunchyData
https://github.com/CrunchyData/postgres-operator
</section>
<section id='tectonic' data-markdown>
### Tectonic
Tectonic uses operators to manage "self-hosted" Kubernetes
[k8s cluster upgrades made easy](https://twitter.com/ryanj/status/846866079792062464)
</section>
<!--
<section id='' data-markdown>
###
</section>
<section id='' data-markdown>
###
</section>
-->
</section>
<section>
<section id='operator-challenges' data-markdown>
## Operator Challenges
</section>
<section id='basic-challenge' data-markdown>
### Basic Challenge
1. Try the etcd operator
2. Identify new primitives and interfaces
3. Create a new etcd cluster
4. Test autorecovery, leader election
5. Clean up
</section>
<section id='try'>
<h3>Use an Operator</h3>
<p>Try installing <a href="https://github.com/coreos/etcd-operator">the etcd operator</a></p>
<pre class='fragment'><code contenteditable>kubectl create -f https://raw.githubusercontent.com/coreos/etcd-operator/master/example/deployment.yaml</code></pre>
</section>
<section id='observe'>
<h3>Observations?</h3>
<p>List TPRs to see if any new primitives have become available<p>
<pre class='fragment'><code contenteditable>kubectl get thirdpartyresources</code></pre>
</section>
<section id='create-new'>
<h3>Run etcd</h3>
<p>Use the new TPR endpoint to create an etcd cluster</p>
<pre class='fragment'><code contenteditable>kubectl create -f https://raw.githubusercontent.com/coreos/etcd-operator/master/example/example-etcd-cluster.yaml</code></pre>
</section>
<section id='test'>
<h3>Test Autorecovery, Leader Election</h3>
<ol>
<li>use kubectl to delete etcd members (pods)<br/>
<pre class='fragment'><code contenteditable>kubectl get pods</code></pre>
<pre class='fragment'><code contenteditable>kubectl delete pod pod-id-1 pod-id-2</code></pre>
</li>
<li>list pods to see if the cluster was able to recover automatically<br/>
<pre class='fragment'><code contenteditable>kubectl get pods</code></pre>
</li>
<li class='fragment'><a href="">experiment with other SRE-focused features provided by this operator</a></li>
</ol>
</section>
<section id='clean-up'>
<h3>Clean Up</h3>
<p>Clean up your work, remove the DB cluster and the new API primitives (TPR endpoints)</p>
<pre class='fragment'><code contenteditable>kubectl delete -f https://raw.githubusercontent.com/coreos/etcd-operator/master/example/deployment.yaml</code></pre>
<pre class='fragment'><code contenteditable>kubectl delete endpoints etcd-operator</code></pre>
</section>
</section>
<section>
<section id='advanced-challenge' data-markdown>
### Advanced Challenge
1. Check out and run [Eric's custom rollback-controller code](https://github.com/coreos/rollback-controller#example)
2. [Make a small change and test your work](https://github.com/coreos/rollback-controller#exercises)
3. Consider how a TPR might be used to expose similar functionality, extending the basic collection of primitives
4. Share your results with the CoreOS Community (email us at community at coreos.com)
</section>
</section>
<section>
<section id='follow-up' data-markdown>
### follow-up topics and links
1. [BrandonPhilips' TPR list](https://gist.github.com/philips/a97a143546c87b86b870a82a753db14c)
2. [Eric's "custom go controllers" presentation](https://github.com/ericchiang/go-1.8-release-party)
3. [Eric's rollback controller example](https://github.com/ericchiang/kube-rollback-controller)
4. [Josh's Operator talk from FOSDEM (same stuff at Kubecon)](https://docs.google.com/presentation/d/1MV029sDifRV2c33JW_83k1tjWDczCfVkFpKvIWuxT6E/edit#slide=id.g1c65fcd8a9_0_54 )
5. [Video of Josh's talk from FOSDEM](https://fosdem.org/2017/schedule/event/kubeoperators/)
6. [Paul's new blog post on community use of operators](https://coreos.com/blog/kubernetes-operators-ecosystem.html)
7. [etcd scaling demo from Brandon](https://www.youtube.com/watch?v=Ive1DbIyYZk)
8. [etcd autorecovery demo from Brandon](https://www.youtube.com/watch?v=9sD3mYCPSjc)
9. [Sign up for the CoreOS Community Newsletter](http://coreos.com/newsletter)
</section>
<!--
<section id='exit-interview'>
<h3>Exit Interview</h3>
<ol>
<li class='fragment'>are you confident in your explanation of what a kubernetes operator is?</li>
<li class='fragment'>did this workshop provide enough hands-on experience using kube operators?</li>
<li class='fragment'>do feel like you know what it takes to build an operator, and where to look for follow-up info?</li>
<li class='fragment'>do you feel sufficiently prepared to write your own operator?</li>
<li class='fragment'>are you ready to sign up to demo your new operator at next month's event?</li>
</ol>
</section>
<section id='coreos-training' data-markdown>
### CoreOS Training
Want to learn more?
Check out the lineup of pro training courses from CoreOS!
[coreos.com/training](http://coreos.com/training)
</section>
<section id='coreos-fest' data-markdown>
### CoreOS Fest
Tickets are on sale now!
[coreos.com/fest](http://coreos.com/fest)
</section>
<section id='tectonic-free-teir' data-markdown>
### Tectonic Free Tier
Try CoreOS Tectonic today
[coreos.com/tectonic](http://coreos.com/tectonic)
Your first ten Enterprise-grade Kubernetes nodes are free!
</section>
<section id='coreos-jobs' data-markdown>
### CoreOS is hiring!
Join us in our mission to help *Secure the Internet!*
[coreos.com/careers](https://coreos.com/careers)
</section>
-->
</section>
<section>
<section id='thank-you'>
<h1>Thank You!</h1>
<p>from</p>
<h1>OSCON</h1>
<br/>
<a href="http://bit.ly/oscon-operators"><h5 class='fragment grow'>bit.ly/oscon-operators</h5></a>
</section>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment