diff --git a/pkg/asset/ignition/bootstrap/bootstrap.go b/pkg/asset/ignition/bootstrap/bootstrap.go index 8be09a3388a..61cc881be1c 100644 --- a/pkg/asset/ignition/bootstrap/bootstrap.go +++ b/pkg/asset/ignition/bootstrap/bootstrap.go @@ -15,7 +15,7 @@ import ( "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/ignition" - "github.com/openshift/installer/pkg/asset/ignition/content" + "github.com/openshift/installer/pkg/asset/ignition/bootstrap/content" "github.com/openshift/installer/pkg/asset/installconfig" "github.com/openshift/installer/pkg/asset/kubeconfig" "github.com/openshift/installer/pkg/asset/manifests" @@ -103,7 +103,8 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error { a.Config.Systemd.Units = append( a.Config.Systemd.Units, igntypes.Unit{Name: "bootkube.service", Contents: content.BootkubeSystemdContents}, - igntypes.Unit{Name: "tectonic.service", Contents: content.TectonicSystemdContents, Enabled: util.BoolToPtr(true)}, + igntypes.Unit{Name: "tectonic.service", Contents: content.TectonicSystemdContents}, + igntypes.Unit{Name: "progress.service", Contents: content.ReportSystemdContents, Enabled: util.BoolToPtr(true)}, igntypes.Unit{Name: "kubelet.service", Contents: applyTemplateData(content.KubeletSystemdTemplate, templateData), Enabled: util.BoolToPtr(true)}, ) @@ -183,6 +184,10 @@ func (a *Bootstrap) addBootstrapFiles(dependencies asset.Parents) { a.Config.Storage.Files, ignition.FilesFromAsset(rootDir, 0644, kubeCoreOperator)..., ) + a.Config.Storage.Files = append( + a.Config.Storage.Files, + ignition.FileFromString("/opt/tectonic/report-progress.sh", 0555, content.ReportShFileContents), + ) } func (a *Bootstrap) addBootkubeFiles(dependencies asset.Parents, templateData *bootstrapTemplateData) { diff --git a/pkg/asset/ignition/content/bootkube.go b/pkg/asset/ignition/bootstrap/content/bootkube.go similarity index 87% rename from pkg/asset/ignition/content/bootkube.go rename to pkg/asset/ignition/bootstrap/content/bootkube.go index 8dc4b56a25a..0180cd99391 100644 --- a/pkg/asset/ignition/content/bootkube.go +++ b/pkg/asset/ignition/bootstrap/content/bootkube.go @@ -7,7 +7,8 @@ import ( const ( // BootkubeSystemdContents is a service for running bootkube on the bootstrap // nodes - BootkubeSystemdContents = `[Unit] + BootkubeSystemdContents = ` +[Unit] Description=Bootstrap a Kubernetes cluster Wants=kubelet.service After=kubelet.service @@ -16,9 +17,12 @@ After=kubelet.service WorkingDirectory=/opt/tectonic ExecStart=/opt/tectonic/bootkube.sh +# Workaround for https://github.com/opencontainers/runc/pull/1807 +ExecStartPost=/usr/bin/touch /opt/tectonic/.bootkube.done Restart=on-failure -RestartSec=5s` +RestartSec=5s +` ) var ( @@ -113,22 +117,22 @@ fi if [ ! -d kube-scheduler-bootstrap ] then - echo "Rendering Kubernetes Scheduler core manifests..." - - # shellcheck disable=SC2154 - podman run \ - --volume "$PWD:/assets:z" \ - "${KUBE_SCHEDULER_OPERATOR_IMAGE}" \ - /usr/bin/cluster-kube-scheduler-operator render \ - --asset-input-dir=/assets/tls \ - --asset-output-dir=/assets/kube-scheduler-bootstrap \ - --config-override-file=/usr/share/bootkube/manifests/config/config-overrides.yaml \ - --config-output-file=/assets/kube-scheduler-bootstrap/config - - # TODO: copy the bootstrap manifests to replace kube-core-operator - cp --recursive kube-scheduler-bootstrap/manifests/00_openshift-kube-scheduler-ns.yaml manifests/00_openshift-kube-scheduler-ns.yaml - cp --recursive kube-scheduler-bootstrap/manifests/secret-* manifests/ - cp --recursive kube-scheduler-bootstrap/manifests/configmap-* manifests/ + echo "Rendering Kubernetes Scheduler core manifests..." + + # shellcheck disable=SC2154 + podman run \ + --volume "$PWD:/assets:z" \ + "${KUBE_SCHEDULER_OPERATOR_IMAGE}" \ + /usr/bin/cluster-kube-scheduler-operator render \ + --asset-input-dir=/assets/tls \ + --asset-output-dir=/assets/kube-scheduler-bootstrap \ + --config-override-file=/usr/share/bootkube/manifests/config/config-overrides.yaml \ + --config-output-file=/assets/kube-scheduler-bootstrap/config + + # TODO: copy the bootstrap manifests to replace kube-core-operator + cp --recursive kube-scheduler-bootstrap/manifests/00_openshift-kube-scheduler-ns.yaml manifests/00_openshift-kube-scheduler-ns.yaml + cp --recursive kube-scheduler-bootstrap/manifests/secret-* manifests/ + cp --recursive kube-scheduler-bootstrap/manifests/configmap-* manifests/ fi if [ ! -d mco-bootstrap ] @@ -230,5 +234,6 @@ podman run \ --network=host \ --entrypoint=/bootkube \ "{{.BootkubeImage}}" \ - start --asset-dir=/assets`)) + start --asset-dir=/assets +`)) ) diff --git a/pkg/asset/ignition/content/doc.go b/pkg/asset/ignition/bootstrap/content/doc.go similarity index 73% rename from pkg/asset/ignition/content/doc.go rename to pkg/asset/ignition/bootstrap/content/doc.go index caaafb25a8f..9dceac33402 100644 --- a/pkg/asset/ignition/content/doc.go +++ b/pkg/asset/ignition/bootstrap/content/doc.go @@ -1,3 +1,3 @@ // Package content contains the contents of files and systemd units to be added -// to Ignition configs. +// to bootstrap Ignition configs. package content diff --git a/pkg/asset/ignition/content/kubelet.go b/pkg/asset/ignition/bootstrap/content/kubelet.go similarity index 96% rename from pkg/asset/ignition/content/kubelet.go rename to pkg/asset/ignition/bootstrap/content/kubelet.go index 52e881f2dff..3c533cb0bd6 100644 --- a/pkg/asset/ignition/content/kubelet.go +++ b/pkg/asset/ignition/bootstrap/content/kubelet.go @@ -7,7 +7,8 @@ import ( var ( // KubeletSystemdTemplate is a service for running the kubelet on the // bootstrap nodes. - KubeletSystemdTemplate = template.Must(template.New("kubelet.service").Parse(`[Unit] + KubeletSystemdTemplate = template.Must(template.New("kubelet.service").Parse(` +[Unit] Description=Kubernetes Kubelet Wants=rpc-statd.service @@ -46,5 +47,6 @@ Restart=always RestartSec=10 [Install] -WantedBy=multi-user.target`)) +WantedBy=multi-user.target +`)) ) diff --git a/pkg/asset/ignition/bootstrap/content/report.go b/pkg/asset/ignition/bootstrap/content/report.go new file mode 100644 index 00000000000..5178c2be5ab --- /dev/null +++ b/pkg/asset/ignition/bootstrap/content/report.go @@ -0,0 +1,54 @@ +package content + +const ( + // ReportSystemdContents is a service that reports the bootstrap progress + // via a Kubernetes Event. + ReportSystemdContents = ` +[Unit] +Description=Report the completion of the cluster bootstrap process +# Workaround for https://github.com/systemd/systemd/issues/1312 +Wants=bootkube.service tectonic.service +After=bootkube.service tectonic.service + +[Service] +# Workaround for https://github.com/systemd/systemd/issues/1312 and https://github.com/opencontainers/runc/pull/1807 +ExecStartPre=/usr/bin/test -f /opt/tectonic/.bootkube.done +ExecStartPre=/usr/bin/test -f /opt/tectonic/.tectonic.done +ExecStart=/opt/tectonic/report-progress.sh /opt/tectonic/auth/kubeconfig bootstrap-complete "cluster bootstrapping has completed" + +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target +` + + // ReportShFileContents is a script for reporting the bootstrap progress. + ReportShFileContents = `#!/usr/bin/env bash +set -e + +KUBECONFIG="${1}" +NAME="${2}" +MESSAGE="${3}" +TIMESTAMP="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" + +echo "Reporting install progress..." + +oc --config="$KUBECONFIG" create <