Kubernetes – Kubernetes with CoreOS

Now that we understand the benefits, let’s take a look at a Kubernetes cluster using CoreOS. The documentation supports a number of platforms, but one of the easiest to spin up is AWS with the CoreOS CloudFormation and CLI scripts.

If you are interested in running Kubernetes with CoreOS on other platforms, you can find more details in the CoreOS documentation at https://coreos.com/kubernetes/docs/latest/. You can find the latest instructions for AWS at https://coreos.com/kubernetes/docs/latest/kubernetes-on-aws.html.

You can follow the instructions covered previously in this chapter to spin up Kubernetes on CoreOS. You’ll need to create a key pair on AWS, and also specify a region, cluster name, cluster size, and DNS to proceed.

In addition, we will need to create a DNS entry, and will require a service such as Route 53 or a production DNS service. When following the instructions, you’ll want to set the DNS to a domain or sub-domain on which you have permission to set up a record. We will need to update the record after the cluster is up and running and has a dynamic endpoint defined. 

There you have it! We now have a cluster running CoreOS. The script creates all the necessary AWS resources, such as Virtual Private Clouds (VPCs), security groups, and IAM roles. Now that the cluster is up and running, we can get the endpoint with the status command and update our DNS record as follows:

$ kube-aws status

Copy the entry listed next to Controller DNS Name in the output from the preceding command, and then edit your DNS records to get the domain or sub-domain you specified earlier to point to this load balancer.

If you forget which domain you specified or need to check on the configuration, you can look in the generated kubeconfig file with your favorite editor. It will look something like this:

apiVersion: v1
kind: Config
clusters:
- cluster:
    certificate-authority: credentials/ca.pem
    server: https://coreos.mydomain.com
  name: kube-aws-my-coreos-cluster-cluster
contexts:
- context:
    cluster: kube-aws-my-coreos-cluster-cluster
    namespace: default
    user: kube-aws-my-coreos-cluster-admin
  name: kube-aws-my-coreos-cluster-context
users:
- name: kube-aws-my-coreos-cluster-admin
  user:
    client-certificate: credentials/admin.pem
    client-key: credentials/admin-key.pem
current-context: kube-aws-my-coreos-cluster-context

In this case, the server line will have your domain name.

If this is a fresh box, you will need to download kubectl separately, as it is not bundled with kube-aws:
$ wget https://storage.googleapis.com/kubernetes-release/release/v1.0.6/bin/linux/amd64/kubectl

We can now use kubectl to see our new cluster:

$ ./kubectl --kubeconfig=kubeconfig get nodes

We should see a single node listed with the EC2 internal DNS as the name. Note kubeconfig, this tells Kubernetes the path to use the configuration file for the cluster that was just created instead. This is also useful if we want to manage multiple clusters from the same machine.

Comments are closed.