Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vikube: Operate Kubernetes in Vim

Vikube: Operate Kubernetes in Vim

Yo-An Lin

June 20, 2018
Tweet

More Decks by Yo-An Lin

Other Decks in Technology

Transcript

  1. 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.
  2. 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.
  3. Minion kubelet Pod Container Master API Server Replication Controller Scheduler

    Pod Container Minion kubelet Pod Container Pod Container Minion kubelet Pod Container Pod Container
  4. 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.
  5. 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,
  6. 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.
  7. 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.
  8. VIKUBE KUBERNETES VERBS ▸ kubectl create ▸ kubectl delete ▸

    kubectl get ▸ kubectl edit ▸ kubectl replace ▸ kubectl patch
  9. 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)
  10. 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 ...
  11. b: g: s: w: t: let foo = 1 let

    let let let foo = 1 foo = 1 foo = 1 foo = 1
  12. function! Foo() let x = 0 function! Bar() closure let

    x += 1 return x endfunction return funcref('Bar') endfunction let F = Foo() echo F()
  13. :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.
  14. -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)
  15. 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
  16. 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