Slide 1

Slide 1 text

Intro to Kubernetes Through React, SVG, and the OpenShift API Jan Kleinert jan.kleinert@redhat.com February 22, 2019

Slide 2

Slide 2 text

@jankleinert 2 Jan Kleinert Developer Advocate, Red Hat twitter/github: @jankleinert Hello!

Slide 3

Slide 3 text

@jankleinert 3 What is Kubernetes? 4 basic primitives How the visualization works Additional OpenShift concepts What We’ll Cover

Slide 4

Slide 4 text

@jankleinert 4 What is Kubernetes?

Slide 5

Slide 5 text

@jankleinert 5 Kubernetes is... An open source platform for running container-based workloads and managing them at scale

Slide 6

Slide 6 text

@jankleinert 6 Kubernetes provides... An API kind apiVersion metadata spec status API object primitives include these attributes:

Slide 7

Slide 7 text

@jankleinert 7 Basic K8s Terminology 1. node 2. pod 3. service 4. deployment

Slide 8

Slide 8 text

@jankleinert 8 Node ● Node: a host machine where containerized processes run ● Node activity is managed via one or more Master instances

Slide 9

Slide 9 text

@jankleinert 9 Pod ● A group of one or more co-located containers ● Minimum unit of scale kind: Pod apiVersion: v1 metadata: creationTimestamp: name: hello-k8s labels: run: hello-k8s spec: containers: - name: hello-k8s image: jkleinert/nodejsint-workshop ports: - containerPort: 8080 resources: {}

Slide 10

Slide 10 text

@jankleinert 10 https://youtu.be/E7KWcvuFVns

Slide 11

Slide 11 text

@jankleinert 11 Service ● Acts as a single endpoint for a collection of replicated pods ● Like a load balancer kind: Service apiVersion: v1 metadata: name: hello-k8s creationTimestamp: labels: run: hello-k8s spec: ports: - protocol: TCP port: 8080 targetPort: 8080 selector: run: hello-k8s type: NodePort status: loadBalancer: {}

Slide 12

Slide 12 text

@jankleinert 12 https://youtu.be/mkLNa_5w_58

Slide 13

Slide 13 text

@jankleinert 13 Deployment ● Helps you specify container runtime requirements (in terms of pods) kind: Deployment
 apiVersion: apps/v1beta1
 metadata:
 name: hello-k8s
 creationTimestamp: 
 labels:
 run: hello-k8s
 spec:
 replicas: 1
 selector:
 matchLabels:
 run: hello-k8s
 template:
 metadata:
 creationTimestamp: 
 labels:
 run: hello-k8s
 spec:
 containers:
 - name: hello-k8s
 image: jkleinert/nodejsint-workshop
 resources: {}
 strategy: {}
 status: {}

Slide 14

Slide 14 text

@jankleinert 14 https://youtu.be/1gjTeR4tsj0

Slide 15

Slide 15 text

@jankleinert 15 https://youtu.be/V8BOQhmC30w

Slide 16

Slide 16 text

@jankleinert 16 https://youtu.be/C8xAqfFaSLI

Slide 17

Slide 17 text

@jankleinert 17 https://youtu.be/YEkIAWFc9WE

Slide 18

Slide 18 text

@jankleinert 18 How does the visualization work? 1. Java backend
 https://github.com/jankleinert/k8s-visualization-backend 2. Node.js server 3. React frontend
 https://github.com/jankleinert/k8s-visualization-frontend

Slide 19

Slide 19 text

@jankleinert 19

Slide 20

Slide 20 text

@jankleinert 20 server.js client.on('subscribeToPods', (interval) => { setInterval(() => { var req = http.request(podOptions, function (res) { var responseString = ""; res.on("data", function (data) { responseString += data; }); res.on("end", function () { pods = JSON.parse(responseString); }); }); req.end(); client.emit('pods', pods); }, interval); });

Slide 21

Slide 21 text

@jankleinert 21 App.js class App extends Component { render() { const podGroup = Object.keys(this.state.pods).map(key => <> {this.state.pods[key].objectType} {this.state.pods[key].objectName} > )

Slide 22

Slide 22 text

@jankleinert 22 Kubernetes By Example: http://kubernetesbyexample.com Interactive Learning Portal: https://learn.openshift.com Backend repo:
 https://github.com/jankleinert/k8s-visualizer-backend Frontend repo: https://github.com/jankleinert/k8s-visualizer-frontend Resources

Slide 23

Slide 23 text

THANK YOU plus.google.com/+RedHat linkedin.com/company/red-hat youtube.com/user/RedHatVideos facebook.com/redhatinc twitter.com/RedHat