-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Huy Mai <[email protected]>
- Loading branch information
Showing
29 changed files
with
776 additions
and
201 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
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,34 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
launch_fake_ipa() | ||
{ | ||
# Create a folder to host fakeIPA config and certs | ||
mkdir -p "${WORKING_DIR}/fake-ipa" | ||
if [[ "${EPHEMERAL_CLUSTER}" = "kind" ]] && [[ "${IRONIC_TLS_SETUP}" = "true" ]]; then | ||
cp "${IRONIC_CACERT_FILE}" "${WORKING_DIR}/fake-ipa/ironic-ca.crt" | ||
elif [[ "${IRONIC_TLS_SETUP}" = "true" ]]; then | ||
# wait for ironic to be running to ensure ironic-cert is created | ||
kubectl -n baremetal-operator-system wait --for=condition=available deployment/baremetal-operator-ironic --timeout=900s | ||
# Extract ironic-cert to be used inside fakeIPA for TLS | ||
kubectl get secret -n baremetal-operator-system ironic-cert -o json -o=jsonpath="{.data.ca\.crt}" | base64 -d > "${WORKING_DIR}/fake-ipa/ironic-ca.crt" | ||
fi | ||
|
||
# Create fake IPA custom config | ||
cat <<EOF > "${WORKING_DIR}/fake-ipa/config.py" | ||
FAKE_IPA_API_URL = "https://${CLUSTER_BARE_METAL_PROVISIONER_IP}:${IRONIC_API_PORT}" | ||
FAKE_IPA_INSPECTION_CALLBACK_URL = "${IRONIC_URL}/continue_inspection" | ||
FAKE_IPA_ADVERTISE_ADDRESS_IP = "${EXTERNAL_SUBNET_V4_HOST}" | ||
FAKE_IPA_INSECURE = ${FAKE_IPA_INSECURE:-False} | ||
FAKE_IPA_CAFILE = "${FAKE_IPA_CAFILE:-/root/cert/ironic-ca.crt}" | ||
FAKE_IPA_MIN_BOOT_TIME = ${FAKE_IPA_MIN_BOOT_TIME:-20} | ||
FAKE_IPA_MAX_BOOT_TIME = ${FAKE_IPA_MAX_BOOT_TIME:-30} | ||
EOF | ||
|
||
# shellcheck disable=SC2086 | ||
sudo "${CONTAINER_RUNTIME}" run -d --net host --name fake-ipa ${POD_NAME_INFRA} \ | ||
-v "/opt/metal3-dev-env/fake-ipa":/root/cert -v "/root/.ssh":/root/ssh \ | ||
-e CONFIG='/root/cert/config.py' \ | ||
"${FAKE_IPA_IMAGE}" | ||
} |
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,16 @@ | ||
<network> | ||
<name>baremetal-e2e</name> | ||
<forward mode='nat'> | ||
<nat> | ||
<port start='1024' end='65535'/> | ||
</nat> | ||
</forward> | ||
<bridge name='metal3'/> | ||
<ip address='192.168.222.1' netmask='255.255.255.0'> | ||
<dhcp> | ||
<range start='192.168.222.2' end='192.168.222.199'/> | ||
<host mac='52:54:00:6c:3c:01' name='minikube' ip='192.168.222.199'/> | ||
<bootp file='http://192.168.222.199:6180/boot.ipxe'/> | ||
</dhcp> | ||
</ip> | ||
</network> |
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,49 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
set -eux | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
MINIMUM_GO_VERSION=go1.22.4 | ||
|
||
# Ensure the go tool exists and is a viable version. | ||
# Ensure the go tool exists and is a viable version, or installs it | ||
verify_go_version() | ||
{ | ||
if [[ -z "$(command -v go)" ]]; then | ||
cat << EOF | ||
Can't find 'go' in PATH, please fix and retry. | ||
See http://golang.org/doc/install for installation instructions. | ||
EOF | ||
return 2 | ||
# If go is not available on the path, get it | ||
if ! [ -x "$(command -v go)" ]; then | ||
if [[ "${OSTYPE}" == "linux-gnu" ]]; then | ||
echo 'go not found, installing' | ||
curl -sLo "/tmp/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz" "https://go.dev/dl/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz" | ||
sudo tar -C /usr/local -xzf "/tmp/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz" | ||
export PATH=/usr/local/go/bin:$PATH | ||
else | ||
echo "Missing required binary in path: go" | ||
return 2 | ||
fi | ||
fi | ||
|
||
local go_version | ||
IFS=" " read -ra go_version <<< "$(go version)" | ||
local minimum_go_version | ||
minimum_go_version=go1.20 | ||
if [[ "${minimum_go_version}" != $(echo -e "${minimum_go_version}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]] && [[ "${go_version[2]}" != "devel" ]]; then | ||
if [[ "${MINIMUM_GO_VERSION}" != $(echo -e "${MINIMUM_GO_VERSION}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]] && [[ "${go_version[2]}" != "devel" ]]; then | ||
cat << EOF | ||
Detected go version: ${go_version[*]}. | ||
Kubernetes requires ${minimum_go_version} or greater. | ||
Please install ${minimum_go_version} or later. | ||
Detected go version: ${go_version[2]}. | ||
Requires ${MINIMUM_GO_VERSION} or greater. | ||
Please install ${MINIMUM_GO_VERSION} or later. | ||
EOF | ||
return 2 | ||
fi | ||
} | ||
|
||
verify_go_version | ||
|
||
# Explicitly opt into go modules, even though we're inside a GOPATH directory | ||
export GO111MODULE=on |
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,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eux | ||
|
||
USR_LOCAL_BIN="/usr/local/bin" | ||
MINIMUM_KUBECTL_VERSION=v1.32.0 | ||
|
||
# Ensure the kubectl tool exists and is a viable version, or installs it | ||
verify_kubectl_version() | ||
{ | ||
# If kubectl is not available on the path, get it | ||
if ! [ -x "$(command -v kubectl)" ]; then | ||
if [[ "${OSTYPE}" == "linux-gnu" ]]; then | ||
echo "kubectl not found, installing" | ||
curl -LO "https://dl.k8s.io/release/${MINIMUM_KUBECTL_VERSION}/bin/linux/amd64/kubectl" | ||
sudo install kubectl "${USR_LOCAL_BIN}/kubectl" | ||
else | ||
echo "Missing required binary in path: kubectl" | ||
return 2 | ||
fi | ||
fi | ||
|
||
local kubectl_version | ||
IFS=" " read -ra kubectl_version <<< "$(kubectl version --client)" | ||
if [[ "${MINIMUM_KUBECTL_VERSION}" != $(echo -e "${MINIMUM_KUBECTL_VERSION}\n${kubectl_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]]; then | ||
cat << EOF | ||
Detected kubectl version: ${kubectl_version[2]}. | ||
Requires ${MINIMUM_KUBECTL_VERSION} or greater. | ||
Please install ${MINIMUM_KUBECTL_VERSION} or later. | ||
EOF | ||
return 2 | ||
fi | ||
} | ||
|
||
verify_kubectl_version |
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,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
USR_LOCAL_BIN="/usr/local/bin" | ||
OS=$(go env GOOS) | ||
ARCH=$(go env GOARCH) | ||
MINIMUM_MINIKUBE_VERSION=v1.33.0 | ||
|
||
verify_minikube_version() { | ||
if ! [ -x "$(command -v minikube)" ]; then | ||
if [[ "${OSTYPE}" == "linux-gnu" ]]; then | ||
echo "minikube not found, installing" | ||
curl -LO "https://storage.googleapis.com/minikube/releases/${MINIMUM_MINIKUBE_VERSION}/minikube-${OS}-${ARCH}" | ||
sudo install minikube-linux-amd64 "${USR_LOCAL_BIN}/minikube" | ||
else | ||
echo "Missing required binary in path: minikube" | ||
return 2 | ||
fi | ||
fi | ||
local minikube_version | ||
minikube_version="$(minikube version --short)" | ||
if [[ "${MINIMUM_MINIKUBE_VERSION}" != $(echo -e "${MINIMUM_MINIKUBE_VERSION}\n${minikube_version}" | sort -V | head -n1) ]]; then | ||
cat << EOF | ||
Detected minikube version: ${minikube_version}. | ||
Requires ${MINIMUM_MINIKUBE_VERSION} or greater. | ||
Please install ${MINIMUM_MINIKUBE_VERSION} or later. | ||
EOF | ||
return 2 | ||
fi | ||
} | ||
|
||
verify_minikube_version |
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,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
USR_LOCAL_BIN="/usr/local/bin" | ||
YQ_VERSION="v4.40.5" | ||
|
||
# Check if yq tool is installed and install it if not | ||
verify_yq() | ||
{ | ||
if ! [[ -x "$(command -v yq)" ]]; then | ||
if [[ "${OSTYPE}" == "linux-gnu" ]]; then | ||
echo "yq not found, installing" | ||
curl -LO "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64.tar.gz" | ||
tar xvf yq_linux_amd64.tar.gz | ||
sudo install yq_linux_amd64 "${USR_LOCAL_BIN}/yq" | ||
else | ||
echo "Missing required binary in path: yq" | ||
return 2 | ||
fi | ||
fi | ||
} | ||
|
||
verify_yq |
Oops, something went wrong.