Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request kubernetes-retired#1123 from ivanilves/node-draine…
Browse files Browse the repository at this point in the history
…r-iam-role

Add [optional] explicit IAM role specification to NodeDrainer
  • Loading branch information
mumoshu authored Feb 6, 2018
2 parents 0d26618 + de4b7ca commit d20102b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/controlplane/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func NewDefaultCluster() *Cluster {
NodeDrainer: model.NodeDrainer{
Enabled: false,
DrainTimeout: 5,
IAMRole: model.IAMRole{},
},
Oidc: model.Oidc{
Enabled: false,
Expand Down
4 changes: 4 additions & 0 deletions core/controlplane/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,17 +930,21 @@ func TestNodeDrainerConfig(t *testing.T) {
nodeDrainer: model.NodeDrainer{
Enabled: false,
DrainTimeout: 5,
IAMRole: model.IAMRole{},
},
},
{
conf: `
experimental:
nodeDrainer:
enabled: true
iamRole:
arn: arn:aws:iam::0123456789012:role/asg-list-role
`,
nodeDrainer: model.NodeDrainer{
Enabled: true,
DrainTimeout: 5,
IAMRole: model.IAMRole{ARN: model.ARN{Arn: "arn:aws:iam::0123456789012:role/asg-list-role"}},
},
},
{
Expand Down
3 changes: 3 additions & 0 deletions core/controlplane/config/templates/cloud-config-controller
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,9 @@ write_files:
k8s-app: kube-node-drainer-asg-status-updater
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
{{if ne .Experimental.NodeDrainer.IAMRole.ARN.Arn "" -}}
iam.amazonaws.com/role: {{ .Experimental.NodeDrainer.IAMRole.ARN.Arn }}
{{ end }}
spec:
{{if .Experimental.Admission.Priority.Enabled -}}
priorityClassName: system-node-critical
Expand Down
6 changes: 5 additions & 1 deletion core/controlplane/config/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ addons:

# When set to true this configures security groups for prometheus between nodes.
# This includes the following ports: 10252, 10251, 10250, 9100, and 4194
prometheus:
prometheus:
securityGroupsEnabled: false

# Experimental features will change in backward-incompatible ways
Expand Down Expand Up @@ -1296,6 +1296,10 @@ experimental:
enabled: false
# Maximum time to wait, in minutes, for the node to be completely drained. Must be an integer between 1 and 60.
drainTimeout: 5
# IAM role to assume with kube2iam for the pod in "kube-node-drainer-asg-status-updater" deployment.
iamRole:
# Empty, inactive by default. Set it to valid ARN "arn: arn:aws:iam::0123456789012:role/roleName" to activate.
arn: ""

# Configure OpenID Connect token authenticator plugin in Kubernetes API server.
# For using Dex as a custom OIDC provider, please check "contrib/dex/README.md".
Expand Down
5 changes: 3 additions & 2 deletions model/node_drainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
)

type NodeDrainer struct {
Enabled bool `yaml:"enabled"`
DrainTimeout int `yaml:"drainTimeout"`
Enabled bool `yaml:"enabled"`
DrainTimeout int `yaml:"drainTimeout"`
IAMRole IAMRole `yaml:"iamRole,omitempty"`
}

func (nd *NodeDrainer) DrainTimeoutInSeconds() int {
Expand Down

0 comments on commit d20102b

Please sign in to comment.