feat: add machined
This commit splits our current init into init and machined. Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
This commit is contained in:
parent
7adef1ea62
commit
8e8aae98dd
12
.drone.yml
12
.drone.yml
@ -46,6 +46,17 @@ steps:
|
||||
depends_on:
|
||||
- lint
|
||||
|
||||
- name: build-machined
|
||||
image: autonomy/build-container:latest
|
||||
pull: always
|
||||
environment:
|
||||
BUILDKIT_HOST: tcp://buildkitd.ci.svc:1234
|
||||
BINDIR: /usr/local/bin
|
||||
commands:
|
||||
- make machined
|
||||
depends_on:
|
||||
- lint
|
||||
|
||||
- name: build-osd
|
||||
image: autonomy/build-container:latest
|
||||
pull: always
|
||||
@ -124,6 +135,7 @@ steps:
|
||||
- name: dockersock
|
||||
path: /var/run
|
||||
depends_on:
|
||||
- build-machined
|
||||
- build-osd
|
||||
- build-proxyd
|
||||
- build-trustd
|
||||
|
22
Dockerfile
22
Dockerfile
@ -29,13 +29,13 @@ RUN protoc -I./proto --go_out=plugins=grpc:proto proto/api.proto
|
||||
WORKDIR /trustd
|
||||
COPY ./internal/app/trustd/proto ./proto
|
||||
RUN protoc -I./proto --go_out=plugins=grpc:proto proto/api.proto
|
||||
WORKDIR /init
|
||||
COPY ./internal/app/init/proto ./proto
|
||||
WORKDIR /machined
|
||||
COPY ./internal/app/machined/proto ./proto
|
||||
RUN protoc -I./proto --go_out=plugins=grpc:proto proto/api.proto
|
||||
FROM scratch AS generate
|
||||
COPY --from=generate-build /osd/proto/api.pb.go /internal/app/osd/proto/
|
||||
COPY --from=generate-build /trustd/proto/api.pb.go /internal/app/trustd/proto/
|
||||
COPY --from=generate-build /init/proto/api.pb.go /internal/app/init/proto/
|
||||
COPY --from=generate-build /machined/proto/api.pb.go /internal/app/machined/proto/
|
||||
|
||||
# The base target provides a container that can be used to build all Talos
|
||||
# assets.
|
||||
@ -64,6 +64,18 @@ RUN chmod +x /init
|
||||
FROM scratch AS init
|
||||
COPY --from=init-build /init /init
|
||||
|
||||
# The machined target builds the machined image.
|
||||
|
||||
FROM base AS machined-build
|
||||
ARG SHA
|
||||
ARG TAG
|
||||
ARG VERSION_PKG="github.com/talos-systems/talos/internal/pkg/version"
|
||||
WORKDIR /src/internal/app/machined
|
||||
RUN --mount=type=cache,target=/root/.cache go build -a -ldflags "-s -w -X ${VERSION_PKG}.Name=Server -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /machined
|
||||
RUN chmod +x /machined
|
||||
FROM scratch AS machined
|
||||
COPY --from=machined-build /machined /machined
|
||||
|
||||
# The ntpd target builds the ntpd image.
|
||||
|
||||
FROM base AS ntpd-build
|
||||
@ -192,6 +204,7 @@ COPY --from=docker.io/autonomy/base:f9a4941 /toolchain/lib/libblkid.* /rootfs/li
|
||||
COPY --from=docker.io/autonomy/base:f9a4941 /toolchain/lib/libuuid.* /rootfs/lib
|
||||
COPY --from=docker.io/autonomy/base:f9a4941 /toolchain/lib/libkmod.* /rootfs/lib
|
||||
COPY --from=docker.io/autonomy/kernel:ebaa167 /lib/modules /rootfs/lib/modules
|
||||
COPY --from=machined /machined /rootfs/sbin/machined
|
||||
COPY images/*.tar /rootfs/usr/images
|
||||
COPY ./hack/cleanup.sh /toolchain/bin/cleanup.sh
|
||||
RUN cleanup.sh /rootfs
|
||||
@ -212,8 +225,7 @@ COPY --from=rootfs-archive /rootfs.tar.gz /rootfs.tar.gz
|
||||
|
||||
FROM scratch AS talos
|
||||
COPY --from=rootfs-base / /
|
||||
COPY --from=init /init /sbin/init
|
||||
ENTRYPOINT ["/sbin/init"]
|
||||
ENTRYPOINT ["/sbin/machined"]
|
||||
|
||||
# The installer target generates an image that can be used to install Talos to
|
||||
# various environments.
|
||||
|
9
Makefile
9
Makefile
@ -138,7 +138,7 @@ initramfs: buildkitd
|
||||
$(COMMON_ARGS)
|
||||
|
||||
.PHONY: rootfs
|
||||
rootfs: buildkitd osd trustd proxyd ntpd
|
||||
rootfs: buildkitd machined osd trustd proxyd ntpd
|
||||
@$(BINDIR)/buildctl --addr $(BUILDKIT_HOST) \
|
||||
build \
|
||||
--output type=local,dest=build \
|
||||
@ -249,6 +249,13 @@ osctl-darwin: buildkitd
|
||||
--opt target=$@ \
|
||||
$(COMMON_ARGS)
|
||||
|
||||
.PHONY: machined
|
||||
machined: buildkitd images
|
||||
@$(BINDIR)/buildctl --addr $(BUILDKIT_HOST) \
|
||||
build \
|
||||
--opt target=$@ \
|
||||
$(COMMON_ARGS)
|
||||
|
||||
.PHONY: osd
|
||||
osd: buildkitd images
|
||||
@$(BINDIR)/buildctl --addr $(BUILDKIT_HOST) \
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
|
||||
"github.com/talos-systems/talos/cmd/osctl/pkg/client"
|
||||
"github.com/talos-systems/talos/cmd/osctl/pkg/helpers"
|
||||
initproto "github.com/talos-systems/talos/internal/app/init/proto"
|
||||
initproto "github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
)
|
||||
|
||||
// lsCmd represents the ls command
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
|
||||
"github.com/talos-systems/talos/cmd/osctl/pkg/client"
|
||||
"github.com/talos-systems/talos/cmd/osctl/pkg/helpers"
|
||||
initproto "github.com/talos-systems/talos/internal/app/init/proto"
|
||||
initproto "github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
)
|
||||
|
||||
// serviceCmd represents the service command
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/talos-systems/talos/cmd/osctl/pkg/client/config"
|
||||
initproto "github.com/talos-systems/talos/internal/app/init/proto"
|
||||
initproto "github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
"github.com/talos-systems/talos/internal/app/osd/proto"
|
||||
"github.com/talos-systems/talos/internal/pkg/proc"
|
||||
)
|
||||
|
@ -5,51 +5,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/platform"
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/reg"
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/rootfs"
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/rootfs/mount"
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/security/kspp"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/network"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/services"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/internal/pkg/grpc/factory"
|
||||
"github.com/talos-systems/talos/internal/pkg/kernel"
|
||||
"github.com/talos-systems/talos/internal/pkg/startup"
|
||||
"github.com/talos-systems/talos/internal/pkg/network"
|
||||
"github.com/talos-systems/talos/internal/pkg/rootfs"
|
||||
"github.com/talos-systems/talos/internal/pkg/rootfs/mount"
|
||||
"github.com/talos-systems/talos/internal/pkg/security/kspp"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
)
|
||||
|
||||
var (
|
||||
switchRoot *bool
|
||||
inContainer *bool
|
||||
rebootFlag = unix.LINUX_REBOOT_CMD_RESTART
|
||||
userdataArg *string
|
||||
)
|
||||
|
||||
func init() {
|
||||
switchRoot = flag.Bool("switch-root", false, "perform a switch_root")
|
||||
inContainer = flag.Bool("in-container", false, "run Talos in a container")
|
||||
userdataArg = flag.String("userdata", "", "the base64 encoded userdata")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func kmsg(prefix string) (*os.File, error) {
|
||||
out, err := os.OpenFile("/dev/kmsg", os.O_RDWR|unix.O_CLOEXEC|unix.O_NONBLOCK|unix.O_NOCTTY, 0666)
|
||||
if err != nil {
|
||||
@ -62,54 +33,6 @@ func kmsg(prefix string) (*os.File, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func container() (err error) {
|
||||
log.Println("preparing container based deploy")
|
||||
|
||||
log.Println("remounting volumes as shared mounts")
|
||||
targets := []string{"/", "/var/lib/kubelet", "/etc/cni"}
|
||||
for _, t := range targets {
|
||||
if err = unix.Mount("", t, "", unix.MS_SHARED, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if *userdataArg != "" {
|
||||
log.Printf("writing the user data: %s\n", constants.UserDataPath)
|
||||
var decoded []byte
|
||||
if decoded, err = base64.StdEncoding.DecodeString(*userdataArg); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = ioutil.WriteFile(constants.UserDataPath, decoded, 0400); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var data *userdata.UserData
|
||||
if data, err = userdata.Open(constants.UserDataPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Workarounds for running in a container.
|
||||
|
||||
data.Services.Kubeadm.IgnorePreflightErrors = []string{"FileContent--proc-sys-net-bridge-bridge-nf-call-iptables", "Swap", "SystemVerification"}
|
||||
initConfiguration, ok := data.Services.Kubeadm.Configuration.(*kubeadmapi.InitConfiguration)
|
||||
if ok {
|
||||
initConfiguration.ClusterConfiguration.ComponentConfigs.Kubelet.FailSwapOn = false
|
||||
// See https://github.com/kubernetes/kubernetes/issues/58610#issuecomment-359552443
|
||||
max := int32(0)
|
||||
maxPerCore := int32(0)
|
||||
initConfiguration.ClusterConfiguration.ComponentConfigs.KubeProxy.Conntrack.Max = &max
|
||||
initConfiguration.ClusterConfiguration.ComponentConfigs.KubeProxy.Conntrack.MaxPerCore = &maxPerCore
|
||||
}
|
||||
|
||||
log.Println("preparing the root filesystem")
|
||||
if err = rootfs.Prepare("", true, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// nolint: gocyclo
|
||||
func initram() (err error) {
|
||||
var initializer *mount.Initializer
|
||||
@ -189,250 +112,15 @@ func initram() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createOverlay(path string) error {
|
||||
log.Printf("mounting overlay for %s\n", path)
|
||||
|
||||
parts := strings.Split(path, "/")
|
||||
prefix := strings.Join(parts[1:], "-")
|
||||
diff := fmt.Sprintf("/var/%s-diff", prefix)
|
||||
workdir := fmt.Sprintf("/var/%s-workdir", prefix)
|
||||
|
||||
for _, s := range []string{diff, workdir} {
|
||||
if err := os.MkdirAll(s, 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", path, diff, workdir)
|
||||
if err := unix.Mount("overlay", path, "overlay", 0, opts); err != nil {
|
||||
return errors.Errorf("error creating overlay mount to %s: %v", path, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// nolint: gocyclo
|
||||
func root() (err error) {
|
||||
if !*inContainer {
|
||||
// Setup logging to /dev/kmsg.
|
||||
if _, err = kmsg("[talos]"); err != nil {
|
||||
return fmt.Errorf("failed to setup logging to /dev/kmsg: %v", err)
|
||||
}
|
||||
|
||||
for _, overlay := range []string{"/etc/kubernetes", "/etc/cni", "/usr/libexec/kubernetes", "/usr/etc/udev", "/opt"} {
|
||||
if err = createOverlay(overlay); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read the user data.
|
||||
log.Printf("reading the user data: %s\n", constants.UserDataPath)
|
||||
var data *userdata.UserData
|
||||
if data, err = userdata.Open(constants.UserDataPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Mount the extra partitions.
|
||||
log.Printf("mounting the extra partitions")
|
||||
if err = mount.ExtraDevices(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Write any user specified files to disk.
|
||||
log.Println("writing the files specified in the user data to disk")
|
||||
if err = data.WriteFiles(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set the requested environment variables.
|
||||
log.Println("setting environment variables")
|
||||
for key, val := range data.Env {
|
||||
if err = os.Setenv(key, val); err != nil {
|
||||
log.Printf("WARNING failed to set enivronment variable: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
poweroffCh, err := listenForPowerButton()
|
||||
if err != nil {
|
||||
log.Printf("WARNING: power off events will be ignored: %+v", err)
|
||||
}
|
||||
|
||||
termCh := make(chan os.Signal, 1)
|
||||
signal.Notify(termCh, syscall.SIGTERM)
|
||||
|
||||
// Get a handle to the system services API.
|
||||
svcs := system.Services(data)
|
||||
defer svcs.Shutdown()
|
||||
|
||||
// Instantiate internal init API
|
||||
api := reg.NewRegistrator(data)
|
||||
server := factory.NewServer(api)
|
||||
listener, err := factory.NewListener(
|
||||
factory.Network("unix"),
|
||||
factory.SocketPath(constants.InitSocketPath),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer server.Stop()
|
||||
|
||||
go func() {
|
||||
// nolint: errcheck
|
||||
server.Serve(listener)
|
||||
}()
|
||||
|
||||
startSystemServices(data)
|
||||
startKubernetesServices(data)
|
||||
|
||||
select {
|
||||
case <-api.ShutdownCh:
|
||||
log.Printf("poweroff via API received")
|
||||
// poweroff, proceed to shutdown but mark as poweroff
|
||||
rebootFlag = unix.LINUX_REBOOT_CMD_POWER_OFF
|
||||
case <-poweroffCh:
|
||||
log.Printf("poweroff via ACPI")
|
||||
// poweroff, proceed to shutdown but mark as poweroff
|
||||
rebootFlag = unix.LINUX_REBOOT_CMD_POWER_OFF
|
||||
case <-termCh:
|
||||
log.Printf("SIGTERM received, rebooting...")
|
||||
case <-api.RebootCh:
|
||||
log.Printf("reboot via API received, rebooting...")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func startSystemServices(data *userdata.UserData) {
|
||||
svcs := system.Services(data)
|
||||
|
||||
log.Println("starting system services")
|
||||
// Start the services common to all nodes.
|
||||
svcs.Start(
|
||||
&services.Networkd{},
|
||||
&services.Containerd{},
|
||||
&services.Udevd{},
|
||||
&services.UdevdTrigger{},
|
||||
&services.OSD{},
|
||||
&services.NTPd{},
|
||||
)
|
||||
// Start the services common to all master nodes.
|
||||
if data.Services.Kubeadm.IsControlPlane() {
|
||||
svcs.Start(
|
||||
&services.Trustd{},
|
||||
&services.Proxyd{},
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func startKubernetesServices(data *userdata.UserData) {
|
||||
svcs := system.Services(data)
|
||||
|
||||
log.Println("starting kubernetes services")
|
||||
svcs.Start(
|
||||
&services.Kubelet{},
|
||||
&services.Kubeadm{},
|
||||
)
|
||||
}
|
||||
|
||||
func sync() {
|
||||
syncdone := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
defer close(syncdone)
|
||||
unix.Sync()
|
||||
}()
|
||||
|
||||
log.Printf("waiting for sync...")
|
||||
|
||||
for i := 29; i >= 0; i-- {
|
||||
select {
|
||||
case <-syncdone:
|
||||
log.Printf("sync done")
|
||||
return
|
||||
case <-time.After(time.Second):
|
||||
}
|
||||
if i != 0 {
|
||||
log.Printf("waiting %d more seconds for sync to finish", i)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("sync hasn't completed in time, aborting...")
|
||||
}
|
||||
|
||||
func reboot() {
|
||||
// See http://man7.org/linux/man-pages/man2/reboot.2.html.
|
||||
sync()
|
||||
|
||||
// nolint: errcheck
|
||||
unix.Reboot(rebootFlag)
|
||||
|
||||
if *inContainer {
|
||||
return
|
||||
}
|
||||
|
||||
select {}
|
||||
}
|
||||
|
||||
func recovery() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("recovered from: %+v\n", r)
|
||||
for i := 10; i >= 0; i-- {
|
||||
log.Printf("rebooting in %d seconds\n", i)
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// This is main entrypoint into init() execution, after kernel boot control is passsed
|
||||
// to this function.
|
||||
//
|
||||
// When initram() finishes, it execs into itself with -switch-root flag, so control is passed
|
||||
// once again into this function.
|
||||
//
|
||||
// When init() terminates either on normal shutdown (reboot, poweroff), or due to panic, control
|
||||
// goes through recovery() and reboot() functions below, which finalize node state - sync buffers,
|
||||
// initiate poweroff or reboot. Also on shutdown, other deferred function are called, for example
|
||||
// services are gracefully shutdown.
|
||||
|
||||
// on any return from init.main(), initiate host reboot or shutdown
|
||||
defer reboot()
|
||||
// handle any panics in the main goroutine, and proceed to reboot() above
|
||||
defer recovery()
|
||||
|
||||
if err := startup.RandSeed(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// TODO(andrewrynhard): Remove this and be explicit.
|
||||
if err := os.Setenv("PATH", constants.PATH); err != nil {
|
||||
panic(errors.New("error setting PATH"))
|
||||
}
|
||||
|
||||
switch {
|
||||
case *switchRoot:
|
||||
if err := root(); err != nil {
|
||||
panic(errors.Wrap(err, "boot failed"))
|
||||
}
|
||||
|
||||
// root() hangs until reboot
|
||||
case *inContainer:
|
||||
if err := container(); err != nil {
|
||||
panic(errors.Wrap(err, "failed to prepare container based deploy"))
|
||||
}
|
||||
if err := root(); err != nil {
|
||||
panic(errors.Wrap(err, "boot failed"))
|
||||
}
|
||||
|
||||
// root() hangs until reboot
|
||||
default:
|
||||
if err := initram(); err != nil {
|
||||
panic(errors.Wrap(err, "early boot failed"))
|
||||
}
|
||||
|
||||
// We should never reach this point if things are working as intended.
|
||||
panic(errors.New("unknown error"))
|
||||
if err := initram(); err != nil {
|
||||
panic(errors.Wrap(err, "early boot failed"))
|
||||
}
|
||||
|
||||
// We should never reach this point if things are working as intended.
|
||||
panic(errors.New("unknown error"))
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/init/proto"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
"github.com/talos-systems/talos/internal/pkg/archiver"
|
||||
"github.com/talos-systems/talos/internal/pkg/chunker/stream"
|
||||
"github.com/talos-systems/talos/internal/pkg/upgrade"
|
338
internal/app/machined/main.go
Normal file
338
internal/app/machined/main.go
Normal file
@ -0,0 +1,338 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/talos-systems/talos/internal/app/machined/internal/reg"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/services"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/internal/pkg/grpc/factory"
|
||||
"github.com/talos-systems/talos/internal/pkg/rootfs"
|
||||
"github.com/talos-systems/talos/internal/pkg/rootfs/mount"
|
||||
"github.com/talos-systems/talos/internal/pkg/startup"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
)
|
||||
|
||||
var (
|
||||
inContainer *bool
|
||||
rebootFlag = unix.LINUX_REBOOT_CMD_RESTART
|
||||
userdataArg *string
|
||||
)
|
||||
|
||||
func init() {
|
||||
inContainer = flag.Bool("in-container", false, "run Talos in a container")
|
||||
userdataArg = flag.String("userdata", "", "the base64 encoded userdata")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func kmsg(prefix string) (*os.File, error) {
|
||||
out, err := os.OpenFile("/dev/kmsg", os.O_RDWR|unix.O_CLOEXEC|unix.O_NONBLOCK|unix.O_NOCTTY, 0666)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to open /dev/kmsg")
|
||||
}
|
||||
log.SetOutput(out)
|
||||
log.SetPrefix(prefix + " ")
|
||||
log.SetFlags(0)
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func container() (err error) {
|
||||
log.Println("preparing container based deploy")
|
||||
|
||||
log.Println("remounting volumes as shared mounts")
|
||||
targets := []string{"/", "/var/lib/kubelet", "/etc/cni"}
|
||||
for _, t := range targets {
|
||||
if err = unix.Mount("", t, "", unix.MS_SHARED, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if *userdataArg != "" {
|
||||
log.Printf("writing the user data: %s\n", constants.UserDataPath)
|
||||
var decoded []byte
|
||||
if decoded, err = base64.StdEncoding.DecodeString(*userdataArg); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = ioutil.WriteFile(constants.UserDataPath, decoded, 0400); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var data *userdata.UserData
|
||||
if data, err = userdata.Open(constants.UserDataPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Workarounds for running in a container.
|
||||
|
||||
data.Services.Kubeadm.IgnorePreflightErrors = []string{"FileContent--proc-sys-net-bridge-bridge-nf-call-iptables", "Swap", "SystemVerification"}
|
||||
initConfiguration, ok := data.Services.Kubeadm.Configuration.(*kubeadmapi.InitConfiguration)
|
||||
if ok {
|
||||
initConfiguration.ClusterConfiguration.ComponentConfigs.Kubelet.FailSwapOn = false
|
||||
// See https://github.com/kubernetes/kubernetes/issues/58610#issuecomment-359552443
|
||||
max := int32(0)
|
||||
maxPerCore := int32(0)
|
||||
initConfiguration.ClusterConfiguration.ComponentConfigs.KubeProxy.Conntrack.Max = &max
|
||||
initConfiguration.ClusterConfiguration.ComponentConfigs.KubeProxy.Conntrack.MaxPerCore = &maxPerCore
|
||||
}
|
||||
|
||||
log.Println("preparing the root filesystem")
|
||||
if err = rootfs.Prepare("", true, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createOverlay(path string) error {
|
||||
log.Printf("mounting overlay for %s\n", path)
|
||||
|
||||
parts := strings.Split(path, "/")
|
||||
prefix := strings.Join(parts[1:], "-")
|
||||
diff := fmt.Sprintf("/var/%s-diff", prefix)
|
||||
workdir := fmt.Sprintf("/var/%s-workdir", prefix)
|
||||
|
||||
for _, s := range []string{diff, workdir} {
|
||||
if err := os.MkdirAll(s, 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", path, diff, workdir)
|
||||
if err := unix.Mount("overlay", path, "overlay", 0, opts); err != nil {
|
||||
return errors.Errorf("error creating overlay mount to %s: %v", path, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// nolint: gocyclo
|
||||
func root() (err error) {
|
||||
if !*inContainer {
|
||||
// Setup logging to /dev/kmsg.
|
||||
if _, err = kmsg("[talos]"); err != nil {
|
||||
return fmt.Errorf("failed to setup logging to /dev/kmsg: %v", err)
|
||||
}
|
||||
|
||||
for _, overlay := range []string{"/etc/kubernetes", "/etc/cni", "/usr/libexec/kubernetes", "/usr/etc/udev", "/opt"} {
|
||||
if err = createOverlay(overlay); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read the user data.
|
||||
log.Printf("reading the user data: %s\n", constants.UserDataPath)
|
||||
var data *userdata.UserData
|
||||
if data, err = userdata.Open(constants.UserDataPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Mount the extra partitions.
|
||||
log.Printf("mounting the extra partitions")
|
||||
if err = mount.ExtraDevices(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Write any user specified files to disk.
|
||||
log.Println("writing the files specified in the user data to disk")
|
||||
if err = data.WriteFiles(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set the requested environment variables.
|
||||
log.Println("setting environment variables")
|
||||
for key, val := range data.Env {
|
||||
if err = os.Setenv(key, val); err != nil {
|
||||
log.Printf("WARNING failed to set enivronment variable: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
poweroffCh, err := listenForPowerButton()
|
||||
if err != nil {
|
||||
log.Printf("WARNING: power off events will be ignored: %+v", err)
|
||||
}
|
||||
|
||||
termCh := make(chan os.Signal, 1)
|
||||
signal.Notify(termCh, syscall.SIGTERM)
|
||||
|
||||
// Get a handle to the system services API.
|
||||
svcs := system.Services(data)
|
||||
defer svcs.Shutdown()
|
||||
|
||||
// Instantiate internal init API
|
||||
api := reg.NewRegistrator(data)
|
||||
server := factory.NewServer(api)
|
||||
listener, err := factory.NewListener(
|
||||
factory.Network("unix"),
|
||||
factory.SocketPath(constants.InitSocketPath),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer server.Stop()
|
||||
|
||||
go func() {
|
||||
// nolint: errcheck
|
||||
server.Serve(listener)
|
||||
}()
|
||||
|
||||
startSystemServices(data)
|
||||
startKubernetesServices(data)
|
||||
|
||||
select {
|
||||
case <-api.ShutdownCh:
|
||||
log.Printf("poweroff via API received")
|
||||
// poweroff, proceed to shutdown but mark as poweroff
|
||||
rebootFlag = unix.LINUX_REBOOT_CMD_POWER_OFF
|
||||
case <-poweroffCh:
|
||||
log.Printf("poweroff via ACPI")
|
||||
// poweroff, proceed to shutdown but mark as poweroff
|
||||
rebootFlag = unix.LINUX_REBOOT_CMD_POWER_OFF
|
||||
case <-termCh:
|
||||
log.Printf("SIGTERM received, rebooting...")
|
||||
case <-api.RebootCh:
|
||||
log.Printf("reboot via API received, rebooting...")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func startSystemServices(data *userdata.UserData) {
|
||||
svcs := system.Services(data)
|
||||
|
||||
log.Println("starting system services")
|
||||
// Start the services common to all nodes.
|
||||
svcs.Start(
|
||||
&services.Networkd{},
|
||||
&services.Containerd{},
|
||||
&services.Udevd{},
|
||||
&services.UdevdTrigger{},
|
||||
&services.OSD{},
|
||||
&services.NTPd{},
|
||||
)
|
||||
// Start the services common to all master nodes.
|
||||
if data.Services.Kubeadm.IsControlPlane() {
|
||||
svcs.Start(
|
||||
&services.Trustd{},
|
||||
&services.Proxyd{},
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func startKubernetesServices(data *userdata.UserData) {
|
||||
svcs := system.Services(data)
|
||||
|
||||
log.Println("starting kubernetes services")
|
||||
svcs.Start(
|
||||
&services.Kubelet{},
|
||||
&services.Kubeadm{},
|
||||
)
|
||||
}
|
||||
|
||||
func sync() {
|
||||
syncdone := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
defer close(syncdone)
|
||||
unix.Sync()
|
||||
}()
|
||||
|
||||
log.Printf("waiting for sync...")
|
||||
|
||||
for i := 29; i >= 0; i-- {
|
||||
select {
|
||||
case <-syncdone:
|
||||
log.Printf("sync done")
|
||||
return
|
||||
case <-time.After(time.Second):
|
||||
}
|
||||
if i != 0 {
|
||||
log.Printf("waiting %d more seconds for sync to finish", i)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("sync hasn't completed in time, aborting...")
|
||||
}
|
||||
|
||||
func reboot() {
|
||||
// See http://man7.org/linux/man-pages/man2/reboot.2.html.
|
||||
sync()
|
||||
|
||||
// nolint: errcheck
|
||||
unix.Reboot(rebootFlag)
|
||||
|
||||
if *inContainer {
|
||||
return
|
||||
}
|
||||
|
||||
select {}
|
||||
}
|
||||
|
||||
func recovery() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("recovered from: %+v\n", r)
|
||||
for i := 10; i >= 0; i-- {
|
||||
log.Printf("rebooting in %d seconds\n", i)
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// This is main entrypoint into init() execution, after kernel boot control is passsed
|
||||
// to this function.
|
||||
//
|
||||
// When initram() finishes, it execs into itself with -switch-root flag, so control is passed
|
||||
// once again into this function.
|
||||
//
|
||||
// When init() terminates either on normal shutdown (reboot, poweroff), or due to panic, control
|
||||
// goes through recovery() and reboot() functions below, which finalize node state - sync buffers,
|
||||
// initiate poweroff or reboot. Also on shutdown, other deferred function are called, for example
|
||||
// services are gracefully shutdown.
|
||||
|
||||
// on any return from init.main(), initiate host reboot or shutdown
|
||||
defer reboot()
|
||||
// handle any panics in the main goroutine, and proceed to reboot() above
|
||||
defer recovery()
|
||||
|
||||
if err := startup.RandSeed(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// TODO(andrewrynhard): Remove this and be explicit.
|
||||
if err := os.Setenv("PATH", constants.PATH); err != nil {
|
||||
panic(errors.New("error setting PATH"))
|
||||
}
|
||||
|
||||
if *inContainer {
|
||||
if err := container(); err != nil {
|
||||
panic(errors.Wrap(err, "failed to prepare container based deploy"))
|
||||
}
|
||||
}
|
||||
|
||||
if err := root(); err != nil {
|
||||
panic(errors.Wrap(err, "boot failed"))
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
)
|
||||
|
||||
type AllSuite struct {
|
@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
)
|
||||
|
||||
type FilesSuite struct {
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/proto"
|
||||
"github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
)
|
||||
|
||||
// MaxEventsToKeep is maximum number of events to keep per service before dropping old entries
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
)
|
||||
|
||||
type EventsSuite struct {
|
@ -13,7 +13,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
)
|
||||
|
||||
type CheckSuite struct {
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/proto"
|
||||
"github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
)
|
||||
|
||||
// Status of the healthcheck
|
@ -10,10 +10,10 @@ import (
|
||||
"time"
|
||||
|
||||
"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/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -17,8 +17,8 @@ import (
|
||||
"github.com/containerd/containerd/oci"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -21,11 +21,11 @@ import (
|
||||
"github.com/containerd/containerd/oci"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
containerdrunner "github.com/talos-systems/talos/internal/app/init/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
containerdrunner "github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
)
|
||||
|
@ -14,9 +14,9 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/log"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/log"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -17,9 +17,9 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/goroutine"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/goroutine"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -14,9 +14,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
processlogger "github.com/talos-systems/talos/internal/app/init/pkg/system/log"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
processlogger "github.com/talos-systems/talos/internal/app/machined/pkg/system/log"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
@ -16,10 +16,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
)
|
||||
|
||||
type restarter struct {
|
@ -14,8 +14,8 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
)
|
||||
|
||||
type RestartSuite struct {
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/oci"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
)
|
||||
|
@ -7,9 +7,9 @@ package system
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
)
|
||||
|
||||
// StateEvent is a service event (e.g. 'up', 'down')
|
@ -12,11 +12,11 @@ import (
|
||||
"time"
|
||||
|
||||
"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/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/init/proto"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
)
|
||||
|
||||
type ServiceRunnerSuite struct {
|
@ -14,12 +14,12 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/health/grpc_health_v1"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
@ -16,10 +16,10 @@ import (
|
||||
criconstants "github.com/containerd/cri/pkg/constants"
|
||||
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/runner"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/services/kubeadm"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/services/kubeadm"
|
||||
"github.com/talos-systems/talos/internal/app/trustd/proto"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
@ -18,10 +18,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/security/cis"
|
||||
"github.com/talos-systems/talos/internal/app/trustd/proto"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/internal/pkg/grpc/middleware/auth/basic"
|
||||
"github.com/talos-systems/talos/internal/pkg/security/cis"
|
||||
"github.com/talos-systems/talos/pkg/crypto/x509"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
"google.golang.org/grpc"
|
@ -17,14 +17,14 @@ import (
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/rootfs/cni"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"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/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/internal/pkg/rootfs/cni"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -7,10 +7,10 @@ package services
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/network"
|
||||
"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/goroutine"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/goroutine"
|
||||
"github.com/talos-systems/talos/internal/pkg/network"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
containerdapi "github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/oci"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"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/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
@ -13,12 +13,12 @@ import (
|
||||
containerdapi "github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/oci"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"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/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
@ -13,12 +13,12 @@ import (
|
||||
containerdapi "github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/oci"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"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/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
@ -13,12 +13,12 @@ import (
|
||||
containerdapi "github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/oci"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
|
||||
"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/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/health"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
@ -9,10 +9,10 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"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/process"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"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/process"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/restart"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
)
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system"
|
||||
)
|
||||
|
||||
type SystemServicesSuite struct {
|
@ -9,7 +9,7 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/talos-systems/talos/internal/app/init/proto"
|
||||
"github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
initproto "github.com/talos-systems/talos/internal/app/init/proto"
|
||||
initproto "github.com/talos-systems/talos/internal/app/machined/proto"
|
||||
"github.com/talos-systems/talos/internal/app/osd/proto"
|
||||
"github.com/talos-systems/talos/internal/pkg/chunker"
|
||||
filechunker "github.com/talos-systems/talos/internal/pkg/chunker/file"
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/conditions"
|
||||
"github.com/talos-systems/talos/internal/app/proxyd/internal/frontend"
|
||||
"github.com/talos-systems/talos/internal/pkg/startup"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
|
@ -18,10 +18,10 @@ import (
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
containerdrunner "github.com/talos-systems/talos/internal/app/init/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
containerdrunner "github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/containerd"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
ctrd "github.com/talos-systems/talos/internal/pkg/containers/containerd"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
|
@ -17,9 +17,9 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
ctrs "github.com/talos-systems/talos/internal/pkg/containers"
|
||||
"github.com/talos-systems/talos/internal/pkg/containers/cri"
|
||||
|
@ -16,9 +16,9 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/system/runner/process"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/internal/pkg/cri"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
|
@ -234,8 +234,8 @@ func (i *Initializer) Switch() (err error) {
|
||||
return errors.Wrap(err, "error deleting initramfs")
|
||||
}
|
||||
|
||||
if err = unix.Exec("/proc/self/exe", []string{"exe", "--switch-root"}, []string{}); err != nil {
|
||||
return errors.Wrap(err, "error executing /proc/self/exe")
|
||||
if err = unix.Exec("/sbin/machined", []string{"/sbin/machined"}, []string{}); err != nil {
|
||||
return errors.Wrap(err, "error executing /sbin/machined")
|
||||
}
|
||||
|
||||
return nil
|
@ -13,11 +13,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/rootfs/cni"
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/rootfs/etc"
|
||||
"github.com/talos-systems/talos/internal/app/init/internal/rootfs/proc"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/internal/pkg/grpc/gen"
|
||||
"github.com/talos-systems/talos/internal/pkg/rootfs/cni"
|
||||
"github.com/talos-systems/talos/internal/pkg/rootfs/etc"
|
||||
"github.com/talos-systems/talos/internal/pkg/rootfs/proc"
|
||||
"github.com/talos-systems/talos/pkg/crypto/x509"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
yaml "gopkg.in/yaml.v2"
|
Loading…
x
Reference in New Issue
Block a user