Skip to content

Commit

Permalink
added kind setup
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed Mar 20, 2024
1 parent 970138d commit ec21646
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
14 changes: 8 additions & 6 deletions .buildkite/deploy/kubernetes/deploy-k8s-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
env:
IMAGE_UBUNTU_X86_64: "family/platform-ingest-beats-ubuntu-2204"
GCP_HI_PERF_MACHINE_TYPE: "c2d-highcpu-16"
KIND_VERSION: "v0.20.0"
K8S_VERSION": "v1.29.0"
KUBECONFIG: "${WORKSPACE}/kubecfg"

steps:
- label: "Checks"
command: ".buildkite/deploy/kubernetes/scripts/make.sh"
# if: build.env("BUILDKITE_PULL_REQUEST") != "false" && build.env("GITHUB_PR_LABELS") == "kubernetes"
if: build.env("BUILDKITE_PULL_REQUEST") != "false" && build.env("GITHUB_PR_LABELS") == "kubernetes"
notify:
- github_commit_status:
context: "Deploy K8S/Checks"
Expand All @@ -20,11 +18,15 @@ steps:
machineType: "${GCP_HI_PERF_MACHINE_TYPE}"

- label: "K8S Test"
key: "k8s-test"
env:
k8sTest: "v1.29.0,v1.28.0,v1.27.3,v1.26.6"
command:
- ".buildkite/deploy/kubernetes/scripts/setup-k8s-env.sh"
- "MODULE=kubernetes make -C metricbeat integration-tests"
command: ".buildkite/deploy/kubernetes/scripts/setup-k8s-env.sh"
# - "MODULE=kubernetes make -C metricbeat integration-tests"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MACHINE_TYPE}"


# setEnvVar('ONLY_DOCS', isGitRegionMatch(patterns: [ '(.*\\.(asciidoc|md)|deploy/kubernetes/.*-kubernetes\\.yaml)' ], shouldMatchAll: true).toString())
Expand Down
4 changes: 3 additions & 1 deletion .buildkite/deploy/kubernetes/scripts/install-kind.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euxo pipefail
set -euo pipefail

MSG="environment variable missing."
DEFAULT_HOME="/usr/local"
Expand All @@ -12,6 +12,8 @@ then
set +e
echo "--- Found Kind. Checking version.."
FOUND_KIND_VERSION=$(kind --version 2>&1 >/dev/null | awk '{print $3}')
echo "--- Kind version found: $FOUND_KIND_VERSION"
echo "--- Kind version required: $KIND_VERSION"
if [ "$FOUND_KIND_VERSION" == "$KIND_VERSION" ]
then
echo "--- Versions match. No need to install Kind. Exiting."
Expand Down
4 changes: 3 additions & 1 deletion .buildkite/deploy/kubernetes/scripts/install-kubectl.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euxo pipefail
set -euo pipefail

MSG="parameter missing."
DEFAULT_HOME="/usr/local"
Expand All @@ -12,6 +12,8 @@ then
set +e
echo "--- Found kubectl. Checking version.."
FOUND_KUBECTL_VERSION=$(kubectl version --client --short 2>&1 >/dev/null | awk '{print $3}')
echo "--- Kubectl version found: $(kubectl version --client --short 2>&1 >/dev/null)"
echo "--- Kubectl version required: $K8S_VERSION"
if [ "${FOUND_KUBECTL_VERSION}" == "${K8S_VERSION}" ]
then
echo "--- Versions match. No need to install kubectl. Exiting."
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/deploy/kubernetes/scripts/kind-setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
set -euxo pipefail

echo "--- Creating cluster"
kind create cluster --image kindest/node:${K8S_VERSION}
/usr/local/bin/kind create cluster --image kindest/node:${K8S_VERSION}
kubectl cluster-info
7 changes: 4 additions & 3 deletions .buildkite/deploy/kubernetes/scripts/setup-k8s-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -euo pipefail

source .buildkite/env-scripts/util.sh

echo "--- Installing kind"
retry_with_count .buildkite/deploy/kubernetes/scripts/install-kind.sh
retry_with_count .buildkite/deploy/kubernetes/scripts/install-kubectl.sh
echo "--- Installing kind & kubectl"
retry_with_count 5 .buildkite/deploy/kubernetes/scripts/install-kubectl.sh
retry_with_count 5 .buildkite/deploy/kubernetes/scripts/install-kind.sh

echo "--- Setting up kind"
max_retries=3
Expand All @@ -15,6 +15,7 @@ retries=0

while true; do
script_output=$(.buildkite/deploy/kubernetes/scripts/kind-setup.sh 2>&1)
echo "--- $script_output"
exit_code=$?

if [ $exit_code -eq 0 ]; then
Expand Down
6 changes: 6 additions & 0 deletions .buildkite/env-scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ ONLY_DOCS=$(changeset_applies "$DOCS_CHANGESET")
PACKAGING_CHANGES=$(changeset_applies "$PACKAGING_CHANGESET")
GO_MOD_CHANGES=$(changeset_applies "^go.mod")

KIND_VERSION="v0.20.0"
K8S_VERSION="v1.29.0"

export REPO
export WORKSPACE
export BIN
Expand All @@ -53,3 +56,6 @@ export KUBECONFIG
export ONLY_DOCS
export PACKAGING_CHANGES
export GO_MOD_CHANGES

export KIND_VERSION
export K8S_VERSION

0 comments on commit ec21646

Please sign in to comment.