Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
fed74b72
Commit
fed74b72
authored
Aug 16, 2018
by
George Kraft
Committed by
cdkbot
Aug 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
juju: Add kubelet-extra-config to kubernetes-worker (#145)
parent
57784969
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
2 deletions
+40
-2
config.yaml
cluster/juju/layers/kubernetes-worker/config.yaml
+17
-0
kubernetes_worker.py
...ju/layers/kubernetes-worker/reactive/kubernetes_worker.py
+23
-2
No files found.
cluster/juju/layers/kubernetes-worker/config.yaml
View file @
fed74b72
...
...
@@ -89,3 +89,20 @@ options:
as possible. You may also set a custom string as described in the
'refresh.timer' section here:
https://forum.snapcraft.io/t/system-options/87
kubelet-extra-config
:
default
:
"
{}"
type
:
string
description
:
|
Extra configuration to be passed to kubelet. Any values specified in this
config will be merged into a KubeletConfiguration file that is passed to
the kubelet service via the --config flag. This can be used to override
values provided by the charm.
Requires Kubernetes 1.10+.
The value for this config must be a YAML mapping that can be safely
merged with a KubeletConfiguration file. For example:
{evictionHard: {memory.available: 200Mi}}
For more information about KubeletConfiguration, see upstream docs:
https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/
cluster/juju/layers/kubernetes-worker/reactive/kubernetes_worker.py
View file @
fed74b72
...
...
@@ -552,8 +552,9 @@ def apply_node_labels():
@when_any
(
'config.changed.kubelet-extra-args'
,
'config.changed.proxy-extra-args'
)
def
extra_args_changed
():
'config.changed.proxy-extra-args'
,
'config.changed.kubelet-extra-config'
)
def
config_changed_requires_restart
():
set_state
(
'kubernetes-worker.restart-needed'
)
...
...
@@ -674,6 +675,20 @@ def configure_kubernetes_service(service, base_args, extra_args_key):
db
.
set
(
prev_args_key
,
args
)
def
merge_kubelet_extra_config
(
config
,
extra_config
):
''' Updates config to include the contents of extra_config. This is done
recursively to allow deeply nested dictionaries to be merged.
This is destructive: it modifies the config dict that is passed in.
'''
for
k
,
extra_config_value
in
extra_config
.
items
():
if
isinstance
(
extra_config_value
,
dict
):
config_value
=
config
.
setdefault
(
k
,
{})
merge_kubelet_extra_config
(
config_value
,
extra_config_value
)
else
:
config
[
k
]
=
extra_config_value
def
configure_kubelet
(
dns
,
ingress_ip
):
layer_options
=
layer
.
options
(
'tls-client'
)
ca_cert_path
=
layer_options
.
get
(
'ca_certificate_path'
)
...
...
@@ -727,6 +742,12 @@ def configure_kubelet(dns, ingress_ip):
'DevicePlugins'
:
True
}
# Add kubelet-extra-config. This needs to happen last so that it
# overrides any config provided by the charm.
kubelet_extra_config
=
hookenv
.
config
(
'kubelet-extra-config'
)
kubelet_extra_config
=
yaml
.
load
(
kubelet_extra_config
)
merge_kubelet_extra_config
(
kubelet_config
,
kubelet_extra_config
)
# Render the file and configure Kubelet to use it
os
.
makedirs
(
'/root/cdk/kubelet'
,
exist_ok
=
True
)
with
open
(
'/root/cdk/kubelet/config.yaml'
,
'w'
)
as
f
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment