github.com/googlecloudplatform/kubernetes-workshops@v0.0.0-20180501174420-d8199445b2c3/bring-up/cloud.md (about) 1 # Cloud Cluster Bring-Up 2 3 ## Prerequisites 4 5 A cloud account with a supported cloud provider. 6 7 * [GCP](http://cloud.google.com/) 8 * AWS 9 10 ## Lab 11 12 Download the `kubernetes.tar.gz` latest binary release: 13 14 ``` 15 curl -LO https://github.com/kubernetes/kubernetes/releases/download/v1.2.4/kubernetes.tar.gz 16 ``` 17 18 Extract 19 20 ``` 21 tar -xzvf kubernetes.tar.gz 22 cd kubernetes/ 23 ``` 24 25 ## Configure your cloud defaults 26 27 ### GCP 28 29 Edit `cluster/gce/config-default.sh` in your favorite text editor. The 30 defaults are all fine, but you may wish to customize your cluster: 31 32 | Variable | Description | 33 | --- | --- | 34 | ZONE | Set this to whichever zone you wish. | 35 | NODE_SIZE | VM size of individual nodes. | 36 | MASTER_SIZE | VM size of the master. | 37 | NUM_NODES | Number of node VMs to create. | 38 39 > Note: These can be set by environment variable as well. 40 41 Also, specify that you want kubernetes to start on GCP, we'll use the 42 environment variable here: 43 44 ``` 45 export KUBERNETES_PROVIDER=gce 46 ``` 47 48 ### AWS 49 50 Edit `cluster/aws/config-default.sh` in your favorite text editor. By 51 default, the script will provision a new VPC and a 4 node k8s cluster 52 in us-west-2a (Oregon) with EC2 instances running on Ubuntu. 53 54 Also, specify that you want kubernetes to start on AWS, we'll use the 55 environment variable here: 56 57 ``` 58 export KUBERNETES_PROVIDER=aws 59 ``` 60 61 ## Configure your cloud-specific prerequisites 62 63 ### GCP 64 65 1. Go to the 66 [Google Cloud Platform Console](https://console.cloud.google.com/project/_/compute/instances?_ga=1.92147801.233469832.1449873262). 67 When prompted, select an existing project or create a new project. 68 2. Follow the prompts to set up billing. If you are new to Google 69 Cloud Platform, you have 70 [free trial](https://cloud.google.com/free-trial/) credit to pay 71 for your instances. 72 73 > Note: If you are using Cloud Shell, you don't need to do the below steps. 74 75 3. Download and extract the 76 [Google Cloud SDK](https://cloud.google.com/sdk/), which includes 77 the `gcloud` command line tool. It will be extracted to the 78 `google-cloud-sdk` directory. 79 4. Run the install script to add SDK tools to your path, enable 80 command completion in your bash shell, and/or and enable usage 81 reporting. 82 83 ``` 84 ./google-cloud-sdk/install.sh 85 ``` 86 87 5. Run gcloud init to initialize the SDK: 88 89 90 ``` 91 gcloud init 92 ``` 93 94 ### AWS 95 96 1. You need an AWS account. Visit 97 [http://aws.amazon.com](http://aws.amazon.com) to get started 98 2. Install and configure 99 [AWS Command Line Interface](http://aws.amazon.com/cli) 100 3. You need an AWS 101 [instance profile and role](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) 102 with EC2 full access. 103 104 This script use the 'default' AWS profile by default. You may 105 explicitly set AWS profile to use using the `AWS_DEFAULT_PROFILE` 106 environment variable: 107 108 ``` 109 export AWS_DEFAULT_PROFILE=myawsprofile 110 ``` 111 112 ## Start the cluster 113 114 Now everything should be set up to start your cluster 115 116 ``` 117 cluster/kube-up.sh 118 ``` 119 120 Cluster bring-up can take a while, once all the VMs are created, the 121 script will wait for the cluster to start up and self provision, you 122 will see: 123 124 ``` 125 Waiting up to 300 seconds for cluster initialization. 126 127 This will continually check to see if the API for kubernetes is reachable. 128 This may time out if there was some uncaught error during start up. 129 ``` 130 131 And then, once successful communication and validation has taken place, look for: 132 133 ``` 134 Cluster validation succeeded 135 ``` 136 137 ## Setup kubectl 138 139 Great! Now `kubectl` is configured with authentication to communicate 140 with your cluster. This is set up for you in your `~/.kube/config` 141 file. 142 143 > Note: If you are using GCP and have `gcloud` installed, you will 144 > have the latest release of `kubectl` installed in your path. 145 > You can skip the rest of this section. 146 147 The release tarball contains various builds of `kubectl` as 148 `platforms/<os>/<arch>/kubectl`. There is also a helper script under 149 `cluster/kubectl.sh` which will identify and run the proper version. Do 150 one of the following: 151 152 * Add the proper `platforms/<os>/<arch>/kubectl` binary to your path. 153 * Use `cluster/kubectl.sh` in lieu of `kubectl`. 154 155 Run `kubectl` or `cluster/kubectl.sh` and verify communication with the 156 cluster: 157 158 ``` 159 kubectl cluster-info 160 ``` 161 162 You should see a list of url endpoints for the cluster. 163 164 165 ## Cleanup 166 167 Don't do it yet, but shutting down the cluster is simply: 168 169 ``` 170 cluster/kube-down.sh 171 ```