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

refactor: run kubelet and etcd in system containerd #9829

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
5 changes: 3 additions & 2 deletions internal/app/machined/pkg/system/services/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (e *Etcd) PreFunc(ctx context.Context, r runtime.Runtime) error {
return err
}

client, err := containerdapi.New(constants.CRIContainerdAddress)
client, err := containerdapi.New(constants.SystemContainerdAddress)
if err != nil {
return err
}
Expand Down Expand Up @@ -181,7 +181,7 @@ func (e *Etcd) Condition(r runtime.Runtime) conditions.Condition {

// DependsOn implements the Service interface.
func (e *Etcd) DependsOn(runtime.Runtime) []string {
return []string{"cri"}
return []string{"containerd"}
}

// Runner implements the Service interface.
Expand Down Expand Up @@ -223,6 +223,7 @@ func (e *Etcd) Runner(r runtime.Runtime) (runner.Runner, error) {
r.Config().Debug(),
&args,
runner.WithLoggingManager(r.Logging()),
runner.WithContainerdAddress(constants.SystemContainerdAddress),
runner.WithNamespace(constants.SystemContainerdNamespace),
runner.WithContainerImage(e.imgRef),
runner.WithEnv(env),
Expand Down
5 changes: 3 additions & 2 deletions internal/app/machined/pkg/system/services/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (k *Kubelet) PreFunc(ctx context.Context, r runtime.Runtime) error {

spec := specResource.TypedSpec()

client, err := containerdapi.New(constants.CRIContainerdAddress)
client, err := containerdapi.New(constants.SystemContainerdAddress)
if err != nil {
return err
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func (k *Kubelet) Condition(r runtime.Runtime) conditions.Condition {

// DependsOn implements the Service interface.
func (k *Kubelet) DependsOn(runtime.Runtime) []string {
return []string{"cri"}
return []string{"containerd"}
}

// Runner implements the Service interface.
Expand Down Expand Up @@ -167,6 +167,7 @@ func (k *Kubelet) Runner(r runtime.Runtime) (runner.Runner, error) {
r.Config().Debug() && r.Config().Machine().Type() == machine.TypeWorker, // enable debug logs only for the worker nodes
&args,
runner.WithLoggingManager(r.Logging()),
runner.WithContainerdAddress(constants.SystemContainerdAddress),
runner.WithNamespace(constants.SystemContainerdNamespace),
runner.WithContainerImage(k.imgRef),
runner.WithEnv(environment.Get(r.Config())),
Expand Down
Binary file modified internal/pkg/selinux/policy/policy.33
Binary file not shown.
14 changes: 0 additions & 14 deletions internal/pkg/selinux/policy/selinux/services/cri.cil
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@
(typetransition pod_containerd_t containerd_state_t process pod_t)
(allow pod_t containerd_state_t (file (entrypoint execute_no_trans)))

(type etcd_t)
(call pod_p (etcd_t))
; FIXME: insecure as anyone with access to the pod containerd may obtain this domain
(allow etcd_t containerd_state_t (file (entrypoint)))

(type etcd_pki_t)
(call protected_f (etcd_pki_t))
(allow etcd_pki_t tmpfs_t (filesystem (associate)))
(allow etcd_t etcd_pki_t (fs_classes (ro)))

(type cni_conf_t)
(call filesystem_f (cni_conf_t))
(filecon "/etc/cni(/.*)?" any (system_u object_r cni_conf_t (systemLow systemLow)))
Expand All @@ -37,10 +27,6 @@
(call filesystem_f (containerd_plugin_t))
(filecon "/opt/containerd(/.*)?" any (system_u object_r containerd_plugin_t (systemLow systemLow)))

(type etcd_data_t)
(call protected_f (etcd_data_t))
(allow etcd_t etcd_data_t (fs_classes (rw)))

(type containerd_state_t)
(call common_f (containerd_state_t))

Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/selinux/policy/selinux/services/kubelet.cil
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(type kubelet_t)
(call pod_p (kubelet_t))
; FIXME: insecure as anyone with access to the pod containerd may obtain this domain
(allow kubelet_t containerd_state_t (file (entrypoint execute_no_trans)))
(call system_container_p (kubelet_t))
(allow kubelet_t system_var_t (file (entrypoint execute execute_no_trans)))
(allow kubelet_t system_var_t (fs_classes (rw)))

(type k8s_conf_t)
(call filesystem_f (k8s_conf_t))
Expand Down
14 changes: 14 additions & 0 deletions internal/pkg/selinux/policy/selinux/services/system-containers.cil
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@
(call system_socket_f (trustd_runtime_socket_t))
(allow trustd_t trustd_runtime_socket_t (sock_file (write)))
(allow trustd_t trustd_runtime_socket_t (sock_file (relabelto)))

(type etcd_t)
(call system_container_p (etcd_t))
(allow etcd_t system_var_t (file (entrypoint execute execute_no_trans)))
(allow etcd_t system_var_t (fs_classes (rw)))

(type etcd_pki_t)
(call protected_f (etcd_pki_t))
(allow etcd_pki_t tmpfs_t (filesystem (associate)))
(allow etcd_t etcd_pki_t (fs_classes (ro)))

(type etcd_data_t)
(call protected_f (etcd_data_t))
(allow etcd_t etcd_data_t (fs_classes (rw)))
Loading