Tuan Anh

container nerd. k8s || GTFO

Getting started with Kubernetes

Just some of my notes while learning about Kubernetes. I use Google Compute Engine to install mine.

Installation

To install Kubernetes, it’s as easy as copy and paste the below command

curl -sS https://get.k8s.io | bash

If you want to customize some default options, you can edit environment variables

curl -sS https://get.k8s.io | MULTIZONE=true KUBERNETES_PROVIDER=gce KUBE_GCE_ZONE=asia-east1-b NUM_NODES=4 bash

There’re more environment variables that you can take a look in kubernetes/cluster/gce/config-default.sh

It’s recommended to export it to environment instead of passing it to the command as above as taking the cluster down will be easier.

export KUBERNETES_PROVIDER=gce
export KUBE_GCE_ZONE=asia-east1-b
export NODE_SIZE=n1-highcpu-2
export MULTIZONE=true
export NUM_NODES=2
export KUBE_AUTOSCALER_MIN_NODES=2
export KUBE_AUTOSCALER_MAX_NODES=10
export KUBE_ENABLE_CLUSTER_AUTOSCALER=true
export PREEMPTIBLE_NODE=true

Add more nodes to cluster

KUBE_USE_EXISTING_MASTER=true KUBERNETES_PROVIDER=gce KUBE_GCE_ZONE=asia-east1-b NUM_NODES=2 ./kube-up.sh

Bring down cluster

KUBERNETES_PROVIDER=gce KUBE_GCE_ZONE=asia-east1-b ./kube-down.sh

Deploying applications on Kubernetes

We use Docker at work and deploying Docker containers in Kubernetes is a breeze.

docker build -t gcr.io/$PROJECT_ID/app-name:v1 .
gcloud docker push gcr.io/$PROJECT_ID/app-name:v1

# update
kubectl rolling-update <replication-controller> --image=gcr.io/$PROJECT_ID/app-name:v2

Expose the service to external

kubectl expose deployment <deployment-name> --type="LoadBalancer"

Enable autoscale

kubectl autoscale rc <replication-controller> --min 3 --max=10 --cpu-percent=60

The state of tiling window manager for OS X

kwm seems to be the best - feature-wise but it requires too many hacking to be done. I’ve given up at some point and just went back with Amethyst. Slate and Hammerspoon aren’t really what I’m looking for.


Should I use yarn?

Myles Borins (@thealphanerd) recently ran citgm with yarn, and shared the results. It was 25 minutes faster than npm, but 20 modules failed to install. Yarn is not a drop in replacement.

Some areas where issues arise:

  • Reliance on npm-shrinkwrap.json
  • Private modules on npm
  • Modules backed by self-signed certificates
  • Exotic dependencies declarations like .zip or shorthand urls
  • Edge case issues on specific OSes, like Windows
  • Pre- and post-script hooks don’t work like they do in npm
  • Scripts that rely on npm environmental variables
link bài gốc

Breaking changes between v4 LTS and v6 LTS

I’ve just migrated 4 big applications at work from Node.js v4 to Node.js v6 LTS. 3 of them require some little changes and 1 with no changes at all since it’s using Babeljs.

You can view the complete list of breaking changes from v4 to v6 here on GitHub.

link bài gốc

AMP'ed

This site is now AMP-friendly

The cached version of the page is up at this url below, remove the s if your site isn’t on HTTPS.

https://cdn.ampproject.org/c/s/tuananh.org/2014/09/01/a-poor-mans-seedbox-for-15-dollars-a-year/

Xbox Scorpio vs PS Neo

If this were true, I will definitely upgrade to Scorpio. The difference in GPU power is huge!!


mincss

the world’s smallest (995 bytes) CSS framework http://mincss.com

In an attempt to make my website fast again.

Custom font no more.

link bài gốc

How to import csv file in MySQL

If your MySQL server started with --secure-file-priv option, you will have to move your csv file to that specific folder first.

To check where that folder is, first run SHOW VARIABLES LIKE "secure_file_priv";

Move your csv file to that folder and issue the following command in MySQL console. Remember to replace /var/lib/mysql-files/ with your secure_file_priv path variable.

LOAD DATA INFILE "/var/lib/mysql-files/data.csv" \
INTO TABLE my_table \
COLUMNS TERMINATED BY ',' \
OPTIONALLY ENCLOSED BY '"' \
ESCAPED BY '"' \
LINES TERMINATED BY '\n' \
IGNORE 1 LINES;

Do’s and Don’ts of AWS Lambda

TJ Holowaychuk writes about Do and Don’ts of AWS Lambda.

link bài gốc

No More Vietnam

Nixon’s retrospective on Vietnam war, 10 years later.

link bài gốc