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
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 5 additions & 2 deletions images/Makefile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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)
Expand All @@ -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.


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
Expand Down
38 changes: 38 additions & 0 deletions images/k3s/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion vendor/golang.org/x/tools/internal/event/core/event.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down