Add support for [cluster] parameters and [cluster_template] parameters
This change introduces support managing parameters in the following two sections. - [cluster] - [cluster_template] Note that parameters for swarm and mesos are intentionally excluded from this change, because mesos support is being deprecated and usage of swarm would be not so popular as kubernetes these days. Change-Id: I41ebc97d67eee5e5543bb48d878802e7777c47a8
This commit is contained in:
parent
b3f2138647
commit
344a27abf7
manifests
releasenotes/notes
spec/classes
40
manifests/cluster.pp
Normal file
40
manifests/cluster.pp
Normal file
@ -0,0 +1,40 @@
|
||||
# == Class: magnum::cluster
|
||||
#
|
||||
# Setup magnum cluster.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*etcd_discovery_service_endpoint_format*]
|
||||
# (optional) Url for etcd public discovery endpoint.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*nodes_affinity_policy*]
|
||||
# (optional) Affinity policy for server group of cluster nodes.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*temp_cache_dir*]
|
||||
# (optional) Explicitly specify the temporary directory to hold cached TLS
|
||||
# certs.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*pre_delete_lb_timeout*]
|
||||
# (optional) The timeout in seconds to wait for the load balancers to be
|
||||
# deleted.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
class magnum::cluster (
|
||||
$etcd_discovery_service_endpoint_format = $::os_service_default,
|
||||
$nodes_affinity_policy = $::os_service_default,
|
||||
$temp_cache_dir = $::os_service_default,
|
||||
$pre_delete_lb_timeout = $::os_service_default,
|
||||
) {
|
||||
|
||||
include magnum::deps
|
||||
|
||||
magnum_config {
|
||||
'cluster/etcd_discovery_service_endpoint_format': value => $etcd_discovery_service_endpoint_format;
|
||||
'cluster/nodes_affinity_policy': value => $nodes_affinity_policy;
|
||||
'cluster/temp_cache_dir': value => $temp_cache_dir;
|
||||
'cluster/pre_delete_lb_timeout': value => $pre_delete_lb_timeout;
|
||||
}
|
||||
}
|
26
manifests/cluster_template.pp
Normal file
26
manifests/cluster_template.pp
Normal file
@ -0,0 +1,26 @@
|
||||
# == Class: magnum::cluster_template
|
||||
#
|
||||
# Setup magnum cluster_template.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*kubernetes_allowed_network_drivers*]
|
||||
# (optional) Allowed network drivers for kubernetes cluster-templates.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*kubernetes_default_network_driver*]
|
||||
# (optional) Default network driver for kubernetes.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
class magnum::cluster_template (
|
||||
$kubernetes_allowed_network_drivers = $::os_service_default,
|
||||
$kubernetes_default_network_driver = $::os_service_default,
|
||||
) {
|
||||
|
||||
include magnum::deps
|
||||
|
||||
magnum_config {
|
||||
'cluster_template/kubernetes_allowed_network_drivers': value => join(any2array($kubernetes_allowed_network_drivers), ',');
|
||||
'cluster_template/kubernetes_default_network_driver': value => $kubernetes_default_network_driver;
|
||||
}
|
||||
}
|
7
releasenotes/notes/magnum-cluster-3a22edc482e33171.yaml
Normal file
7
releasenotes/notes/magnum-cluster-3a22edc482e33171.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The following two classes have been added.
|
||||
|
||||
- ``magnum::cluster``
|
||||
- ``magnum::cluster_template``
|
44
spec/classes/magnum_cluster_spec.rb
Normal file
44
spec/classes/magnum_cluster_spec.rb
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'magnum::cluster' do
|
||||
shared_examples 'magnum::cluster' do
|
||||
|
||||
it 'contains default values' do
|
||||
is_expected.to contain_magnum_config('cluster/etcd_discovery_service_endpoint_format').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_magnum_config('cluster/nodes_affinity_policy').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_magnum_config('cluster/temp_cache_dir').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_magnum_config('cluster/pre_delete_lb_timeout').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
context 'configure cluster with parameters' do
|
||||
let :params do
|
||||
{
|
||||
:etcd_discovery_service_endpoint_format => 'https://discovery.etcd.io/new?size=%(size)d',
|
||||
:nodes_affinity_policy => 'soft-anti-affinity',
|
||||
:temp_cache_dir => '/var/lib/magnum/certificate-cache',
|
||||
:pre_delete_lb_timeout => 60,
|
||||
}
|
||||
end
|
||||
|
||||
it 'contains overrided values' do
|
||||
is_expected.to contain_magnum_config('cluster/etcd_discovery_service_endpoint_format').with_value('https://discovery.etcd.io/new?size=%(size)d')
|
||||
is_expected.to contain_magnum_config('cluster/nodes_affinity_policy').with_value('soft-anti-affinity')
|
||||
is_expected.to contain_magnum_config('cluster/temp_cache_dir').with_value('/var/lib/magnum/certificate-cache')
|
||||
is_expected.to contain_magnum_config('cluster/pre_delete_lb_timeout').with_value(60)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge(OSDefaults.get_facts({}))
|
||||
end
|
||||
|
||||
it_behaves_like 'magnum::cluster'
|
||||
end
|
||||
end
|
||||
end
|
37
spec/classes/magnum_cluster_template_spec.rb
Normal file
37
spec/classes/magnum_cluster_template_spec.rb
Normal file
@ -0,0 +1,37 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'magnum::cluster_template' do
|
||||
shared_examples 'magnum::cluster_template' do
|
||||
|
||||
it 'contains default values' do
|
||||
is_expected.to contain_magnum_config('cluster_template/kubernetes_allowed_network_drivers').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_magnum_config('cluster_template/kubernetes_default_network_driver').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
context 'configure cluster_template with parameters' do
|
||||
let :params do
|
||||
{
|
||||
:kubernetes_allowed_network_drivers => ['all'],
|
||||
:kubernetes_default_network_driver => 'flannel',
|
||||
}
|
||||
end
|
||||
|
||||
it 'contains overrided values' do
|
||||
is_expected.to contain_magnum_config('cluster_template/kubernetes_allowed_network_drivers').with_value('all')
|
||||
is_expected.to contain_magnum_config('cluster_template/kubernetes_default_network_driver').with_value('flannel')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge(OSDefaults.get_facts({}))
|
||||
end
|
||||
|
||||
it_behaves_like 'magnum::cluster_template'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user