Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kubespray
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Kubespray
Commits
9ddace05
Commit
9ddace05
authored
8 years ago
by
Smaine Kahlouch
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #294 from billyoung/master
Add IAM profiles for Kubernetes nodes
parents
47061a31
1556d1c6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/terraform/aws/00-create-infrastructure.tf
+118
-0
118 additions, 0 deletions
contrib/terraform/aws/00-create-infrastructure.tf
with
118 additions
and
0 deletions
contrib/terraform/aws/00-create-infrastructure.tf
+
118
−
0
View file @
9ddace05
...
...
@@ -81,6 +81,112 @@ provider "aws" {
region
=
"
${
var
.
awsRegion
}
"
}
variable
"iam_prefix"
{
type
=
"string"
description
=
"Prefix name for IAM profiles"
}
resource
"aws_iam_instance_profile"
"kubernetes_master_profile"
{
name
=
"
${
var
.
iam_prefix
}
_kubernetes_master_profile"
roles
=
[
"
${
aws_iam_role
.
kubernetes_master_role
.
name
}
"
]
}
resource
"aws_iam_role"
"kubernetes_master_role"
{
name
=
"
${
var
.
iam_prefix
}
_kubernetes_master_role"
assume_role_policy
=
<<
EOF
{
"Version"
:
"2012-10-17"
,
"Statement"
:
[
{
"Effect"
:
"Allow"
,
"Principal"
:
{
"Service"
:
"ec2.amazonaws.com"
},
"Action"
:
"sts:AssumeRole"
}
]
}
EOF
}
resource
"aws_iam_role_policy"
"kubernetes_master_policy"
{
name
=
"
${
var
.
iam_prefix
}
_kubernetes_master_policy"
role
=
"
${
aws_iam_role
.
kubernetes_master_role
.
id
}
"
policy
=
<<
EOF
{
"Version"
:
"2012-10-17"
,
"Statement"
:
[
{
"Effect"
:
"Allow"
,
"Action"
:
[
"ec2:*"
],
"Resource"
:
[
"*"
]
},
{
"Effect"
:
"Allow"
,
"Action"
:
[
"elasticloadbalancing:*"
],
"Resource"
:
[
"*"
]
},
{
"Effect"
:
"Allow"
,
"Action"
:
"s3:*"
,
"Resource"
:
"*"
}
]
}
EOF
}
resource
"aws_iam_instance_profile"
"kubernetes_node_profile"
{
name
=
"
${
var
.
iam_prefix
}
_kubernetes_node_profile"
roles
=
[
"
${
aws_iam_role
.
kubernetes_node_role
.
name
}
"
]
}
resource
"aws_iam_role"
"kubernetes_node_role"
{
name
=
"
${
var
.
iam_prefix
}
_kubernetes_node_role"
assume_role_policy
=
<<
EOF
{
"Version"
:
"2012-10-17"
,
"Statement"
:
[
{
"Effect"
:
"Allow"
,
"Principal"
:
{
"Service"
:
"ec2.amazonaws.com"
},
"Action"
:
"sts:AssumeRole"
}
]
}
EOF
}
resource
"aws_iam_role_policy"
"kubernetes_node_policy"
{
name
=
"
${
var
.
iam_prefix
}
_kubernetes_node_policy"
role
=
"
${
aws_iam_role
.
kubernetes_node_role
.
id
}
"
policy
=
<<
EOF
{
"Version"
:
"2012-10-17"
,
"Statement"
:
[
{
"Effect"
:
"Allow"
,
"Action"
:
"s3:*"
,
"Resource"
:
"*"
},
{
"Effect"
:
"Allow"
,
"Action"
:
"ec2:Describe*"
,
"Resource"
:
"*"
},
{
"Effect"
:
"Allow"
,
"Action"
:
"ec2:AttachVolume"
,
"Resource"
:
"*"
},
{
"Effect"
:
"Allow"
,
"Action"
:
"ec2:DetachVolume"
,
"Resource"
:
"*"
}
]
}
EOF
}
resource
"aws_instance"
"master"
{
count
=
"
${
var
.
numControllers
}
"
ami
=
"
${
var
.
ami
}
"
...
...
@@ -89,6 +195,7 @@ resource "aws_instance" "master" {
vpc_security_group_ids
=
[
"
${
var
.
securityGroups
}
"
]
key_name
=
"
${
var
.
SSHKey
}
"
disable_api_termination
=
"
${
var
.
terminate_protect
}
"
iam_instance_profile
=
"
${
aws_iam_instance_profile
.
kubernetes_master_profile
.
id
}
"
root_block_device
{
volume_size
=
"
${
var
.
volSizeController
}
"
}
...
...
@@ -122,6 +229,7 @@ resource "aws_instance" "minion" {
vpc_security_group_ids
=
[
"
${
var
.
securityGroups
}
"
]
key_name
=
"
${
var
.
SSHKey
}
"
disable_api_termination
=
"
${
var
.
terminate_protect
}
"
iam_instance_profile
=
"
${
aws_iam_instance_profile
.
kubernetes_node_profile
.
id
}
"
root_block_device
{
volume_size
=
"
${
var
.
volSizeNodes
}
"
}
...
...
@@ -130,6 +238,14 @@ resource "aws_instance" "minion" {
}
}
output
"kubernetes_master_profile"
{
value
=
"
${
aws_iam_instance_profile
.
kubernetes_master_profile
.
id
}
"
}
output
"kubernetes_node_profile"
{
value
=
"
${
aws_iam_instance_profile
.
kubernetes_node_profile
.
id
}
"
}
output
"master-ip"
{
value
=
"
${
join
(
", "
,
aws_instance
.
master
.
*
.
private_ip
)}
"
}
...
...
@@ -141,3 +257,5 @@ output "etcd-ip" {
output
"minion-ip"
{
value
=
"
${
join
(
", "
,
aws_instance
.
minion
.
*
.
private_ip
)}
"
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment