diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cf8b9e39a0..b57d32b6c3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ If you're interested in contributing documentation, please note the following: ## Developer Certificate Of Origin ## -To contribute to this project, you must agree to the Developer Certificate of Origin (DCO) for each commit you make. The DCO is a simple statement that you, as a contributor, have the legal rite to make the contribution. +To contribute to this project, you must agree to the Developer Certificate of Origin (DCO) for each commit you make. The DCO is a simple statement that you, as a contributor, have the legal right to make the contribution. See the [DCO](DCO) file for the full text of what you must agree to. diff --git a/Makefile b/Makefile index 172af7d4bc..1b2ff55f05 100644 --- a/Makefile +++ b/Makefile @@ -29,3 +29,7 @@ generate: build/data build/data: mkdir -p $@ + +.PHONY: binary-size-check +binary-size-check: + scripts/binary_size_check.sh diff --git a/README.md b/README.md index f9beec482e..8ad23359e7 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ There are two major ways that K3s is lighter weight than upstream Kubernetes: 1. The memory footprint to run it is smaller 2. The binary, which contains all the non-containerized components needed to run a cluster, is smaller -The memory footprint is reduced primarily by running many components inside of single process. This eliminates significant overhead that would otherwise be duplicated for each component. +The memory footprint is reduced primarily by running many components inside of a single process. This eliminates significant overhead that would otherwise be duplicated for each component. The binary is smaller by removing third-party storage drivers and cloud providers, which is explained in more detail below. diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index 367b8e3d60..124ea5244c 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -3,7 +3,6 @@ package cmds import ( "context" - "github.com/rancher/k3s/pkg/daemons/config" "github.com/rancher/k3s/pkg/version" "github.com/urfave/cli" ) @@ -60,7 +59,7 @@ type Server struct { ClusterReset bool ClusterResetRestorePath string EncryptSecrets bool - StartupHooks []func(context.Context, config.Control) error + StartupHooks []func(context.Context, <-chan struct{}, string) error EtcdDisableSnapshots bool EtcdSnapshotDir string EtcdSnapshotCron string diff --git a/pkg/server/server.go b/pkg/server/server.go index 89b7bb05fe..f0520e8903 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -61,7 +61,7 @@ func StartServer(ctx context.Context, config *Config) error { } for _, hook := range config.StartupHooks { - if err := hook(ctx, config.ControlConfig); err != nil { + if err := hook(ctx, config.ControlConfig.Runtime.APIServerReady, config.ControlConfig.Runtime.KubeConfigAdmin); err != nil { return errors.Wrap(err, "startup hook") } } diff --git a/pkg/server/types.go b/pkg/server/types.go index 69f96389e1..d7b84ed3a2 100644 --- a/pkg/server/types.go +++ b/pkg/server/types.go @@ -12,5 +12,5 @@ type Config struct { ControlConfig config.Control Rootless bool SupervisorPort int - StartupHooks []func(context.Context, config.Control) error + StartupHooks []func(context.Context, <-chan struct{}, string) error } diff --git a/scripts/binary_size_check.sh b/scripts/binary_size_check.sh new file mode 100755 index 0000000000..d8dccaccbf --- /dev/null +++ b/scripts/binary_size_check.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +if [ "${DEBUG}" = 1 ]; then + set -x +fi + +MAX_BINARY_SIZE=61000000 +SIZE=$(ls -l dist/artifacts/k3s | awk -F ' ' '{print $5}') + +if [ ${SIZE} -gt ${MAX_BINARY_SIZE} ]; then + echo "k3s binary exceeds acceptable size of "${MAX_BINARY_SIZE} + exit 1 +fi + +exit 0 diff --git a/scripts/ci b/scripts/ci index a0de81fdee..0e69a46376 100755 --- a/scripts/ci +++ b/scripts/ci @@ -7,5 +7,7 @@ cd $(dirname $0) if [ -z "$SKIP_VALIDATE" ]; then ./validate fi + ./build ./package +./binary_size_check.sh