k3s/docs/getting-started-guides/aws.md

142 lines
4.0 KiB
Markdown
Raw Normal View History

## Getting started on AWS
2014-11-06 11:06:30 +00:00
### Prerequisites
2014-11-06 11:06:30 +00:00
2014-11-06 22:27:15 +00:00
1. You need an AWS account. Visit [http://aws.amazon.com](http://aws.amazon.com) to get started
2. Install and configure [AWS Command Line Interface](http://aws.amazon.com/cli)
3. You need an AWS [instance profile and role](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) with EC2 full access.
2014-11-06 11:06:30 +00:00
### Cluster turnup
2014-11-06 22:27:15 +00:00
Using ```wget```
```sh
export KUBERNETES_PROVIDER=aws; wget -q -O - https://get.k8s.io | bash
```
2014-11-18 05:41:13 +00:00
or if you prefer ```curl```
2014-11-24 16:09:08 +00:00
```sh
export KUBERNETES_PROVIDER=aws; curl -sS https://get.k8s.io | bash
2014-11-06 11:06:30 +00:00
```
NOTE: This script calls [cluster/kube-up.sh](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/kube-up.sh)
which in turn calls [cluster/aws/util.sh](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/aws/util.sh)
using [cluster/aws/config-default.sh](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/aws/config-default.sh).
By default, the script will provision a new VPC and a 4 node k8s cluster in us-west-2 (Oregon). It'll also try to create or reuse
a keypair called "kubernetes", and IAM profiles called "kubernetes-master" and "kubernetes-minion". If these already exist, make
sure you want them to be used here. You can override the variables defined in config-default.sh to change this behavior.
Once the cluster is up, it will print the ip address of your cluster, this process takes about 5 to 10 minutes.
2014-11-18 05:41:13 +00:00
```
export KUBERNETES_MASTER=https://<ip-address>
```
2014-11-18 05:49:56 +00:00
Also setup your path to point to the released binaries:
```
export PATH=$PATH:$PWD:/kubernetes/cluster
2014-11-18 05:49:56 +00:00
```
If you run into trouble come ask questions on IRC at #google-containers on freenode.
2014-11-06 22:27:15 +00:00
2014-11-06 11:06:30 +00:00
### Running a container (simple version)
Once you have your cluster created you can use ```${SOME_DIR}/kubernetes/cluster/kubectl.sh``` to access
the kubernetes api.
The `kubectl.sh` line below spins up two containers running
[Nginx](http://nginx.org/en/) running on port 80:
```bash
cluster/kubectl.sh run-container my-nginx --image=nginx --replicas=2 --port=80
2014-11-06 11:06:30 +00:00
```
To stop the containers:
```bash
cluster/kubectl.sh stop rc my-nginx
```
To delete the containers:
```bash
cluster/kubectl.sh delete rc my-nginx
```
### Running a container (more complete version)
```bash
cd kubernetes
cluster/kubectl.sh create -f docs/getting-started-guides/pod.json
```
Where pod.json contains something like:
```json
{
"id": "php",
"kind": "Pod",
"apiVersion": "v1beta1",
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "php",
"containers": [{
"name": "nginx",
"image": "nginx",
"ports": [{
"containerPort": 80,
"hostPort": 8081
}],
"livenessProbe": {
"enabled": true,
"type": "http",
"initialDelaySeconds": 30,
"httpGet": {
"path": "/index.html",
"port": 8081
}
}
}]
}
},
"labels": {
"name": "foo"
}
}
```
You can see your cluster's pods:
```bash
cluster/kubectl.sh get pods
```
and delete the pod you just created:
```bash
cluster/kubectl.sh delete pods php
```
Since this pod is scheduled on a minion running in AWS, you will have to enable incoming tcp traffic via the port specified in the
pod manifest before you see the nginx welcome page. After doing so, it should be visible at http://<external ip of minion running nginx>:<port from manifest>.
Look in `examples/` for more examples
### Tearing down the cluster
```bash
2014-11-06 22:27:15 +00:00
cd kubernetes
cluster/kube-down.sh
```
### Running examples
Take a look at [next steps](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples/guestbook)
2014-11-18 05:49:56 +00:00
### Cloud Formation [optional]
There is a contributed [example](aws-coreos.md) from [CoreOS](http://www.coreos.com) using Cloud Formation.
### Further reading
Please see the [Kubernetes docs](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs) for more details on administering and using a Kubernetes cluster.