Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ mod 'puppetlabs-stdlib', '6.6.0'
mod 'puppet-augeasproviders_sysctl', '3.2.0'
mod 'puppet-augeasproviders_core', '3.2.1'
mod 'puppet-kmod', '3.2.0'
mod 'puppetlabs-vcsrepo', '6.1.0'

1 change: 1 addition & 0 deletions data/k8s_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ kubernetes::cni_provider: flannel
kubernetes::etcd_ip: "%{networking.ip}"
kubernetes::kube_api_advertise_address: "%{networking.ip}"
kubernetes::install_dashboard: true
kubernetes::ttl: 0h

kubernetes::etcd_peers: "%{alias('terraform.tag_ip.controller')}"
kubernetes::controller_address: "%{lookup('terraform.tag_ip.controller.0')}:6443"
3 changes: 3 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ hierarchy:
- name: "Terraform data"
paths:
- "terraform_data.yaml"
- name: "User data"
paths:
- "user_data.yaml"
- name: "Other YAML hierarchy levels"
paths:
- "common.yaml"
Expand Down
64 changes: 64 additions & 0 deletions manifests/autoscaler.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
class autoscaler ()
{
$instances = lookup('terraform.instances')

$pool_instances = $instances.filter |$name, $instance| {
'pool' in $instance['tags']
}
$yaml_instances = $pool_instances.map |$name, $instance| {
{
$name => {
'specs' => $instance['specs'],
},
}
}

$yaml_provider = {
'tfe' => {
'token' => lookup('tfe_token'),
'workspace' => lookup('tfe_workspace')
}
}

$yaml_content = {
'provider' => $yaml_provider,
'instances' => $yaml_instances,
}

file { '/etc/kubernetes/autoscaler.yaml':
content => $yaml_content.to_yaml,
}

vcsrepo { '/etc/kubernetes/k8s-autoscaler':
ensure => present,
provider => git,
source => 'https://github.com/etiennedub/k8s-autoscaler-python.git',
}

exec { 'autoscaler_config':
command => 'kubectl create cm externalgrpc-autoscaler-cluster-config --from-file=autoscaler.yaml --namespace=kube-system -o yaml --dry-run | kubectl apply -f -',
path => ['/usr/bin'],
cwd => '/etc/kubernetes/',
environment => ['KUBECONFIG=/etc/kubernetes/admin.conf'],
refreshonly => true,
subscribe => File['/etc/kubernetes/autoscaler.yaml'],
tries => 4,
try_sleep => 15,
timeout => 15,
}

exec { 'autoscaler_deploy':
command => 'kubectl apply -f cluster-autoscaler-config.yaml -f ./cluster-autoscaler.yaml -f ./externalgrpc-autoscaler-service.yaml -f ./externalgrpc-autoscaler.yaml',
path => ['/usr/bin'],
cwd => '/etc/kubernetes/k8s-autoscaler/deploy',
environment => ['KUBECONFIG=/etc/kubernetes/admin.conf'],
refreshonly => true,
subscribe => Vcsrepo['/etc/kubernetes/k8s-autoscaler'],
tries => 4,
try_sleep => 15,
timeout => 15,
require => [
Exec['autoscaler_config'],
],
}
}
5 changes: 5 additions & 0 deletions manifests/site.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
content => inline_template($host_template)
}


if 'controller' in $tags {
class { 'kubernetes':
controller => true,
Expand All @@ -46,6 +47,10 @@
File['/etc/hosts']
]
}
class { 'autoscaler':
require => Class['kubernetes']
}

} elsif 'worker' in $tags {
class { 'kubernetes':
worker => true,
Expand Down