2019-12-23 21:36:14 +03:00
REGISTRY ?= docker.io
USERNAME ?= autonomy
2019-12-24 23:23:52 +03:00
SHA ?= $( shell git describe --match= none --always --abbrev= 8 --dirty)
TAG ?= $( shell git describe --tag --always --dirty)
BRANCH ?= $( shell git rev-parse --abbrev-ref HEAD)
2019-12-23 21:36:14 +03:00
REGISTRY_AND_USERNAME := $( REGISTRY) /$( USERNAME)
2020-02-13 23:07:36 +03:00
DOCKER_LOGIN_ENABLED ?= true
2019-12-23 21:36:14 +03:00
2019-12-24 23:23:52 +03:00
ARTIFACTS := _out
2020-05-22 23:26:56 +03:00
TOOLS ?= autonomy/tools:v0.2.0-1-g418e800
2020-02-26 22:27:34 +03:00
GO_VERSION ?= 1.14
2019-12-24 23:23:52 +03:00
OPERATING_SYSTEM := $( shell uname -s | tr "[:upper:]" "[:lower:]" )
2020-03-21 03:38:48 +03:00
OSCTL_DEFAULT_TARGET := talosctl-$( OPERATING_SYSTEM)
2020-01-05 00:19:34 +03:00
INTEGRATION_TEST_DEFAULT_TARGET := integration-test-$( OPERATING_SYSTEM)
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
INTEGRATION_TEST_PROVISION_DEFAULT_TARGET := integration-test-provision-$( OPERATING_SYSTEM)
2020-03-26 18:13:32 +03:00
KUBECTL_URL ?= https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/$( OPERATING_SYSTEM) /amd64/kubectl
2020-04-29 22:24:07 +03:00
CLUSTERCTL_VERSION ?= 0.3.5
CLUSTERCTL_URL ?= https://github.com/kubernetes-sigs/cluster-api/releases/download/v$( CLUSTERCTL_VERSION) /clusterctl-$( OPERATING_SYSTEM) -amd64
2020-04-06 17:45:31 +03:00
SONOBUOY_VERSION ?= 0.18.0
2020-01-24 07:52:02 +03:00
SONOBUOY_URL ?= https://github.com/heptio/sonobuoy/releases/download/v$( SONOBUOY_VERSION) /sonobuoy_$( SONOBUOY_VERSION) _$( OPERATING_SYSTEM) _amd64.tar.gz
2019-12-24 23:23:52 +03:00
TESTPKGS ?= ./...
2020-05-28 16:39:39 +03:00
RELEASES ?= v0.5.0 v0.6.0-alpha.1
2019-12-24 23:23:52 +03:00
BUILD := docker buildx build
2019-12-23 21:36:14 +03:00
PLATFORM ?= linux/amd64
PROGRESS ?= auto
PUSH ?= false
COMMON_ARGS := --file= Dockerfile
COMMON_ARGS += --progress= $( PROGRESS)
COMMON_ARGS += --platform= $( PLATFORM)
COMMON_ARGS += --push= $( PUSH)
COMMON_ARGS += --build-arg= TOOLS = $( TOOLS)
COMMON_ARGS += --build-arg= SHA = $( SHA)
COMMON_ARGS += --build-arg= TAG = $( TAG)
2019-12-27 23:49:24 +03:00
COMMON_ARGS += --build-arg= ARTIFACTS = $( ARTIFACTS)
2019-11-01 07:55:58 +03:00
COMMON_ARGS += --build-arg= TESTPKGS = $( TESTPKGS)
2020-02-14 15:26:44 +03:00
COMMON_ARGS += --build-arg= USERNAME = $( USERNAME)
2020-02-20 14:33:12 +03:00
COMMON_ARGS += --build-arg= http_proxy = $( http_proxy)
COMMON_ARGS += --build-arg= https_proxy = $( https_proxy)
2019-04-24 04:52:31 +03:00
2020-03-21 03:38:48 +03:00
all : initramfs kernel installer talosctl talos
2019-12-24 23:23:52 +03:00
# Help Menu
d e f i n e H E L P _ M E N U _ H E A D E R
# Getting Started
To build this project, you must have the following installed :
- g i t
- m a k e
- d o c k e r ( 1 9 . 0 3 o r h i g h e r )
- buildx (https : //github .com /docker /buildx )
## Creating a Builder Instance
T h e b u i l d p r o c e s s m a k e s u s e o f f e a t u r e s n o t c u r r e n t l y s u p p o r t e d b y t h e d e f a u l t
builder instance (docker driver). To create a compatible builder instance, run :
2019-07-23 17:17:16 +03:00
2019-12-24 23:23:52 +03:00
` ` `
d o c k e r b u i l d x c r e a t e - - d r i v e r d o c k e r - c o n t a i n e r - - n a m e l o c a l - - b u i l d k i t d - f l a g s '--allow-insecure-entitlement security.insecure' - - u s e
` ` `
2019-04-29 19:25:04 +03:00
2019-12-24 23:23:52 +03:00
I f y o u a l r e a d y h a v e a c o m p a t i b l e b u i l d e r i n s t a n c e , y o u m a y u s e t h a t i n s t e a d .
2019-02-15 07:32:00 +03:00
2020-02-13 23:07:36 +03:00
> Note : The security .insecure entitlement is only required , and used by the unit -tests target and targets which build container images
f o r a p p l i c a t i o n s u s i n g ` i m g ` t o o l .
2019-06-05 21:44:15 +03:00
2019-12-24 23:23:52 +03:00
## Artifacts
2019-02-15 07:32:00 +03:00
2019-12-24 23:23:52 +03:00
A l l a r t i f a c t s w i l l b e o u t p u t t o . / $( ARTIFACTS ) . I m a g e s w i l l b e t a g g e d w i t h t h e
registry "$(REGISTRY)", username "$(USERNAME)", and a dynamic tag (e.g. $(REGISTRY_AND_USERNAME)/image : $( TAG ) ).
T h e r e g i s t r y a n d u s e r n a m e c a n b e o v e r r i d e n b y e x p o r t i n g R E G I S T R Y , a n d U S E R N A M E
r e s p e c t i v e l y .
e n d e f
export HELP_MENU_HEADER
help : ## This help menu.
@echo " $$ HELP_MENU_HEADER "
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $( MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Build Abstractions
.PHONY : base
target-% : ## Builds the specified target defined in the Dockerfile. The build result will only remain in the build cache.
2019-12-23 21:36:14 +03:00
@$( BUILD) \
2019-12-24 23:23:52 +03:00
--target= $* \
$( COMMON_ARGS) \
$( TARGET_ARGS) .
2019-11-01 07:55:58 +03:00
local-% : ## Builds the specified target defined in the Dockerfile using the local output type. The build result will be output to the specified local destination.
2019-12-24 23:23:52 +03:00
@$( MAKE) target-$* TARGET_ARGS = " --output=type=local,dest= $( DEST) $( TARGET_ARGS) "
2019-11-01 07:55:58 +03:00
docker-% : ## Builds the specified target defined in the Dockerfile using the docker output type. The build result will be output to the specified local destination.
2019-12-24 23:23:52 +03:00
@mkdir -p $( DEST)
@$( MAKE) target-$* TARGET_ARGS = " --output type=docker,dest= $( DEST) / $* .tar,name= $( REGISTRY_AND_USERNAME) / $* : $( TAG) $( TARGET_ARGS) "
2019-11-01 07:55:58 +03:00
hack-test-% : ## Runs the specied script in ./hack/test with well known environment variables.
2020-01-24 07:52:02 +03:00
@./hack/test/$* .sh
2019-11-01 07:55:58 +03:00
2019-12-24 23:23:52 +03:00
# Generators
2019-04-24 04:52:31 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : generate
2019-12-24 23:23:52 +03:00
generate : ## Generates source code from protobuf definitions.
@$( MAKE) local-$@ DEST = ./
2019-08-09 06:45:13 +03:00
2019-11-09 18:22:43 +03:00
.PHONY : docs
2020-03-21 03:38:48 +03:00
docs : ## Generates the documentation for machine config, and talosctl.
@rm -rf docs/talosctl/*
2019-12-24 23:23:52 +03:00
@$( MAKE) local-$@ DEST = ./
# Local Artifacts
2019-11-09 18:22:43 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : kernel
2019-12-24 23:23:52 +03:00
kernel : ## Outputs the kernel package contents (vmlinuz, and vmlinux) to the artifact directory.
@$( MAKE) local-$@ DEST = $( ARTIFACTS)
@-rm -rf $( ARTIFACTS) /modules
2019-01-18 06:14:52 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : initramfs
2020-02-14 15:26:44 +03:00
initramfs : ## Builds the compressed initramfs and outputs it to the artifact directory.
@$( MAKE) local-$@ DEST = $( ARTIFACTS) TARGET_ARGS = "--allow security.insecure"
2018-12-20 09:22:05 +03:00
2019-12-24 23:23:52 +03:00
.PHONY : installer
2020-02-14 15:26:44 +03:00
installer : ## Builds the container image for the installer and outputs it to the artifact directory.
@$( MAKE) docker-$@ DEST = $( ARTIFACTS) TARGET_ARGS = "--allow security.insecure"
2019-12-24 23:23:52 +03:00
@docker load < $( ARTIFACTS) /$@ .tar
2019-10-31 01:52:36 +03:00
2019-12-24 23:23:52 +03:00
.PHONY : talos
2020-02-14 15:26:44 +03:00
talos : ## Builds the Talos container image and outputs it to the artifact directory.
@$( MAKE) docker-$@ DEST = $( ARTIFACTS) TARGET_ARGS = "--allow security.insecure"
2019-12-24 23:23:52 +03:00
@mv $( ARTIFACTS) /$@ .tar $( ARTIFACTS) /container.tar
@docker load < $( ARTIFACTS) /container.tar
2018-12-20 09:22:05 +03:00
2020-03-21 03:38:48 +03:00
talosctl-% :
2019-12-24 23:23:52 +03:00
@$( MAKE) local-$@ DEST = $( ARTIFACTS)
2020-03-21 03:38:48 +03:00
talosctl : $( OSCTL_DEFAULT_TARGET ) ## Builds the talosctl binary for the local machine.
2019-12-24 23:23:52 +03:00
2019-11-01 07:55:58 +03:00
image-% : ## Builds the specified image. Valid options are aws, azure, digital-ocean, gcp, and vmware (e.g. image-aws)
@docker run --rm -v /dev:/dev -v $( PWD) /$( ARTIFACTS) :/out --privileged autonomy/installer:$( TAG) image --platform $*
images : image -aws image -azure image -digital -ocean image -gcp image -vmware ## Builds all known images (AWS, Azure, Digital Ocean, GCP, and VMware).
2019-04-05 07:34:58 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : iso
2019-12-24 23:23:52 +03:00
iso : ## Builds the ISO and outputs it to the artifact directory.
@docker run --rm -i -v $( PWD) /$( ARTIFACTS) :/out autonomy/installer:$( TAG) iso
2019-08-09 06:45:13 +03:00
2020-01-09 23:25:25 +03:00
.PHONY : boot
boot : ## Creates a compressed tarball that includes vmlinuz and initramfs.xz. Note that these files must already be present in the artifacts directory.
@tar -C $( ARTIFACTS) -czf $( ARTIFACTS) /boot.tar.gz vmlinuz initramfs.xz
2019-12-24 23:23:52 +03:00
# Code Quality
2019-02-19 19:41:41 +03:00
2019-12-24 23:23:52 +03:00
.PHONY : fmt
fmt : ## Formats the source code.
2020-04-24 07:12:44 +03:00
@docker run --rm -it -v $( PWD) :/src -w /src golang:$( GO_VERSION) bash -c "export GO111MODULE=on; export GOPROXY=https://proxy.golang.org; cd /tmp && go mod init tmp && go get mvdan.cc/gofumpt/gofumports@aaa7156f4122b1055c466e26e77812fa32bac1d9 && cd - && gofumports -w -local github.com/talos-systems/talos ."
2019-04-28 22:06:03 +03:00
2019-11-01 07:55:58 +03:00
lint-% : ## Runs the specified linter. Valid options are go, protobuf, and markdown (e.g. lint-go).
2019-12-24 23:23:52 +03:00
@$( MAKE) target-lint-$*
2019-08-02 18:05:34 +03:00
2019-12-24 23:23:52 +03:00
lint : ## Runs linters on go, protobuf, and markdown file types.
@$( MAKE) lint-go lint-protobuf lint-markdown
2020-04-07 22:49:12 +03:00
check-dirty : ## Verifies that source tree is not dirty
@case " $( TAG) " in *-dirty) echo "Source tree is dirty" ; exit 1 ; ; esac
2019-12-24 23:23:52 +03:00
# Tests
2019-06-17 19:36:48 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : unit -tests
2020-02-14 15:26:44 +03:00
unit-tests : ## Performs unit tests.
2020-01-24 07:52:02 +03:00
@$( MAKE) local-$@ DEST = $( ARTIFACTS) TARGET_ARGS = "--allow security.insecure"
2019-08-07 01:08:27 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : unit -tests -race
2019-12-24 23:23:52 +03:00
unit-tests-race : ## Performs unit tests with race detection enabled.
2020-05-22 23:26:56 +03:00
@$( MAKE) target-$@ TARGET_ARGS = "--allow security.insecure"
2019-12-24 23:23:52 +03:00
2020-01-24 07:52:02 +03:00
$(ARTIFACTS)/$(INTEGRATION_TEST_DEFAULT_TARGET)-amd64 :
@$( MAKE) local-$( INTEGRATION_TEST_DEFAULT_TARGET) DEST = $( ARTIFACTS)
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
$(ARTIFACTS)/$(INTEGRATION_TEST_PROVISION_DEFAULT_TARGET)-amd64 :
@$( MAKE) local-$( INTEGRATION_TEST_PROVISION_DEFAULT_TARGET) DEST = $( ARTIFACTS)
2020-01-24 07:52:02 +03:00
$(ARTIFACTS)/sonobuoy :
@mkdir -p $( ARTIFACTS)
@curl -L -o /tmp/sonobuoy.tar.gz ${ SONOBUOY_URL }
@tar -xf /tmp/sonobuoy.tar.gz -C $( ARTIFACTS)
$(ARTIFACTS)/kubectl :
@mkdir -p $( ARTIFACTS)
@curl -L -o $( ARTIFACTS) /kubectl " $( KUBECTL_URL) "
@chmod +x $( ARTIFACTS) /kubectl
2020-04-29 22:24:07 +03:00
$(ARTIFACTS)/clusterctl :
@mkdir -p $( ARTIFACTS)
@curl -L -o $( ARTIFACTS) /clusterctl " $( CLUSTERCTL_URL) "
@chmod +x $( ARTIFACTS) /clusterctl
e2e-% : $( ARTIFACTS ) /$( INTEGRATION_TEST_DEFAULT_TARGET ) -amd 64 $( ARTIFACTS ) /sonobuoy $( ARTIFACTS ) /kubectl $( ARTIFACTS ) /clusterctl ## Runs the E2E test for the specified platform (e.g. e2e-docker).
2020-01-24 07:52:02 +03:00
@$( MAKE) hack-test-$@ \
PLATFORM = $* \
TAG = $( TAG) \
SHA = $( SHA) \
IMAGE = $( REGISTRY_AND_USERNAME) /talos:$( TAG) \
ARTIFACTS = $( ARTIFACTS) \
OSCTL = $( PWD) /$( ARTIFACTS) /$( OSCTL_DEFAULT_TARGET) -amd64 \
INTEGRATION_TEST = $( PWD) /$( ARTIFACTS) /$( INTEGRATION_TEST_DEFAULT_TARGET) -amd64 \
KUBECTL = $( PWD) /$( ARTIFACTS) /kubectl \
2020-04-29 22:24:07 +03:00
SONOBUOY = $( PWD) /$( ARTIFACTS) /sonobuoy \
CLUSTERCTL = $( PWD) /$( ARTIFACTS) /clusterctl
2019-12-24 23:23:52 +03:00
2020-03-24 21:20:36 +03:00
provision-tests-prepare : release -artifacts $( ARTIFACTS ) /$( INTEGRATION_TEST_PROVISION_DEFAULT_TARGET ) -amd 64
provision-tests : provision -tests -prepare
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
@$( MAKE) hack-test-$@ \
TAG = $( TAG) \
OSCTL = $( PWD) /$( ARTIFACTS) /$( OSCTL_DEFAULT_TARGET) -amd64 \
INTEGRATION_TEST = $( PWD) /$( ARTIFACTS) /$( INTEGRATION_TEST_PROVISION_DEFAULT_TARGET) -amd64
2020-03-24 21:20:36 +03:00
provision-tests-track-% :
@$( MAKE) hack-test-provision-tests \
TAG = $( TAG) \
OSCTL = $( PWD) /$( ARTIFACTS) /$( OSCTL_DEFAULT_TARGET) -amd64 \
INTEGRATION_TEST = $( PWD) /$( ARTIFACTS) /$( INTEGRATION_TEST_PROVISION_DEFAULT_TARGET) -amd64 \
INTEGRATION_TEST_RUN = " TestIntegration/.+-TR $* "
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
# Assets for releases
.PHONY : $( ARTIFACTS ) /$( TALOS_RELEASE )
$(ARTIFACTS)/$(TALOS_RELEASE) : $( ARTIFACTS ) /$( TALOS_RELEASE ) /vmlinux $( ARTIFACTS ) /$( TALOS_RELEASE ) /initramfs .xz
# download release artifacts for specific version
$(ARTIFACTS)/$(TALOS_RELEASE)/% :
@mkdir -p $( ARTIFACTS) /$( TALOS_RELEASE) /
@curl -L -o " $( ARTIFACTS) / $( TALOS_RELEASE) / $* " " https://github.com/talos-systems/talos/releases/download/ $( TALOS_RELEASE) / $* "
.PHONY : release -artifacts
release-artifacts :
@for release in $( RELEASES) ; do \
$( MAKE) $( ARTIFACTS) /$$ release TALOS_RELEASE = $$ release; \
done
2019-12-24 23:23:52 +03:00
# Utilities
2019-01-19 12:58:26 +03:00
2020-04-11 03:06:59 +03:00
.PHONY : conformance
conformance : ## Performs policy checks against the commit and source code.
docker run --rm -it -v $( PWD) :/src -w /src docker.io/autonomy/conform:v0.1.0-alpha.19
2019-04-12 09:40:30 +03:00
.PHONY : login
2019-12-24 23:23:52 +03:00
login : ## Logs in to the configured container registry.
2020-02-13 23:07:36 +03:00
i f e q ( $( DOCKER_LOGIN_ENABLED ) , t r u e )
2019-12-24 23:23:52 +03:00
@docker login --username " $( DOCKER_USERNAME) " --password " $( DOCKER_PASSWORD) " $( REGISTRY)
2020-02-13 23:07:36 +03:00
e n d i f
2019-04-12 09:40:30 +03:00
2020-01-01 21:28:44 +03:00
push : login ## Pushes the installer, and talos images to the configured container registry with the generated tag.
2020-02-13 23:07:36 +03:00
@docker push $( REGISTRY_AND_USERNAME) /installer:$( TAG)
@docker push $( REGISTRY_AND_USERNAME) /talos:$( TAG)
2020-01-01 21:28:44 +03:00
push-% : login ## Pushes the installer, and talos images to the configured container registry with the specified tag (e.g. push-latest).
2020-02-13 23:07:36 +03:00
@docker tag $( REGISTRY_AND_USERNAME) /installer:$( TAG) $( REGISTRY_AND_USERNAME) /installer:$*
@docker tag $( REGISTRY_AND_USERNAME) /talos:$( TAG) $( REGISTRY_AND_USERNAME) /talos:$*
@docker push $( REGISTRY_AND_USERNAME) /installer:$*
@docker push $( REGISTRY_AND_USERNAME) /talos:$*
2019-04-12 09:40:30 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : clean
2019-12-24 23:23:52 +03:00
clean : ## Cleans up all artifacts.
2020-01-24 07:52:02 +03:00
@-rm -rf $( ARTIFACTS)