anchor.diff:  = Create Kubernetes cluster using kops
   :toc:
   
  -This tutorial will walk you through how to install a Kubernetes cluster using kops on AWS.
  -
  -https://github.com/kubernetes/kops[kops], short for Kubernetes Operations, is a set of tools for installing, operating, and deleting Kubernetes clusters in the cloud. A rolling upgrade of an older version of Kubernetes to a new version can also be performed. It also manages the cluster add-ons. After the cluster is created, the usual kubectl CLI can be used to manage resources in the cluster.
  +This tutorial will walk you through how to install a Kubernetes cluster on AWS using kops.
  +
  +https://github.com/kubernetes/kops[kops], short for Kubernetes Operations, is a set of tools for installing, operating, and deleting Kubernetes clusters in the cloud. It can also perform rolling upgrades from older versions of Kubernetes to newer ones. kops also manages the cluster add-ons. After the cluster is created, the usual link:getting-started[kubectl CLI] can be used to manage resources in the cluster.
  +
  +kops is available on Mac OSX, Linux, or the Windows 10 Linux Subsystem. 
   
   == Install kops
   
  
positive.code: 
  Latest and early versions of kops can be downloaded from https://github.com/kubernetes/kops/releases.
  
  In addition, if not already installed, you also need kubectl CLI to manage the resources on Kubernetes cluster. This is explained link:../getting-started#download-and-install[].
  
  === Configure kops
  
  kops uses a public SSH key while creating a cluster. The location of this file defaults to `~/.ssh/id_rsa.pub`. Please generate an SSH key using `ssh-keygen` command.
  
  Alternatively, you can use the `--ssh-public-key` option to specify a custom location. More details about kops security can be found in the https://github.com/kubernetes/kops/blob/master/docs/security.md[kops docs].
  
  
  == IAM user permission
  
  Make sure the latest version of http://docs.aws.amazon.com/cli/latest/userguide/installing.html[AWS CLI]
  is installed. User permissions used in this workshop must have these http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html[IAM policies] attached.
  
      AmazonEC2FullAccess
      AmazonRoute53FullAccess
  
negative.code: 
  == S3 bucket to store Kubernetes config
  
  kops needs a "`state store`" to store the configuration information of the cluster.  For example: how many nodes in the cluster, the instance type of each node, and the Kubernetes version. The state is stored during the initial cluster creation. Any subsequent changes to the cluster are also persisted to this store. As of now, Amazon S3 is the only supported storage mechanism. Create an S3 bucket and pass that to the kops CLI during cluster creation.
  
  NOTE: The bucket name must be unique otherwise you will encounter an error on deployment. We will use an example bucket name of `example-state-store-` and add a randomly generated string to the end.
  
      # create variables for bucket, state store and cluster names
      $ export S3_BUCKET=example-state-store-$(cat /dev/random | LC_ALL=C tr -dc "[:alpha:]" | tr '[:upper:]' '[:lower:]' | head -c 32)
      $ export KOPS_STATE_STORE=s3://${S3_BUCKET}
  
      # use aws cli to create bucket
      $ aws s3 mb $KOPS_STATE_STORE
  
      # enable versioning and export
      $ aws s3api put-bucket-versioning \
        --bucket $S3_BUCKET \
        --versioning-configuration \
        Status=Enabled
  
  == Create the cluster
  
  The kops CLI can be used to create a highly available cluster, with multiple master nodes spread across multiple Availability Zones. Workers can be spread across multiple zones as well. Some of the tasks that happen behind the scene during cluster creation are:
  
  - Provisioning EC2 instances
  - Setting up AWS resources such as Networking, Auto Scaling Groups, IAM policies, and Security Groups
  - Installing Kubernetes
  
  When setting up a cluster you have two options on how the nodes in the cluster communicate:
  