mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-25 16:41:12 +02:00
fix(init): move directory creation to kubeadm pre-func (#688)
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
parent
6cf260c5af
commit
20f4d77d39
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
criconstants "github.com/containerd/cri/pkg/constants"
|
criconstants "github.com/containerd/cri/pkg/constants"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/containerd"
|
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/containerd"
|
||||||
@ -38,6 +39,24 @@ func (k *Kubeadm) ID(data *userdata.UserData) string {
|
|||||||
// PreFunc implements the Service interface.
|
// PreFunc implements the Service interface.
|
||||||
// nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func (k *Kubeadm) PreFunc(ctx context.Context, data *userdata.UserData) (err error) {
|
func (k *Kubeadm) PreFunc(ctx context.Context, data *userdata.UserData) (err error) {
|
||||||
|
requiredMounts := []string{
|
||||||
|
"/dev/disk/by-path",
|
||||||
|
"/etc/kubernetes",
|
||||||
|
"/etc/kubernetes/manifests",
|
||||||
|
"/run",
|
||||||
|
"/sys/fs/cgroup",
|
||||||
|
"/usr/libexec/kubernetes",
|
||||||
|
"/var/lib/containerd",
|
||||||
|
"/var/lib/kubelet",
|
||||||
|
"/var/log/pods",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, dir := range requiredMounts {
|
||||||
|
if err = os.MkdirAll(dir, os.ModeDir); err != nil {
|
||||||
|
return errors.Wrapf(err, "create %s", dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reqs := []*containerd.ImportRequest{
|
reqs := []*containerd.ImportRequest{
|
||||||
{
|
{
|
||||||
Path: "/usr/images/hyperkube.tar",
|
Path: "/usr/images/hyperkube.tar",
|
||||||
@ -148,9 +167,7 @@ func (k *Kubeadm) DependsOn(data *userdata.UserData) []string {
|
|||||||
|
|
||||||
// Condition implements the Service interface.
|
// Condition implements the Service interface.
|
||||||
func (k *Kubeadm) Condition(data *userdata.UserData) conditions.Condition {
|
func (k *Kubeadm) Condition(data *userdata.UserData) conditions.Condition {
|
||||||
files := []string{constants.ContainerdAddress}
|
return nil
|
||||||
|
|
||||||
return conditions.WaitForFilesToExist(files...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Runner implements the Service interface.
|
// Runner implements the Service interface.
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -40,24 +39,6 @@ func (k *Kubelet) ID(data *userdata.UserData) string {
|
|||||||
|
|
||||||
// PreFunc implements the Service interface.
|
// PreFunc implements the Service interface.
|
||||||
func (k *Kubelet) PreFunc(ctx context.Context, data *userdata.UserData) error {
|
func (k *Kubelet) PreFunc(ctx context.Context, data *userdata.UserData) error {
|
||||||
requiredMounts := []string{
|
|
||||||
"/dev/disk/by-path",
|
|
||||||
"/etc/kubernetes",
|
|
||||||
"/etc/kubernetes/manifests",
|
|
||||||
"/run",
|
|
||||||
"/sys/fs/cgroup",
|
|
||||||
"/usr/libexec/kubernetes",
|
|
||||||
"/var/lib/containerd",
|
|
||||||
"/var/lib/kubelet",
|
|
||||||
"/var/log/pods",
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, dir := range requiredMounts {
|
|
||||||
if err := os.MkdirAll(dir, os.ModeDir); err != nil {
|
|
||||||
return fmt.Errorf("create %s: %s", dir, err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user