cluster_provision
kud_bm_deploy_mini:
+ source user_config.sh && \
pushd $(KUD_PATH) && ./kud_bm_launch.sh minimal v1 && popd
kud_bm_deploy:
# IPMI address) specified in the machine pool values. IPMI in the
# virtual environment is emulated by virtualbmc listening on the host.
baremetal_cidr = nil
+registry_mirrors = nil
Dir.glob("deploy/site/#{site}/*.yaml") do |file|
YAML.load_stream(File.read(file)) do |document|
values = document.fetch('spec', {}).fetch('values', {})
- next if values['machineName'].nil? || values['bootMACAddress'].nil?
- bmc_host = URI.parse(values['bmcAddress']).host
- baremetal_cidr = "#{IPAddr.new(bmc_host).mask(24)}/24"
+ unless values['bmcAddress'].nil?
+ bmc_host = URI.parse(values['bmcAddress']).host
+ baremetal_cidr = "#{IPAddr.new(bmc_host).mask(24)}/24"
+ end
+ unless values['dockerRegistryMirrors'].nil?
+ registry_mirrors = values['dockerRegistryMirrors'].join(' ')
+ end
end
end
if baremetal_cidr.nil?
m.trigger.after [:up] do |trigger|
trigger.name = 'Creating ICN user_config.sh'
- trigger.run = {inline: "./tools/vagrant/create_user_config.sh"}
+ trigger.run = {inline: "bash -c 'DOCKER_REGISTRY_MIRRORS=\"#{registry_mirrors}\" ./tools/vagrant/create_user_config.sh'"}
end
m.vm.provision 'Configuring ICN prerequisites', type: 'shell', privileged: true, inline: <<-SHELL
ssh-keygen -f "${HOME}/.ssh/id_rsa" -P "" <<<y
mkdir -p /etc/containerd
containerd config default | tee /etc/containerd/config.toml
sed -i 's/\(.*\)\[plugins\."io\.containerd\.grpc\.v1\.cri"\.containerd\.runtimes\.runc\.options\]/&\n\1 SystemdCgroup = true/' /etc/containerd/config.toml
+{{- if .dockerRegistryMirrors }}
+ sed -i 's/endpoint = \["https:\/\/registry-1\.docker\.io"\]/endpoint = {{ append .dockerRegistryMirrors "https://registry-1.docker.io" | toJson | replace "/" "\\/" | replace "[" "\\[" | replace "]" "\\]" }}/' /etc/containerd/config.toml
+{{- end }}
systemctl restart containerd
{{- else if eq .containerRuntime "docker" -}}
- path: /usr/local/bin/install-container-runtime.sh
"log-opts": {
"max-size": "100m"
},
+{{- if .dockerRegistryMirrors }}
+ "registry-mirrors": {{ .dockerRegistryMirrors | toJson }}
+{{- end }}
"storage-driver": "overlay2"
}
{{- end }}
kube-reserved: cpu=100m,memory=256Mi
name: '{{ "{{" }} ds.meta_data.name {{ "}}" }}'
preKubeadmCommands:
+{{- if .Values.preKubeadmCommands }}
+{{ toYaml .Values.preKubeadmCommands | indent 6 }}
+{{- end }}
{{- if .Values.networks }}
# Without touching up /etc/hosts, kubeadm may pick the wrong
# (i.e. provisioning network) address for the node IP
kube-reserved: cpu=200m,memory=512Mi
name: '{{ "{{" }} ds.meta_data.name {{ "}}" }}'
preKubeadmCommands:
+{{- if .Values.preKubeadmCommands }}
+{{ toYaml .Values.preKubeadmCommands | indent 4 }}
+{{- end }}
{{- if .Values.networks }}
# Without touching up /etc/hosts, kubeadm may pick the wrong
# (i.e. provisioning network) address for the node IP
containerdVersion: 1.4.11-1
# dockerVersion is the version of docker installed.
dockerVersion: 5:20.10.10~3-0~ubuntu-focal
+# dockerRegistryMirrors are optional mirrors for docker.io, in priority order
+#dockerRegistryMirrors: ["https://myregistry.com:5000"]
+# preKubeadmCommands execute on the provisioned machine before the
+# container runtime or K8s is configured
+#preKubeadmCommands:
+#- apt-get update -y
+#- apt-get install -y unzip
function set_bm_kud {
pushd ${KUDPATH}/kud/hosting_providers/vagrant/inventory
HOST_IP=${HOST_IP:-$(hostname -I | cut -d ' ' -f 1)}
+ DOCKER_OPTIONS=""
+ if [[ ! -z "${DOCKER_REGISTRY_MIRRORS+x}" ]]; then
+ OPTIONS=""
+ for mirror in ${DOCKER_REGISTRY_MIRRORS}; do
+ OPTIONS="${OPTIONS} --registry-mirror=${mirror}"
+ done
+ DOCKER_OPTIONS="docker_options=\"${OPTIONS# }\""
+ fi
if [ "$1" == "minimal" ] ; then
cat <<EOL > hosts.ini
[all]
-$HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22
+$HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22 ${DOCKER_OPTIONS}
[kube-master]
$HOSTNAME
else
cat <<EOL > hosts.ini
[all]
-$HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22
+$HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22 ${DOCKER_OPTIONS}
[kube-master]
$HOSTNAME
#Ironic Metal3 settings for provisioning network
export IRONIC_INTERFACE="eth1"
EOF
+
+if [[ ! -z "${DOCKER_REGISTRY_MIRRORS+x}" ]]; then
+ cat <<EOF >>user_config.sh
+
+#Use a registry mirror for downloading container images
+export DOCKER_REGISTRY_MIRRORS="${DOCKER_REGISTRY_MIRRORS}"
+EOF
+fi