You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 01-path-basics/102-your-first-cluster/readme.adoc
+117Lines changed: 117 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,3 +140,120 @@ The next step is link:../103-kubernetes-concepts[to learn about basic Kubernetes
140
140
141
141
The sections below provide information on other capabilities of Kubernetes clusters.
142
142
You are welcome to read and refer to them should you need to use those capabilities.
143
+
144
+
== Alternative: Create a Kubernetes Cluster with kops
145
+
146
+
This section will walk you through how to install a Kubernetes cluster on AWS using kops.
147
+
148
+
https://github.com/kubernetes/kops[kops, window="_blank"], short for Kubernetes Operations, is a set of tools for installing, operating, and deleting Kubernetes clusters. kops can also perform rolling upgrades from older versions of Kubernetes to newer ones, and manage the cluster add-ons.
149
+
150
+
kops can be used to create a highly available cluster, with multiple master and worker nodes spread across multiple availability zones.
151
+
The master and worker nodes within the cluster can use either DNS or the https://github.com/weaveworks/mesh[Weave Mesh, window="_blank"] *gossip* protocol for name resolution. For this workshop, we will use the gossip protocol. A gossip-based cluster is easier and quicker to setup, and does not require a domain, subdomain, or Route53 hosted zone to be registered. Instructions for creating a DNS-based cluster are provided as an appendix at the bottom of this page.
152
+
153
+
To create a cluster using the gossip protocol, simply use a cluster name with a suffix of `.k8s.local`. In the following steps, we will use `example.cluster.k8s.local` as a sample gossip cluster name. You may choose a different name as long as it ends with `.k8s.local`.
154
+
155
+
We show two examples of creating gossip-based clusters below. You can choose whether to create a single-master or multi-master cluster. Most workshop exercises will work on both types of cluster, however some modules require using a multi-master cluster _(to demonstrate rolling updates, for instance)._ If you aren't sure, please create a xref:multi-master[multi-master cluster].
156
+
157
+
=== Single-Master Cluster
158
+
159
+
By default, the `kops create cluster` command creates a single master node and two worker nodes in the specified zones.
160
+
161
+
Create a Kubernetes cluster using the following command. Run it in the "bash" terminal tab at the bottom of the Cloud9 IDE. This will create a cluster with a single master, multi-node and multi-az configuration:
162
+
163
+
$ kops create cluster \
164
+
--name example.cluster.k8s.local \
165
+
--zones $AWS_AVAILABILITY_ZONES \
166
+
--yes
167
+
168
+
The `AWS_AVAILABILITY_ZONES` environment variable should have been set during the link:../101-start-here[Cloud9 Environment Setup].
169
+
170
+
The `create cluster` command only creates and stores the cluster config in the S3 bucket. Adding the `--yes` flag ensures that the cluster is immediately created as well.
171
+
172
+
Once the `kops create cluster` command is issued, it provisions the EC2 instances, sets up Auto Scaling Groups, IAM users, Security Groups, installs Kubernetes on each node, then configures the master and worker nodes. This process can take some time based upon the number of master and worker nodes.
173
+
174
+
Note: If your 'create cluster' fails with an error like:
175
+
```
176
+
error reading s3://example-kops-state-store/example.cluster.k8s.local/config: Unable to list AWS regions: NoCredentialProviders: no valid providers in chain
177
+
caused by: EnvAccessKeyNotFound: failed to find credentials in the environment."
178
+
```
179
+
Please confirm the following environment variables are set before executing the 'create cluster' command:
180
+
```
181
+
echo $AWS_DEFAULT_PROFILE
182
+
echo $KOPS_STATE_STORE
183
+
echo $AWS_SDK_LOAD_CONFIG
184
+
```
185
+
If any of those environment variables are blank, please re-run the "Build Script" section of the link:../101-start-here[Cloud9 Environment Setup].
186
+
187
+
Wait for 5-8 minutes and then the cluster can be validated as shown:
188
+
189
+
```
190
+
$ kops validate cluster
191
+
Using cluster from kubectl context: example.cluster.k8s.local
The command below creates a cluster in a multi-master, multi-node, and multi-az configuration.
214
+
Run it in the "bash" terminal tab at the bottom of the Cloud9 IDE.
215
+
We can create and build the cluster in one step by passing the `--yes` flag.
216
+
217
+
$ kops create cluster \
218
+
--name example.cluster.k8s.local \
219
+
--master-count 3 \
220
+
--node-count 5 \
221
+
--zones $AWS_AVAILABILITY_ZONES \
222
+
--yes
223
+
224
+
A multi-master cluster can be created by using the `--master-count` option and specifying the number of master nodes. An odd value is recommended. By default, the master nodes are spread across the AZs specified using the `--zones` option. Alternatively, you can use the `--master-zones` option to explicitly specify the zones for the master nodes.
225
+
226
+
The `--zones` option is also used to distribute the worker nodes. The number of workers is specified using the `--node-count` option.
227
+
228
+
It will take 5-8 minutes for the cluster to be created. Validate the cluster:
229
+
230
+
```
231
+
$ kops validate cluster
232
+
Using cluster from kubectl context: example.cluster.k8s.local
Copy file name to clipboardExpand all lines: 01-path-basics/103-kubernetes-concepts/readme.adoc
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,9 @@ Kubernetes as a platform has a number of abstractions that map to API objects. T
16
16
17
17
This chapter uses an EKS cluster with worker nodes as described link:../102-your-first-cluster[here].
18
18
19
+
[NOTE]
20
+
This lab and future labs can be completed using the EKS cluster or the multi-master kops cluster. Some of the outputs may vary slightly if using the kops cluster.
21
+
19
22
All configuration files for this chapter are in the `01-path-basics/103-kubernetes-concepts/templates` directory.
20
23
Please be sure to `cd` into that directory before running the commands below.
0 commit comments