Final thoughts on Kubernetes
In production, define deployments to setup replicas in case of failure.
Modify deployments.
Rolling updates.
Works ideally with this stack, and might need tweaking if changing any of the below components:
- Any continuous integration build tool
- Container technology : Docker
- Kubernetes
- Cloud platform : Google Cloud Platform
1 | kubectl describe deployments [name] |
Scalable microservices - Part 3
Today infrastructure is more about choose of tools rather than developing yourself. IT today is about higher level services.
Kubernetes is an abstraction for containers. It enables to treat a entire cluster like a single machine.
Pod have an IP address and can access volumes, they are apps containers.
Using nginx to reverse proxy the app in HTTPS:
Monitoring and Health checks : https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/
Configuration: http://kubernetes.io/docs/user-guide/configmap/
Secrets: http://kubernetes.io/docs/user-guide/secrets/
Configuration and secrets files are accessed through mounted volumes defined in the kubernetes YAML configuration file after loading the secrets
and configmap
on the master node.
Service is another level of abstraction: it is a set of identical pods.
Services: http://kubernetes.io/docs/user-guide/services/
Sample configuration files: https://github.com/udacity/ud615/tree/master/kubernetes
###Useful commands
Create a Kubernetes cluster
1 | gcloud container clusters create k0 |
Create a pod.
1 | kubectl create -f [yaml-file] |
Port forwarding between the cluster and the master machine.
1 | kubectl port-forward monolith 10080:80 |
Executing from within the container
1 | kubectl exec monolith --stdin --tty -c monolith /bin/sh |
Setting nginx configuration and TLS keys.
1 | kubectl create secret generic [name] --from-file=[folderls] |
Create a service
1 | kubectl create -f [yaml-file of type NodePort] |
References
Scalable microservices - Part 2
Lesson 2 tells us how to use Docker and run an instance on Google Cloud Platform.
Using Google Compute Engine we first create a new linux image, connect to it through SSH. Then run docker containers on top of it.
Containers main advantage is that you can run two virtual machines on the same operating system. You can retrieve image from a repo and manage instances with the docker
command line tool like you would with a regular UNIX process.
Docker images can be either downloaded or customly built using dockerfiles. Developers responsibility in this case is to delivery the application AND the configuration file for the container.
The docker images then can be sent in a public or private registry for reuse. Most notables ones are Docker Hub, Quay, Google Cloud Registry.
Useful commands
Creating an instance called ubuntu
on Compute Engine
1 | gcloud compute instances create ubuntu --image-project ubuntu-os-cloud --image ubuntu-1604-xenial-v20160420c |
SSH connecting to it
1 | gcloud compute ssh ubuntu |
Running nginx on the remote host.
1 | michel@ubuntu:~$ sudo apt-get install nginx |
Installing docker on the operating system.
1 | sudo apt-get install docker.io |
Listing docker images and downloading nginx image.
1 | michel@ubuntu:~$ docker images |
Running an image. The image is pulled off automatically if not found locally.
1 | michel@ubuntu:~$ docker run -d nginx:1.10.0 |
Checking which instance is running
1 | michel@ubuntu:~$ docker ps |
Stoping a docker instance
1 | # Stoping instance |
Get the ip address of a docker instance
1 | docker inspect [container id] |
Sample Dockerfile defining a base image (Alpine Linux),
1 | FROM alpine:3.1 |
Then build the docker image and run it as told above.
1 | docker build -t hello:1.0.0 |
Pushing an image on a registry
1 | docker tag hello:1.0.0 username/hello:1.0.0 |
To check later
- GCP Documentation - gcloud compute instances create
- The list of images available can be obtained with
gcloud compute images list
:centos
,cos
,debian
,rhel
,suse
,suse-sap
,ubuntu-os
,windows
,windows-sql
…
- The list of images available can be obtained with
- Docker docs - Deploy a registry server
Scalable microservices - Part 1
Today, I am learning more about microservices, a subject software architect Martin Fowler has been writing about a lot in his personal blog.
Kubernetes looks like a cool technology. Google, who supports it, has an online course Scalable Microservices with Kubernetes intended for both devops and developers.
The course has 4 lessons of 2 hours each for the following topics:
- Introduction to Microservices
- Building the Containers with Docker
- Kubernetes
- Deploying Microservices
Here are my notes for the lesson 1 Introduction to microservices:
The course uses the following technology to demonstrate : Docker, Go language, Google Cloud Container Engine.
The software industry is pressuring developers to release more often and more quickly. Microservices allows them to do with a simplified lifecycle but require tools to use automation and infrastructure capacity to their limits.
Lesson 1 asks us build a Go project from Github which is a webserver doing authentication and building separate microservices from it.
More stuff coming tomorrow with Lesson 2.
To check later
Kelsey Hightower, main contributor of Kubernetes at Google has written a more comprehensive tutorial on GitHub.
Writing a book
Today I found out some interesting resources for book authoring.
Software books writer Scott Meyers gives developers tips on how to manage such a project.
As Tim Ferris wrote and proved with the 4-Hour workweek, writing a book can be a one man business muse.
Modern tools such as Asciidoc from O'Reilly can facilitate the workflow so that it very much looks like the workflow of software engineering with build and continuous integration aspects.References
Accounting from the CLI with Ledger
Doing basic balanced accounting from the command line with Ledger CLI.
Ledger is an un-opinionated tool for text logging every financial transaction you make.
Logging directly from the Atom text editor with the language-ledger plugin.
Correcting mistakes with the debugger and generating a detailed report.
Summary by topic to see how much I have spent so far for lunch at work.
Using JIRA from the CLI
Some cool stuff you can do with JIRA inside the command line.