Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new parameter node_extra_taints #586

Merged
merged 3 commits into from
Jan 27, 2023
Merged
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,19 @@ An override to the label of a node.

Defaults to `hostname`.

#### `node_extra_taints`

Additional taints for node.
Defaults to `undef`.

For example,

```puppet
[{'key' => 'dedicated','value' => 'NewNode','effect' => 'NoSchedule', 'operator', => 'Equal'}]
```

About kubernetes taints `https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/`

#### `runc_source`

The download URL for `runc`.
Expand Down
1 change: 1 addition & 0 deletions manifests/config/worker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Optional[String] $feature_gates = undef,
Optional[String] $cloud_provider = $kubernetes::cloud_provider,
Optional[String] $cloud_config = $kubernetes::cloud_config,
Optional[Array[Hash]] $node_extra_taints = $kubernetes::node_extra_taints,
Optional[Array] $kubelet_extra_arguments = $kubernetes::kubelet_extra_arguments,
Optional[Hash] $kubelet_extra_config = $kubernetes::kubelet_extra_config,
Optional[Array] $ignore_preflight_errors = undef,
Expand Down
9 changes: 8 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@
# Defaults to hostname.
# NOTE: Ignored when cloud_provider is AWS, until this lands fixed https://github.com/kubernetes/kubernetes/pull/61878
#
# [*node_extra_taints*]
# Additional taints for node.
# Example:
# [{'key' => 'dedicated','value' => 'NewNode','effect' => 'NoSchedule', 'operator' => 'Equal'}]
# Defaults to undef
#
# [*token*]
# A string to use when joining nodes to the cluster. Must be in the form of '[a-z0-9]{6}.[a-z0-9]{16}'
# Defaults to undef
Expand Down Expand Up @@ -643,7 +649,8 @@
Array $controllermanager_extra_arguments = [],
Array $scheduler_extra_arguments = [],
String $service_cidr = '10.96.0.0/12',
Optional[Stdlib::Fqdn] $node_label = undef,
Optional[String] $node_label = undef,
Optional[Array[Hash]] $node_extra_taints = undef,
Optional[String] $controller_address = undef,
Optional[String] $cloud_provider = undef,
Optional[String] $cloud_config = undef,
Expand Down
34 changes: 34 additions & 0 deletions spec/classes/config/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,38 @@
expect(config_yaml['nodeRegistration']['kubeletExtraArgs']).to include('cloud-provider' => 'aws')
end
end

context 'with version => 1.20.0 and node_extra_taints => [{key => key1, value => NewNode, effect => NoSchedule, operator => Equal}' do
let(:params) do
{
'kubernetes_version' => '1.20.0',
'node_extra_taints' => [
{
'key' => 'key1',
'value' => 'NewNode',
'effect' => 'NoSchedule',
'operator' => 'Equal',
},
{
'key' => 'key2',
'value' => 'NewNode',
'effect' => 'NoSchedule',
'operator' => 'Equal',
},
],
}
end

let(:config_yaml) { YAML.safe_load(catalogue.resource('file', '/etc/kubernetes/config.yaml').send(:parameters)[:content]) }

it 'has arg key1 in first YAML document (taints) NodeRegistration' do
expect(config_yaml['nodeRegistration']['taints'][0]['key']).to include('key1')
end
it 'has arg key2 in first YAML document (taints) NodeRegistration' do
expect(config_yaml['nodeRegistration']['taints'][1]['key']).to include('key2')
end
it 'has arg effect in first YAML document (taints) NodeRegistration' do
expect(config_yaml['nodeRegistration']['taints'][0]['effect']).to include('NoSchedule')
end
end
end
13 changes: 13 additions & 0 deletions templates/v1alpha3/config_worker.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ tlsBootstrapToken: <%= @tls_bootstrap_token %>
token: <%= @token %>
nodeRegistration:
name: <%= @node_name %>
<%- if @node_extra_taints -%>
taints:
<%- @node_extra_taints.each do |item| -%>
- key: <%= item['key'] %>
<%- if item['value'] -%>
value: <%= item['value'] %>
<%- end -%>
<%- if item['operator'] -%>
operator: <%= item['operator'] %>
<%- end -%>
effect: <%= item['effect'] %>
<%- end -%>
<%- end -%>
<%- if @container_runtime == "cri_containerd" -%>
criSocket: unix:///run/containerd/containerd.sock
<%- end -%>
Expand Down
13 changes: 13 additions & 0 deletions templates/v1beta1/config_worker.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ discovery:
- 'sha256:<%= @discovery_token_hash %>'
nodeRegistration:
name: <%= @node_name %>
<%- if @node_extra_taints -%>
taints:
<%- @node_extra_taints.each do |item| -%>
- key: <%= item['key'] %>
<%- if item['value'] -%>
value: <%= item['value'] %>
<%- end -%>
<%- if item['operator'] -%>
operator: <%= item['operator'] %>
<%- end -%>
effect: <%= item['effect'] %>
<%- end -%>
<%- end -%>
<%- if @container_runtime == "cri_containerd" -%>
criSocket: unix:///run/containerd/containerd.sock
<%- end -%>
Expand Down
14 changes: 13 additions & 1 deletion templates/v1beta2/config_worker.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ discovery:
- 'sha256:<%= @discovery_token_hash %>'
nodeRegistration:
name: <%= @node_name %>
<%- if @node_extra_taints -%>
taints:
<%- @node_extra_taints.each do |item| -%>
- key: <%= item['key'] %>
<%- if item['value'] -%>
value: <%= item['value'] %>
<%- end -%>
<%- if item['operator'] -%>
operator: <%= item['operator'] %>
<%- end -%>
effect: <%= item['effect'] %>
<%- end -%>
<%- end -%>
<%- if @container_runtime == "cri_containerd" -%>
criSocket: unix:///run/containerd/containerd.sock
taints: null
<%- end -%>
kubeletExtraArgs:
<%- if @cloud_provider -%>
Expand Down
14 changes: 13 additions & 1 deletion templates/v1beta3/config_worker.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@ discovery:
- 'sha256:<%= @discovery_token_hash %>'
nodeRegistration:
name: <%= @node_name %>
<%- if @node_extra_taints -%>
taints:
<%- @node_extra_taints.each do |item| -%>
- key: <%= item['key'] %>
<%- if item['value'] -%>
value: <%= item['value'] %>
<%- end -%>
<%- if item['operator'] -%>
operator: <%= item['operator'] %>
<%- end -%>
effect: <%= item['effect'] %>
<%- end -%>
<%- end -%>
<%- if @container_runtime == "cri_containerd" -%>
criSocket: unix:///run/containerd/containerd.sock
taints: null
<%- end -%>
kubeletExtraArgs:
<%- if @cloud_provider -%>
Expand Down