Skip to content

Commit

Permalink
Merge pull request #1022 from syself/tg/installimage-tgz-adapt-path
Browse files Browse the repository at this point in the history
🌱 Update of hetzner-installimage via Makefile.
  • Loading branch information
batistein authored Oct 23, 2023
2 parents b0c2271 + b829680 commit cd2d6c2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,15 @@ tilt-up: env-vars-for-wl-cluster $(ENVSUBST) $(KUBECTL) $(KUSTOMIZE) $(TILT) clu
watch: ## Watch CRDs cluster, machines and Events.
watch -c -n 2 hack/output-for-watch.sh

installimageurl := $(shell curl -sL https://api.github.com/repos/syself/hetzner-installimage/releases/latest | jq -r .assets[].browser_download_url)
.PHONY: create-hetzner-installimage-tgz
create-hetzner-installimage-tgz:
rm -rf data/hetzner-installimage*
cd data; curl -sSLO $(installimageurl)
cd data; \
installimageurl=$$(curl -sL https://api.github.com/repos/syself/hetzner-installimage/releases/latest | jq -r .assets[].browser_download_url); \
echo $$installimageurl; \
curl -sSLO $$installimageurl
@if [ $$(tar -tzf data/hetzner-installimage*tgz| cut -d/ -f1| sort | uniq) != "hetzner-installimage" ]; then \
echo "tgz must contain only one directory. And it must be 'hetzner-installimage'."; \
exit 1; \
fi

2 changes: 1 addition & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def caph():

# copy things from data directory to .tiltbuild
if not os.path.exists('.tiltbuild/installimage.tgz'):
local("cp data/hetzner-install-image-v1.0.0.tgz .tiltbuild/installimage.tgz")
local("cp data/hetzner-installimage-v1.0.3.tgz .tiltbuild/installimage.tgz")

# Set up a local_resource build of the provider's manager binary.

Expand Down
Binary file removed data/hetzner-install-image-v1.0.0.tgz
Binary file not shown.
Binary file added data/hetzner-installimage-v1.0.3.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/reference/hetzner-bare-metal-machine-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ When the `HetznerBareMetalMachine` object gets deleted, it removes the informati

Updating a `HetznerBareMetalMachineTemplate` is not possible. Instead, a new template should be created.

## cloud-init and install-image
## cloud-init and installimage

Both in install-image and cloud-init the ports used for SSH can be changed, e.g. with the following code snippet:
Both in installimage and cloud-init the ports used for SSH can be changed, e.g. with the following code snippet:

```
sed -i -e '/^\(#\|\)Port/s/^.*$/Port 2223/' /etc/ssh/sshd_config
Expand Down
2 changes: 1 addition & 1 deletion images/caph/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go/pkg \

FROM --platform=${BUILDPLATFORM} gcr.io/distroless/static:nonroot
WORKDIR /
COPY data/hetzner-install-image-v1.0.0.tgz /installimage.tgz
COPY data/hetzner-installimage-v1.0.3.tgz /installimage.tgz
COPY --from=build /src/cluster-api-provider-hetzner/manager .
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
USER 65532
Expand Down
8 changes: 4 additions & 4 deletions pkg/services/baremetal/client/ssh/ssh_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (c *sshClient) ExecuteInstallImage(hasPostInstallScript bool) Output {
cmd = `/root/hetzner-installimage/installimage -a -c /autosetup`
}

out := c.runSSH(fmt.Sprintf(`cat << 'EOF' > /root/install-image-script.sh
out := c.runSSH(fmt.Sprintf(`cat << 'EOF' > /root/installimage-wrapper.sh
#!/bin/bash
export TERM=xterm
Expand All @@ -255,20 +255,20 @@ EOF`, cmd))
return out
}

out = c.runSSH(`chmod +x /root/install-image-script.sh . `)
out = c.runSSH(`chmod +x /root/installimage-wrapper.sh . `)
if out.Err != nil || out.StdErr != "" {
return out
}

installImageOut := c.runSSH(`sh /root/install-image-script.sh`)
installImageOut := c.runSSH(`sh /root/installimage-wrapper.sh`)

debugTxtOut := c.runSSH(`cat /root/debug.txt`)
installImageOut.StdOut = fmt.Sprintf(`debug.txt:
%s
%s
######################################
/root/install-image-script.sh stdout:
/root/installimage-wrapper.sh stdout:
%s
######################################
Expand Down

0 comments on commit cd2d6c2

Please sign in to comment.