Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactor cluster allocation script to use latest Knative bits #2197

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions hack/allocate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

main() {

local knative_serving_version=v1.13.0
local knative_eventing_version=v1.13.0
local contour_version=v1.13.0
local knative_serving_version="v$(get_latest_release_version "knative" "serving")"
local knative_eventing_version="v$(get_latest_release_version "knative" "eventing")"
local contour_version="v$(get_latest_release_version "knative-extensions" "net-contour")"

# Kubernetes Version node image per Kind releases (full hash is suggested):
# https://github.com/kubernetes-sigs/kind/releases
Expand Down Expand Up @@ -56,6 +56,34 @@
echo "${em}DONE${me}"
}

# Returns whether the current branch is a release branch.
function is_release_branch() {
[[ $(current_branch) =~ ^release-[0-9\.]+$ ]]
}

# Retrieve latest version from given Knative repository tags
# On 'main' branch the latest released version is returned
# On 'release-x.y' branch the latest patch version for 'x.y.*' is returned
# Similar to hack/library.sh get_latest_knative_yaml_source()
function get_latest_release_version() {
local org_name="$1"
local repo_name="$2"
local major_minor=""
if is_release_branch; then
local branch_name
branch_name="$(current_branch)"
major_minor="${branch_name##release-}"
fi
local version
version="$(git ls-remote --tags --ref https://github.com/"${org_name}"/"${repo_name}".git \
| grep "${major_minor}" \
| cut -d '-' -f2 \
| cut -d 'v' -f2 \
| sort -Vr \
| head -n 1)"
echo "${version}"
}

kubernetes() {
echo "${em}① Kubernetes${me}"
cat <<EOF | kind create cluster --name=func --wait=60s --config=-
Expand Down Expand Up @@ -92,13 +120,14 @@

serving() {
echo "${em}② Knative Serving${me}"
echo "Version: ${knative_serving_version}"

kubectl apply --filename https://github.com/knative/serving/releases/download/knative-$knative_serving_version/serving-crds.yaml

Check failure on line 125 in hack/allocate.sh

View workflow job for this annotation

GitHub Actions / style / suggester / shell

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: hack/allocate.sh:125:- kubectl apply --filename https://github.com/knative/serving/releases/download/knative-$knative_serving_version/serving-crds.yaml hack/allocate.sh:125:+ kubectl apply --filename https://github.com/knative/serving/releases/download/knative-"$knative_serving_version"/serving-crds.yaml

sleep 5
kubectl wait --for=condition=Established --all crd --timeout=5m

curl -L -s https://github.com/knative/serving/releases/download/knative-$knative_serving_version/serving-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f -

Check failure on line 130 in hack/allocate.sh

View workflow job for this annotation

GitHub Actions / style / suggester / shell

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: hack/allocate.sh:130:- curl -L -s https://github.com/knative/serving/releases/download/knative-$knative_serving_version/serving-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f - hack/allocate.sh:130:+ curl -L -s https://github.com/knative/serving/releases/download/knative-"$knative_serving_version"/serving-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f -


sleep 5
Expand Down Expand Up @@ -129,6 +158,7 @@

networking() {
echo "${em}④ Contour Ingress${me}"
echo "Version: ${contour_version}"

echo "Install load balancer."
kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml"
Expand Down Expand Up @@ -181,24 +211,25 @@

eventing() {
echo "${em}⑤ Knative Eventing${me}"
echo "Version: ${knative_eventing_version}"

# CRDs
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/eventing-crds.yaml

Check failure on line 217 in hack/allocate.sh

View workflow job for this annotation

GitHub Actions / style / suggester / shell

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: hack/allocate.sh:217:- kubectl apply -f https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/eventing-crds.yaml hack/allocate.sh:217:+ kubectl apply -f https://github.com/knative/eventing/releases/download/knative-"$knative_eventing_version"/eventing-crds.yaml
sleep 5
kubectl wait --for=condition=Established --all crd --timeout=5m

# Core
curl -L -s https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/eventing-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f -

Check failure on line 222 in hack/allocate.sh

View workflow job for this annotation

GitHub Actions / style / suggester / shell

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: hack/allocate.sh:222:- curl -L -s https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/eventing-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f - hack/allocate.sh:222:+ curl -L -s https://github.com/knative/eventing/releases/download/knative-"$knative_eventing_version"/eventing-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f -
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n knative-eventing --timeout=5m

# Channel
curl -L -s https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/in-memory-channel.yaml | kubectl apply -f -

Check failure on line 227 in hack/allocate.sh

View workflow job for this annotation

GitHub Actions / style / suggester / shell

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: hack/allocate.sh:227:- curl -L -s https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/in-memory-channel.yaml | kubectl apply -f - hack/allocate.sh:227:+ curl -L -s https://github.com/knative/eventing/releases/download/knative-"$knative_eventing_version"/in-memory-channel.yaml | kubectl apply -f -
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n knative-eventing --timeout=5m

# Broker
curl -L -s https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/mt-channel-broker.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f -

Check failure on line 232 in hack/allocate.sh

View workflow job for this annotation

GitHub Actions / style / suggester / shell

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: hack/allocate.sh:232:- curl -L -s https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/mt-channel-broker.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f - hack/allocate.sh:232:+ curl -L -s https://github.com/knative/eventing/releases/download/knative-"$knative_eventing_version"/mt-channel-broker.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | yq | kubectl apply -f -
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n knative-eventing --timeout=5m

Expand Down
Loading