Skip to content

Commit

Permalink
Avoid second run for bootstrap script (#275)
Browse files Browse the repository at this point in the history
Signed-off-by: Waleed Malik <[email protected]>
  • Loading branch information
ahmedwaleedmalik authored Mar 14, 2023
1 parent 698123d commit 8d8b6be
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 28 deletions.
17 changes: 15 additions & 2 deletions deploy/osps/default/osp-amzn2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ metadata:
spec:
osName: "amzn2"
osVersion: "2.0"
version: "v1.2.0"
version: "v1.2.1"
supportedCloudProviders:
- name: "aws"

Expand Down Expand Up @@ -67,6 +67,12 @@ spec:
#!/bin/bash
set -xeuo pipefail
# Check if bootstrap phase has already completed. This is required when we run `cloud-init init` again since it tries to re-run
# the bootstrap cloud-config as well, from the userdata.
if [ -f /etc/bootstrap-complete ]; then
exit 0
fi
{{- /* Configure proxy as the first step to ensure that all the phases of provisioning respect the proxy environment. */}}
{{- template "configureProxyScript" }}
Expand All @@ -76,8 +82,15 @@ spec:
cloud-init clean
cloud-init --file /etc/cloud/cloud.cfg.d/{{ .SecretName }}.cfg init
systemctl daemon-reload
systemctl restart setup.service
# cloud-init should only run on the first boot. From this point forward we don't need cloud-init anymore.
systemctl disable cloud-init
touch /etc/cloud/cloud-init.disabled
# Bootstrap phase for the machine is complete.
touch /etc/bootstrap-complete
systemctl disable bootstrap.service
# Start provisioning phase for the machine.
systemctl restart setup.service
- path: /etc/systemd/system/bootstrap.service
permissions: 644
Expand Down
17 changes: 15 additions & 2 deletions deploy/osps/default/osp-centos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ metadata:
spec:
osName: "centos"
osVersion: "7.7"
version: "v1.2.0"
version: "v1.2.1"
supportedCloudProviders:
- name: "alibaba"
- name: "aws"
Expand Down Expand Up @@ -76,6 +76,12 @@ spec:
#!/bin/bash
set -xeuo pipefail
# Check if bootstrap phase has already completed. This is required when we run `cloud-init init` again since it tries to re-run
# the bootstrap cloud-config as well, from the userdata.
if [ -f /etc/bootstrap-complete ]; then
exit 0
fi
{{- /* Configure proxy as the first step to ensure that all the phases of provisioning respect the proxy environment. */}}
{{- template "configureProxyScript" }}
Expand All @@ -92,8 +98,15 @@ spec:
cloud-init --file /etc/cloud/cloud.cfg.d/{{ .SecretName }}.cfg init
systemctl daemon-reload
systemctl restart setup.service
# cloud-init should only run on the first boot. From this point forward we don't need cloud-init anymore.
systemctl disable cloud-init
touch /etc/cloud/cloud-init.disabled
# Bootstrap phase for the machine is complete.
touch /etc/bootstrap-complete
systemctl disable bootstrap.service
# Start provisioning phase for the machine.
systemctl restart setup.service
- path: /etc/systemd/system/bootstrap.service
permissions: 644
Expand Down
17 changes: 15 additions & 2 deletions deploy/osps/default/osp-rhel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ metadata:
spec:
osName: "rhel"
osVersion: "8.5"
version: "v1.2.0"
version: "v1.2.1"
supportedCloudProviders:
- name: "aws"
- name: "azure"
Expand Down Expand Up @@ -71,6 +71,12 @@ spec:
#!/bin/bash
set -xeuo pipefail
# Check if bootstrap phase has already completed. This is required when we run `cloud-init init` again since it tries to re-run
# the bootstrap cloud-config as well, from the userdata.
if [ -f /etc/bootstrap-complete ]; then
exit 0
fi
{{- /* Configure proxy as the first step to ensure that all the phases of provisioning respect the proxy environment. */}}
{{- template "configureProxyScript" }}
Expand All @@ -81,8 +87,15 @@ spec:
cloud-init --file /etc/cloud/cloud.cfg.d/{{ .SecretName }}.cfg init
systemctl daemon-reload
systemctl restart setup.service
# cloud-init should only run on the first boot. From this point forward we don't need cloud-init anymore.
systemctl disable cloud-init
touch /etc/cloud/cloud-init.disabled
# Bootstrap phase for the machine is complete.
touch /etc/bootstrap-complete
systemctl disable bootstrap.service
# Start provisioning phase for the machine.
systemctl restart setup.service
- path: /etc/systemd/system/bootstrap.service
permissions: 644
Expand Down
17 changes: 15 additions & 2 deletions deploy/osps/default/osp-rockylinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ metadata:
spec:
osName: "rockylinux"
osVersion: "8.6"
version: "v1.2.0"
version: "v1.2.1"
supportedCloudProviders:
- name: "aws"
- name: "azure"
Expand Down Expand Up @@ -74,6 +74,12 @@ spec:
#!/bin/bash
set -xeuo pipefail
# Check if bootstrap phase has already completed. This is required when we run `cloud-init init` again since it tries to re-run
# the bootstrap cloud-config as well, from the userdata.
if [ -f /etc/bootstrap-complete ]; then
exit 0
fi
{{- /* Configure proxy as the first step to ensure that all the phases of provisioning respect the proxy environment. */}}
{{- template "configureProxyScript" }}
Expand All @@ -84,8 +90,15 @@ spec:
cloud-init --file /etc/cloud/cloud.cfg.d/{{ .SecretName }}.cfg init
systemctl daemon-reload
systemctl restart setup.service
# cloud-init should only run on the first boot. From this point forward we don't need cloud-init anymore.
systemctl disable cloud-init
touch /etc/cloud/cloud-init.disabled
# Bootstrap phase for the machine is complete.
touch /etc/bootstrap-complete
systemctl disable bootstrap.service
# Start provisioning phase for the machine.
systemctl restart setup.service
- path: /etc/systemd/system/bootstrap.service
permissions: 644
Expand Down
17 changes: 15 additions & 2 deletions deploy/osps/default/osp-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ metadata:
spec:
osName: "ubuntu"
osVersion: "20.04"
version: "v1.2.0"
version: "v1.2.1"
supportedCloudProviders:
- name: "alibaba"
- name: "aws"
Expand Down Expand Up @@ -86,6 +86,12 @@ spec:
#!/bin/bash
set -xeuo pipefail
# Check if bootstrap phase has already completed. This is required when we run `cloud-init init` again since it tries to re-run
# the bootstrap cloud-config as well, from the userdata.
if [ -f /etc/bootstrap-complete ]; then
exit 0
fi
{{- /* Configure proxy as the first step to ensure that all the phases of provisioning respect the proxy environment. */}}
{{- template "configureProxyScript" }}
Expand All @@ -109,8 +115,15 @@ spec:
{{- end }}
systemctl daemon-reload
systemctl restart setup.service
# cloud-init should only run on the first boot. From this point forward we don't need cloud-init anymore.
systemctl disable cloud-init
touch /etc/cloud/cloud-init.disabled
# Bootstrap phase for the machine is complete.
touch /etc/bootstrap-complete
systemctl disable bootstrap.service
# Start provisioning phase for the machine.
systemctl restart setup.service
- path: /etc/systemd/system/bootstrap.service
permissions: 644
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ spec:
permissions: 755
- content:
inline:
data: "#!/bin/bash\nset -xeuo pipefail\n\ncat <<EOF | tee -a /etc/environment\nHTTP_PROXY=http://test-http-proxy.com\nhttp_proxy=http://test-http-proxy.com\nHTTPS_PROXY=http://test-http-proxy.com\nhttps_proxy=http://test-http-proxy.com\nEOF\ncat
data: "#!/bin/bash\nset -xeuo pipefail\n\n# Check if bootstrap phase has
already completed. This is required when we run `cloud-init init` again
since it tries to re-run\n# the bootstrap cloud-config as well, from the
userdata.\nif [ -f /etc/bootstrap-complete ]; then\n exit 0\nfi\n\ncat
<<EOF | tee -a /etc/environment\nHTTP_PROXY=http://test-http-proxy.com\nhttp_proxy=http://test-http-proxy.com\nHTTPS_PROXY=http://test-http-proxy.com\nhttps_proxy=http://test-http-proxy.com\nEOF\ncat
<<EOF | tee -a /etc/environment\nNO_PROXY=http://test-no-proxy.com\nno_proxy=http://test-no-proxy.com\nEOF\n\nsudo
mkdir -p /etc/apt/apt.conf.d\ncat <<EOF | sudo tee /etc/apt/apt.conf.d/proxy.conf\nAcquire::https::Proxy
\"http://test-http-proxy.com\";\nAcquire::http::Proxy \"http://test-http-proxy.com\";\nEOF\n\nsource
Expand All @@ -32,8 +36,12 @@ spec:
top-secret'\thttps://foo.bar:6443/api/v1/namespaces/cloud-init-settings/secrets/kubelet-configuration-kube-system-provisioning-config
| jq '.data[\"cloud-config\"]' -r| base64 -d > /etc/cloud/cloud.cfg.d/kubelet-configuration-kube-system-provisioning-config.cfg\ncloud-init
clean\n\ncloud-init --file /etc/cloud/cloud.cfg.d/kubelet-configuration-kube-system-provisioning-config.cfg
init\nsystemctl daemon-reload\n\nsystemctl daemon-reload\nsystemctl restart
setup.service\nsystemctl disable bootstrap.service\n"
init\nsystemctl daemon-reload\n\nsystemctl daemon-reload\n\n# cloud-init
should only run on the first boot. From this point forward we don't need
cloud-init anymore.\nsystemctl disable cloud-init\ntouch /etc/cloud/cloud-init.disabled\n#
Bootstrap phase for the machine is complete.\ntouch /etc/bootstrap-complete\nsystemctl
disable bootstrap.service\n# Start provisioning phase for the machine.\nsystemctl
restart setup.service\n"
encoding: b64
path: /opt/bin/bootstrap
permissions: 755
Expand Down
15 changes: 14 additions & 1 deletion pkg/controllers/osc/testdata/osc-rhel-8.x-azure-containerd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ spec:
#!/bin/bash
set -xeuo pipefail
# Check if bootstrap phase has already completed. This is required when we run `cloud-init init` again since it tries to re-run
# the bootstrap cloud-config as well, from the userdata.
if [ -f /etc/bootstrap-complete ]; then
exit 0
fi
cat <<EOF | tee -a /etc/environment
HTTP_PROXY=http://test-http-proxy.com
http_proxy=http://test-http-proxy.com
Expand All @@ -47,8 +53,15 @@ spec:
cloud-init --file /etc/cloud/cloud.cfg.d/osp-rhel-azure-kube-system-provisioning-config.cfg init
systemctl daemon-reload
systemctl restart setup.service
# cloud-init should only run on the first boot. From this point forward we don't need cloud-init anymore.
systemctl disable cloud-init
touch /etc/cloud/cloud-init.disabled
# Bootstrap phase for the machine is complete.
touch /etc/bootstrap-complete
systemctl disable bootstrap.service
# Start provisioning phase for the machine.
systemctl restart setup.service
encoding: b64
path: /opt/bin/bootstrap
permissions: 755
Expand Down
14 changes: 11 additions & 3 deletions pkg/controllers/osc/testdata/osc-ubuntu-aws-containerd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ spec:
permissions: 755
- content:
inline:
data: "#!/bin/bash\nset -xeuo pipefail\n\ncat <<EOF | tee -a /etc/environment\nHTTP_PROXY=http://test-http-proxy.com\nhttp_proxy=http://test-http-proxy.com\nHTTPS_PROXY=http://test-http-proxy.com\nhttps_proxy=http://test-http-proxy.com\nEOF\ncat
data: "#!/bin/bash\nset -xeuo pipefail\n\n# Check if bootstrap phase has
already completed. This is required when we run `cloud-init init` again
since it tries to re-run\n# the bootstrap cloud-config as well, from the
userdata.\nif [ -f /etc/bootstrap-complete ]; then\n exit 0\nfi\n\ncat
<<EOF | tee -a /etc/environment\nHTTP_PROXY=http://test-http-proxy.com\nhttp_proxy=http://test-http-proxy.com\nHTTPS_PROXY=http://test-http-proxy.com\nhttps_proxy=http://test-http-proxy.com\nEOF\ncat
<<EOF | tee -a /etc/environment\nNO_PROXY=http://test-no-proxy.com\nno_proxy=http://test-no-proxy.com\nEOF\n\nsudo
mkdir -p /etc/apt/apt.conf.d\ncat <<EOF | sudo tee /etc/apt/apt.conf.d/proxy.conf\nAcquire::https::Proxy
\"http://test-http-proxy.com\";\nAcquire::http::Proxy \"http://test-http-proxy.com\";\nEOF\n\nsource
Expand All @@ -32,8 +36,12 @@ spec:
top-secret'\thttps://foo.bar:6443/api/v1/namespaces/cloud-init-settings/secrets/ubuntu-aws-kube-system-provisioning-config
| jq '.data[\"cloud-config\"]' -r| base64 -d > /etc/cloud/cloud.cfg.d/ubuntu-aws-kube-system-provisioning-config.cfg\ncloud-init
clean\n\ncloud-init --file /etc/cloud/cloud.cfg.d/ubuntu-aws-kube-system-provisioning-config.cfg
init\nsystemctl daemon-reload\n\nsystemctl daemon-reload\nsystemctl restart
setup.service\nsystemctl disable bootstrap.service\n"
init\nsystemctl daemon-reload\n\nsystemctl daemon-reload\n\n# cloud-init
should only run on the first boot. From this point forward we don't need
cloud-init anymore.\nsystemctl disable cloud-init\ntouch /etc/cloud/cloud-init.disabled\n#
Bootstrap phase for the machine is complete.\ntouch /etc/bootstrap-complete\nsystemctl
disable bootstrap.service\n# Start provisioning phase for the machine.\nsystemctl
restart setup.service\n"
encoding: b64
path: /opt/bin/bootstrap
permissions: 755
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ spec:
permissions: 755
- content:
inline:
data: "#!/bin/bash\nset -xeuo pipefail\n\ncat <<EOF | tee -a /etc/environment\nHTTP_PROXY=http://test-http-proxy.com\nhttp_proxy=http://test-http-proxy.com\nHTTPS_PROXY=http://test-http-proxy.com\nhttps_proxy=http://test-http-proxy.com\nEOF\ncat
data: "#!/bin/bash\nset -xeuo pipefail\n\n# Check if bootstrap phase has
already completed. This is required when we run `cloud-init init` again
since it tries to re-run\n# the bootstrap cloud-config as well, from the
userdata.\nif [ -f /etc/bootstrap-complete ]; then\n exit 0\nfi\n\ncat
<<EOF | tee -a /etc/environment\nHTTP_PROXY=http://test-http-proxy.com\nhttp_proxy=http://test-http-proxy.com\nHTTPS_PROXY=http://test-http-proxy.com\nhttps_proxy=http://test-http-proxy.com\nEOF\ncat
<<EOF | tee -a /etc/environment\nNO_PROXY=http://test-no-proxy.com\nno_proxy=http://test-no-proxy.com\nEOF\n\nsudo
mkdir -p /etc/apt/apt.conf.d\ncat <<EOF | sudo tee /etc/apt/apt.conf.d/proxy.conf\nAcquire::https::Proxy
\"http://test-http-proxy.com\";\nAcquire::http::Proxy \"http://test-http-proxy.com\";\nEOF\n\nsource
Expand All @@ -32,8 +36,12 @@ spec:
top-secret'\thttps://foo.bar:6443/api/v1/namespaces/cloud-init-settings/secrets/ubuntu-aws-kube-system-provisioning-config
| jq '.data[\"cloud-config\"]' -r| base64 -d > /etc/cloud/cloud.cfg.d/ubuntu-aws-kube-system-provisioning-config.cfg\ncloud-init
clean\n\ncloud-init --file /etc/cloud/cloud.cfg.d/ubuntu-aws-kube-system-provisioning-config.cfg
init\nsystemctl daemon-reload\n\nsystemctl daemon-reload\nsystemctl restart
setup.service\nsystemctl disable bootstrap.service\n"
init\nsystemctl daemon-reload\n\nsystemctl daemon-reload\n\n# cloud-init
should only run on the first boot. From this point forward we don't need
cloud-init anymore.\nsystemctl disable cloud-init\ntouch /etc/cloud/cloud-init.disabled\n#
Bootstrap phase for the machine is complete.\ntouch /etc/bootstrap-complete\nsystemctl
disable bootstrap.service\n# Start provisioning phase for the machine.\nsystemctl
restart setup.service\n"
encoding: b64
path: /opt/bin/bootstrap
permissions: 755
Expand Down
14 changes: 11 additions & 3 deletions pkg/controllers/osc/testdata/osc-ubuntu-aws-dualstack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ spec:
permissions: 755
- content:
inline:
data: "#!/bin/bash\nset -xeuo pipefail\n\ncat <<EOF | tee -a /etc/environment\nHTTP_PROXY=http://test-http-proxy.com\nhttp_proxy=http://test-http-proxy.com\nHTTPS_PROXY=http://test-http-proxy.com\nhttps_proxy=http://test-http-proxy.com\nEOF\ncat
data: "#!/bin/bash\nset -xeuo pipefail\n\n# Check if bootstrap phase has
already completed. This is required when we run `cloud-init init` again
since it tries to re-run\n# the bootstrap cloud-config as well, from the
userdata.\nif [ -f /etc/bootstrap-complete ]; then\n exit 0\nfi\n\ncat
<<EOF | tee -a /etc/environment\nHTTP_PROXY=http://test-http-proxy.com\nhttp_proxy=http://test-http-proxy.com\nHTTPS_PROXY=http://test-http-proxy.com\nhttps_proxy=http://test-http-proxy.com\nEOF\ncat
<<EOF | tee -a /etc/environment\nNO_PROXY=http://test-no-proxy.com\nno_proxy=http://test-no-proxy.com\nEOF\n\nsudo
mkdir -p /etc/apt/apt.conf.d\ncat <<EOF | sudo tee /etc/apt/apt.conf.d/proxy.conf\nAcquire::https::Proxy
\"http://test-http-proxy.com\";\nAcquire::http::Proxy \"http://test-http-proxy.com\";\nEOF\n\nsource
Expand All @@ -32,8 +36,12 @@ spec:
top-secret'\thttps://foo.bar:6443/api/v1/namespaces/cloud-init-settings/secrets/ubuntu-aws-kube-system-provisioning-config
| jq '.data[\"cloud-config\"]' -r| base64 -d > /etc/cloud/cloud.cfg.d/ubuntu-aws-kube-system-provisioning-config.cfg\ncloud-init
clean\n\ncloud-init --file /etc/cloud/cloud.cfg.d/ubuntu-aws-kube-system-provisioning-config.cfg
init\nsystemctl daemon-reload\n\nsystemctl daemon-reload\nsystemctl restart
setup.service\nsystemctl disable bootstrap.service\n"
init\nsystemctl daemon-reload\n\nsystemctl daemon-reload\n\n# cloud-init
should only run on the first boot. From this point forward we don't need
cloud-init anymore.\nsystemctl disable cloud-init\ntouch /etc/cloud/cloud-init.disabled\n#
Bootstrap phase for the machine is complete.\ntouch /etc/bootstrap-complete\nsystemctl
disable bootstrap.service\n# Start provisioning phase for the machine.\nsystemctl
restart setup.service\n"
encoding: b64
path: /opt/bin/bootstrap
permissions: 755
Expand Down
Loading

0 comments on commit 8d8b6be

Please sign in to comment.