Skip to content

Commit

Permalink
Merge pull request knative#166 from navidshaikh/pr/updates-ci-setup
Browse files Browse the repository at this point in the history
Updates OpenShift CI setup script
  • Loading branch information
openshift-merge-robot authored Nov 12, 2019
2 parents b9c7929 + 57435a2 commit f91ea43
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 123 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ FROM rhel8/go-toolset:1.12.8 AS builder
WORKDIR /opt/app-root/src/go/src/github.com/knative/client
USER root
COPY . .
RUN TAG="v0.8.0" make build
RUN TAG="v0.10.0" make build

FROM ubi8:8-released
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn /usr/bin/kn
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn /ko-app/kn

LABEL \
com.redhat.component="openshift-serverless-1-tech-preview-client-kn-rhel8-container" \
name="openshift-serverless-1-tech-preview/client-kn-rhel8" \
version="0.8.0" \
version="0.10.0" \
summary="Red Hat OpenShift Serverless 1 kn CLI" \
description="CLI client 'kn' for managing Red Hat OpenShift Serverless 1" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 kn CLI" \
io.k8s.description="CLI client 'kn' for managing Red Hat OpenShift Serverless 1" \
io.openshift.build.source-location="https://github.com/openshift/knative-client" \
maintainer="nshaikh@redhat.com"
maintainer="serverless-support@redhat.com"

ENTRYPOINT ["/usr/bin/kn"]
ENTRYPOINT ["/ko-app/kn"]
136 changes: 18 additions & 118 deletions openshift/e2e-tests-openshift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/e2e-tests.sh

set -x

readonly SERVING_RELEASE="release-v0.8.1"
readonly KN_DEFAULT_TEST_IMAGE="gcr.io/knative-samples/helloworld-go"
readonly SERVING_NAMESPACE="knative-serving"
readonly SERVICEMESH_NAMESPACE="istio-system"
readonly SERVICEMESH_NAMESPACE="knative-serving-ingress"
readonly E2E_TIMEOUT="60m"
readonly E2E_PARALLEL="1"
readonly CS_NS="openshift-marketplace"
readonly OPERATOR_NS="openshift-operators"
readonly OLM_NAMESPACE="openshift-marketplace"
env

function scale_up_workers(){
Expand Down Expand Up @@ -78,43 +76,6 @@ function wait_until_hostname_resolves() {
return 1
}

# Waits until the given hostname resolves via DNS
# Parameters: $1 - hostname
function wait_until_hostname_resolves() {
echo -n "Waiting until hostname $1 resolves via DNS"
for i in {1..150}; do # timeout after 15 minutes
local output="$(host -t a $1 | grep 'has address')"
if [[ -n "${output}" ]]; then
echo -e "\n${output}"
return 0
fi
echo -n "."
sleep 6
done
echo -e "\n\nERROR: timeout waiting for hostname $1 to resolve via DNS"
return 1
}

# Waits until the configmap in the given namespace contains the
# desired content.
# Parameters: $1 - namespace
# $2 - configmap name
# $3 - desired content
function wait_until_configmap_contains() {
echo -n "Waiting until configmap $1/$2 contains '$3'"
for _ in {1..180}; do # timeout after 3 minutes
local output="$(oc -n "$1" get cm "$2" -oyaml | grep "$3")"
if [[ -n "${output}" ]]; then
echo -e "\n${output}"
return 0
fi
echo -n "."
sleep 1
done
echo -e "\n\nERROR: timeout waiting for configmap $1/$2 to contain '$3'"
return 1
}

# Loops until duration (car) is exceeded or command (cdr) returns non-zero
function timeout() {
SECONDS=0; TIMEOUT=$1; shift
Expand All @@ -125,49 +86,6 @@ function timeout() {
return 0
}

function install_servicemesh(){
header "Installing ServiceMesh"

# Install the ServiceMesh Operator
oc apply -f https://raw.githubusercontent.com/openshift/knative-serving/$SERVING_RELEASE/openshift/servicemesh/operator-install.yaml

# Wait for the istio-operator pod to appear
timeout 900 '[[ $(oc get pods -n openshift-operators | grep -c istio-operator) -eq 0 ]]' || return 1

# Wait until the Operator pod is up and running
wait_until_pods_running openshift-operators || return 1

# Deploy ServiceMesh
oc new-project $SERVICEMESH_NAMESPACE
oc apply -n $SERVICEMESH_NAMESPACE -f https://raw.githubusercontent.com/openshift/knative-serving/$SERVING_RELEASE/openshift/servicemesh/controlplane-install.yaml
cat <<EOF | oc apply -f -
apiVersion: maistra.io/v1
kind: ServiceMeshMemberRoll
metadata:
name: default
namespace: ${SERVICEMESH_NAMESPACE}
spec:
members:
- ${SERVING_NAMESPACE}
- kne2etests0
- kne2etests1
- kne2etests2
- kne2etests3
- kne2etests4
- kne2etests5
EOF

# Wait for the ingressgateway pod to appear.
timeout 900 '[[ $(oc get pods -n $SERVICEMESH_NAMESPACE | grep -c istio-ingressgateway) -eq 0 ]]' || return 1

wait_until_service_has_external_ip $SERVICEMESH_NAMESPACE istio-ingressgateway || fail_test "Ingress has no external IP"
wait_until_hostname_resolves "$(kubectl get svc -n $SERVICEMESH_NAMESPACE istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"

wait_until_pods_running $SERVICEMESH_NAMESPACE

header "ServiceMesh installed successfully"
}

function install_knative_serving(){
header "Installing Knative serving"

Expand All @@ -176,9 +94,6 @@ function install_knative_serving(){
# Deploy Serverless Operator
deploy_serverless_operator

# Wait for the CRD to appear
timeout 900 '[[ $(oc get crd | grep -c knativeservings) -eq 0 ]]' || return 1

# Install Knative Serving
cat <<-EOF | oc apply -f -
apiVersion: serving.knative.dev/v1alpha1
Expand All @@ -188,42 +103,42 @@ metadata:
namespace: ${SERVING_NAMESPACE}
EOF

# Wait for 6 pods to appear first
timeout 900 '[[ $(oc get pods -n $SERVING_NAMESPACE --no-headers | wc -l) -lt 6 ]]' || return
# Wait for 4 pods to appear first
timeout 900 '[[ $(oc get pods -n $SERVING_NAMESPACE --no-headers | wc -l) -lt 4 ]]' || return

wait_until_pods_running $SERVING_NAMESPACE || return 1

wait_until_service_has_external_ip $SERVICEMESH_NAMESPACE istio-ingressgateway || fail_test "Ingress has no external IP"

wait_until_hostname_resolves "$(kubectl get svc -n $SERVICEMESH_NAMESPACE istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"

header "Knative Serving installed successfully"
}

function deploy_serverless_operator(){
git clone https://github.com/openshift-knative/serverless-operator.git /tmp/serverless-operator
/tmp/serverless-operator/hack/catalog.sh | oc apply -n $CS_NS -f -
/tmp/serverless-operator/hack/catalog.sh | oc apply -n $OLM_NAMESPACE -f -

timeout 900 '[[ $(oc get pods -n $OLM_NAMESPACE | grep -c serverless) -eq 0 ]]' || ret

wait_until_pods_running $OLM_NAMESPACE

cat <<-EOF | kubectl apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: serverless-operator-sub
generateName: serverless-operator-
namespace: $OPERATOR_NS
namespace: openshift-operators
spec:
source: serverless-operator
sourceNamespace: $CS_NS
sourceNamespace: $OLM_NAMESPACE
name: serverless-operator
channel: techpreview
EOF
}

function enable_knative_interaction_with_registry() {
local configmap_name=config-service-ca
local cert_name=service-ca.crt
local mount_path=/var/run/secrets/kubernetes.io/servicecerts

oc -n $SERVING_NAMESPACE create configmap $configmap_name
oc -n $SERVING_NAMESPACE annotate configmap $configmap_name service.alpha.openshift.io/inject-cabundle="true"
wait_until_configmap_contains $SERVING_NAMESPACE $configmap_name $cert_name
oc -n $SERVING_NAMESPACE set volume deployment/controller --add --name=service-ca --configmap-name=$configmap_name --mount-path=$mount_path
oc -n $SERVING_NAMESPACE set env deployment/controller SSL_CERT_FILE=$mount_path/$cert_name
# Wait for the CRD to appear
timeout 900 '[[ $(oc get crd | grep -c knativeservings) -eq 0 ]]' || return 1
}

function build_knative_client() {
Expand Down Expand Up @@ -290,17 +205,6 @@ function delete_test_namespace(){
oc delete project --ignore-not-found=true kne2etests0 kne2etests1 kne2etests2 kne2etests3 kne2etests4 kne2etests5
}

function delete_service_mesh(){
echo ">> Bringin down Service Mesh"
oc delete --ignore-not-found=true -n $SERVICEMESH_NAMESPACE -f https://raw.githubusercontent.com/openshift/knative-serving/$SERVING_RELEASE/openshift/servicemesh/controlplane-install.yaml
oc delete --ignore-not-found=true -f https://raw.githubusercontent.com/openshift/knative-serving/$SERVING_RELEASE/openshift/servicemesh/operator-install.yaml
}

function teardown() {
delete_test_namespace
delete_service_mesh
delete_knative_openshift
}

echo ">> Check resources"
echo ">> - meminfo:"
Expand All @@ -318,14 +222,10 @@ failed=0

(( !failed )) && build_knative_client || failed=1

(( !failed )) && install_servicemesh || failed=1

(( !failed )) && install_knative_serving || failed=1

(( !failed )) && run_e2e_tests || failed=1

teardown

(( failed )) && exit 1

success

0 comments on commit f91ea43

Please sign in to comment.