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

[MANOPD-90205] fix for vulnerability scanning failure #474

Closed
wants to merge 3 commits into from
Closed
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
9 changes: 6 additions & 3 deletions kubemarine/kubernetes/__init__.py
Original file line number Diff line number Diff line change
@@ -428,7 +428,8 @@ def join_control_plane(cluster: KubernetesCluster, node: NodeGroup, join_dict: d
"kubeadm join "
" --config=/etc/kubernetes/join-config.yaml"
" --ignore-preflight-errors='" + cluster.inventory['services']['kubeadm_flags']['ignorePreflightErrors'] + "'"
" --v=5",
" --v=5 &&"
"sudo chown etcd:etcd /var/lib/etcd",
hide=False)

log.debug("Patching apiServer bind-address for control-plane %s" % node_name)
@@ -443,7 +444,8 @@ def join_control_plane(cluster: KubernetesCluster, node: NodeGroup, join_dict: d
"kubeadm join "
" --config=/etc/kubernetes/join-config.yaml "
" --ignore-preflight-errors='" + cluster.inventory['services']['kubeadm_flags']['ignorePreflightErrors'] + "'"
" --v=5",
" --v=5 &&"
"sudo chown etcd:etcd /var/lib/etcd",
hide=False)
defer.sudo("systemctl restart kubelet")
copy_admin_config(log, defer)
@@ -570,7 +572,8 @@ def init_first_control_plane(group: NodeGroup) -> None:
" --upload-certs"
" --config=/etc/kubernetes/init-config.yaml"
" --ignore-preflight-errors='" + cluster.inventory['services']['kubeadm_flags']['ignorePreflightErrors'] + "'"
" --v=5",
" --v=5 &&"
"sudo chown etcd:etcd /var/lib/etcd",
hide=False)

copy_admin_config(log, first_control_plane)
14 changes: 14 additions & 0 deletions kubemarine/procedures/install.py
Original file line number Diff line number Diff line change
@@ -139,6 +139,19 @@ def system_prepare_system_sysctl(group: NodeGroup):
sysctl.reload,
])

@_applicable_for_new_nodes_with_roles('all')
def system_prepare_add_etcd_user(group: NodeGroup):
cluster: KubernetesCluster = group.cluster
log = cluster.log
log.debug("Checking existence of etcd user for ETCD")
kubernetes_nodes = cluster.make_group_from_roles(['control-plane'])
for member_node in kubernetes_nodes.get_ordered_members_list():
user_exists = member_node.sudo("id etcd", warn=True)
# log.debug(user_exists.stderr_contains("no such user"))
if user_exists.stderr_contains("no such user"):
log.debug("etcd user doesn't exists, creating the user")
member_node.sudo("adduser etcd --disabled-password --gecos ''")
else: log.debug("etcd user already exits")

@_applicable_for_new_nodes_with_roles('all')
def system_prepare_system_setup_selinux(group: NodeGroup):
@@ -583,6 +596,7 @@ def overview(cluster: KubernetesCluster):
"disable_swap": system_prepare_system_disable_swap,
"modprobe": system_prepare_system_modprobe,
"sysctl": system_prepare_system_sysctl,
"user_add": system_prepare_add_etcd_user,
"audit": {
"install": system_install_audit,
"configure_daemon": system_prepare_audit_daemon,
8 changes: 6 additions & 2 deletions kubemarine/procedures/restore.py
Original file line number Diff line number Diff line change
@@ -114,13 +114,17 @@ def stop_cluster(cluster: KubernetesCluster):
'sudo docker rm -f $(sudo docker ps -a -q); '
'sudo docker ps -a; '
'sudo rm -rf /var/lib/etcd; '
'sudo mkdir -p /var/lib/etcd', warn=True)
'sudo mkdir -p /var/lib/etcd && '
'sudo chmod 700 /var/lib/etcd && '
'sudo chown etcd:etcd /var/lib/etcd', warn=True)
else:
result = cluster.nodes['control-plane'].sudo('systemctl stop kubelet; '
'sudo crictl rm -fa; '
'sudo crictl ps -a; '
'sudo rm -rf /var/lib/etcd; '
'sudo mkdir -p /var/lib/etcd', warn=True)
'sudo mkdir -p /var/lib/etcd && '
'sudo chmod 700 /var/lib/etcd && '
'sudo chown etcd:etcd /var/lib/etcd', warn=True)
cluster.log.verbose(result)