src: cleanup setup scripts (#2247)

The current binaries and allocation scrips are very CI-centric, this PR
takes a few steps to make them more friendly to running in a dev
environment; mainly centered around not polluting global scope (keeping
filesystem mutations in a relative local directory).

- binaries (and kind kubeconfig) are installed in ./hack/bin
- adds /hack/bin to .gitignore
- binary paths can be overridden via env vars FUNC_TEST_{name}
- binary fallback is system-installed (when binaries.sh not run)
- Cleanup of the UX, including colors and some shared helpers via
  library.sh
- Removes `yq` as the hack that required it appears to no longer be necessary.
- Adds some notes for Nix users
- Better error messaging when !linux
- Refactors the installers to pipe directly to tar rather than touch
  disk.
- begin to standardize on hyphens in filenames
This commit is contained in:
Luke Kingland 2024-04-02 08:29:03 +00:00 committed by GitHub
parent 31bebd1bfc
commit e4010db028
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 604 additions and 312 deletions

View File

@ -42,10 +42,14 @@ jobs:
test-integration:
runs-on: "ubuntu-latest"
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- name: Install Binaries
run: ./hack/binaries.sh
run: ./hack/install-binaries.sh
- name: Allocate Cluster
run: ./hack/allocate.sh
- name: Local Registry
@ -65,6 +69,10 @@ jobs:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- name: Install Binaries
@ -86,6 +94,10 @@ jobs:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- uses: imjasonh/setup-ko@v0.6
@ -96,9 +108,9 @@ jobs:
- name: Setup testing images
run: ./hack/setup-testing-images.sh
- name: Deploy Tekton
run: ./hack/tekton.sh
run: ./hack/install-tekton.sh
- name: Deploy Test Git Server
run: ./test/gitserver.sh
run: ./hack/install-git-server.sh
- name: E2E On Cluster Test
env:
E2E_RUNTIMES: ""

View File

@ -12,19 +12,23 @@ jobs:
func_builder: ["pack", "s2i"]
runs-on: ${{ matrix.os }}
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- uses: imjasonh/setup-ko@v0.6
- name: Install Binaries
run: ./hack/binaries.sh
run: ./hack/install-binaries.sh
- name: Allocate Cluster
run: ./hack/allocate.sh
- name: Setup testing images
run: ./hack/setup-testing-images.sh
- name: Deploy Tekton
run: ./hack/tekton.sh
run: ./hack/install-tekton.sh
- name: Deploy Test Git Server
run: ./test/gitserver.sh
run: ./hack/install-git-server.sh
- name: E2E On Cluster Test (Runtimes)
env:
TEST_TAGS: runtime

View File

@ -10,19 +10,23 @@ jobs:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- uses: imjasonh/setup-ko@v0.6
- name: Install Binaries
run: ./hack/binaries.sh
run: ./hack/install-binaries.sh
- name: Allocate Cluster
run: ./hack/allocate.sh
- name: Setup testing images
run: ./hack/setup-testing-images.sh
- name: Deploy Tekton
run: ./hack/tekton.sh
run: ./hack/install-tekton.sh
- name: Deploy Test Git Server
run: ./test/gitserver.sh
run: ./hack/install-git-server.sh
- name: E2E On Cluster Test
env:
E2E_RUNTIMES: ""

View File

@ -15,10 +15,14 @@ jobs:
runtime: ["node", "go", "python", "quarkus", "springboot", "typescript", "rust"]
runs-on: ubuntu-latest
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- name: Install Binaries
run: ./hack/binaries.sh
run: ./hack/install-binaries.sh
- name: Allocate Cluster
run: ./hack/allocate.sh
- name: Local Registry

View File

@ -10,10 +10,14 @@ jobs:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- name: Install Binaries
run: ./hack/binaries.sh
run: ./hack/install-binaries.sh
- name: Allocate Cluster
run: ./hack/allocate.sh
- name: Local Registry

View File

@ -10,11 +10,20 @@ jobs:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
echo "TEKTON_TESTS_ENABLED=1" >> "$GITHUB_ENV"
echo "GITLAB_TESTS_ENABLED=1" >> "$GITHUB_ENV"
echo "GITLAB_HOSTNAME=gitlab.127.0.0.1.sslip.io" >> "$GITHUB_ENV"
echo "GITLAB_ROOT_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32})" >> "$GITHUB_ENV"
echo "PAC_CONTROLLER_HOSTNAME=pac-ctr.127.0.0.1.sslip.io" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- uses: imjasonh/setup-ko@v0.6
- name: Install Binaries
run: ./hack/binaries.sh
run: ./hack/install-binaries.sh
- name: Local Registry
run: ./hack/registry.sh
- name: Allocate Cluster
@ -22,14 +31,7 @@ jobs:
- name: Setup testing images
run: ./hack/setup-testing-images.sh
- name: Install Tekton
run: ./hack/tekton.sh
- name: Set up environment variables
run: |
echo "TEKTON_TESTS_ENABLED=1" >> "$GITHUB_ENV"
echo "GITLAB_TESTS_ENABLED=1" >> "$GITHUB_ENV"
echo "GITLAB_HOSTNAME=gitlab.127.0.0.1.sslip.io" >> "$GITHUB_ENV"
echo "GITLAB_ROOT_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32})" >> "$GITHUB_ENV"
echo "PAC_CONTROLLER_HOSTNAME=pac-ctr.127.0.0.1.sslip.io" >> "$GITHUB_ENV"
run: ./hack/install-tekton.sh
- name: Install Pipelines as Code
run: ./hack/install-pac.sh
- name: Install Gitlab

View File

@ -10,6 +10,10 @@ jobs:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Set Environment Variables
run: |
echo "KUBECONFIG=${{ github.workspace }}/hack/bin/kubeconfig.yaml" >> "$GITHUB_ENV"
echo "PATH=${{ github.workspace }}/hack/bin:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: ./.github/composite/go-setup
- name: Install Podman
@ -28,7 +32,7 @@ jobs:
sudo apt-get -qq -y install podman
podman info
- name: Install Binaries
run: ./hack/binaries.sh
run: ./hack/install-binaries.sh
- name: Allocate Cluster
run: ./hack/allocate.sh
- name: Local Registry

1
.gitignore vendored
View File

@ -10,6 +10,7 @@
/.coverage
/bin
/target
/hack/bin
# Nodejs
node_modules

View File

@ -20,28 +20,33 @@ set -o errexit
set -o nounset
set -o pipefail
CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker}
export TERM="${TERM:-dumb}"
source "$(dirname "$(realpath "$0")")/common.sh"
set_versions() {
# Note: Kubernetes Version node image per Kind releases (full hash is suggested):
# https://github.com/kubernetes-sigs/kind/releases
kind_node_version=v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245
knative_serving_version="v$(get_latest_release_version "knative" "serving")"
knative_eventing_version="v$(get_latest_release_version "knative" "eventing")"
contour_version="v$(get_latest_release_version "knative-extensions" "net-contour")"
}
main() {
echo "${blue}Allocating${reset}"
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
local kind_node_version=v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245
# shellcheck disable=SC2155
local em=$(tput bold)$(tput setaf 2)
# shellcheck disable=SC2155
local me=$(tput sgr0)
echo "${em}Allocating...${me}"
set_versions
kubernetes
loadbalancer
echo "${blue}Beginning Cluster Configuration${reset}"
echo "Tasks will be executed in parallel. Logs will be prefixed:"
echo "svr: Serving, DNS and Networking"
echo "evt: Eventing and Namespace"
echo "reg: Local Registry"
echo "dpr: Dapr Runtime"
echo ""
( set -o pipefail; (serving && dns && networking) 2>&1 | sed -e 's/^/svr /')&
( set -o pipefail; (eventing && namespace) 2>&1 | sed -e 's/^/evt /')&
( set -o pipefail; registry 2>&1 | sed -e 's/^/reg /') &
@ -54,24 +59,7 @@ main() {
next_steps
echo "${em}DONE${me}"
}
# Returns the current branch.
# Taken from knative/hack. The function covers Knative CI use cases and local variant.
function current_branch() {
local branch_name=""
# Get the branch name from Prow's env var, see https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md.
# Otherwise, try getting the current branch from git.
(( IS_PROW )) && branch_name="${PULL_BASE_REF:-}"
[[ -z "${branch_name}" ]] && branch_name="${GITHUB_BASE_REF:-}"
[[ -z "${branch_name}" ]] && branch_name="$(git rev-parse --abbrev-ref HEAD)"
echo "${branch_name}"
}
# Returns whether the current branch is a release branch.
function is_release_branch() {
[[ $(current_branch) =~ ^release-[0-9\.]+$ ]]
echo -e "\n${green}🎉 DONE${reset}\n"
}
# Retrieve latest version from given Knative repository tags
@ -97,9 +85,25 @@ function get_latest_release_version() {
echo "${version}"
}
# Returns whether the current branch is a release branch.
function is_release_branch() {
[[ $(current_branch) =~ ^release-[0-9\.]+$ ]]
}
# Returns the current branch.
# Taken from knative/hack. The function covers Knative CI use cases and local variant.
function current_branch() {
local branch_name=""
# Get the branch name from Prow's env var, see https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md.
# Otherwise, try getting the current branch from git.
(( ${IS_PROW:-} )) && branch_name="${PULL_BASE_REF:-}"
[[ -z "${branch_name}" ]] && branch_name="${GITHUB_BASE_REF:-}"
[[ -z "${branch_name}" ]] && branch_name="$(git rev-parse --abbrev-ref HEAD)"
echo "${branch_name}"
}
kubernetes() {
echo "${em}① Kubernetes${me}"
cat <<EOF | kind create cluster --name=func --wait=60s --config=-
cat <<EOF | $KIND create cluster --name=func --kubeconfig="${KUBECONFIG}" --wait=60s --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
@ -127,34 +131,34 @@ containerdConfigPatches:
endpoint = ["http://func-registry:5000"]
EOF
sleep 10
kubectl wait pod --for=condition=Ready -l '!job-name' -n kube-system --timeout=5m
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n kube-system --timeout=5m
echo "${green}✅ Kubernetes${reset}"
}
serving() {
echo "${em}② Knative Serving${me}"
echo "${blue}Installing Serving${reset}"
echo "Version: ${knative_serving_version}"
kubectl apply --filename https://github.com/knative/serving/releases/download/knative-$knative_serving_version/serving-crds.yaml
$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
sleep 2
$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 -
curl -L -s https://github.com/knative/serving/releases/download/knative-$knative_serving_version/serving-core.yaml | $KUBECTL apply -f -
sleep 2
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n knative-serving --timeout=5m
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n knative-serving --timeout=5m
kubectl get pod -A
$KUBECTL get pod -A
echo "${green}✅ Knative Serving${reset}"
}
dns() {
echo "${em}③ DNS${me}"
echo "${blue}Configuring DNS${reset}"
i=0; n=10
while :; do
kubectl patch configmap/config-domain \
$KUBECTL patch configmap/config-domain \
--namespace knative-serving \
--type merge \
--patch '{"data":{"127.0.0.1.sslip.io":""}}' && break
@ -167,13 +171,14 @@ dns() {
echo 'Retrying...'
sleep 5
done
echo "${green}✅ DNS${reset}"
}
loadbalancer() {
echo "Install load balancer."
kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml"
echo "${blue}Installing Load Balancer (Metallb)${reset}"
$KUBECTL apply -f "https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml"
sleep 5
kubectl wait --namespace metallb-system \
$KUBECTL wait --namespace metallb-system \
--for=condition=ready pod \
--selector=app=metallb \
--timeout=300s
@ -182,7 +187,7 @@ loadbalancer() {
kind_addr="$($CONTAINER_ENGINE container inspect func-control-plane | jq '.[0].NetworkSettings.Networks.kind.IPAddress' -r)"
echo "Setting up address pool."
kubectl apply -f - <<EOF
$KUBECTL apply -f - <<EOF
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
@ -198,62 +203,65 @@ metadata:
name: empty
namespace: metallb-system
EOF
echo "${green}✅ Loadbalancer${reset}"
}
networking() {
echo "${em}④ Contour Ingress${me}"
echo "${blue}Installing Ingress Controller (Contour)${reset}"
echo "Version: ${contour_version}"
echo "Install a properly configured Contour."
kubectl apply -f "https://github.com/knative/net-contour/releases/download/knative-${contour_version}/contour.yaml"
echo "Installing a configured Contour."
$KUBECTL apply -f "https://github.com/knative/net-contour/releases/download/knative-${contour_version}/contour.yaml"
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n contour-external --timeout=10m
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n contour-external --timeout=10m
echo "Install the Knative Contour controller."
kubectl apply -f "https://github.com/knative/net-contour/releases/download/knative-${contour_version}/net-contour.yaml"
echo "Installing the Knative Contour controller."
$KUBECTL apply -f "https://github.com/knative/net-contour/releases/download/knative-${contour_version}/net-contour.yaml"
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n knative-serving --timeout=10m
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n knative-serving --timeout=10m
echo "Configure Knative Serving to use Contour."
kubectl patch configmap/config-network \
echo "Configuring Knative Serving to use Contour."
$KUBECTL patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress-class":"contour.ingress.networking.knative.dev"}}'
kubectl wait pod --for=condition=Ready -l '!job-name' -n contour-external --timeout=10m
kubectl wait pod --for=condition=Ready -l '!job-name' -n knative-serving --timeout=10m
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n contour-external --timeout=10m
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n knative-serving --timeout=10m
echo "${green}✅ Ingress${reset}"
}
eventing() {
echo "${em}⑤ Knative Eventing${me}"
echo "${blue}Installing Eventing${reset}"
echo "Version: ${knative_eventing_version}"
# CRDs
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/eventing-crds.yaml
$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
$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 -
curl -L -s https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/eventing-core.yaml | $KUBECTL apply -f -
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n knative-eventing --timeout=5m
$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 -
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
$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 -
curl -L -s https://github.com/knative/eventing/releases/download/knative-$knative_eventing_version/mt-channel-broker.yaml | $KUBECTL apply -f -
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n knative-eventing --timeout=5m
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n knative-eventing --timeout=5m
echo "${green}✅ Eventing${reset}"
}
registry() {
# see https://kind.sigs.k8s.io/docs/user/local-registry/
echo "${em}⑥ Registry${me}"
echo "${blue}Creating Registry${reset}"
if [ "$CONTAINER_ENGINE" == "docker" ]; then
$CONTAINER_ENGINE run -d --restart=always -p "127.0.0.1:50000:5000" --name "func-registry" registry:2
$CONTAINER_ENGINE network connect "kind" "func-registry"
@ -261,7 +269,7 @@ registry() {
$CONTAINER_ENGINE run -d --restart=always -p "127.0.0.1:50000:5000" --net=kind --name "func-registry" registry:2
fi
kubectl apply -f - <<EOF
$KUBECTL apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
@ -275,7 +283,7 @@ EOF
# Make the registry available in cluster under registry.default.svc.cluster.local:5000.
# This is useful since for "*.local" registries HTTP (not HTTPS) is used by default by some applications.
kubectl apply -f - <<EOF
$KUBECTL apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
@ -285,16 +293,17 @@ spec:
type: ExternalName
externalName: func-registry
EOF
echo "${green}✅ Registry${reset}"
}
namespace() {
echo "${em}⑦ Configure Namespace${me}"
echo "${blue}Configuring Namespace \"func\"${reset}"
# Create Namespace
kubectl create namespace "func"
$KUBECTL create namespace "func"
# Default Broker
kubectl apply -f - <<EOF
$KUBECTL apply -f - <<EOF
apiVersion: eventing.knative.dev/v1
kind: broker
metadata:
@ -303,7 +312,7 @@ namespace() {
EOF
# Default Channel
kubectl apply -f - << EOF
$KUBECTL apply -f - << EOF
apiVersion: v1
kind: ConfigMap
metadata:
@ -316,7 +325,7 @@ data:
EOF
# Connect Default Broker->Channel
kubectl apply -f - << EOF
$KUBECTL apply -f - << EOF
apiVersion: v1
kind: ConfigMap
metadata:
@ -333,11 +342,12 @@ data:
namespace: knative-eventing
EOF
echo "${green}✅ Namespace${reset}"
}
dapr_runtime() {
echo "${em}⑦ Dapr${me}"
echo "Version:\\n$(dapr version)"
echo "${blue}Installing Dapr Runtime${reset}"
echo "Version:\\n$($DAPR version)"
local dapr_flags=""
if [ "${GITHUB_ACTIONS:-false}" = "true" ]; then
@ -346,7 +356,7 @@ dapr_runtime() {
# Install Dapr Runtime
# shellcheck disable=SC2086
dapr init ${dapr_flags} --kubernetes --wait
$DAPR init ${dapr_flags} --kubernetes --wait
# Enalble Redis Persistence and Pub/Sub
#
@ -358,14 +368,14 @@ dapr_runtime() {
# TODO: If the bitnami redis chart seems worth the effort, munge this command
# to only start a single instance rather than four.
# helm repo add bitnami https://charts.bitnami.com/bitnami
echo "${em}- Redis ${me}"
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install redis bitnami/redis --set image.tag=6.2
helm repo update
echo "${blue}- Redis ${reset}"
$HELM repo add bitnami https://charts.bitnami.com/bitnami
$HELM install redis bitnami/redis --set image.tag=6.2
$HELM repo update
# 2) Expose a Redis-backed Dapr State Storage component
echo "${em}- State Storage Component${me}"
kubectl apply -f - << EOF
echo "${blue}- State Storage Component${reset}"
$KUBECTL apply -f - << EOF
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
@ -384,8 +394,8 @@ spec:
EOF
# 3) Expose A Redis-backed Dapr Pub/Sub Component
echo "${em}- Pub/Sub Component${me}"
kubectl apply -f - << EOF
echo "${blue}- Pub/Sub Component${reset}"
$KUBECTL apply -f - << EOF
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
@ -403,17 +413,28 @@ spec:
key: redis-password
EOF
echo "${green}✅ Dapr Runtime${reset}"
}
next_steps() {
# shellcheck disable=SC2155
local red=$(tput bold)$(tput setaf 1)
echo "${em}Image Registry${me}"
echo "If not in CI (running ci.sh): "
echo " ${red}set registry as insecure${me} in the docker daemon config (/etc/docker/daemon.json on linux or ~/.docker/daemon.json on OSX):"
echo " { \"insecure-registries\": [ \"localhost:50000\" ] }"
echo -e ""
echo -e "${blue}Next Steps${reset}"
echo -e "${blue}----------${reset}"
echo -e ""
echo -e "${grey}REGISTRY"
echo -e "Before using the cluster for integration and E2E tests, please run \"${reset}registry.sh${grey}\" (Linux systems) which will configure podman or docker to communicate with the standalone container registry without TLS."
echo -e ""
echo -e "For other operating systems, or to do this manually, edit the docker daemon config (/etc/docker/daemon.json on linux and ~/.docker/daemon.json on OSX), add:"
echo -e "${reset}{ \"insecure-registries\": [ \"localhost:50000\" ] }"
echo -e ""
echo -e "${grey}For podman, edit /etc/container/registries.conf to include:"
echo -e "${reset}[[registry-insecure-local]]\nlocation = \"localhost:50000\"\ninsecure = true\n"
echo -e "${grey}The cluster and resources can be removed with \"${reset}delete.sh\""
echo -e ""
echo -e "${grey}KUBECONFIG"
echo -e "The kubeconfig for your test cluster has been saved to:${reset}"
echo -e "${KUBECONFIG}"
echo -e ""
}
main "$@"

View File

@ -1,93 +0,0 @@
#!/usr/bin/env bash
#
# Installs binaries on linux systems.
#
# Note that there are multiple 'yq's out there. The one we want is kislyuk/yq,
# which is a thin wrapper around jq.
set -o errexit
set -o nounset
set -o pipefail
export TERM="${TERM:-dumb}"
main() {
local kubectl_version=v1.29.2
local kind_version=v0.22.0
local dapr_version=v1.11.0
local helm_version=v3.12.0
local stern_version=1.25.0
local kn_version=v1.13.0
local em=$(tput bold)$(tput setaf 2)
local me=$(tput sgr0)
echo "${em}Fetching Binaries...${me}"
install_kubectl
install_kind
install_yq
install_dapr
install_helm
install_stern
install_kn
echo "${em}DONE${me}"
}
install_kubectl() {
echo 'Installing kubectl...'
curl -sSLO "https://storage.googleapis.com/kubernetes-release/release/$kubectl_version/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
kubectl version --client=true
}
install_kind() {
echo 'Installing kind...'
curl -sSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/$kind_version/kind-linux-amd64"
chmod +x kind
sudo mv kind /usr/local/bin/
kind version
}
install_yq() {
echo 'Installing yq...'
sudo pip3 install yq
yq --version
}
install_dapr() {
echo 'Installing dapr...'
curl -sSLo dapr.tgz "https://github.com/dapr/cli/releases/download/$dapr_version/dapr_linux_amd64.tar.gz"
tar -xvf dapr.tgz
chmod +x dapr
sudo mv dapr /usr/local/bin/
dapr version
}
install_helm() {
echo 'Installing helm (v3)...'
curl -sSLo helm.tgz "https://get.helm.sh/helm-$helm_version-linux-amd64.tar.gz"
tar -xvf helm.tgz
chmod +x linux-amd64/helm
sudo mv linux-amd64/helm /usr/local/bin/
helm version
}
install_stern() {
echo 'Installing stern...'
curl -sSL "https://github.com/stern/stern/releases/download/v${stern_version}/stern_${stern_version}_linux_amd64.tar.gz" | \
tar fxz - -C /usr/local/bin/ stern
stern -v
}
install_kn() {
echo 'Installing kn...'
curl -sSLo kn https://github.com/knative/client/releases/download/knative-${kn_version}/kn-linux-amd64
chmod +x kn && sudo mv kn /usr/local/bin/
kn version
}
main "$@"

93
hack/common.sh Normal file
View File

@ -0,0 +1,93 @@
#!/usr/bin/env bash
# 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
#
# https://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.
init() {
find_executables
populate_environment
define_colors
}
find_executables() {
KUBECTL=$(find_executable "kubectl")
KIND=$(find_executable "kind")
DAPR=$(find_executable "dapr")
HELM=$(find_executable "helm")
STERN=$(find_executable "stern")
KN=$(find_executable "kn")
JQ=$(find_executable "jq")
}
populate_environment() {
export ARCH="${ARCH:-amd64}"
export CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker}
export KUBECONFIG="${KUBECONFIG:-$(dirname "$(realpath "$0")")/bin/kubeconfig.yaml}"
export TERM="${TERM:-dumb}"
echo "KUBECONFIG=${KUBECONFIG}"
}
define_colors() {
# For some reason TERM=dumb results in the tput commands exiting 1. It must
# not support that terminal type. A reasonable fallback should be "xterm".
local TERM="$TERM"
if [[ -z "$TERM" || "$TERM" == "dumb" ]]; then
TERM="xterm" # Set TERM to a tput-friendly value when undefined or "dumb".
fi
# shellcheck disable=SC2155
red=$(tput bold)$(tput setaf 1)
# shellcheck disable=SC2155
green=$(tput bold)$(tput setaf 2)
# shellcheck disable=SC2155
blue=$(tput bold)$(tput setaf 4)
# shellcheck disable=SC2155
grey=$(tput bold)$(tput setaf 8)
# shellcheck disable=SC2155
yellow=$(tput bold)$(tput setaf 11)
# shellcheck disable=SC2155
reset=$(tput sgr0)
}
# find returns the path to an executable by name.
# An environment variable FUNC_TEST_$name takes precidence.
# Next is an executable matching the name in hack/bin/
# (the install location of hack/install-binaries.sh)
# Finally, a matching executable from the current PATH is used.
find_executable() {
local name="$1" # requested binary name
local path="" # the path to output
# Use the environment variable if defined
local env=$(echo "FUNC_TEST_$name" | awk '{print toupper($0)}')
local path="${!env:-}"
if [[ -x "$path" ]]; then
echo "$path" & return 0
fi
# Use the binary installed into hack/bin/ by allocate.sh if
# it exists.
path=$(dirname "$(realpath "$0")")"/bin/$name"
if [[ -x "$path" ]]; then
echo "$path" & return 0
fi
# Finally fallback to anything matchin in the current PATH
path=$(command -v "$name")
if [[ -x "$path" ]]; then
echo "$path" & return 0
fi
echo "Error: ${name} not found." >&2
return 1
}
init "$@"

View File

@ -3,19 +3,12 @@
# Suitable for use locally during development.
# CI/CD uses the very similar knative-kind action
set -o errexit
set -o nounset
set -o pipefail
source "$(dirname "$(realpath "$0")")/common.sh"
export TERM="${TERM:-dumb}"
delete_resources() {
echo "${blue}Deleting Cluster and Registry${reset}"
main() {
local green=$(tput bold)$(tput setaf 2)
local red=$(tput bold)$(tput setaf 2)
local reset=$(tput sgr0)
echo "${green}Deleting Cluster and Registry${reset}"
kind delete cluster --name "func"
$KIND delete cluster --name=func --kubeconfig="${KUBECONFIG}"
docker stop func-registry && docker rm func-registry
echo "${red}NOTE:${reset} The following changes have not been undone:"
echo " - Config setting registry localhost:50000 (func-registry) as insecure"
@ -23,4 +16,13 @@ main() {
echo "${green}DONE${reset}"
}
main
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
set -o errexit
set -o nounset
set -o pipefail
function main() {
delete_resources
}
main "$@"
fi

132
hack/install-binaries.sh Executable file
View File

@ -0,0 +1,132 @@
#//usr/bin/env bash
# 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
#
# https://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.
#
# Installs binaries on linux systems.
#
source "$(dirname "$(realpath "$0")")/common.sh"
install_binaries() {
assert_linux
warn_architecture
local root="$(dirname "$(realpath "$0")")"
local bin="${root}/bin"
local kubectl_version=1.29.2
local kind_version=0.22.0
local dapr_version=1.11.0
local helm_version=3.12.0
local stern_version=1.25.0
local kn_version=1.13.0
local jq_version=1.7.1
echo "${blue}Installing binaries${reset}"
echo " Architecture: ${ARCH}"
echo " Destination: ${bin}"
mkdir -p "${bin}"
install_kubectl
install_kind
install_dapr
install_helm
install_stern
install_kn
install_jq
echo "${green}DONE${reset}"
}
assert_linux() {
os_name=$(uname -s)
if [ "$os_name" != "Linux" ]; then
echo "${yellow}----------------------------------------------------------------------${reset}"
echo "${yellow}This script currently only supports Linux${reset}"
echo "Please install the dependencies manually"
echo "${yellow}----------------------------------------------------------------------${reset}"
exit 1
fi
}
warn_architecture() {
arch=$(uname -m)
if [ "$arch" != "x86_64" ]; then
echo -e "${yellow}Detected untested architecture ${arch}.${reset}\n This script is only tested with amd64, but you can use the ARCH env variable to specify an architecture to be interpolated in download links."
fi
}
install_kubectl() {
echo '=== kubectl'
curl -sSLo "${bin}"/kubectl "https://storage.googleapis.com/kubernetes-release/release/v$kubectl_version/bin/linux/${ARCH}/kubectl"
chmod +x "${bin}"/kubectl
"${bin}"/kubectl version --client=true
}
install_kind() {
echo '=== kind'
curl -sSLo "${bin}"/kind "https://github.com/kubernetes-sigs/kind/releases/download/v$kind_version/kind-linux-${ARCH}"
chmod +x "${bin}"/kind
"${bin}"/kind version
}
install_dapr() {
echo '=== dapr'
curl -sSL "https://github.com/dapr/cli/releases/download/v$dapr_version/dapr_linux_${ARCH}.tar.gz" | \
tar fxz - -C "${bin}" dapr
"${bin}"/dapr version
}
install_helm() {
echo '=== helm'
curl -sSL "https://get.helm.sh/helm-v$helm_version-linux-${ARCH}.tar.gz" | \
tar fxz - -C "${bin}" linux-"${ARCH}"/helm
mv "${bin}/linux-${ARCH}"/helm "${bin}" && rmdir "${bin}/linux-${ARCH}"
"${bin}"/helm version
}
install_stern() {
echo '=== stern'
curl -sSL "https://github.com/stern/stern/releases/download/v${stern_version}/stern_${stern_version}_linux_${ARCH}.tar.gz" | \
tar fxz - -C "${bin}" stern
"${bin}"/stern -v
}
install_kn() {
echo '=== kn'
curl -sSLo "${bin}"/kn "https://github.com/knative/client/releases/download/knative-v${kn_version}/kn-linux-${ARCH}"
chmod +x "${bin}"/kn
"${bin}"/kn version
}
install_jq() {
echo '=== jq'
# "https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64"
curl -sSLo "${bin}"/jq "https://github.com/jqlang/jq/releases/download/jq-${jq_version}/jq-linux-${ARCH}"
chmod +x "${bin}"/jq
"${bin}"/jq --version
}
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
set -o errexit
set -o nounset
set -o pipefail
function main() {
install_binaries
}
main "$@"
fi

View File

@ -1,9 +1,29 @@
#!/usr/bin/env bash
# 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
#
# https://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.
#
# Install GitLab
#
source "$(dirname "$(realpath "$0")")/common.sh"
function install_gitlab() {
echo "${blue}Installing GitLab${reset}"
local -r gitlab_host="${GITLAB_HOSTNAME:-gitlab.127.0.0.1.sslip.io}"
kubectl apply -f - <<EOF
$KUBECTL apply -f - <<EOF
kind: Namespace
apiVersion: v1
metadata:
@ -146,19 +166,22 @@ spec:
EOF
sleep 1
kubectl wait pod --for=condition=Ready -l '!job-name' -n gitlab --timeout=5m
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n gitlab --timeout=5m
echo '::group::Waiting for Gitlab'
if ! curl --retry 120 -f --retry-all-errors --retry-delay 5 "${gitlab_host}"; then
kubectl logs pod/gitlab -n gitlab
$KUBECTL logs pod/gitlab -n gitlab
echo '::endgroup::'
return 1
fi
echo
echo '::endgroup::'
echo "the GitLab server is available at: http://${gitlab_host}"
echo "${green}✅ GitLab${reset}"
}
# Invoke only when run directly
# Be a library when sourced
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
set -o errexit
set -o nounset

View File

@ -1,16 +1,36 @@
#!/usr/bin/env bash
# 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
#
# https://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.
#
# Installs the Pipelines-as-code controller
#
source "$(dirname "$(realpath "$0")")/common.sh"
function install_pac() {
echo "${blue}Installing the Pipelines-as-Code Controller${reset}"
local -r pac_ctr_host="${PAC_CONTROLLER_HOSTNAME:-pac-ctr.127.0.0.1.sslip.io}"
local -r pac_version="v0.17.1"
# Install Pipelines as Code
kubectl apply -f "https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/release-${pac_version}/release.k8s.yaml"
$KUBECTL apply -f "https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/release-${pac_version}/release.k8s.yaml"
sleep 5
kubectl wait pod --for=condition=Ready -l '!job-name' -n pipelines-as-code --timeout=5m
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n pipelines-as-code --timeout=5m
# Install ingress for the PaC controller. This is used by VCS Webhooks.
kubectl apply -f - << EOF
$KUBECTL apply -f - << EOF
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
@ -31,6 +51,7 @@ spec:
path: /
EOF
echo "the Pipeline as Code controller is available at: http://${pac_ctr_host}"
echo "${green}✅ PAC${reset}"
}
if [ "$0" = "${BASH_SOURCE[0]}" ]; then

49
hack/install-tekton.sh Executable file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
# 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
#
# https://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.
#
# Install Tekton and required tasks in the cluster
#
source "$(dirname "$(realpath "$0")")/common.sh"
install_tekton() {
echo "${blue}Installing Tekton${reset}"
tekton_release="previous/v0.49.0"
namespace="${NAMESPACE:-default}"
$KUBECTL apply -f "https://storage.googleapis.com/tekton-releases/pipeline/${tekton_release}/release.yaml"
sleep 10
$KUBECTL wait pod --for=condition=Ready --timeout=180s -n tekton-pipelines -l "app=tekton-pipelines-controller"
$KUBECTL wait pod --for=condition=Ready --timeout=180s -n tekton-pipelines -l "app=tekton-pipelines-webhook"
sleep 10
$KUBECTL create clusterrolebinding "${namespace}:knative-serving-namespaced-admin" --clusterrole=knative-serving-namespaced-admin --serviceaccount="${namespace}:default"
echo "${green}✅ Tekton${reset}"
}
# Invoke only when run directly
# Be a library when sourced
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
set -o errexit
set -o nounset
set -o pipefail
function main() {
install_tekton
}
main "$@"
fi

View File

@ -1,13 +1,31 @@
#!/usr/bin/env bash
# This script creates a DNS A records for '127.0.0.1.sslip.io' and '*.127.0.0.1.sslip.io' pointing to the cluster node.
# 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
#
# https://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.
#
# Create DNS A records for '127.0.0.1.sslip.io' and '*.127.0.0.1.sslip.io' pointing to the cluster node.
#
source "$(dirname "$(realpath "$0")")/common.sh"
function patch_hosts() {
echo "${blue}Configuring Magic DNS${reset}"
local cluster_node_addr
cluster_node_addr="$(docker container inspect func-control-plane | jq ".[0].NetworkSettings.Networks.kind.IPAddress" -r)"
kubectl patch cm/coredns -n kube-system --patch-file /dev/stdin <<EOF
$KUBECTL patch cm/coredns -n kube-system --patch-file /dev/stdin <<EOF
{
"data": {
"Corefile": ".:53 {\n errors\n health {\n lameduck 5s\n }\n ready\n kubernetes cluster.local in-addr.arpa ip6.arpa {\n pods insecure\n fallthrough in-addr.arpa ip6.arpa\n ttl 30\n }\n file /etc/coredns/example.db 127.0.0.1.sslip.io\n prometheus :9153\n forward . /etc/resolv.conf {\n max_concurrent 1000\n }\n cache 30\n loop\n reload\n loadbalance\n}\n",
@ -16,7 +34,7 @@ function patch_hosts() {
}
EOF
kubectl patch deploy/coredns -n kube-system --patch-file /dev/stdin <<EOF
$KUBECTL patch deploy/coredns -n kube-system --patch-file /dev/stdin <<EOF
{
"spec": {
"template": {
@ -53,7 +71,9 @@ EOF
}
EOF
sleep 1
kubectl wait pod --for=condition=Ready -l '!job-name' -n kube-system --timeout=15s
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n kube-system --timeout=15s
echo "${green}✅ Magic DNS${reset}"
}
if [ "$0" = "${BASH_SOURCE[0]}" ]; then

View File

@ -1,5 +1,17 @@
#!/usr/bin/env bash
# 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
#
# https://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.
#
# - Registers registry with Docker as trusted (linux only)
#
@ -8,15 +20,12 @@ set -o errexit
set -o nounset
set -o pipefail
CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker}
export TERM="${TERM:-dumb}"
source "$(dirname "$(realpath "$0")")/common.sh"
main() {
local em=$(tput bold)$(tput setaf 2)
local me=$(tput sgr0)
echo "${em}Configuring for CI...${me}"
registry() {
echo "${blue}Enabling Insecure Local Registry${reset}"
warn_nix
# Check the value of CONTAINER_ENGINE
echo 'Setting registry as trusted local-only'
@ -26,8 +35,25 @@ main() {
set_registry_insecure_podman
fi
echo "${em}DONE${me}"
echo "${green}✅ Registry${reset}"
}
warn_nix() {
if [[ -x $(command -v "nix") || -x $(command -v "nixos-rebuild") ]]; then
if [ "$CONTAINER_ENGINE" == "docker" ]; then
echo "${yellow}Warning: Nix detected${reset}"
echo "If Docker was configured using nix, this command will fail to find daemon.json. please configure the insecure registry by modifying your nix config:"
echo " virtualisation.docker = {"
echo " enable = true;"
echo " daemon.settings.insecure-registries = [ \"localhost:50000\" ];"
echo " };"
elif [ "$CONTAINER_ENGINE" == "podman" ]; then
echo "${yellow}Warning: Nix detected${reset}"
echo "If podman was configured via Nix, this command will likely fail. At time of this writing, podman configured via the nix option 'virtualisation.podman' does not have an option for configuring insecure registries."
echo "The configuration required is adding the following to registries.conf:"
echo -e " [[registry-insecure-local]]\n location = \"localhost:50000\"\n insecure = true"
fi
fi
}
set_registry_insecure() {
@ -46,5 +72,13 @@ set_registry_insecure_podman() {
fi
}
main "$@"
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
set -o errexit
set -o nounset
set -o pipefail
function main() {
registry
}
main "$@"
fi

View File

@ -1,42 +0,0 @@
#!/usr/bin/env bash
# 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
#
# https://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.
#
# Install Tekton and required tasks in the cluster
#
set -o errexit
set -o nounset
set -o pipefail
export TERM="${TERM:-dumb}"
tekton_release="previous/v0.49.0"
namespace="${NAMESPACE:-default}"
tekton() {
echo "Installing Tekton..."
kubectl apply -f "https://storage.googleapis.com/tekton-releases/pipeline/${tekton_release}/release.yaml"
sleep 10
kubectl wait pod --for=condition=Ready --timeout=180s -n tekton-pipelines -l "app=tekton-pipelines-controller"
kubectl wait pod --for=condition=Ready --timeout=180s -n tekton-pipelines -l "app=tekton-pipelines-webhook"
sleep 10
kubectl create clusterrolebinding "${namespace}:knative-serving-namespaced-admin" \
--clusterrole=knative-serving-namespaced-admin --serviceaccount="${namespace}:default"
}
tekton
echo Done

View File

@ -5,21 +5,10 @@
# invoking an http echoing server.
#
set -o errexit
set -o nounset
set -o pipefail
source "$(dirname "$(realpath "$0")")/common.sh"
export TERM="${TERM:-dumb}"
main() {
echo "TERM: $TERM"
local em=$(tput bold)$(tput setaf 2)
local me=$(tput sgr0)
# Drop some debug in the event even the above excessive wait does not work.
echo "${em}Testing...${me}"
echo "${em} Creating echo server${me}"
echo_test() {
echo "${blue}Testing Cluster via Echo Service${reset}"
i=0; n=10
while :; do
@ -50,16 +39,24 @@ EOF
sleep 60
# Wait for the test to become available
echo "${em} Waiting for echo route${me}"
echo "${blue}Waiting for echo route${reset}"
kubectl wait --for=condition=Ready route echo -n func --timeout=600s
echo "${em} Invoking echo server${me}"
echo "${blue}Invoking echo server${reset}"
curl http://echo.func.127.0.0.1.sslip.io/
echo "${em}DONE${me}"
echo "${green}✅ Echo succeeded${reset}"
}
main "$@"
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
set -o errexit
set -o nounset
set -o pipefail
function main() {
echo_test
}
main "$@"
fi

View File

@ -36,7 +36,7 @@ import (
// such as that which is setup and configured in CI (see .github/workflows).
// Linux developers can set up the cluster via:
//
// ./hack/binaries.sh && ./hack/allocate.sh && ./hack/registry.sh
// ./hack/install-binaries.sh && ./hack/allocate.sh && ./hack/registry.sh
//
// ## Cluster Cleanup
//

View File

@ -29,12 +29,12 @@ a Kubernetes Cluster with the following deployed:
For your convenience you can run the following script to setup Tekton and required Tasks:
```
$ ./hack/tekton.sh
$ ./hack/install-tekton.sh
```
To install the Git Server required by tests, run:
```
$ ./gitserver.sh
$ ./hack/install-git-server.sh
```
#### Running all the Tests on KinD
@ -43,8 +43,8 @@ The below instructions will run all the tests on KinD using an **ephemeral** con
```
# Pre-Reqs
./hack/allocate.sh
./hack/tekton.sh
./test/gitserver.sh
./hack/install-tekton.sh
./hack/install-git-server.sh
make build
# Run tests