-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add basic build infrastructure
- Loading branch information
Showing
5 changed files
with
176 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
_build/ | ||
|
||
.vagrant/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.POSIX: | ||
|
||
MAKEFLAGS += -r | ||
.DEFAULT_GOAL := default | ||
.DELETE_ON_ERROR: | ||
.SUFFIXES: | ||
|
||
VERSION ?= 2.0 | ||
|
||
PWD := $(shell pwd) | ||
|
||
BUILD_ROOT ?= $(PWD)/_build | ||
ISO_ROOT ?= $(BUILD_ROOT)/root | ||
|
||
ALL = \ | ||
$(ISO_ROOT)/bootstrap.sh \ | ||
\ | ||
$(ISO_ROOT)/salt/metalk8s/containerd/configured.sls \ | ||
$(ISO_ROOT)/salt/metalk8s/containerd/init.sls \ | ||
$(ISO_ROOT)/salt/metalk8s/containerd/installed.sls \ | ||
\ | ||
$(ISO_ROOT)/salt/metalk8s/defaults.yaml \ | ||
\ | ||
$(ISO_ROOT)/salt/metalk8s/kubelet/init.sls \ | ||
$(ISO_ROOT)/salt/metalk8s/kubelet/installed.sls \ | ||
\ | ||
$(ISO_ROOT)/salt/metalk8s/map.jinja \ | ||
\ | ||
$(ISO_ROOT)/salt/metalk8s/repo/configured.sls \ | ||
$(ISO_ROOT)/salt/metalk8s/repo/init.sls \ | ||
$(ISO_ROOT)/salt/metalk8s/repo/offline.sls \ | ||
$(ISO_ROOT)/salt/metalk8s/repo/online.sls \ | ||
\ | ||
$(ISO_ROOT)/salt/metalk8s/runc/init.sls \ | ||
$(ISO_ROOT)/salt/metalk8s/runc/installed.sls \ | ||
\ | ||
$(ISO_ROOT)/pillar/repositories.sls \ | ||
$(ISO_ROOT)/pillar/top.sls \ | ||
|
||
|
||
default: all | ||
.PHONY: default | ||
|
||
all: $(ALL) | ||
.PHONY: all | ||
|
||
$(ISO_ROOT)/bootstrap.sh: scripts/bootstrap.sh.in | ||
mkdir -p $(shell dirname $@) | ||
rm -f $@ | ||
sed s/@VERSION@/$(VERSION)/g < $< > $@ || rm -f $@ | ||
chmod a+x $@ | ||
|
||
$(ISO_ROOT)/salt/%: salt/% | ||
mkdir -p $(shell dirname $@) | ||
rm -f $@ | ||
cp --archive $< $@ | ||
|
||
$(ISO_ROOT)/pillar/top.sls: pillar/top.sls.in | ||
mkdir -p $(shell dirname $@) | ||
rm -f $@ | ||
sed s/@VERSION@/$(VERSION)/g < $< > $@ || rm -f $@ | ||
|
||
$(ISO_ROOT)/pillar/%: pillar/% | ||
mkdir -p $(shell dirname $@) | ||
rm -f $@ | ||
cp --archive $< $@ | ||
|
||
clean: | ||
rm -rf $(BUILD_ROOT) | ||
.PHONY: clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
metalk8s-2.0: | ||
metalk8s-@VERSION@: | ||
'*': | ||
- repositories |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -u | ||
# The trickery below is to only run `set -o pipefail`, which is a Bash'ism, | ||
# when running in Bash and not some other `sh` which doesn't necessarily | ||
# support `-o pipefail` (though must support `-e` and `-u` per POSIX). | ||
if test -z "$(type -p)"; then set -o pipefail; fi | ||
|
||
RPM=${RPM:-$(command -v rpm)} | ||
SYSTEMCTL=${SYSTEMCTL:-$(command -v systemctl)} | ||
YUM=${YUM:-$(command -v yum)} | ||
SALT_CALL=${SALT_CALL:-salt-call} | ||
|
||
SALT_MINION_FILE_CLIENT_LOCAL_CONF=/etc/salt/minion.d/99-file-client-local.conf | ||
|
||
die() { | ||
echo 1>&2 "$@" | ||
exit 1 | ||
} | ||
|
||
pre_minion_checks() { | ||
test "x$(whoami)" = "xroot" || die "Script must run as root" | ||
test -n "${RPM}" || die "rpm not found" | ||
test -x "${RPM}" || die "rpm at '${RPM}' is not executable" | ||
test -n "${SYSTEMCTL}" || die "systemctl not found" | ||
test -x "${SYSTEMCTL}" || die "systemctl at '${SYSTEMCTL}' is not executable" | ||
test -n "${YUM}" || die "yum not found" | ||
test -x "${YUM}" || die "yum at '${YUM}' is not executable" | ||
} | ||
|
||
disable_salt_minion_service() { | ||
${SYSTEMCTL} disable salt-minion.service 2>/dev/null || true | ||
} | ||
|
||
stop_salt_minion_service() { | ||
${SYSTEMCTL} stop salt-minion.service 2>/dev/null || true | ||
} | ||
|
||
configure_salt_repository() { | ||
${RPM} --import https://repo.saltstack.com/yum/redhat/7/x86_64/archive/2018.3.3/SALTSTACK-GPG-KEY.pub | ||
cat > /etc/yum.repos.d/saltstack.repo << EOF | ||
[saltstack-repo] | ||
name=SaltStack repo for RHEL/CentOS \$releasever | ||
baseurl=https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/archive/2018.3.3 | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/archive/2018.3.3/SALTSTACK-GPG-KEY.pub | ||
EOF | ||
${YUM} clean expire-cache | ||
} | ||
|
||
install_salt_minion() { | ||
${YUM} install -y salt-minion | ||
} | ||
|
||
configure_salt_minion_local_mode() { | ||
cat > "${SALT_MINION_FILE_CLIENT_LOCAL_CONF}" << EOF | ||
file_client: local | ||
file_roots: | ||
metalk8s-@VERSION@: | ||
- /srv/scality/metalk8s-dev/salt | ||
pillar_roots: | ||
metalk8s-@VERSION@: | ||
- /srv/scality/metalk8s-dev/pillar | ||
EOF | ||
} | ||
|
||
run_bootstrap_prechecks() { | ||
return | ||
} | ||
|
||
install_kubelet() { | ||
${SALT_CALL} --local --retcode-passthrough state.apply metalk8s.containerd saltenv=metalk8s-@VERSION@ pillarenv=metalk8s-@VERSION@ | ||
${SALT_CALL} --local --retcode-passthrough state.apply metalk8s.kubelet saltenv=metalk8s-@VERSION@ pillarenv=metalk8s-@VERSION@ | ||
} | ||
|
||
main() { | ||
pre_minion_checks | ||
disable_salt_minion_service | ||
stop_salt_minion_service | ||
configure_salt_repository | ||
install_salt_minion | ||
configure_salt_minion_local_mode | ||
run_bootstrap_prechecks | ||
install_kubelet | ||
} | ||
|
||
main |