Skip to content

Instantly share code, notes, and snippets.

@ryanj
Last active August 3, 2016 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanj/4ca683dff6cdb9601c495e27d4bb5289 to your computer and use it in GitHub Desktop.
Save ryanj/4ca683dff6cdb9601c495e27d4bb5289 to your computer and use it in GitHub Desktop.
Defining "Applications" for Kubernetes (and OpenShift) / Kubetnetes SIG-Apps August 3rd 2016 - http://bit.ly/sig-apps-openshift
<section data-transition="linear">
<section id='Defining_Applications'>
<h3>Defining:</h3>
<h1>Applications</h1>
<h3>for</h3>
<h1>K8s and OpenShift</h1>
<h3><i>SIG-Apps</i></h3>
<a href='http://bit.ly/sig-apps-openshift'>bit.ly/sig-apps-openshift</a>
</section>
<section id='the-problem'>
<h2>What do you mean by "Application"?</h2>
<p>the term "Application" can be a difficult thing to define</p>
</section>
</section>
<section id='definition'>
<h2>Define: "Application"</h2>
<p class="fragment">Equation: App = OCI/SRE</p>
<ol>
<li class='fragment'><a href='#/objects'>raw K8s API Objects</a></li>
<li class='fragment'><a href='#/configuration'>Configuration</a></li>
<li class='fragment'><a href='#/images'>Images</a></li>
<li class='fragment'><a href='#/pipeline-stage'>pipeline Stage</a></li>
<li class='fragment'><a href='#/resources'>system Resources</a></li>
<li class='fragment'><a href='#/human-effort'>human Effort</a></li>
</ol>
</section>
<section data-transition="linear">
<section id="openshift-intro" data-markdown>
Introducing&hellip;
# OpenShift
</section>
<section id='openshift-v3'>
<h2>OpenShift "V3"</h2>
<p class='fragment'>Our New Stack:</p>
<ul>
<li class='fragment'>Host OS: RHEL-7+ / CentOS-7+ / Fedora-latest / <a href="http://www.projectatomic.io/">Atomic</a>
<ul><li>Recent kernels, SELinux, systemd</li></ul>
</li>
<li class='fragment'>Container Runtime: <a href="https://hub.docker.com/">Docker</a></li>
<li class='fragment'>Container LifeCycle Management: <a href="http://kubernetes.io/">Kubernetes</a></li>
<li class='fragment'>Cluster State:
<ul>
<li><a href="https://github.com/coreos/etcd">Etcd</a> (platform)</li>
<li><a href="https://github.com/gluster/glusterfs">Gluster</a> &amp; <a href="https://github.com/ceph/ceph">Ceph</a> (application)</li>
</ul>
</li>
<li class='fragment'>Multi-tennancy and Developer Experience: <a href="http://openshift.org/">OpenShift</a></li>
</ul>
</section>
<section data-transition="linear" id='primitives'>
<h2>Extending Kubernetes</h2>
<p clas='fragment'>OpenShift extends the basic collection of K8s primitives to provide additional features related to developer interaction, multitennant security, and collaborative image maintenance</p>
</section>
<section data-transition="linear" id='objects' data-markdown>
## Objects
Kubernetes Primitives:
1. [node](#/node)
2. [image](#/img)
3. [container](#/container)
4. [volume](#/volume)
5. [pod](#/pod)
6. [replicationController (rc)](#/rc)
7. [deploymentConfig (dc)](#/dc)
8. [buildConfig (bc)](#/bc)
9. [service](#/svc)
10. [route](#/route)
</section>
<section data-transition="linear" id='node' data-markdown>
### Node
A [node](https://docs.openshift.org/latest/admin_guide/manage_nodes.html) is a host machine (physical or virtual) where workloads can be run. Node activity is managed via one or more Master instances.
</section>
<section data-transition="linear" id='img' data-markdown>
### [Image](https://docs.openshift.org/latest/architecture/core_concepts/containers_and_images.html#docker-images)
A packaged runtime or workload environment. A bootable linux container that runs wherever Docker is supported. See also, [`ImageStreams`](https://docs.openshift.org/latest/architecture/core_concepts/builds_and_image_streams.html#image-streams)
</section>
<section data-transition="linear" id='container' data-markdown>
### [Container](https://docs.openshift.org/latest/architecture/core_concepts/containers_and_images.html)
A running image with an allocation of system resources.
</section>
<section id='volume' data-markdown>
### Volumes
* https://docs.openshift.org/latest/dev_guide/volumes.html
* http://kubernetes.io/v1.1/docs/user-guide/volumes.html
* http://kubernetes.io/v1.1/docs/user-guide/persistent-volumes.html
</section>
<section data-transition="linear" id='pod' data-markdown>
### Pod
A group of one or more co-located containers. [Pods](https://docs.openshift.org/latest/architecture/core_concepts/pods_and_services.html) represent your minimum increment of scale.
</section>
<section data-transition="linear" id='rc' data-markdown>
### ReplicationController
An [`RC`](https://docs.openshift.org/latest/architecture/core_concepts/deployments.html) is created for every deployment, allowing you to easily scale your workloads by adjusting your desired number of pods
</section>
<section data-transition="linear" id='dc' data-markdown>
### DeploymentConfig
A [`DC`](https://docs.openshift.org/latest/architecture/core_concepts/deployments.html#deployments-and-deployment-configurations) helps you define how and when images are distributed to nodes (as pods, containers)
</section>
<section data-transition="linear" id='bc' data-markdown>
### BuildConfig
A [`BC`](https://docs.openshift.org/latest/architecture/core_concepts/builds_and_image_streams.html#builds) allows you build new images in a variety of ways
</section>
<section data-transition="linear" id='svc' data-markdown>
### [Service](https://docs.openshift.org/latest/architecture/core_concepts/pods_and_services.html#services)
A service (svc) is a software load-balancer that distributes inbound traffic to associated pods
</section>
<section data-transition="linear" id='route' data-markdown>
### [Route](https://docs.openshift.org/latest/architecture/core_concepts/routes.html)
A `service` will receive traffic based on the inbound `Host` header. Similar to how Apache VirtualHosts works.
</section>
<section id='models' data-markdown>
### Models
![Model Diagram](http://i.imgur.com/tHcpDud.png)
</section>
<section id='more-info' data-markdown>
### More Information
* OpenShift Sources: http://github.com/openshift/origin
* OpenShift Docs: https://docs.openshift.com/
* Kubernetes Docs: http://kubernetes.io/docs/
</section>
</section>
<section data-transition="linear">
<section id="templates">
<h1>Templates</h1>
<p class='fragment'>Quickly compose multi-service solutions</p>
<a class='fragment' href="https://github.com/kubernetes/kubernetes/issues/11492">https://github.com/kubernetes/kubernetes/issues/11492</a>
</section>
<section id='new-app'>
<h2 id="oc-new-app-examples">oc new-app examples</h2>
<div class='fragment'>
<p>Deploy an image from DockerHub:</p>
<pre><code contenteditable>oc new-app kubernetes/guestbook -o json</code></pre>
</div>
<div class='fragment'>
<p>Build from a local source folder, or from a Dockerfile:</p>
<pre><code contenteditable>oc new-app . -o yaml</code></pre>
</div>
<div class='fragment'>
<p>Add source layers to an operationally-maintained base:</p>
<pre><code contenteditable>oc new-app openshift/nodejs~https://github.com/ryanj/pillar-base -o json</code></pre>
</div>
<p class='fragment'>Run with <code>-o</code> to view the generated object list, then try piping the resulting object list to "<code>oc create -f -</code>"</p>
</section>
<section id='openshift-templates'>
<h2>OpenShift Templates</h2>
<p class='fragment'><a href="https://docs.openshift.org/latest/dev_guide/templates.html">Templates</a> contain a list of objects which document your application composition</p>
<p class='fragment'>Templates also include support for basic parameter injection, but may need to be customized per deployment pipeline stage</p>
</section>
<section id='template-parameters'>
<h3>Template Processing</h3>
<div class='fragment'>
<p>Convert a parameterized template to a primitive object list:</p>
<pre><code contenteditable>oc process -f template.json -p KEY=VALUE</code></pre>
</div>
<div class='fragment'>
<p>Submit a processed template (or any list of k8s object primitives) to the k8s API with "<code>oc create</code>":</p>
<pre><code contenteditable>oc process -f template.yaml -p KEY=VALUE | oc create -f -</code></pre>
</div>
</section>
<section id='installers'>
<h2>Templates as Installers</h2>
<div class='fragment'>
<p>Install a template into the current project, making it easier to reuse:</p>
<pre><code contenteditable>oc create -f template.json</code></pre>
</div>
<div class='fragment'>
<p>Create an application from an installed template, from a file, or from a url:</p>
<pre><code contenteditable>oc new-app -f template.json</code></pre>
</div>
</section>
<section id='composable-app-example'>
<h2>Multi-Service App Example</h2>
<p>Nodejs and MongoDB multi-service application example:</p>
<pre><code contenteditable>oc new-app -f https://raw.githubusercontent.com/ryanj/restify-mongodb-parks/master/restify-mongodb-parks-template.json</code></pre>
<p><a href="https://github.com/ryanj/restify-mongodb-parks/blob/master/restify-mongodb-parks-template.json">github.com/ryanj/restify-mongodb-parks</a></p>
</section>
</section>
<section>
<section id='images'>
<h1>Image</h1>
<p class='fragment'>definition</p>
</section>
<section id='source-to-image-demo'>
<h2>Source</h2>
<p>to</p>
<h1>Image</h1>
<p class='fragment'>Combines source repos and operationally-maintained builder images to produce application images</p>
<p class='fragment'>Available as a standalone project, for use with Jenkins or other external builder processes: <a href="https://github.com/openshift/source-to-image">github.com/openshift/source-to-image</a></p>
</section>
<section id='add-to-project'>
<h2>Web Workflow: Create</h2>
<p class='fragment'>For this example, we will deploy a fork of the <code>pillar-base</code> repo by clicking on "Add to Project" in the web console. Then, select a nodejs base image, name your webservice, and enter it's github source url</p>
<p class='fragment'>Optionally, explore the "Advanced routing, build, and deployment options" before starting your build with the "Create" button</p>
<p class="fragment">Example repo source: <a href="http://github.com/ryanj/pillar-base/">github.com/ryanj/pillar-base</a></p>
</section>
<section id='get-pods'>
<h2>Container Status</h2>
<p class='fragment'>The web console uses a socket stream to report status changes as they occur throughout the cluster</p>
<div class='fragment'>
<p>After the build task has completed, find the <code>NAME</code> of the pod where your image has been deployed:</p>
<pre><code contenteditable>oc get pods</code></pre>
</div>
<div class='fragment'>
<p>As with the core APIs, the CLI output is consistently formatted, following established patterns:</p>
<pre><code contenteditable>kubectl get pods</code></pre>
</div>
</section>
<section id="terminal" data-markdown>
## Terminal Access
* Available in the Web Console
* And on the CLI, with:
oc exec -it PODNAME -- bash
</section>
<section id='configuration' data-markdown>
## Configuration
[Environment Variables](https://docs.openshift.org/latest/dev_guide/environment_variables.html) are one way to add configuration settings to your images:
oc env dc/pillar-base KEY=VALUE
</section>
</section>
<section data-transition="linear">
<section id="iterate">
<h1>Iterate</h1>
<p class='fragment'>Iterate on container-based solutions</p>
</section>
<section id='oc-rsync'>
<h3>Developing on Docker</h3>
<p class='fragment'>Make a minor edit to your local repo's <code>index.html</code> file,</p>
<div class='fragment'>
<p>then test your changes <i>before you commit</i> by synching content into your hosted container:</p>
<pre><code contenteditable>oc rsync --exclude='node_modules*' . PODNAME:</code></pre>
</div>
<div class='fragment'>
<p>Make sure to use a valid <code>PODNAME</code> from:</p>
<pre><code contenteditable>oc get pods</code></pre>
</div>
</section>
<section id="oc-rsync-watch" data-markdown>
## Rsync on Change
Continually mirror contents from a local folder into a remote container using the `--watch` flag:
oc rsync --watch FILEPATH PODNAME:
</section>
<section id='webhooks'>
<h2>WebHook Build Automation</h2>
<p class='fragment'>Set up a commit WebHook to automate image production</p>
<p class='fragment'>If you're running OpenShift locally in a VM, try using <a href="http://www.ultrahook.com/">ultrahook</a> to proxy webhook events to your laptop</p>
</section>
<section id='git-push-to-build-and-ship'>
<h2>ReBuild on Push</h2>
<p class='fragment'>Or, use GitHub's web-based editor to make a minor change</p>
<div class='fragment'><p>If you don't have a working webhook to automate the build process, it can also be started manually:</p>
<pre><code contenteditable>oc start-build pillar-base</code></pre>
</div>
</section>
<!--
<section id='nodejs-builders'>
Add new base layers, automatically rebuild
</section>
<section id='standard-base'>
more info about building your own base images
bit.ly/IB-SIG-kickoff
</section>
-->
<section id="deployment-strategies">
<h2>Deployment Strategies</h2>
<p class="fragment">Get more control of your container rollout and update processes by selecting appropriate <a href="https://docs.openshift.org/latest/dev_guide/deployments.html#strategies">deployment strategies</a> for your fleet of managed containers</p>
</section>
</section>
<section data-transition="linear">
<section id='template-take-aways' data-markdown>
## Templating Take-Aways
1. alternatives exist (helm charts, kpm, jade, jinja2, etc)
2. the goal is to develop a process that resolves everything down to a list of native k8s objects as easily as possible for a given pipeline stage
</section>
<section id='latest-status' data-markdown>
## Latest Status
* Proposal: https://github.com/kubernetes/kubernetes/blob/master/docs/proposals/templates.md
* Issue: https://github.com/kubernetes/kubernetes/issues/23896
</section>
</section>
<section data-transition="linear">
<section id='kubernetes-as-a-paas' data-markdown>
# OpenShift Online
#### Next-Gen Developer Preview
Multi-tennant Kubernetes as a public PaaS
Request access at [openshift.com/devpreview](https://www.openshift.com/devpreview/)
</section>
<section data-transition="concave" id="more-openshift" data-markdown>
## More ways to try OpenShift
* OpenShift Origin CLI tools and upstream releases: https://github.com/openshift/origin/releases
* All-in-One OpenShift / K8s cluster in a VM: http://openshift.org/vm
* Build your own OpenShift cluster w/ Ansible: http://github.com/openshift/openshift-ansible
* Containerized installer for OSE on AWS: [hub.docker.com/r/ryanj/ose-aws-deployer](https://hub.docker.com/r/ryanj/ose-aws-deployer/)
</section>
<section id="follow-along" data-markdown>
## OpenShift VM Setup
To try these examples in your own OpenShift Virtual Machine:
1. [Install the `oc` command-line tool](#/get-oc)
2. [Add `oc` to your `PATH`](#/install-oc)
3. [Set up your Kubernetes / OpenShift environment using Vagrant and Virtualbox](#/setup-vm)
</section>
<section id="get-oc" data-markdown>
### Get the `oc` command-line tool
Download the correct binaries for your OS: https://github.com/openshift/origin/releases
</section>
<section id="install-oc" data-markdown>
### Add `oc` to your `PATH`
Extract the bundle and add `oc` to your `PATH`:
mkdir -p ~/bin
tar zxvf ~/Downloads/openshift-RELEASE-ARCH.tar.gz -C ~/bin --overwrite --strip-components=1
export PATH=$PATH:~/bin
</section>
<section id="setup-vm" data-markdown>
### Vagrant Up
Set up your own K8s / OpenShift cluster in a VM!
vagrant init openshift/origin-all-in-one && vagrant up --provider=virtualbox
(requires [vagrant](https://www.vagrantup.com) and [virtualbox](https://www.virtualbox.org/))
See [http://openshift.org/vm](openshift.org/vm) for advanced setup notes
**WARNING:** This is a *very large* download (2GB+)!
***DO NOT ATTEMPT TO PULL THIS VM OVER THE CONFERENCE WIFI***
</section>
<section id="openshift-vm-testing" data-markdown>
### Test your K8s / OpenShift VM
1. Connect on the CLI with:
oc login https://10.2.2.2:8443/
2. Connect to the VM web console at: https://10.2.2.2:8443/
</section>
</section>
<section id='oreilly-ebooks'>
<h2>Free O'Reilly EBooks</h2>
<p>Courtesy of Red Hat:</p>
<ol>
<li><a href="https://www.openshift.com/promotions/for-developers.html">OpenShift for Developers</a></li>
<li><a href="https://www.openshift.com/promotions/kubernetes">Kubernetes: Scheduling the Future at Cloud Scale</a></li>
<li><a href="https://www.openshift.com/promotions/docker-security.html">Docker Security: Using Containers Safely in Production</a></li>
<li><a href="https://www.openshift.com/promotions/microservices.html">Microservices vs. Service-Oriented Architecture</a></li>
</ol>
</section>
<section id="get-involved" data-state="blackout">
<h2>Get Involved!</h2>
<ul>
<li style="list-style: outside none none;text-align: center;"><h4>Try OpenShift Container Platform:</h4></li>
<li>Sign up for <a href="https://www.openshift.com/dedicated/">OpenShift Dedicated</a> w/ Red Hat Ops</li>
<li>Run <a href="https://enterprise.openshift.com/trial.html">OpenShift Enterprise</a> w/ Red Hat support</li>
<li>Try the <a href="https://www.openshift.com/devpreview/">OpenShift Online Next-Gen Dev Preview</a></li>
<li>Check out the latest <a href="https://github.com/openshift/origin/releases">upstream releases on GitHub</a></li>
<li style="list-style: outside none none;text-align: center;"><br/><h4>More Information and Opportunites to Learn:</h4></li>
<li><a href="http://commons.openshift.org">Openshift Commons</a> and <a href="http://commons.openshift.org/briefings.html">Commons Briefings</a></li>
<li><a href="https://docs.openshift.com/">OpenShift Documentation</a></li>
<li><a href="#/oreilly-ebooks">Free O'Reilly EBooks, courtesy of Red Hat</a></li>
<li><a href="https://youtu.be/_tfNY27vzq4">OpenShift Booth Demos from OSCON</a></li>
<li><a href="https://www.openshift.com/openshift-gcp/">Kubernetes Workshop Series from Red Hat & Google</a></li>
<li><a href="https://enterprise.openshift.com/resources/">OSE Whitepapers</a> and <a href="http://openshift.com/customers">customer references</a> </li>
<p>these slides: <a href="http://bit.ly/sig-apps-openshift">bit.ly/sig-apps-openshift</a></p>
</ul>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment