Nikon 50mm F1.4

Don’t ever get that. Get anything else. The 50mm F1.8 is a great choice.

Success, Failure, and Mediocrity

Failure brings humility. It develops your character. It helps you laugh at your mistakes and not take things so seriously. Like a plant placed from the shade into sunlight, your growth rate will accelerate 10×.

Knife and Skills

I love a good knife. I love chopping with my knife, and I have no idea why.

The key, I realize, is to hold the knife right. That, and a good knife.

This is my current knife – a Victorinox 8 Inch Chef’s Knife and I love it.

Kubernetes Setup Using Azure ACS Engine - Part II

Continuing on from Part I

Now that we have the acs-engine binary, we can create a template and launch the kubernetes cluster.

Before we proceed, it doesn’t hurt to pull a fresh copy of acs-engine, bootstrap and build it.

$ git clone https://github.com/Azure/acs-engine.git
$ cd acs-engine
$ sudo ./scripts/devenv.sh

Once the bootstrap is complete, build acs-engine as follows:

# make build
# # ./bin/acs-engine
ACS-Engine deploys and manages Kubernetes, Swarm Mode, and DC/OS clusters in Azure

Usage:
  acs-engine [command]

Available Commands:
  deploy        deploy an Azure Resource Manager template
  generate      Generate an Azure Resource Manager template
  help          Help about any command
  orchestrators provide info about supported orchestrators
  upgrade       upgrades an existing Kubernetes cluster
  version       Print the version of ACS-Engine

Flags:
      --debug   enable verbose debug logs
  -h, --help    help for acs-engine

Use "acs-engine [command] --help" for more information about a command.

That’s our prep done. Next, we need to create a template that will generate the deployment templates.

You can find templates that you can use in the examples folder.

Here’s my example that launches a kubernetes cluster within an existing vnet.

Once you have your template ready, you can generate the deployment templates, as follows:

$ ./bin/acs-engine generate examples/kubernetes.json
INFO[0000] Generating assets into _output/k8s...

Your deployment templates will be written to a directory with the dnsPrefix used in your template into the _output directory.

Login to Azure and create a resource group to use for your kubernetes cluster:

$ az login
$ az group create -n k8s -l westus2

Validate the generated templates:

$ cd _output/k8s
$ az group deployment validate -g k8s --template-file azuredeploy.json --parameters @./azuredeploy.parameters.json

Once the template has been validated, deploy as follows:

$ az group deployment create -g k8s --template-file azuredeploy.json --parameters @./azuredeploy.parameters.json

The deployment should take a while. My last one took around 9 minutes.

Once the deployment is complete, copy the kube config from the acs-engine folder to your .kube directory.

$ mkdir ~/.kube
$ cp _output/k8s/kubeconfig/kubeconfig.westus2.json ~/.kube/config

Once the config is in place, ensure you have the kubectl binary installed. If you don’t have it installed, you an follow the instructions here to install it.

Once it’s installed, you can get a list of the nodes:

$ kubectl get nodes
NAME                        STATUS    ROLES     AGE       VERSION
k8s-master-14054749-0       Ready     master    3d        v1.8.2
k8s-master-14054749-1       Ready     master    3d        v1.8.2
k8s-master-14054749-2       Ready     master    3d        v1.8.2
k8s-workerpool-14054749-0   Ready     agent     3d        v1.8.2
k8s-workerpool-14054749-1   Ready     agent     3d        v1.8.2
k8s-workerpool-14054749-2   Ready     agent     3d        v1.8.2
k8s-workerpool-14054749-3   Ready     agent     3d        v1.8.2

Using Azure Container Registry with Kubernetes

Instead of specifying this directly in your configuration, we’ll use the concept of k8s secrets. You decouple the k8s object from the registry configuration by just referencing the secret by it’s name. But first, let’s create a new k8s secret.

$ kubectl create secret docker-registry <SECRET_NAME> --docker-server <REGISTRY_NAME>.azurecr.io --docker-email <YOUR_MAIL> --docker-username=<SERVICE_PRINCIPAL_ID> --docker-password <YOUR_PASSWORD>