Bangalore Kubernetes May 2019


Hrishikesh Shinde talked about "Intro to sample controller"

He introduced to following github repositories

https://github.com/kubernetes/client-go
Go clients for talking to a kubernetes cluster. It implements watch. 

https://github.com/kubernetes/apimachinery
Scheme, typing, encoding, decoding, and conversion packages for Kubernetes and Kubernetes-like API objects. It is used for filter. 

https://github.com/kubernetes/api
Schema of the external API types that are served by the Kubernetes API server.

https://github.com/kubernetes/code-generator 
Golang code-generators used to implement Kubernetes-style API types.

Hrishikesh further explained his own code repository. 

https://github.com/hrishin/podset-operator
Build replicaset kind of k8s object. Build controller from scratch to demonstrate  KuberBuilder or Operator SDK frameworks

We need to develop boiler plate code at path /pkg/apis/demo/v1alpha1/
1. doc.go
2. register.go
3. types.go

The controller takes 3 actions

1. Check for desire state
2. Strive for desire state
3. Update about resourse status using AvailableReplicaStatus variable. 

Controller uses various data structures (modules) like informer, listers, reflect etc. 

Hrishikesh suggested books like
https://www.amazon.com/Programming-Kubernetes-Developing-Native-Applications/dp/1492047104 and others. 

Slide deck

Nikhil Tomas talked about "Intro to operator SDK"

I have updated my blog "K8s Operator" with useful details. 

- quick start: https://github.com/operator-framework/operator-sdk#quick-start

- user guide: https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md

Slide deck

Suraj Narwade gave valuable tips about CKA examNeependra Khare also added some more points. 

One need to focus on concepts and tasks, by studying them four to five times. 

Also study 4 to 5 times the course
Kubernetes - the hard way
https://github.com/kelseyhightower/kubernetes-the-hard-way
https://github.com/kinvolk/kubernetes-the-hard-way-vagrant

Practise, Practise and Practise
Use GCP, AWS, minkube on Linux box or online like Katacoda and CloudYuga
Also refer my blog : Kubernetes Practicals 

There will be only one termianl. So better get familar with tmux

They suggested book : Kubernetes up and runningdive into the future of infrastructure

At begining of exam set alias for various frequently used kubectl commands. 
Also set auto completion of commands
  
Few useful blogs/URLs
https://kubernauts.dev/
https://suraj.pro/
https://suraj.io/

Suraj's slide deck

Neependra mentioned about upcomign webinar from CloudYuga

Meetup Reference
https://www.meetup.com/kubernetes-openshift-India-Meetup/events/261130273/

Python : collections module


Python has general purpose data types like dict, list, set, tuple. Collections module has following additional useful datatype

1. namedtuple

Useful to contruct objects

2. Counter

It works with string, list, and sentence. Sentence should be split with ' ' to convert into list of words. 

suppose

c = Counter(list)

then 
c.values() gives only count. So sum(c.values()) givestotal of all counts 
c.most_common() sort based on frequency and return list of tuples
c.most_common()[0][0] gives the item with maximum occurance
c.most_common()[:-2:-1] gives the item with maximum occurance
c.most_common()[:-n-1:-1]  gives the item with n least common elements 
c.substract(d) Here is d is another Counter. The result will be frequency for each element will be substraced as per its frequency in d. 

3. defaultdict(object)
It gives default empty dictionary. 

4. OrderedDict

OrderedDict(sorted(d.items(), key=lambda t: t[0])) to sort with key
OrderedDict(sorted(d.items(), key=lambda t: t[1])) to sort with value

5. deque

To add : append(), appendleft()
To remove : pop() , popleft()
to count: count()
To insert as specific index i : insert(i, x)


6. ChainMap
This is to join 2 dict as a list with 2 elements as dict

Open Container Initiative


1. Image specification

An OCI Image is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime

https://github.com/opencontainers/image-spec/blob/master/spec.md

1.1 manifest
It contains metadata (annotation = key, value pair) about the contents and dependencies of the image 
JSON file
https://github.com/opencontainers/image-spec/blob/master/manifest.md
https://docs.docker.com/engine/reference/commandline/manifest/

1.2 image index (optional)
For platform specific version of image

1.3 image layout

1.4 file system layers

1.5 configuration
JSON file https://github.com/opencontainers/image-spec/blob/master/config.md

1.6 conversion

1.7 descriptor 

Tools

2. Distribution specification

It describes the API that might be used by a registry to distribute images, to easily 
- share, 
- search, 
- obtain and 
- verify 
container image

https://github.com/opencontainers/distribution-spec/blob/master/spec.md

It is implemented by Docker Registry and https://github.com/atlaskerr/stori

3. Runtime Specification

It aims to specify the configuration, execution environment, and lifecycle of a container.
aims to specify the configuration, execution environment, and lifecycle of a container.

runc is Runtime specification OCI implementation 

LifeCycle


3.1 create command
3.2 create runtime environment using config.json
3.3 start command
3.4 pre-start hook
3.5 user program specified by process
3.6 post-start hook
3.7 exit due to exit, error, kill, crash
3.8 delete
3.9 destroy container. undo create
3.10 post-stop hook

https://github.com/opencontainers/runtime-spec/blob/master/glossary.md

CRI = Container Runtime Interface = protocol buffers + gRPC APIs + Libraries

Virtual Machine


Operating System level virtualization / containers /  virtual private servers / virtual environments (VEs) / partitions / jails

  • Docker, 
  • Solaris Containers, 
  • OpenVZ, 
  • Linux-VServer, 
  • LXC, 
  • AIX Workload Partitions, 
  • Parallels Virtuozzo Containers, and 
  • iCore Virtual Accounts.
with lx zones on Solaris, one can run old Solaris and Linux inside lx zones container.

Hardware-assisted virtualization 
  • KVM, 
  • VMware Workstation, 
  • VMware Fusion, 
  • Hyper-V, 
  • Windows Virtual PC, 
  • Xen, 
  • Parallels Desktop for Mac, 
  • Oracle VM Server for SPARC, 
  • VirtualBox and 
  • Parallels Workstation.
Process Virtual Machine / application virtual machine / Managed Runtime Environment (MRE)

  • Java JRE Java Runetime Environment : JVM
  • .NET framework CLR Common Language Runetime : Parrot Virtual Machine
System Virtual Machine
  • using hypervisor