mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
docs: add aws getting started guide
This commit is contained in:
parent
3b1ef739d1
commit
efe7de38ea
203
docs/getting-started-guides/aws.md
Normal file
203
docs/getting-started-guides/aws.md
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
# Getting started on Amazon EC2
|
||||||
|
|
||||||
|
The example below creates an elastic Kubernetes cluster with 3 worker nodes and a master.
|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
|
||||||
|
* Cluster bootstrapping using [cloud-config](https://coreos.com/docs/cluster-management/setup/cloudinit-cloud-config)
|
||||||
|
* Cross container networking with [flannel](https://github.com/coreos/flannel#flannel)
|
||||||
|
* Auto worker registration with [kube-register](https://github.com/kelseyhightower/kube-register#kube-register)
|
||||||
|
* Kubernetes v0.4.2 [official binaries](https://github.com/GoogleCloudPlatform/kubernetes/releases/tag/v0.4.2)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
* [kubecfg CLI](aws/kubecfg.md)
|
||||||
|
* [aws CLI](http://aws.amazon.com/cli)
|
||||||
|
* CoreOS 490.0.0+
|
||||||
|
|
||||||
|
## Starting a Cluster
|
||||||
|
|
||||||
|
### Cloud Formation
|
||||||
|
|
||||||
|
The [cloudformation-template.json](aws/cloudformation-template.json) can be used to bootstrap a Kubernetes cluster with a single command.
|
||||||
|
|
||||||
|
```
|
||||||
|
aws cloudformation create-stack --stack-name kubernetes --region us-west-2 \
|
||||||
|
--template-body file://aws/cloudformation-template.json \
|
||||||
|
--parameters ParameterKey=KeyPair,ParameterValue=<keypair>
|
||||||
|
```
|
||||||
|
|
||||||
|
It will take a few minutes for the entire stack to come up. You can monitor the stack progress with the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
aws cloudformation describe-stack-events --stack-name kubernetes
|
||||||
|
```
|
||||||
|
|
||||||
|
> Record the Kubernetes Master IP address
|
||||||
|
|
||||||
|
```
|
||||||
|
aws cloudformation describe-stacks --stack-name kubernetes
|
||||||
|
```
|
||||||
|
|
||||||
|
[Skip to kubecfg client configuration](#configure-the-kubecfg-ssh-tunnel)
|
||||||
|
|
||||||
|
### Manually
|
||||||
|
|
||||||
|
The following commands use the CoreOS 490.0.0 alpha AMI `ami-e18dc5d1` from the `us-west-2` region. For a list of different regions and corresponding AMI IDs see the [CoreOS EC2 cloud provider documentation](https://coreos.com/docs/running-coreos/cloud-providers/ec2/#choosing-a-channel).
|
||||||
|
|
||||||
|
#### Create the Kubernetes Security Group
|
||||||
|
|
||||||
|
```
|
||||||
|
aws ec2 create-security-group --group-name kubernetes --description "Kubernetes Security Group"
|
||||||
|
aws ec2 authorize-security-group-ingress --group-name kubernetes --protocol tcp --port 22 --cidr 0.0.0.0/0
|
||||||
|
aws ec2 authorize-security-group-ingress --group-name kubernetes --protocol tcp --port 80 --cidr 0.0.0.0/0
|
||||||
|
aws ec2 authorize-security-group-ingress --group-name kubernetes --source-security-group-name kubernetes
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Save the master and node cloud-configs
|
||||||
|
|
||||||
|
* [master.yaml](aws/cloud-configs/master.yaml)
|
||||||
|
* [node.yaml](aws/cloud-configs/node.yaml)
|
||||||
|
|
||||||
|
#### Launch the master
|
||||||
|
|
||||||
|
```
|
||||||
|
aws ec2 run-instances --image-id ami-e18dc5d1 --key-name <keypair> \
|
||||||
|
--region us-west-2 --security-groups kubernetes --instance-type m3.medium \
|
||||||
|
--user-data file://master.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
> Record the `InstanceId` for the master.
|
||||||
|
|
||||||
|
Gather the public and private IPs for the master node:
|
||||||
|
|
||||||
|
```
|
||||||
|
aws ec2 describe-instances --instance-id <instance-id>
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"Reservations": [
|
||||||
|
{
|
||||||
|
"Instances": [
|
||||||
|
{
|
||||||
|
"PublicDnsName": "ec2-54-68-97-117.us-west-2.compute.amazonaws.com",
|
||||||
|
"RootDeviceType": "ebs",
|
||||||
|
"State": {
|
||||||
|
"Code": 16,
|
||||||
|
"Name": "running"
|
||||||
|
},
|
||||||
|
"PublicIpAddress": "54.68.97.117",
|
||||||
|
"PrivateIpAddress": "172.31.9.9",
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Update the node.yaml cloud-config
|
||||||
|
|
||||||
|
Edit `node.yaml` and replace all instances of `<master-private-ip>` with the **private** IP address of the master node.
|
||||||
|
|
||||||
|
### Launch 3 worker nodes
|
||||||
|
|
||||||
|
```
|
||||||
|
aws ec2 run-instances --count 3 --image-id ami-e18dc5d1 --key-name <keypair> \
|
||||||
|
--region us-west-2 --security-groups kubernetes --instance-type m3.medium \
|
||||||
|
--user-data file://node.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Add additional worker nodes
|
||||||
|
|
||||||
|
```
|
||||||
|
aws ec2 run-instances --count 1 --image-id ami-e18dc5d1 --key-name <keypair> \
|
||||||
|
--region us-west-2 --security-groups kubernetes --instance-type m3.medium \
|
||||||
|
--user-data file://node.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configure the kubecfg SSH tunnel
|
||||||
|
|
||||||
|
This command enables secure communication between the kubecfg client and the Kubernetes API.
|
||||||
|
|
||||||
|
```
|
||||||
|
ssh -f -nNT -L 8080:127.0.0.1:8080 core@<master-public-ip>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Listing worker nodes
|
||||||
|
|
||||||
|
Once the worker instances have fully booted, they will be automatically registered with the Kubernetes API server by the kube-register service running on the master node. It may take a few mins.
|
||||||
|
|
||||||
|
```
|
||||||
|
kubecfg list minions
|
||||||
|
```
|
||||||
|
|
||||||
|
## Starting a simple pod
|
||||||
|
|
||||||
|
Create a pod manifest: `pod.json`
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"id": "hello",
|
||||||
|
"kind": "Pod",
|
||||||
|
"apiVersion": "v1beta1",
|
||||||
|
"desiredState": {
|
||||||
|
"manifest": {
|
||||||
|
"version": "v1beta1",
|
||||||
|
"id": "hello",
|
||||||
|
"containers": [{
|
||||||
|
"name": "hello",
|
||||||
|
"image": "quay.io/kelseyhightower/hello",
|
||||||
|
"ports": [{
|
||||||
|
"containerPort": 80,
|
||||||
|
"hostPort": 80
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"name": "hello",
|
||||||
|
"environment": "testing"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Create the pod using the kubecfg command line tool
|
||||||
|
|
||||||
|
```
|
||||||
|
kubecfg -c pod.json create pods
|
||||||
|
```
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
```
|
||||||
|
kubecfg list pods
|
||||||
|
```
|
||||||
|
|
||||||
|
> Record the **Host** of the pod, which should be the private IP address.
|
||||||
|
|
||||||
|
Gather the public IP address for the worker node.
|
||||||
|
|
||||||
|
```
|
||||||
|
aws ec2 describe-instances --filters 'Name=private-ip-address,Values=<host>'
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"Reservations": [
|
||||||
|
{
|
||||||
|
"Instances": [
|
||||||
|
{
|
||||||
|
"PublicDnsName": "ec2-54-68-97-117.us-west-2.compute.amazonaws.com",
|
||||||
|
"RootDeviceType": "ebs",
|
||||||
|
"State": {
|
||||||
|
"Code": 16,
|
||||||
|
"Name": "running"
|
||||||
|
},
|
||||||
|
"PublicIpAddress": "54.68.97.117",
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Visit the public IP address in your browser to view the running pod.
|
||||||
|
|
||||||
|
### Delete the pod
|
||||||
|
|
||||||
|
```
|
||||||
|
kubecfg delete pods/hello
|
||||||
|
```
|
108
docs/getting-started-guides/aws/cloud-configs/master.yaml
Normal file
108
docs/getting-started-guides/aws/cloud-configs/master.yaml
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#cloud-config
|
||||||
|
|
||||||
|
coreos:
|
||||||
|
fleet:
|
||||||
|
etcd_servers: http://127.0.0.1:4001
|
||||||
|
metadata: role=master
|
||||||
|
etcd:
|
||||||
|
name: etcd
|
||||||
|
addr: $private_ipv4:4001
|
||||||
|
bind-addr: 0.0.0.0
|
||||||
|
peer-addr: $private_ipv4:7001
|
||||||
|
cluster-active-size: 1
|
||||||
|
etcd-http-read-timeout: 86400
|
||||||
|
snapshot: true
|
||||||
|
units:
|
||||||
|
- name: etcd.service
|
||||||
|
command: start
|
||||||
|
- name: fleet.service
|
||||||
|
command: start
|
||||||
|
- name: flannel.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Requires=etcd.service
|
||||||
|
After=etcd.service
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
Description=flannel is an etcd backed overlay network for containers
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
|
||||||
|
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/flanneld
|
||||||
|
ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld
|
||||||
|
ExecStartPre=-/usr/bin/etcdctl mk /coreos.com/network/config '{"Network":"10.0.0.0/16"}'
|
||||||
|
ExecStart=/opt/bin/flanneld
|
||||||
|
- name: kube-apiserver.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=Kubernetes API Server
|
||||||
|
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
|
||||||
|
Requires=etcd.service
|
||||||
|
After=etcd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/apiserver
|
||||||
|
ExecStartPre=/usr/bin/chmod +x /opt/bin/apiserver
|
||||||
|
ExecStart=/opt/bin/apiserver \
|
||||||
|
--address=0.0.0.0 \
|
||||||
|
--port=8080 \
|
||||||
|
--etcd_servers=http://127.0.0.1:4001 \
|
||||||
|
--logtostderr=true
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
- name: kube-controller-manager.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=Kubernetes Controller Manager
|
||||||
|
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
|
||||||
|
Requires=kube-apiserver.service
|
||||||
|
After=kube-apiserver.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/controller-manager
|
||||||
|
ExecStartPre=/usr/bin/chmod +x /opt/bin/controller-manager
|
||||||
|
ExecStart=/opt/bin/controller-manager \
|
||||||
|
--master=127.0.0.1:8080 \
|
||||||
|
--logtostderr=true
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
- name: kube-scheduler.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=Kubernetes Scheduler
|
||||||
|
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
|
||||||
|
Requires=kube-apiserver.service
|
||||||
|
After=kube-apiserver.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/scheduler
|
||||||
|
ExecStartPre=/usr/bin/chmod +x /opt/bin/scheduler
|
||||||
|
ExecStart=/opt/bin/scheduler --master=127.0.0.1:8080
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
- name: kube-register.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=Kubernetes Registration Service
|
||||||
|
Documentation=https://github.com/kelseyhightower/kube-register
|
||||||
|
Requires=kube-apiserver.service
|
||||||
|
After=kube-apiserver.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/kube-register
|
||||||
|
ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-register
|
||||||
|
ExecStart=/opt/bin/kube-register \
|
||||||
|
--metadata=role=knode \
|
||||||
|
--fleet-endpoint=unix:///var/run/fleet.sock \
|
||||||
|
--api-endpoint=http://127.0.0.1:8080
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
update:
|
||||||
|
group: alpha
|
||||||
|
reboot-strategy: off
|
81
docs/getting-started-guides/aws/cloud-configs/node.yaml
Normal file
81
docs/getting-started-guides/aws/cloud-configs/node.yaml
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#cloud-config
|
||||||
|
|
||||||
|
coreos:
|
||||||
|
fleet:
|
||||||
|
etcd_servers: http://<master-private-ip>:4001
|
||||||
|
metadata: role=knode
|
||||||
|
units:
|
||||||
|
- name: etcd.service
|
||||||
|
mask: true
|
||||||
|
- name: fleet.service
|
||||||
|
command: start
|
||||||
|
- name: flannel.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
Description=flannel is an etcd backed overlay network for containers
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
|
||||||
|
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/flanneld
|
||||||
|
ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld
|
||||||
|
ExecStart=/opt/bin/flanneld -etcd-endpoints http://<master-private-ip>:4001
|
||||||
|
- name: docker.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
After=flannel.service
|
||||||
|
Wants=flannel.service
|
||||||
|
Description=Docker Application Container Engine
|
||||||
|
Documentation=http://docs.docker.io
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=/run/flannel/subnet.env
|
||||||
|
ExecStartPre=/bin/mount --make-rprivate /
|
||||||
|
ExecStart=/usr/bin/docker -d --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} -s=btrfs -H fd://
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
- name: setup-network-environment.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=Setup Network Environment
|
||||||
|
Documentation=https://github.com/kelseyhightower/setup-network-environment
|
||||||
|
Requires=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
|
||||||
|
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/setup-network-environment
|
||||||
|
ExecStartPre=/usr/bin/chmod +x /opt/bin/setup-network-environment
|
||||||
|
ExecStart=/opt/bin/setup-network-environment
|
||||||
|
RemainAfterExit=yes
|
||||||
|
Type=oneshot
|
||||||
|
- name: kube-kubelet.service
|
||||||
|
command: start
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=Kubernetes Kubelet
|
||||||
|
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
|
||||||
|
Requires=setup-network-environment.service
|
||||||
|
After=setup-network-environment.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=/etc/network-environment
|
||||||
|
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/kubelet
|
||||||
|
ExecStartPre=/usr/bin/chmod +x /opt/bin/kubelet
|
||||||
|
ExecStart=/opt/bin/kubelet \
|
||||||
|
--address=0.0.0.0 \
|
||||||
|
--port=10250 \
|
||||||
|
--hostname_override=${DEFAULT_IPV4} \
|
||||||
|
--etcd_servers=http://<master-private-ip>:4001 \
|
||||||
|
--logtostderr=true
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
update:
|
||||||
|
group: alpha
|
||||||
|
reboot-strategy: off
|
313
docs/getting-started-guides/aws/cloudformation-template.json
Normal file
313
docs/getting-started-guides/aws/cloudformation-template.json
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
{
|
||||||
|
"AWSTemplateFormatVersion": "2010-09-09",
|
||||||
|
"Description": "Kubernetes on EC2",
|
||||||
|
"Mappings": {
|
||||||
|
"RegionMap": {
|
||||||
|
"eu-central-1": {"AMI": "ami-54ccfa49"},
|
||||||
|
"ap-northeast-1": {"AMI": "ami-f7b08ff6"},
|
||||||
|
"sa-east-1": {"AMI": "ami-1304b30e"},
|
||||||
|
"ap-southeast-2": {"AMI": "ami-0f117e35"},
|
||||||
|
"ap-southeast-1": {"AMI": "ami-c04f6c92"},
|
||||||
|
"us-east-1": {"AMI": "ami-7ae66812"},
|
||||||
|
"us-west-2": {"AMI": "ami-e18dc5d1"},
|
||||||
|
"us-west-1": {"AMI": "ami-45fbec00"},
|
||||||
|
"eu-west-1": {"AMI": "ami-a27fd5d5"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Parameters": {
|
||||||
|
"InstanceType": {
|
||||||
|
"Description": "EC2 HVM instance type (m3.medium, etc).",
|
||||||
|
"Type": "String",
|
||||||
|
"Default": "m3.medium",
|
||||||
|
"AllowedValues": [
|
||||||
|
"m3.medium",
|
||||||
|
"m3.large",
|
||||||
|
"m3.xlarge",
|
||||||
|
"m3.2xlarge",
|
||||||
|
"c3.large",
|
||||||
|
"c3.xlarge",
|
||||||
|
"c3.2xlarge",
|
||||||
|
"c3.4xlarge",
|
||||||
|
"c3.8xlarge",
|
||||||
|
"cc2.8xlarge",
|
||||||
|
"cr1.8xlarge",
|
||||||
|
"hi1.4xlarge",
|
||||||
|
"hs1.8xlarge",
|
||||||
|
"i2.xlarge",
|
||||||
|
"i2.2xlarge",
|
||||||
|
"i2.4xlarge",
|
||||||
|
"i2.8xlarge",
|
||||||
|
"r3.large",
|
||||||
|
"r3.xlarge",
|
||||||
|
"r3.2xlarge",
|
||||||
|
"r3.4xlarge",
|
||||||
|
"r3.8xlarge",
|
||||||
|
"t2.micro",
|
||||||
|
"t2.small",
|
||||||
|
"t2.medium"
|
||||||
|
],
|
||||||
|
"ConstraintDescription": "Must be a valid EC2 HVM instance type."
|
||||||
|
},
|
||||||
|
"ClusterSize": {
|
||||||
|
"Description": "Number of nodes in cluster (3-12).",
|
||||||
|
"Default": "3",
|
||||||
|
"MinValue": "3",
|
||||||
|
"MaxValue": "12",
|
||||||
|
"Type": "Number"
|
||||||
|
},
|
||||||
|
"AllowSSHFrom": {
|
||||||
|
"Description": "The net block (CIDR) that SSH is available to.",
|
||||||
|
"Default": "0.0.0.0/0",
|
||||||
|
"Type": "String"
|
||||||
|
},
|
||||||
|
"KeyPair" : {
|
||||||
|
"Description": "The name of an EC2 Key Pair to allow SSH access to the instance.",
|
||||||
|
"Type": "String"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Resources": {
|
||||||
|
"KubernetesSecurityGroup": {
|
||||||
|
"Type": "AWS::EC2::SecurityGroup",
|
||||||
|
"Properties": {
|
||||||
|
"GroupDescription": "Kubernetes SecurityGroup",
|
||||||
|
"SecurityGroupIngress": [
|
||||||
|
{
|
||||||
|
"IpProtocol": "tcp",
|
||||||
|
"FromPort": "22",
|
||||||
|
"ToPort": "22",
|
||||||
|
"CidrIp": {"Ref": "AllowSSHFrom"}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"KubernetesIngress": {
|
||||||
|
"Type": "AWS::EC2::SecurityGroupIngress",
|
||||||
|
"Properties": {
|
||||||
|
"GroupName": {"Ref": "KubernetesSecurityGroup"},
|
||||||
|
"IpProtocol": "tcp",
|
||||||
|
"FromPort": "1",
|
||||||
|
"ToPort": "65535",
|
||||||
|
"SourceSecurityGroupId": {
|
||||||
|
"Fn::GetAtt" : [ "KubernetesSecurityGroup", "GroupId" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"KubernetesMasterInstance": {
|
||||||
|
"Type": "AWS::EC2::Instance",
|
||||||
|
"Properties": {
|
||||||
|
"ImageId": {"Fn::FindInMap" : ["RegionMap", {"Ref": "AWS::Region" }, "AMI"]},
|
||||||
|
"InstanceType": {"Ref": "InstanceType"},
|
||||||
|
"KeyName": {"Ref": "KeyPair"},
|
||||||
|
"SecurityGroups": [{"Ref": "KubernetesSecurityGroup"}],
|
||||||
|
"UserData": { "Fn::Base64": {"Fn::Join" : ["", [
|
||||||
|
"#cloud-config\n\n",
|
||||||
|
"coreos:\n",
|
||||||
|
" fleet:\n",
|
||||||
|
" etcd_servers: http://127.0.0.1:4001\n",
|
||||||
|
" metadata: role=master\n",
|
||||||
|
" etcd:\n",
|
||||||
|
" name: etcd\n",
|
||||||
|
" addr: $private_ipv4:4001\n",
|
||||||
|
" bind-addr: 0.0.0.0\n",
|
||||||
|
" peer-addr: $private_ipv4:7001\n",
|
||||||
|
" cluster-active-size: 1\n",
|
||||||
|
" etcd-http-read-timeout: 86400\n",
|
||||||
|
" snapshot: true\n",
|
||||||
|
" units:\n",
|
||||||
|
" - name: etcd.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" - name: fleet.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" - name: flannel.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" Requires=etcd.service\n",
|
||||||
|
" After=etcd.service\n",
|
||||||
|
" After=network-online.target\n",
|
||||||
|
" Wants=network-online.target\n",
|
||||||
|
" Description=flannel is an etcd backed overlay network for containers\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" Type=notify\n",
|
||||||
|
" ExecStartPre=-/usr/bin/mkdir -p /opt/bin\n",
|
||||||
|
" ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/flanneld\n",
|
||||||
|
" ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld\n",
|
||||||
|
" ExecStartPre=-/usr/bin/etcdctl mk /coreos.com/network/config '{\"Network\":\"10.0.0.0/16\"}'\n",
|
||||||
|
" ExecStart=/opt/bin/flanneld\n",
|
||||||
|
" - name: kube-apiserver.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" Description=Kubernetes API Server\n",
|
||||||
|
" Documentation=https://github.com/GoogleCloudPlatform/kubernetes\n",
|
||||||
|
" Requires=etcd.service\n",
|
||||||
|
" After=etcd.service\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/apiserver\n",
|
||||||
|
" ExecStartPre=/usr/bin/chmod +x /opt/bin/apiserver\n",
|
||||||
|
" ExecStart=/opt/bin/apiserver \\\n",
|
||||||
|
" --address=0.0.0.0 \\\n",
|
||||||
|
" --port=8080 \\\n",
|
||||||
|
" --etcd_servers=http://127.0.0.1:4001 \\\n",
|
||||||
|
" --logtostderr=true\n",
|
||||||
|
" Restart=always\n",
|
||||||
|
" RestartSec=10\n",
|
||||||
|
" - name: kube-controller-manager.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" Description=Kubernetes Controller Manager\n",
|
||||||
|
" Documentation=https://github.com/GoogleCloudPlatform/kubernetes\n",
|
||||||
|
" Requires=kube-apiserver.service\n",
|
||||||
|
" After=kube-apiserver.service\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/controller-manager\n",
|
||||||
|
" ExecStartPre=/usr/bin/chmod +x /opt/bin/controller-manager\n",
|
||||||
|
" ExecStart=/opt/bin/controller-manager \\\n",
|
||||||
|
" --master=127.0.0.1:8080 \\\n",
|
||||||
|
" --logtostderr=true\n",
|
||||||
|
" Restart=always\n",
|
||||||
|
" RestartSec=10\n",
|
||||||
|
" - name: kube-scheduler.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" Description=Kubernetes Scheduler\n",
|
||||||
|
" Documentation=https://github.com/GoogleCloudPlatform/kubernetes\n",
|
||||||
|
" Requires=kube-apiserver.service\n",
|
||||||
|
" After=kube-apiserver.service\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/scheduler\n",
|
||||||
|
" ExecStartPre=/usr/bin/chmod +x /opt/bin/scheduler\n",
|
||||||
|
" ExecStart=/opt/bin/scheduler --master=127.0.0.1:8080\n",
|
||||||
|
" Restart=always\n",
|
||||||
|
" RestartSec=10\n",
|
||||||
|
" - name: kube-register.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" Description=Kubernetes Registration Service\n",
|
||||||
|
" Documentation=https://github.com/kelseyhightower/kube-register\n",
|
||||||
|
" Requires=kube-apiserver.service\n",
|
||||||
|
" After=kube-apiserver.service\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/kube-register\n",
|
||||||
|
" ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-register\n",
|
||||||
|
" ExecStart=/opt/bin/kube-register \\\n",
|
||||||
|
" --metadata=role=knode \\\n",
|
||||||
|
" --fleet-endpoint=unix:///var/run/fleet.sock \\\n",
|
||||||
|
" --api-endpoint=http://127.0.0.1:8080\n",
|
||||||
|
" Restart=always\n",
|
||||||
|
" RestartSec=10\n",
|
||||||
|
" update:\n",
|
||||||
|
" group: alpha\n",
|
||||||
|
" reboot-strategy: off\n"
|
||||||
|
]]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"KubernetesNodeLaunchConfig": {
|
||||||
|
"Type": "AWS::AutoScaling::LaunchConfiguration",
|
||||||
|
"Properties": {
|
||||||
|
"ImageId": {"Fn::FindInMap" : ["RegionMap", {"Ref": "AWS::Region" }, "AMI" ]},
|
||||||
|
"InstanceType": {"Ref": "InstanceType"},
|
||||||
|
"KeyName": {"Ref": "KeyPair"},
|
||||||
|
"SecurityGroups": [{"Ref": "KubernetesSecurityGroup"}],
|
||||||
|
"UserData": { "Fn::Base64": {"Fn::Join" : ["", [
|
||||||
|
"#cloud-config\n\n",
|
||||||
|
"coreos:\n",
|
||||||
|
" fleet:\n",
|
||||||
|
" etcd_servers: http://", {"Fn::GetAtt":["KubernetesMasterInstance" , "PrivateIp"]}, ":4001\n",
|
||||||
|
" metadata: role=knode\n",
|
||||||
|
" units:\n",
|
||||||
|
" - name: etcd.service\n",
|
||||||
|
" mask: true\n",
|
||||||
|
" - name: fleet.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" - name: flannel.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" After=network-online.target\n",
|
||||||
|
" Wants=network-online.target\n",
|
||||||
|
" Description=flannel is an etcd backed overlay network for containers\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" Type=notify\n",
|
||||||
|
" ExecStartPre=-/usr/bin/mkdir -p /opt/bin\n",
|
||||||
|
" ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/flanneld\n",
|
||||||
|
" ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld\n",
|
||||||
|
" ExecStart=/opt/bin/flanneld -etcd-endpoints http://", {"Fn::GetAtt" :["KubernetesMasterInstance" , "PrivateIp"]}, ":4001\n",
|
||||||
|
" - name: docker.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" After=flannel.service\n",
|
||||||
|
" Wants=flannel.service\n",
|
||||||
|
" Description=Docker Application Container Engine\n",
|
||||||
|
" Documentation=http://docs.docker.io\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" EnvironmentFile=/run/flannel/subnet.env\n",
|
||||||
|
" ExecStartPre=/bin/mount --make-rprivate /\n",
|
||||||
|
" ExecStart=/usr/bin/docker -d --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} -s=btrfs -H fd://\n\n",
|
||||||
|
" [Install]\n",
|
||||||
|
" WantedBy=multi-user.target\n",
|
||||||
|
" - name: setup-network-environment.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" Description=Setup Network Environment\n",
|
||||||
|
" Documentation=https://github.com/kelseyhightower/setup-network-environment\n",
|
||||||
|
" Requires=network-online.target\n",
|
||||||
|
" After=network-online.target\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" ExecStartPre=-/usr/bin/mkdir -p /opt/bin\n",
|
||||||
|
" ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/setup-network-environment\n",
|
||||||
|
" ExecStartPre=/usr/bin/chmod +x /opt/bin/setup-network-environment\n",
|
||||||
|
" ExecStart=/opt/bin/setup-network-environment\n",
|
||||||
|
" RemainAfterExit=yes\n",
|
||||||
|
" Type=oneshot\n",
|
||||||
|
" - name: kube-kubelet.service\n",
|
||||||
|
" command: start\n",
|
||||||
|
" content: |\n",
|
||||||
|
" [Unit]\n",
|
||||||
|
" Description=Kubernetes Kubelet\n",
|
||||||
|
" Documentation=https://github.com/GoogleCloudPlatform/kubernetes\n",
|
||||||
|
" Requires=setup-network-environment.service\n",
|
||||||
|
" After=setup-network-environment.service\n\n",
|
||||||
|
" [Service]\n",
|
||||||
|
" EnvironmentFile=/etc/network-environment\n",
|
||||||
|
" ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/k8s/kubelet\n",
|
||||||
|
" ExecStartPre=/usr/bin/chmod +x /opt/bin/kubelet\n",
|
||||||
|
" ExecStart=/opt/bin/kubelet \\\n",
|
||||||
|
" --address=0.0.0.0 \\\n",
|
||||||
|
" --port=10250 \\\n",
|
||||||
|
" --hostname_override=${DEFAULT_IPV4} \\\n",
|
||||||
|
" --etcd_servers=http://", {"Fn::GetAtt" :["KubernetesMasterInstance" , "PrivateIp"]}, ":4001\\\n",
|
||||||
|
" --logtostderr=true\n",
|
||||||
|
" Restart=always\n",
|
||||||
|
" RestartSec=10\n",
|
||||||
|
" update:\n",
|
||||||
|
" group: alpha\n",
|
||||||
|
" reboot-strategy: off\n"
|
||||||
|
]]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"KubernetesAutoScalingGroup": {
|
||||||
|
"Type": "AWS::AutoScaling::AutoScalingGroup",
|
||||||
|
"Properties": {
|
||||||
|
"AvailabilityZones": {"Fn::GetAZs": ""},
|
||||||
|
"LaunchConfigurationName": {"Ref": "KubernetesNodeLaunchConfig"},
|
||||||
|
"MinSize": "3",
|
||||||
|
"MaxSize": "12",
|
||||||
|
"DesiredCapacity": {"Ref": "ClusterSize"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Outputs": {
|
||||||
|
"KubernetesMasterPublicIp": {
|
||||||
|
"Description": "Public Ip of the newly created Kubernetes Master instance",
|
||||||
|
"Value": {"Fn::GetAtt": ["KubernetesMasterInstance" , "PublicIp"]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
docs/getting-started-guides/aws/kubecfg.md
Normal file
28
docs/getting-started-guides/aws/kubecfg.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Install and configure kubecfg
|
||||||
|
|
||||||
|
## Downlaod the kubecfg cli tool
|
||||||
|
|
||||||
|
### Darwin
|
||||||
|
|
||||||
|
```
|
||||||
|
wget http://storage.googleapis.com/k8s/darwin/kubecfg
|
||||||
|
```
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
```
|
||||||
|
wget http://storage.googleapis.com/k8s/darwin/kubecfg
|
||||||
|
```
|
||||||
|
|
||||||
|
### Copy kubecfg to your path
|
||||||
|
|
||||||
|
```
|
||||||
|
chmod +x kubecfg
|
||||||
|
mv kubecfg /usr/local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Create a secure tunnel for API communication
|
||||||
|
|
||||||
|
```
|
||||||
|
ssh -f -nNT -L 8080:127.0.0.1:8080 core@<master-public-ip>
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user