Last active
April 16, 2019 17:59
-
-
Save ryanj/5be5a96d2f519c4864032ff4a85210d3 to your computer and use it in GitHub Desktop.
Introducing Red Hat OpenShift 4 - Part1: An Introduction to Kubernetes http://gist-reveal.it/5be5a96d2f519c4864032ff4a85210d3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section data-transition='concave'> | |
<section id='Part1--Introduction-to-Kubernetes'> | |
<h3>Introducing Red Hat OpenShift 4</h3> | |
<h2>Part1: An Introduction to Kubernetes</h2> | |
<br/> | |
<br/> | |
<p><a href="http://bit.ly/v4intro-part1">bit.ly/v4intro-part1</a></p> | |
<p><a href="https://www.redhat.com/en/events/webinar/introduction-kubernetes">April 16, 2019, 11:00 a.m. PDT</a></p> | |
</section> | |
<section data-background-transition='fade' data-background='black' id='presented-by-ryanj'> | |
<p>presented by Ryan Jarvinen (<a href="http://twitter.com/ryanj/">@RyanJ</a>), Developer Advocate at Red Hat</p> | |
<p><a href="http://twitter.com/ryanj/"><img alt="ryanj" src="https://tek.phparch.com/wp-content/uploads/sites/7/2018/05/ryan-jarvinen-headshot-e1525184794614-531x424.jpg" style="width:50%" /></p> | |
</section> | |
</section> | |
<section id="kubernetes-is" data-markdown> | |
## Kubernetes is... | |
</section> | |
<section id="kubernetes-easy" data-markdown> | |
## Kubernetes is | |
a way to manage collections of processes over groups of machines | |
</section> | |
<section id="kubernetes-more-accurate"> | |
<h2>Kubernetes is</h2> | |
<p class="fragment">an Enterprise-grade distributed process scheduler (multi-machine, cluster-scale)</p> | |
<p class="fragment">that provides declarative controls (json/yaml)</p> | |
<p class="fragment">for managing workloads (collections of highly-available, production-quality processes)</p> | |
</section> | |
<section> | |
<section id='kubernetes-control-plane'> | |
<p>Including a highly-available</p> | |
<h2>Control Plane</h2> | |
<br/> | |
<p>A group of machines (nodes) that are responsible for hosting core platform services</p> | |
</section> | |
<section id='an-api' data-markdown> | |
Kubernetes provides… | |
# An API | |
API resources usually include the following attributes: | |
``` | |
kind | |
apiVersion | |
metadata | |
spec | |
status | |
``` | |
Extended Kubernetes API Reference: | |
http://k8s.io/docs/reference/generated/kubernetes-api/v1.12/ | |
</section> | |
<section data-markdown> | |
Kubernetes uses | |
## etcd | |
to keep track of the cluster's state | |
![etcd logo](https://raw.githubusercontent.com/coreos/etcd/master/logos/etcd-glyph-color.png) | |
* a distributed key-value store | |
* implements the [RAFT](https://raft.github.io/raft.pdf) consensus protocol | |
</section> | |
<section data-markdown> | |
## Etcd cluster sizes | |
Fault-tolerance sizing chart: | |
![etcd cluster sizing chart](http://cloudgeekz.com/wp-content/uploads/2016/10/etcd-fault-tolerance-table.png) | |
</section> | |
<section data-transition="linear" id='terminology' data-markdown> | |
### Basic K8s Terminology | |
1. [node](#/node) | |
2. [pod](#/po) | |
3. [service](#/svc) | |
4. [deployment](#/deployment) | |
5. [replicaSet](#/rs) | |
</section> | |
</section> | |
<section> | |
<section data-transition="linear" id='node' data-markdown> | |
### Nodes | |
A node is a host machine (physical or virtual) where containerized processes are run. | |
Activity on each Node is managed by a `kubelet` process, which receives workload scheduling instructions from the Control Plane. | |
</section> | |
</section> | |
<section> | |
<section data-transition="linear" id='po' data-markdown> | |
### Pods | |
A group of one or more co-located containers. | |
</section> | |
<section> | |
<h3>Starting a Pod from the Command-Line</h3> | |
<p>Create a new resource from a json object specification:</p> | |
<pre><code contenteditable>kubectl create -f https://raw.githubusercontent.com/jankleinert/hello-workshop/master/pod.json</code></pre> | |
</section> | |
<section> | |
<pre><code contenteditable>{ | |
"kind": "Pod", | |
"apiVersion": "v1", | |
"metadata": { | |
"creationTimestamp": null, | |
"name": "hello-k8s", | |
"labels": { | |
"run": "hello-k8s" | |
} | |
}, | |
"spec": { | |
"containers": [ | |
{ | |
"name": "hello-k8s", | |
"image": "jkleinert/devweek-workshop", | |
"ports": [ | |
{ | |
"containerPort": 8080 | |
} | |
], | |
"resources": {} | |
} | |
] | |
} | |
}</code></pre> | |
</section> | |
<section data-markdown> | |
### Pod attributes: | |
* Automatic health checking for PID1 in each container | |
* Pods are scheduled to be run on nodes | |
* Pods represent your minimum increment of scale | |
</section> | |
<!-- | |
<section data-markdown> | |
</section> | |
--> | |
</section> | |
<section> | |
<section data-transition="linear" id='svc' data-markdown> | |
### Services | |
Services (svc) establish a single endpoint for a collection of replicated pods, distributing traffic based on label selectors | |
In our K8s modeling language they represent a load balancer. Their implementation may vary per cloud provider | |
</section> | |
<section id='connections'> | |
<h3>Contacting your App</h3> | |
<p>Expose the pod by creating a new <code>service</code> (or "loadbalancer"):</p> | |
<pre><code contenteditable>kubectl expose pod/hello-k8s --port 8080 --type=NodePort</code></pre> | |
<p>Schedule the deletion of all pods that are labeled with:</p> | |
<pre><code contenteditable>kubectl get pods -l run=hello-k8s</code></pre> | |
<pre><code contenteditable>kubectl delete pods -l run=hello-k8s</code></pre> | |
<p>Delete the service:</p> | |
<pre><code contenteditable>kubectl delete service hello-k8s</code></pre> | |
</section> | |
<section data-markdown> | |
### Service Attributes: | |
* a *"service"* is basically an internal abstraction for a *"loadbalancer"* | |
* The Service resource uses label selectors to discover where traffic should be directed | |
* Label selectors can be used to organize workloads and manage groups of related resouces | |
</section> | |
</section> | |
<section> | |
<section data-transition="linear" id='deployment' data-markdown> | |
### Deployments | |
A `deployment` helps you specify container runtime requirements (in terms of pods) | |
</section> | |
<section> | |
<p>Create a specification for your <code>deployment</code>:</p> | |
<pre><code contenteditable>kubectl run hello-k8s --image=jkleinert/nodejsint-workshop \ | |
--dry-run -o json > deployment.json</code></pre> | |
<p>View the generated deployment spec file:</p> | |
<pre><code contenteditable>cat deployment.json</code></pre> | |
</section> | |
<section> | |
<pre><code contenteditable>{ | |
"kind": "Deployment", | |
"apiVersion": "apps/v1beta1", | |
"metadata": { | |
"name": "hello-k8s", | |
"creationTimestamp": null, | |
"labels": { | |
"run": "hello-k8s" | |
} | |
}, | |
"spec": { | |
"replicas": 1, | |
"selector": { | |
"matchLabels": { | |
"run": "hello-k8s" | |
} | |
},</code></pre> | |
</section> | |
<section> | |
<pre><code contenteditable> | |
"template": { | |
"metadata": { | |
"creationTimestamp": null, | |
"labels": { | |
"run": "hello-k8s" | |
} | |
}, | |
"spec": { | |
"containers": [ | |
{ | |
"name": "hello-k8s", | |
"image": "jkleinert/nodejsint-workshop", | |
"resources": {} | |
} | |
] | |
} | |
}, | |
"strategy": {} | |
}, | |
"status": {} | |
}</code></pre> | |
</section> | |
<section> | |
<p>Create a new deployment from your local spec file:</p> | |
<pre><code contenteditable>kubectl create -f deployment.json</code></pre> | |
<p>This action should set <code>spec.replicas</code> to <code>1</code></p> | |
</section> | |
<section> | |
<p>Create a <code>Service</code> spec to direct traffic:</p> | |
<pre><code contenteditable>kubectl expose deploy/hello-k8s --type=NodePort --port=8080 --dry-run -o json > service.json</code></pre> | |
<p>View the resulting spec file:</p> | |
<pre><code contenteditable>cat service.json</code></pre> | |
<p>Create a new service from your local spec file:</p> | |
<pre><code contenteditable>kubectl create -f service.json</code></pre> | |
<p>List multiple resources by type:</p> | |
<pre><code contenteditable>kubectl get po,svc,deploy</code></pre> | |
<p>Connect to your new deployment via the associated service port:</p> | |
<pre><code contenteditable>curl $(minishift ip):$(kubectl get svc/hello-k8s -o jsonpath={.spec.ports[0].nodePort})</code></pre> | |
</section> | |
<section id='replication'> | |
<h2>Replication</h2> | |
<p>Scale up the <code>hello-k8s</code> deployment to 3 replicas:</p> | |
<pre><code contenteditable>kubectl scale deploy/hello-k8s --replicas=3</code></pre> | |
<p>This action should set <code>spec.replicas</code> to <code>3</code></p> | |
<p>List pods to verify:</p> | |
<pre><code contenteditable>kubectl get po</code></pre> | |
</section> | |
<section id='autorecovery'> | |
<h2>AutoRecovery</h2> | |
<p>Watch for changes to <code>pod</code> resources:</p> | |
<pre><code contenteditable>kubectl get pods --watch</code></pre> | |
<p>In another terminal, delete several pods by id:</p> | |
<pre><code contenteditable>kubectl delete pod $(kubectl get pods | grep ^hello-k8s | cut -f1 -s -d' ' | head -n 2 | tr '\n' ' ')</code></pre> | |
<p class='fragment'>What happened? How many pods remain?</p> | |
<pre class='fragment'><code contenteditable>kubectl get pods</code></pre> | |
</section> | |
<section data-markdown> | |
### Deployment Attributes: | |
* A deployment spec contains a pod spec in it's "template" element | |
* You can use the `--dry-run` flag to generate new resource specifications | |
* Declarative specifications: `spec` vs `status` | |
</section> | |
</section> | |
<section> | |
<section data-transition="linear" id='rs' data-markdown> | |
### ReplicaSets | |
A `replicaset` provides replication and lifecycle management for a specific image release | |
</section> | |
<section> | |
<h3>Rollouts</h3> | |
<p>Update your deployment's image spec to rollout a new release:</p> | |
<pre><code contenteditable>kubectl set image deploy/hello-k8s hello-k8s=jkleinert/nodejsint-workshop:v1</code></pre> | |
<p>View the current state of your deployment</p> | |
<pre><code contenteditable>curl $(minishift ip):$(kubectl get svc/hello-k8s -o jsonpath={.spec.ports[0].nodePort})</code></pre> | |
<p>Ask the API to list <code>replicaSets</code></p> | |
<pre><code contenteditable>kubectl get rs</code></pre> | |
</section> | |
<section> | |
<h3>Rollbacks</h3> | |
<p>View the list of previous rollouts:</p> | |
<pre><code contenteditable>kubectl rollout history deploy/hello-k8s</code></pre> | |
<p>Rollback to the previous state:</p> | |
<pre><code contenteditable>kubectl rollout undo deployment hello-k8s</code></pre> | |
</section> | |
<section data-markdown> | |
### ReplicaSet Attributes: | |
* ReplicaSets provide lifecycle management for pod resources | |
* Deployments create ReplicaSets to manage pod replication per rollout (per change in podspec: image:tag, environment vars) | |
* `Deployments` > `ReplicaSets` > `Pods` | |
</section> | |
</section> | |
<section id='kubernetes' data-markdown> | |
# Kubernetes | |
* [is](https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/): an ops tool; open source management for collections of processes over groups of machines | |
* [is not](https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/#what-kubernetes-is-not): an all-inclusive PaaS | |
</section> | |
<section> | |
<h4>CNCF landscape</h4> | |
<p><a href="https://github.com/cncf/landscape"><img src="https://landscape.cncf.io/images/landscape.png" alt="missing pieces" /></a></p> | |
</section> | |
<section> | |
<p><img src="https://gist.githubusercontent.com/ryanj/7827731d9abcc5161f19828aaee42b4f/raw/eadbf043ca3a65453a55607144c43710541390d0/okd-sources.png" alt="the best from the Open Source, LF, and CNCF ecosystems" /></p> | |
</section> | |
<section id='openshift' data-markdown> | |
# OpenShift | |
* includes, extends, & is a distribution of: Kubernetes | |
* adds: Multi-tenant security, PaaS-style workflows, Service Catalog and Brokers, a container registry, distributed metrics, logs, ... | |
* a full-featured Kuberenetes distro: Build, Automate, Iterate, and Collaborate on any hardware | |
</section> | |
<section> | |
<p><img src="https://www.openshift.com/hubfs/images/marketecture.png" alt="Openshift Stack Diagram" /></p> | |
</section> | |
<section data-transition='convex'> | |
<section id='build'> | |
<h1>Build</h1> | |
<p class='fragment'>Build and deploy container images</p> | |
</section> | |
<section id='openshift-web-console'> | |
<h3>Web-based Create Workflow</h3> | |
<img src="https://gist.github.com/ryanj/7827731d9abcc5161f19828aaee42b4f/raw/d81c18c6aaa132293e2f9b2ad0a702f8644473a2/create-workflow.png" alt="Developer-friendly App Creation Workflows" /> | |
</section> | |
<section id='get-pods'> | |
<h2>Container Status</h2> | |
<img src="https://gist.github.com/ryanj/7827731d9abcc5161f19828aaee42b4f/raw/d81c18c6aaa132293e2f9b2ad0a702f8644473a2/overview.png" alt="Developer-friendly Access and Feedback" /> | |
</section> | |
<section id='source-to-image-demo'> | |
<h2>Source to Image</h2> | |
<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 externalized build systems): <a href="https://github.com/openshift/source-to-image">github.com/openshift/source-to-image</a></p> | |
</section> | |
</section> | |
<section data-transition="linear"> | |
<section id="automate"> | |
<h1>Automate</h1> | |
<p class='fragment'><code>git push</code> to deploy</p> | |
</section> | |
<section id='webhooks'> | |
<h2>WebHook Build Automation</h2> | |
<img src="https://gist.github.com/ryanj/7827731d9abcc5161f19828aaee42b4f/raw/d81c18c6aaa132293e2f9b2ad0a702f8644473a2/webhooks.png" alt="git-push webhook automation for continuous delivery" /> | |
</section> | |
</section> | |
<section data-transition="linear"> | |
<section id="iterate"> | |
<h1>Iterate</h1> | |
<p class='fragment'>Iterate using a fully containerized toolchain</p> | |
</section> | |
<section id='logging' data-markdown> | |
## Logs | |
Centralized logging and metrics | |
</section> | |
<section id="terminal" data-markdown> | |
## Terminal Access | |
* Available in the Web Console | |
* And on the CLI, with: | |
oc exec -it $PODNAME -- bash | |
curl http-base | |
</section> | |
<section id='keys-and-configs' 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/http-base KEY=VALUE | |
ConfigMaps and Secrets are also useful configuration abstractions | |
</section> | |
<section id='oc-rsync'> | |
<h3>Live Development</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>export PODNAME=$(oc get pods -l app=http-base | tail -n 1 | cut -f1 -d' ') | |
oc rsync -w --exclude='.git,node_modules' . $PODNAME:</code></pre> | |
</div> | |
</section> | |
</section> | |
<section data-transition="concave"> | |
<section id='collaborate'> | |
<h1>Collaborate</h1> | |
<p class='fragment'>Share and replicate your success</p> | |
</section> | |
<section id='service-catalog-on-openshift'> | |
<h2>Service Catalog & Brokers</h2> | |
<p>Expose and provision services</p> | |
<p><img style='width:100%;' src='https://gist.github.com/ryanj/7827731d9abcc5161f19828aaee42b4f/raw/d81c18c6aaa132293e2f9b2ad0a702f8644473a2/service-catalog.png' alt='pluggable-broker-options' /></p> | |
<p><a href='https://www.openservicebrokerapi.org/'>www.openservicebrokerapi.org</a> | |
</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 create -f https://raw.githubusercontent.com/openshift-roadshow/nationalparks-js/master/nationalparks-js.json</code></pre> | |
<p><a href="https://raw.githubusercontent.com/openshift-roadshow/nationalparks-js/master/nationalparks-js.json">github.com/ryanj/nationalparks-js</a></p> | |
<p>Review and install the above template content using <code>oc create</code>, then try launching it via the web-based Service Catalog.</p> | |
<div class="fragment"> | |
<p>When you're done, list all available API resources to review the contents of your project namespace:</p> | |
<pre><code contenteditable>oc get all</code></pre> | |
</div> | |
</section> | |
</section> | |
<section data-transition="concave"> | |
<section> | |
<h4>API Resources</h4> | |
<img src="https://gist.github.com/ryanj/7827731d9abcc5161f19828aaee42b4f/raw/d81c18c6aaa132293e2f9b2ad0a702f8644473a2/basic-resources.png" alt="Kubernetes and OpenShift resources" /> | |
</section> | |
<section id='more-info'> | |
<h3>More Information</h3> | |
<ul> | |
<li>Kubernetes Sources and Official Releases:<br/> | |
<a href="http://github.com/kubernetes/kubernetes">http://github.com/kubernetes/kubernetes</a></li> | |
<li>Kubernetes Docs: <a href="http://kubernetes.io/docs/home/">http://kubernetes.io/docs/home/</a></li> | |
<li>OpenShift Sources and Official Releases:<br/> | |
<a href="http://github.com/openshift/origin/">http://github.com/openshift/origin/</a></li> | |
<li>OpenShift Docs: <a href="https://docs.openshift.com/">https://docs.openshift.com/</a></li> | |
</ul> | |
</section> | |
<section> | |
<h3>Free O'Reilly Ebook</h3> | |
<p><a href="https://www.openshift.com/deploying-to-openshift/"><img src="https://www.openshift.com/hubfs/images/openshift-legacy/promotions/deploying-to-openshift/deploying-to-openshift.png" style="margin-left:auto;margin-right:auto;width:45%;display:block;box-shadow:none;align:center;"></a></p> | |
<p><a href="https://www.openshift.com/deploying-to-openshift/">Deploying to OpenShift<br/>www.openshift.com/deploying-to-openshift</a></p> | |
</section> | |
<section data-transition='concave' id='learn-openshift'> | |
<h2>learn.openshift.com</h2> | |
<p>Free-access Kubernetes and OpenShift learning portal, available in your browser</p> | |
</section> | |
<section id='get-openshift' data-markdown data-transition="concave"> | |
### More Ways to try OpenShift | |
* [OpenShift Origin (OKD)](https://github.com/openshift/origin) (and [minishift](https://github.com/minishift/minishift)) | |
* [Red Hat CodeReady Workspaces (containerized development)](https://developers.redhat.com/products/codeready-workspaces/) | |
* [OpenShift Online (hosted, Starter and Pro plans available)](https://www.openshift.com/products/online/) | |
* [OpenShift Dedicated (operated on AWS, GCE, and Azure)](https://www.openshift.com/products/dedicated/) | |
* [OpenShift Container Platform (supported on RHEL, CoreOS)](https://www.openshift.com/products/container-platform/) | |
</section> | |
<section data-transition='concave' id='try-openshift'> | |
<h3>OpenShift 4 Developer Preview</h3> | |
<p><a href="http://try.openshift.com">try.openshift.com</a></p> | |
</section> | |
</section> | |
<section id="thank-you"> | |
<h1>Thank You!</h1> | |
<br/> | |
<p>This has been:</p> | |
<h3>Introducing Red Hat OpenShift 4</h3> | |
<h2>Part 1: An Introduction to Kubernetes</h2> | |
<p>presented by @RyanJ</p> | |
<br/> | |
<p>Tune in next time for Part 2 in this series!</p> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment