parent
d7b79395c7
commit
f25b6fce1c
|
@ -39,7 +39,7 @@ class SearchEC2Tags(object):
|
||||||
hosts[group] = []
|
hosts[group] = []
|
||||||
tag_key = "kubespray-role"
|
tag_key = "kubespray-role"
|
||||||
tag_value = ["*"+group+"*"]
|
tag_value = ["*"+group+"*"]
|
||||||
region = os.environ['REGION']
|
region = os.environ['AWS_REGION']
|
||||||
|
|
||||||
ec2 = boto3.resource('ec2', region)
|
ec2 = boto3.resource('ec2', region)
|
||||||
filters = [{'Name': 'tag:'+tag_key, 'Values': tag_value}, {'Name': 'instance-state-name', 'Values': ['running']}]
|
filters = [{'Name': 'tag:'+tag_key, 'Values': tag_value}, {'Name': 'instance-state-name', 'Values': ['running']}]
|
||||||
|
@ -67,6 +67,11 @@ class SearchEC2Tags(object):
|
||||||
if node_labels_tag:
|
if node_labels_tag:
|
||||||
ansible_host['node_labels'] = dict([ label.strip().split('=') for label in node_labels_tag[0]['Value'].split(',') ])
|
ansible_host['node_labels'] = dict([ label.strip().split('=') for label in node_labels_tag[0]['Value'].split(',') ])
|
||||||
|
|
||||||
|
##Set when instance actually has node_taints
|
||||||
|
node_taints_tag = list(filter(lambda t: t['Key'] == 'kubespray-node-taints', instance.tags))
|
||||||
|
if node_taints_tag:
|
||||||
|
ansible_host['node_taints'] = list([ taint.strip() for taint in node_taints_tag[0]['Value'].split(',') ])
|
||||||
|
|
||||||
hosts[group].append(dns_name)
|
hosts[group].append(dns_name)
|
||||||
hosts['_meta']['hostvars'][dns_name] = ansible_host
|
hosts['_meta']['hostvars'][dns_name] = ansible_host
|
||||||
|
|
||||||
|
|
14
docs/aws.md
14
docs/aws.md
|
@ -58,11 +58,23 @@ Guide:
|
||||||
```ShellSession
|
```ShellSession
|
||||||
export AWS_ACCESS_KEY_ID="xxxxx"
|
export AWS_ACCESS_KEY_ID="xxxxx"
|
||||||
export AWS_SECRET_ACCESS_KEY="yyyyy"
|
export AWS_SECRET_ACCESS_KEY="yyyyy"
|
||||||
export REGION="us-east-2"
|
export AWS_REGION="us-east-2"
|
||||||
```
|
```
|
||||||
|
|
||||||
- We will now create our cluster. There will be either one or two small changes. The first is that we will specify `-i inventory/kubespray-aws-inventory.py` as our inventory script. The other is conditional. If your AWS instances are public facing, you can set the `VPC_VISIBILITY` variable to `public` and that will result in public IP and DNS names being passed into the inventory. This causes your cluster.yml command to look like `VPC_VISIBILITY="public" ansible-playbook ... cluster.yml`
|
- We will now create our cluster. There will be either one or two small changes. The first is that we will specify `-i inventory/kubespray-aws-inventory.py` as our inventory script. The other is conditional. If your AWS instances are public facing, you can set the `VPC_VISIBILITY` variable to `public` and that will result in public IP and DNS names being passed into the inventory. This causes your cluster.yml command to look like `VPC_VISIBILITY="public" ansible-playbook ... cluster.yml`
|
||||||
|
|
||||||
|
**Optional** Using labels and taints
|
||||||
|
|
||||||
|
To add labels to your kubernetes node, add the following tag to your instance:
|
||||||
|
|
||||||
|
- Key: `kubespray-node-labels`
|
||||||
|
- Value: `node-role.kubernetes.io/ingress=`
|
||||||
|
|
||||||
|
To add taints to your kubernetes node, add the following tag to your instance:
|
||||||
|
|
||||||
|
- Key: `kubespray-node-taints`
|
||||||
|
- Value: `node-role.kubernetes.io/ingress=:NoSchedule`
|
||||||
|
|
||||||
## Kubespray configuration
|
## Kubespray configuration
|
||||||
|
|
||||||
Declare the cloud config variables for the `aws` provider as follows. Setting these variables are optional and depend on your use case.
|
Declare the cloud config variables for the `aws` provider as follows. Setting these variables are optional and depend on your use case.
|
||||||
|
|
Loading…
Reference in New Issue