From 6905060a7bbb79e9294dca95c9a6264a82116116 Mon Sep 17 00:00:00 2001 From: Michael Jarrett <1077485+EmeraldShift@users.noreply.github.com> Date: Thu, 26 Nov 2020 03:47:07 -0600 Subject: [PATCH 1/4] Add a k3s sample image --- images/Makefile | 7 +++++-- images/k3s/Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 images/k3s/Dockerfile diff --git a/images/Makefile b/images/Makefile index 00e51c2bf..716610f9a 100644 --- a/images/Makefile +++ b/images/Makefile @@ -1,6 +1,6 @@ SHELL:=/bin/bash # Set the command for running `docker` -# -- allows user to override for things like sudo usage or container images +# -- allows user to override for things like sudo usage or container images DOCKER := docker # Set the first containerd.sock that successfully stats -- fallback to the docker4mac default CONTAINERD_SOCK := $(shell \ @@ -141,7 +141,7 @@ push-all: build-all $(MAKE) OP=push build-all -build-all: build-alpine build-amazon-kernel build-amazonlinux build-centos build-kubeadm build-opensuse build-ubuntu +build-all: build-alpine build-amazon-kernel build-amazonlinux build-centos build-k3s build-kubeadm build-opensuse build-ubuntu build-alpine: ifeq ($(OP),build) @@ -161,6 +161,9 @@ build-centos: $(MAKE) ${OP} WHAT=centos RELEASE=7 $(MAKE) ${OP} WHAT=centos RELEASE=8 IS_LATEST=true +build-k3s: + $(MAKE) ${OP} WHAT=k3s RELEASE=v1.0.1 IS_LATEST=true + build-kubeadm: $(MAKE) ${OP} WHAT=kubeadm RELEASE=v1.18.3 BINARY_REF=release/stable-1.18 IS_LATEST=true IS_MANIFEST_LIST=1 GOARCH=arm64 $(MAKE) ${OP} WHAT=kubeadm RELEASE=v1.18.3 BINARY_REF=release/stable-1.18 IS_LATEST=true IS_MANIFEST_LIST=1 GOARCH=amd64 diff --git a/images/k3s/Dockerfile b/images/k3s/Dockerfile new file mode 100644 index 000000000..938191ed9 --- /dev/null +++ b/images/k3s/Dockerfile @@ -0,0 +1,38 @@ +FROM ubuntu:20.04 + +# udev is needed for booting a "real" VM, setting up the ttyS0 console properly +# kmod is needed for modprobing modules +# systemd is needed for running as PID 1 as /sbin/init +# Also, other utilities are installed +RUN apt-get update && apt-get install -y \ + curl \ + dbus \ + jq \ + kmod \ + iproute2 \ + iputils-ping \ + net-tools \ + openssh-server \ + sudo \ + systemd \ + udev \ + wget && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Create the following files, but unset them +RUN echo "" > /etc/machine-id && echo "" > /var/lib/dbus/machine-id + +# Install k3s. The intermediate container used to run this command does not run systemd, so +# the installer can't automatically enable the k3s service. Instead, we do so manually. +ARG RELEASE +RUN curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_ENABLE=true INSTALL_K3S_VERSION="${RELEASE}" sh - +RUN ln -s /etc/systemd/system/k3s.service /etc/systemd/system/multi-user.target.wants/k3s.service + +# This container image doesn't have locales installed. Disable forwarding the +# user locale env variables or we get warnings such as: +# bash: warning: setlocale: LC_ALL: cannot change locale +RUN sed -i -e 's/^AcceptEnv LANG LC_\*$/#AcceptEnv LANG LC_*/' /etc/ssh/sshd_config + +# Set the root password to root when logging in through the VM's ttyS0 console +RUN echo "root:root" | chpasswd From 6320b18362c6c544e4c892dbfb1227a073368741 Mon Sep 17 00:00:00 2001 From: Michael Jarrett <1077485+EmeraldShift@users.noreply.github.com> Date: Thu, 26 Nov 2020 18:33:12 -0600 Subject: [PATCH 2/4] make autogen tidy --- go.mod | 2 +- go.sum | 4 ++-- vendor/golang.org/x/tools/internal/event/core/event.go | 2 +- vendor/modules.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index d89ae3dbc..26f723963 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( github.com/weaveworks/libgitops v0.0.0-20200611103311-2c871bbbbf0c golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f - golang.org/x/tools v0.0.0-20201121010211-780cb80bd7fb // indirect + golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b // indirect gotest.tools v2.2.0+incompatible k8s.io/apimachinery v0.18.3 k8s.io/code-generator v0.19.2 diff --git a/go.sum b/go.sum index 11bee6f52..e818c4e07 100644 --- a/go.sum +++ b/go.sum @@ -1005,8 +1005,8 @@ golang.org/x/tools v0.0.0-20191216052735-49a3e744a425 h1:VvQyQJN0tSuecqgcIxMWnnf golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200616133436-c1934b75d054 h1:HHeAlu5H9b71C+Fx0K+1dGgVFN1DM1/wz4aoGOA5qS8= golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20201121010211-780cb80bd7fb h1:z5+u0pkAUPUWd3taoTialQ2JAMo4Wo1Z3L25U4ZV9r0= -golang.org/x/tools v0.0.0-20201121010211-780cb80bd7fb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b h1:Lq5JUTFhiybGVf28jB6QRpqd13/JPOaCnET17PVzYJE= +golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= diff --git a/vendor/golang.org/x/tools/internal/event/core/event.go b/vendor/golang.org/x/tools/internal/event/core/event.go index e37b49491..a6cf0e64a 100644 --- a/vendor/golang.org/x/tools/internal/event/core/event.go +++ b/vendor/golang.org/x/tools/internal/event/core/event.go @@ -12,7 +12,7 @@ import ( "golang.org/x/tools/internal/event/label" ) -// Event holds the information about an event of note that ocurred. +// Event holds the information about an event of note that occurred. type Event struct { at time.Time diff --git a/vendor/modules.txt b/vendor/modules.txt index d37d61504..1ba199903 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -527,7 +527,7 @@ golang.org/x/text/transform golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm golang.org/x/text/width -# golang.org/x/tools v0.0.0-20201121010211-780cb80bd7fb +# golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b ## explicit golang.org/x/tools/go/ast/astutil golang.org/x/tools/imports From 1bbf55ccf4e265b619215512b2f3dbb3f4537674 Mon Sep 17 00:00:00 2001 From: Michael Jarrett <1077485+EmeraldShift@users.noreply.github.com> Date: Sun, 29 Nov 2020 15:20:31 -0600 Subject: [PATCH 3/4] Allow + in tags, bump k3s version --- images/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/images/Makefile b/images/Makefile index 716610f9a..86bfdcb86 100644 --- a/images/Makefile +++ b/images/Makefile @@ -32,14 +32,15 @@ DOCKER_USER?=weaveworks VERSION?=$(shell git describe HEAD --tags) RELEASE?=latest FULL_IMAGE_NAME=${DOCKER_USER}/ignite-${WHAT}:${TAG} -RELEASE_IMAGE_NAME=${DOCKER_USER}/ignite-${WHAT}:${RELEASE} +escaped_RELEASE:=$(subst +,-,$(RELEASE)) +RELEASE_IMAGE_NAME=${DOCKER_USER}/ignite-${WHAT}:${escaped_RELEASE} LATEST_IMAGE_NAME=${DOCKER_USER}/ignite-${WHAT}:latest GOARCH?=amd64 GOARCH_LIST=amd64 arm64 # Set this flag to build a multiarch image IS_MANIFEST_LIST?=0 -TAG:=${RELEASE}$(if $(strip $(VERSION)),-${VERSION}) +TAG:=${escaped_RELEASE}$(if $(strip $(VERSION)),-${VERSION}) OP:=build TMPDIR?=/tmp @@ -162,7 +163,7 @@ build-centos: $(MAKE) ${OP} WHAT=centos RELEASE=8 IS_LATEST=true build-k3s: - $(MAKE) ${OP} WHAT=k3s RELEASE=v1.0.1 IS_LATEST=true + $(MAKE) ${OP} WHAT=k3s RELEASE=v1.19.4+k3s1 IS_LATEST=true build-kubeadm: $(MAKE) ${OP} WHAT=kubeadm RELEASE=v1.18.3 BINARY_REF=release/stable-1.18 IS_LATEST=true IS_MANIFEST_LIST=1 GOARCH=arm64 From 534815ade753517f74ab62902c31e2ecdaa8781a Mon Sep 17 00:00:00 2001 From: Michael Jarrett <1077485+EmeraldShift@users.noreply.github.com> Date: Sun, 29 Nov 2020 15:49:08 -0600 Subject: [PATCH 4/4] Add simple k3s image README --- images/k3s/README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 images/k3s/README.md diff --git a/images/k3s/README.md b/images/k3s/README.md new file mode 100644 index 000000000..a34873c17 --- /dev/null +++ b/images/k3s/README.md @@ -0,0 +1,37 @@ +# Run k3s with Ignite VMs + +This short guide shows you how to setup Rancher's Lightweight Kubernetes (k3s) distribution with Ignite VMs. + +**NOTE:** At the moment, you need to execute all these commands as `root`. + +**NOTE:** k3s requires ~2 GiB of memory to function properly. The default 512 MiB of memory is not enough. + +The image contains a minimal Ubuntu 20.04 installation with the k3s server running as a daemon on boot. +Thus, spawning a single k3s Ignite VM is sufficient to operate a single-node k3s cluster. To get started: + +```bash +ignite run weaveworks/ignite-k3s:latest \ + --cpus 2 \ + --memory 2GB \ + --ssh \ + --name k3s-master +``` + +We can test the installation by checking the installed k3s version: + +```bash +ignite exec k3s-master -- k3s --version + +> k3s version v1.19.4+k3s1 (2532c10f) +``` + +We can also try to administrate the cluster from the host machine, if `kubectl` is installed: + +```bash +VM_IP=$(ignite inspect vm k3s-master | jq -r ".status.network.ipAddresses[0]") +ignite exec k3s-master -- cat /etc/rancher/k3s/k3s.yaml > kubeconfig +sed -i'' "s/127.0.0.1/$VM_IP/" kubeconfig +kubectl --kubeconfig=kubeconfig get nodes + +# Should list a single Master node, running the same k3s version displayed earlier +```