Skip to content

Instantly share code, notes, and snippets.

@mourjo
Created March 3, 2022 10:51
Show Gist options
  • Save mourjo/175dbdd7d77bbd99ca6ba687301b4e17 to your computer and use it in GitHub Desktop.
Save mourjo/175dbdd7d77bbd99ca6ba687301b4e17 to your computer and use it in GitHub Desktop.
Notes of basic definitions (getting started with Elixir and K8s)

Elixir/Erlang

Knowledge dump

  1. Credo: Static analysis tool https://github.com/rrrene/credo
  2. hackney: HTTP client https://github.com/benoitc/hackney
  3. asdf: Version manager (for elixir and others) https://github.com/asdf-vm/asdf-elixir
  4. Mix: Build tool for elixir https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html
  5. Poison JSON encoder tool https://github.com/devinus/poison

TIL

  1. The order of the messages in the mailbox is always kept in the order they arrived. If you use the send/receive primitives of the language the receiving process can choose in which order (to some degree) to process the messages in the mail box.

Docker

Basics

  1. OS level containerization of applications
    1. Similar to virtualization of OS
    2. Without the additional overhead of virtualization
    3. Uses namespaces in Linux to isolate applications without overhead of virtual OSes
  2. Docker hub: Library of available docker images that can be used

Addl nodes

  1. Dockerfile : Used to define a container
  2. .dockerignore : Used to define files that will be ignored by Docker – useful to do something like “COPY . .” which copies everything, but not the ones that are ignored
  3. Docker compose : Used to define multi-container Docker application
    1. This is different from Kubernetes in the assumption that this is used to deploy to a single node (usually for local development) and Kubernetes is used for cluster deployment, and because of that Kubernetes focuses more on the cluster aspect of it (load balancing, replication, availabilty, deployment etc)

Kubernetes

Basic terms

  1. Node: Worker machine on which kubernetes runs
    1. Kubelet: An agent ensuring containers in pods are running
    2. Kube proxy: A set of network rules
  2. Pod: A set of running containers on a node
  3. Container: Executable image (like docker)
  4. Service: Exposes app requests (internal node-to-node) or from outside (load balanced)
  5. Deployment: What does the desired “state” of the service look like? Eg, how many instances? This is done by a file called “deployment file” (yaml or json).
  6. Master: A special nodes that maintains cluster state (number of replicas etc), other nodes are called worker nodes.

Addl Notes

  1. Handles failures / auto rebooting on crash
  2. Rolling updates (with high availabilty even if the number of replicas is 1)
  3. Mini-kube points kubectl to local installation to play around with Kubernetes https://minikube.sigs.k8s.io/docs/start/
  4. Networking in deployment.yml (ports)
    1. Service ports
      1. port : The port for internal communication between pods (this is for something internal like RPC)
      2. targetPort : The internal port to which external traffic is routed (this is on the worker)
      3. nodePort : Port accessible from outside the cluster (this port is usually on the master), this is the port exposed to the client
    2. ContainerPort : This is the port that a container within a pod listens on for traffic, eg port 80 for a default web server, this is where the application will read reqests from. A service forwards traffic to this port for the container to get the request. The targetPort must match to this if this pod expects external traffic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment