Files
container.training/slides/k8s/ourapponkube.md
Jerome Petazzoni 7d6ab6974d Big autopilot update
'keys' does not handle special keys (like ^J) anymore.
Instead, we should use `key`, which will pass its entire
argument to tmux, without any processing. It is therefore
possible to do something like:

```key ^C```

Or

```key Escape```

Most (if not all) calls to special keys have been
converted to use 'key' instead of 'keys'.

Action ```copypaste``` has been deprecated in favor
of three separate actions:

```copy REGEX``` (searches the regex in the active pane,
and if found, places it in an internal clipboard)

```paste``` (inserts the content of the clipboard as
keystrokes)

```check``` (forces a status check)

Also, a 'tmux' command has been added. It allows to
do stuff like:

```tmux split-pane -v```
2020-01-18 09:49:18 -06:00

2.8 KiB

Running our application on Kubernetes

  • We can now deploy our code (as well as a redis instance)

.exercise[

  • Deploy redis:

    kubectl create deployment redis --image=redis
    
  • Deploy everything else:

    kubectl create deployment hasher --image=dockercoins/hasher:v0.1
    kubectl create deployment rng --image=dockercoins/rng:v0.1
    kubectl create deployment webui --image=dockercoins/webui:v0.1
    kubectl create deployment worker --image=dockercoins/worker:v0.1
    

]


class: extra-details

Deploying other images

  • If we wanted to deploy images from another registry ...

  • ... Or with a different tag ...

  • ... We could use the following snippet:

  REGISTRY=dockercoins
  TAG=v0.1
  for SERVICE in hasher rng webui worker; do
    kubectl create deployment $SERVICE --image=$REGISTRY/$SERVICE:$TAG
  done

Is this working?

  • After waiting for the deployment to complete, let's look at the logs!

    (Hint: use kubectl get deploy -w to watch deployment events)

.exercise[

  • Look at some logs:
    kubectl logs deploy/rng
    kubectl logs deploy/worker
    

]

--

🤔 rng is fine ... But not worker.

--

💡 Oh right! We forgot to expose.


Connecting containers together

  • Three deployments need to be reachable by others: hasher, redis, rng

  • worker doesn't need to be exposed

  • webui will be dealt with later

.exercise[

  • Expose each deployment, specifying the right port:
    kubectl expose deployment redis --port 6379
    kubectl expose deployment rng --port 80
    kubectl expose deployment hasher --port 80
    

]


Is this working yet?

  • The worker has an infinite loop, that retries 10 seconds after an error

.exercise[

  • Stream the worker's logs:

    kubectl logs deploy/worker --follow
    

    (Give it about 10 seconds to recover)

]

--

We should now see the worker, well, working happily.


Exposing services for external access

  • Now we would like to access the Web UI

  • We will expose it with a NodePort

    (just like we did for the registry)

.exercise[

  • Create a NodePort service for the Web UI:

    kubectl expose deploy/webui --type=NodePort --port=80
    
  • Check the port that was allocated:

    kubectl get svc
    

]


Accessing the web UI

  • We can now connect to any node, on the allocated node port, to view the web UI

.exercise[

]

--

Yes, this may take a little while to update. (Narrator: it was DNS.)

--

Alright, we're back to where we started, when we were running on a single node!