Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Add a k3s sample image #739

Merged
merged 5 commits into from
Nov 30, 2020
Merged

Add a k3s sample image #739

merged 5 commits into from
Nov 30, 2020

Conversation

EmeraldShift
Copy link
Contributor

This change adds an image for k3s, a lightweight Kubernetes distribution, as per #329.

A few notes:

  • The rancher/k3s image seems to be too minimal to function correctly—for example, it wouldn't mount /proc, etc. Thus, this image is based on Ubuntu 20.04, with k3s installed via the provided Rancher script
  • Docker can't properly handle tags with a + symbol in them, so the version of k3s used for this image is the highest version before + was introduced into the release tags, i.e. v1.0.1.
  • The image was tested by deploying a hello-kubernetes manifest. The service was reachable from the host (outside the VM) via the external IP leased to the hello-kubernetes Service.

@EmeraldShift
Copy link
Contributor Author

@stealthybox I think this one's ready for review.
Looking through the details of the build failure, I'm not sure how they're related to these changes, but instead they seem like transient failures of some sort. I'm not sure how to get them to pass. Any ideas?

Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the image myself and it works as expected.

root@cb6c15853793e78a:~# k3s kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.4+k3s1", GitCommit:"2532c10faad43e2b6e728fdcc01662dc13d37764", GitTreeState:"clean", BuildDate:"2020-11-18T22:11:18Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.4+k3s1", GitCommit:"2532c10faad43e2b6e728fdcc01662dc13d37764", GitTreeState:"clean", BuildDate:"2020-11-18T22:11:18Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}

Had to set 2GB memory for the VM, else k3s fails with out of memory error. The default 512MB of memory is not enough. We can document it better, similar to the README in images/kubeadm/README.md.
We can also add docs for multi-node HA setup separately, similar to kubeadm, in the future.
Thanks for working on this.

images/Makefile Outdated
@@ -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
Copy link
Contributor

@darkowlzz darkowlzz Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried changing RELEASE to a docker hub image tag found in https://hub.docker.com/r/rancher/k3s/tags?page=1&ordering=last_updated , v1.19.4-k3s1 and as you mentioned, it failed because the official k3s version has a + in the name.

[INFO]  Downloading hash https://github.com/rancher/k3s/releases/download/v1.19.4-k3s1/sha256sum-amd64.txt
The command '/bin/sh -c curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_ENABLE=true INSTALL_K3S_VERSION="${RELEASE}" sh -' returned a non-zero code: 22
Makefile:68: recipe for target 'build' failed

The download URL isn't correct.

Since we need + in the version but just not in the docker image tag, I tried escaping the RELEASE variable with something like:

diff --git a/images/Makefile b/images/Makefile
index 716610f9..fd6fd2c2 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:

That made it work properly.

@darkowlzz
Copy link
Contributor

We don't run the OS image builds in the regular CI, so the build failure is unrelated. Don't need to worry about it 🙂

@EmeraldShift
Copy link
Contributor Author

@darkowlzz Thank you for the feedback! I've patched the Makefile with the changes you mentioned, and added a simple README.

@stealthybox
Copy link
Contributor

LGTM -- thanks for fixing the tag problem

Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks.

@darkowlzz darkowlzz merged commit 5c87deb into weaveworks:master Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants