@@ -12,35 +12,35 @@ Download the [latest](https://github.com/kubernetes/kops/releases/latest) versio
1212#### macOS
1313
1414``` bash
15- curl -sSL https://github.com/kubernetes/kops/releases/download/1.5.1/kops-darwin-amd64 -O
16- chmod +x kops-darwin-amd64
17- sudo mv kops-darwin-amd64 /usr/local/bin
15+ $ curl -sSL https://github.com/kubernetes/kops/releases/download/1.5.1/kops-darwin-amd64 -O
16+ $ chmod +x kops-darwin-amd64
17+ $ sudo mv kops-darwin-amd64 /usr/local/bin
1818```
1919
2020
2121#### linux
2222
2323``` bash
24- curl -sSL https://github.com/kubernetes/kops/releases/download/1.5.1/kops-linux-amd64 -O
25- chmod +x kops-darwin-amd64
26- sudo mv kops-darwin-amd64 /usr/local/bin
24+ $ curl -sSL https://github.com/kubernetes/kops/releases/download/1.5.1/kops-linux-amd64 -O
25+ $ chmod +x kops-darwin-amd64
26+ $ sudo mv kops-darwin-amd64 /usr/local/bin/kops
2727```
2828
29- For more information see the official [ kops installation guide] ( https://github.com/kubernetes/kops/blob/master/docs/aws.md )
29+ For more information see the official [ kops installation guide] ( https://github.com/kubernetes/kops/blob/master/docs/aws.md ) .
3030
3131## Validate kops is installed
3232
33- ```
34- kops version
33+ ``` bash
34+ $ kops version
3535Version 1.5.1
3636```
3737
3838## Install kubectl if you haven't done so yet
3939
40- ```
41- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl
42- chmod +x kubectl
43- sudo mv kubectl /usr/local/bin
40+ ``` bash
41+ $ curl -LO https://storage.googleapis.com/kubernetes-release/release/$( curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) /bin/darwin/amd64/kubectl
42+ $ chmod +x kubectl
43+ $ sudo mv kubectl /usr/local/bin/kops
4444```
4545
4646
@@ -52,40 +52,32 @@ In order to build clusters within AWS we'll create a dedicated IAM user for
5252` kops ` . This user requires API credentials in order to use ` kops ` . Create
5353the user, and credentials, using the [ AWS console] ( http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html ) .
5454
55- The ` kops ` user will require the following IAM permissions to function properly:
55+ The ` kops ` user will require the following IAM permissions to function properly
5656
5757 - AmazonEC2FullAccess
58+ - This is used to deploy to instances in EC2
5859 - AmazonRoute53FullAccess
60+ - This is used so kops can automatically create friendly DNS records for your cluster resources
5961 - AmazonS3FullAccess
62+ - This is used to store meta configuration about your cluster. We will need read/write here to use S3 as a virtual filesystem in kops.
6063 - IAMFullAccess
64+ - This is used because kops will create new IAM users for some of it's resources. Those resources will have permissions managed securely by kops.
6165 - AmazonVPCFullAccess
66+ - This used to create a VPC which serves as the foundation of all networking components in kops. Without a VPC, kops wouldn't be able to deploy any resources dependent on a network.
6267
6368#### Create the IAM user from the command line
6469
6570``` bash
66- aws iam create-group --group-name kops
67-
68- export arns="
69- arn:aws:iam::aws:policy/AmazonEC2FullAccess
70- arn:aws:iam::aws:policy/AmazonRoute53FullAccess
71- arn:aws:iam::aws:policy/AmazonS3FullAccess
72- arn:aws:iam::aws:policy/IAMFullAccess
73- arn:aws:iam::aws:policy/AmazonVPCFullAccess"
74-
75- for arn in $arns ; do aws iam attach-group-policy --policy-arn " $arn " --group-name kops; done
76-
77- aws iam create-user --user-name kops-user
78-
79- aws iam add-user-to-group --user-name kops-user --group-name kops
80-
81- aws iam create-access-key --user-name kops-user
71+ $ curl -O https://raw.githubusercontent.com/kubernetes/kops/master/hack/new-iam-user.sh
72+ $ sh new-iam-user.sh < group> < user>
73+ $ aws iam list-users
8274```
8375
8476Note the * SecretAccessKey* and * AccessKeyID* so you can enter them in the following commands
8577
8678``` bash
87- aws configure # Input your credentials here
88- aws iam list-users
79+ $ aws configure # Input your credentials here
80+ $ aws iam list-users
8981```
9082
9183
@@ -118,12 +110,11 @@ look like `etcd-us-east-1c.internal.clustername.kubernetes.example.com`
118110This is copying the NS servers of your ** SUBDOMAIN** up to the ** PARENT**
119111domain in Route53. To do this you should:
120112
121-
122113``` bash
123- ID=$( uuidgen) && aws route53 create-hosted-zone --name subdomain.example.com --caller-reference $ID | jq .DelegationSet.NameServers
114+ $ ID=$( uuidgen) && aws route53 create-hosted-zone --name subdomain.example.com --caller-reference $ID | jq .DelegationSet.NameServers
124115```
125116
126- * Note your ** PARENT** hosted zone id
117+ * Note your ** PARENT** hosted zone ID
127118
128119``` bash
129120# Note: This example assumes you have jq installed locally.
@@ -134,7 +125,7 @@ aws route53 list-hosted-zones | jq '.HostedZones[] | select(.Name=="example.com.
134125
135126Note: The NS values here are for the ** SUBDOMAIN**
136127
137- ```
128+ ``` json
138129{
139130 "Comment" : " Create a subdomain NS record in the parent domain" ,
140131 "Changes" : [
@@ -167,7 +158,7 @@ Note: The NS values here are for the **SUBDOMAIN**
167158* Apply the ** SUBDOMAIN** NS records to the ** PARENT** hosted zone.
168159
169160```
170- aws route53 change-resource-record-sets \
161+ $ aws route53 change-resource-record-sets \
171162 --hosted-zone-id <parent-zone-id> \
172163 --change-batch file://subdomain.json
173164```
@@ -194,7 +185,7 @@ for some of these instructions.
194185
195186
196187``` bash
197- ID=$( uuidgen) && aws route53 create-hosted-zone --name subdomain.kubernetes.com --caller-reference $ID | jq .DelegationSet.NameServers
188+ $ ID=$( uuidgen) && aws route53 create-hosted-zone --name subdomain.kubernetes.com --caller-reference $ID | jq .DelegationSet.NameServers
198189```
199190
200191* You will now go to your registrars page and log in. You will need to create a
@@ -216,7 +207,7 @@ require private DNS records you should modify the commands we run later in this
216207guide to include:
217208
218209```
219- kops create cluster --dns private $NAME
210+ $ kops create cluster --dns private $NAME
220211```
221212
222213#### Testing your DNS setup
@@ -225,7 +216,7 @@ You should now able to dig your domain (or subdomain) and see the AWS Name
225216Servers on the other end.
226217
227218``` bash
228- dig ns subdomain.example.com
219+ $ dig ns subdomain.example.com
229220```
230221
231222Should return something similar to:
@@ -240,7 +231,7 @@ subdomain.example.com. 172800 IN NS ns-4.awsdns-4.co.uk.
240231
241232This is a critical component of setting up clusters. If you are experiencing
242233problems with the Kubernetes API not coming up, chances are something is wrong
243- with the clusters DNS.
234+ with the cluster's DNS.
244235
245236** Please DO NOT MOVE ON until you have validated your NS records!**
246237
@@ -257,14 +248,14 @@ We recommend keeping the creation of this bucket confined to us-east-1,
257248otherwise more work will be required.
258249
259250``` bash
260- aws s3api create-bucket --bucket prefix-example-com-state-store --region us-east-1
251+ $ aws s3api create-bucket --bucket prefix-example-com-state-store --region us-east-1
261252```
262253
263254Note: We ** STRONGLY** recommend versioning your S3 bucket in case you ever need
264255to revert or recover a previous state store.
265256
266257``` bash
267- aws s3api put-bucket-versioning --bucket prefix-example-com-state-store --versioning-configuration Status=Enabled
258+ $ aws s3api put-bucket-versioning --bucket prefix-example-com-state-store --versioning-configuration Status=Enabled
268259```
269260
270261
@@ -276,27 +267,27 @@ We're ready to start creating our first cluster! Let's first setup a few
276267environment variables to make this process easier.
277268
278269``` bash
279- export NAME=myfirstcluster.example.com
280- export KOPS_STATE_STORE=s3://prefix-example-com-state-store
270+ $ export NAME=myfirstcluster.example.com
271+ $ export KOPS_STATE_STORE=s3://prefix-example-com-state-store
281272```
282273
283274Note: You don’t have to use environmental variables here. You can always define
284- the values using the –name and –state flags later.
275+ the values using the ` –name ` and ` –state ` flags later.
285276
286277#### Create cluster configuration
287278
288279We will need to note which availability zones are available to us. In this
289280example we will be deploying our cluster to the us-west-2 region.
290281
291282``` bash
292- aws ec2 describe-availability-zones --region us-west-2
283+ $ aws ec2 describe-availability-zones --region us-west-2
293284```
294285
295286Below is a basic create cluster command. The
296287below command will generate a cluster configuration, but not start building it.
297288
298289``` bash
299- kops create cluster \
290+ $ kops create cluster \
300291 --zones us-west-2a \
301292 ${NAME}
302293```
@@ -311,7 +302,7 @@ Now we have a cluster configuration, we can look at every aspect that defines
311302our cluster by editing the description.
312303
313304``` bash
314- kops edit cluster ${NAME}
305+ $ kops edit cluster ${NAME}
315306```
316307
317308This opens your editor (as defined by $EDITOR) and allows you to edit the
@@ -328,19 +319,25 @@ while. Once it finishes you'll have to wait longer while the booted instances
328319finish downloading Kubernetes components and reach a "ready" state.
329320
330321``` bash
331- kops update cluster ${NAME} --yes
322+ $ kops update cluster ${NAME} --yes
332323```
333324
334325#### Use the Cluster
335326
336327Remember when you installed ` kubectl ` earlier? The configuration for your
337328cluster was automatically generated and written to ` ~/.kube/config ` for you!
338329
330+ Optionally you can always pull the configuration with the following command:
331+
332+ ``` bash
333+ $ kops export kubecfg --name ${NAME}
334+ ```
335+
339336A simple Kubernetes API call can be used to check if the API is online and
340337listening. Let's use ` kubectl ` to check the nodes.
341338
342339``` bash
343- kubectl get nodes
340+ $ kubectl get nodes
344341```
345342
346343You will see a list of nodes that should match the ` --zones ` flag defined
@@ -351,13 +348,13 @@ Also `kops` ships with a handy validation tool that can be ran to ensure your
351348cluster is working as expected.
352349
353350``` bash
354- kops validate cluster
351+ $ kubectl cluster-info
355352```
356353
357354You can look at all the system components with the following command.
358355
359- ```
360- kubectl -n kube-system get po
356+ ``` bash
357+ $ kubectl -n kube-system get po
361358```
362359
363360
0 commit comments