Slide 1

Slide 1 text

VIKUBE VIM & KUBERNETES OPERTATION

Slide 2

Slide 2 text

VIKUBE @C9S ▸ Started open source development from the Perl community since 2007 ▸ Maintained over 50 modules on CPAN. The largest Perl module platform. ▸ Found over 200 projects on GitHub from C, VimL, Perl, JavaScript, TypeScript and PHP. ▸ Contributed code to Facebook HHVM, PHP Zend Engine and the Google Go project.

Slide 3

Slide 3 text

VIKUBE @C9S & KUBERNETRES ▸ Started using Kubernetes for the deep learning training platform since last year (Mid 2017) ▸ As a Developer, we heavily use Kubernetes API for integrating the applications. ▸ As a DevOps, we integrate CI/CD with Kubernetes, and use Vikube for debugging the Kubernetes deployments.

Slide 4

Slide 4 text

KUBERNETES 5 MINUTES

Slide 5

Slide 5 text

KUBERNETES ARCHITECTUR E REVIEW

Slide 6

Slide 6 text

Minion kubelet Pod Container Master API Server Replication Controller Scheduler Pod Container Minion kubelet Pod Container Pod Container Minion kubelet Pod Container Pod Container

Slide 7

Slide 7 text

KUBERNETES RESOURCE REVIEW

Slide 8

Slide 8 text

5 MINUTES KUBERNETES POD ▸ A pod (as in a pod of whales or pea pod) is a group of one or more containers (such as Docker containers) ▸ with shared storage/network, ▸ and a specification for how to run the containers.

Slide 9

Slide 9 text

5 MINUTES KUBERNETES REPLICATION CONTROLLER ▸ A ReplicationController ensures that a specified number of pod replicas are running at any one time. In other words, a ReplicationController makes sure that a pod or a homogeneous set of pods is always up and available.with shared storage/network,

Slide 10

Slide 10 text

5 MINUTES KUBERNETES REPLICASET ▸ ReplicaSet is the next-generation Replication Controller. The only difference between a ReplicaSet and a Replication Controller right now is the selector support. ▸ Difference: ReplicaSet supports the new set-based selector requirements whereas a Replication Controller only supports equality-based selector requirements.

Slide 11

Slide 11 text

5 MINUTES KUBERNETES DEPLOYMENT ▸ A Deployment controller provides declarative updates for Pods and ReplicaSets. ▸ You describe a desired state in a Deployment object, and the Deployment controller changes the actual state to the desired state at a controlled rate. ▸ You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments.

Slide 12

Slide 12 text

OPERATION DEBUGGING KUBERNETES

Slide 13

Slide 13 text

VIKUBE KUBERNETES VERBS ▸ kubectl create ▸ kubectl delete ▸ kubectl get ▸ kubectl edit ▸ kubectl replace ▸ kubectl patch

Slide 14

Slide 14 text

kubectl get pods 取得現在在預設名稱空間中正在運⾏行行的 Pods CHECK PODS

Slide 15

Slide 15 text

kubectl get pvc 檢查現在可使⽤用的 Persistent Volume Claim CHECK PERSISTENT VOLUME CLAIM

Slide 16

Slide 16 text

kubectl get pods -o wide 取得現在正在運⾏行行的 Pods 以及其 IP 與正在運⾏行行的 Node CHECK PODS WITH IP AND NODES

Slide 17

Slide 17 text

kubectl get pods -o wide \ --all-namespaces 取得現在所有名稱空間中正在運⾏行行的 Pods 以及其 IP 與正在運⾏行行的 Node CHECK PODS FROM ALL NAMESPACES

Slide 18

Slide 18 text

kubectl get pods -w 監測 Pods 動態 WATCH PODS

Slide 19

Slide 19 text

kubectl logs -c webapp -f nginx-xxx 調閱 Container 紀錄 TAIL CONTAINER LOG

Slide 20

Slide 20 text

kubectl exec -it nginx-xxx /bin/sh 在⽬目前正在運⾏行行中的 Container 中執⾏行行命令 EXECUTE COMMAND IN THE CONTAINER

Slide 21

Slide 21 text

CRASHLOOPBACKOFF!

Slide 22

Slide 22 text

VIKUBE SOP FOR FIXING CRASHLOOPBACKOFF ▸ Check the logs of the containers in the pod ▸ Describe the pod ▸ Check if the volume is available? ▸ Check the events of the pod ▸ Check the availability of the image ▸ Exec into the container and try to reproduce the problem ▸ Check the authentication to the image repository (usually happens to the images on ECS or GCR)

Slide 23

Slide 23 text

VIKUBE TIME WASTED ▸ Copy the target pod name ▸ Enter the describe command and paste the pod name ▸ Enter the logs command and paste the pod name ▸ Enter the exec command and paste the pod name ▸ Get the events and then use the pod name to grep ▸ Or, get the related deployment, statefulset ...

Slide 24

Slide 24 text

VIKUBE SOLUTIONS TO THESE REPEATED COMMANDS ▸ kube-shell ▸ kube-prompt ▸ kubesh

Slide 25

Slide 25 text

All of them requires you to type subcommands

Slide 26

Slide 26 text

I have Vim

Slide 27

Slide 27 text

I have Kubernetes

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

WHAT'S VIKUBE?

Slide 30

Slide 30 text

USE VIM AS THE USER INTERFACE

Slide 31

Slide 31 text

vim -c ":Vikube" All you need is VIM ENTERING VIKUBE

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Live Demo

Slide 37

Slide 37 text

WHY USE VIM?

Slide 38

Slide 38 text

跨平台

Slide 39

Slide 39 text

可遠端執⾏

Slide 40

Slide 40 text

超快

Slide 41

Slide 41 text

超⽅便

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Why can't you Get out of vim?

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Why Is It So Hard?

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

嚇你的

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

HOW DOES IT WORK?

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

VIKUBE VIEWPORTS AND BUFFERS

Slide 52

Slide 52 text

VIKUBE TAB VIEWPORTS AND BUFFERS

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

LEARN VIM IN 5 MINUTES

Slide 55

Slide 55 text

Scope

Slide 56

Slide 56 text

b: g: s: w: t: Buffer Scope Global Scope Script Scope Window Scope Tab Scope

Slide 57

Slide 57 text

b: g: s: w: t: let foo = 1 let let let let foo = 1 foo = 1 foo = 1 foo = 1

Slide 58

Slide 58 text

Function

Slide 59

Slide 59 text

function! Add(x, y) return a:x + a:y endfunction let y = Add(1,2)

Slide 60

Slide 60 text

function! Foo() let x = 0 function! Bar() closure let x += 1 return x endfunction return funcref('Bar') endfunction let F = Foo() echo F()

Slide 61

Slide 61 text

:function {arguments} {name} ( ) range abort closure dict :endfunction When the [abort] argument is added, the function will abort as soon as an error is detected. When the [closure] argument is added, the function can access variables and arguments from the outer scope. This is usually called a closure. When the [dict] argument is added, the function must be invoked through an entry in a |Dictionary|. The local variable "self" will then be set to the dictionary. When the [closure] argument is added, the function can access variables and arguments from the outer scope.

Slide 62

Slide 62 text

Command

Slide 63

Slide 63 text

:w :q :buffers :split :vsplit

Slide 64

Slide 64 text

-buffer -range command! {name} {command} -range=% -range=N -bar -count=N -bang -register The first arguments to the command can be an optional register name The command will only be available in the current buffer {options} Range allowed, the default is the current line Range allowed, the default is the whole file A default N which is specified in the line number position A count (default N) which is specified either in the line number position, or as an initial argument The command can be followed by a "|" and another command. A "|" inside the command argument is not allowed then. The command can take a ! modifier (like :q or :w)

Slide 65

Slide 65 text

Define The Source

Slide 66

Slide 66 text

fun! s:source() let cmd = s:cmdbase() let cmd = cmd . " get " . b:resource_type if b:wide let cmd = cmd . " -o wide" endif if b:all_namespace let cmd = cmd . " --all-namespaces" endif if b:show_all let cmd = cmd . " --show-all" endif redraw | echomsg cmd return system(cmd . "| awk 'NR == 1; NR > 1 {print $0 | \"sort -b -k1\"}'") endf

Slide 67

Slide 67 text

Render The Screen

Slide 68

Slide 68 text

:tabnew

Slide 69

Slide 69 text

:setlocal noswapfile nonumber :setlocal nobuflisted buftype=nofile bufhidden=wipe

Slide 70

Slide 70 text

:setlocal updatetime=2000

Slide 71

Slide 71 text

cal s:render() Script Scope

Slide 72

Slide 72 text

fun! s:render() let save_cursor = getcurpos() if b:source_changed || !exists('b:source_cache') let b:source_cache = s:source() let b:source_changed = 0 endif setlocal modifiable " clear the buffer redraw normal ggdG " draw the result redraw put=out " remove the first empty line redraw normal ggdd endf Data Source Clear the screen and redraw Render the screen Unlock buffer

Slide 73

Slide 73 text

Now, Get Your DevOps Done in Vim

Slide 74

Slide 74 text

github.com/c9s/ vikube.vim

Slide 75

Slide 75 text

THANK YOU