Skip to content

Commit

Permalink
📂 update OpenShift specific files
Browse files Browse the repository at this point in the history
  • Loading branch information
serverless-qe committed May 23, 2024
1 parent 7276955 commit 762f9aa
Show file tree
Hide file tree
Showing 33 changed files with 9,763 additions and 8,595 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/test-e2e-oncluster-runtime.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/test-e2e-oncluster.yaml

This file was deleted.

16,983 changes: 8,495 additions & 8,488 deletions generate/zz_filesystem_generated.go

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions hack/install-pull-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

main() {
local -r tmp_docker_config="$(mktemp config.json-XXXXXXXX)"

cat <<EOF > "${tmp_docker_config}"
{
"auths": {
"registry.redhat.io": {
"auth": "$(echo -n "${RH_REG_USR}:${RH_REG_PWD}" | base64 -w0)"
}
}
}
EOF

local node
for node in $(kind get nodes --name "func"); do
tar -cf - "${tmp_docker_config}" --transform="flags=r;s|${tmp_docker_config}|config.json|" | \
docker cp - "${node}:/var/lib/kubelet/"
done
rm "${tmp_docker_config}"
}

main "$@"
85 changes: 85 additions & 0 deletions hack/openshift-pipelines.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env bash

# Copyright 2022 The OpenShift Knative 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 -o errexit
set -o nounset
set -o pipefail

# source of tasks (in this case to the project root folder)
source_path=$(dirname $(cd $(dirname $0) && pwd ))

openshift_pipelines() {
echo "Installing Openshift Pipelines..."

PIPELINE_OPERATOR_DEFAULT_CHANNEL=$(oc get packagemanifests openshift-pipelines-operator-rh -n openshift-marketplace -o json | jq '.status.defaultChannel' | tr -d '"')
PIPELINE_OPERATOR_CHANNEL=${PIPELINE_OPERATOR_CHANNEL:-${PIPELINE_OPERATOR_DEFAULT_CHANNEL}}
PIPELINE_TARGET_VERSION=$(oc get packagemanifests openshift-pipelines-operator-rh -n openshift-marketplace -o json | CHANNEL=$PIPELINE_OPERATOR_CHANNEL jq '.status.channels[] | select(.name==env.CHANNEL) | .currentCSV')

echo Channel: $PIPELINE_OPERATOR_CHANNEL Target Version: $PIPELINE_TARGET_VERSION

cat << EOF | oc apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: openshift-pipelines-operator-rh
namespace: openshift-operators
spec:
channel: $PIPELINE_OPERATOR_CHANNEL
name: openshift-pipelines-operator-rh
source: redhat-operators
sourceNamespace: openshift-marketplace
EOF

}

wait_pipelines_ready() {
echo "Waiting for Openshift Pipeline to get ready..."
rc=1
set +e
for i in $(seq 5); do
oc wait subscription.operators.coreos.com/openshift-pipelines-operator-rh -n openshift-operators --for=jsonpath='{.status.state}'="AtLatestKnown" --timeout=60s && \
oc wait pod --for=condition=Ready --timeout=180s -n openshift-pipelines -l "app=tekton-pipelines-controller" && \
oc wait pod --for=condition=Ready --timeout=180s -n openshift-pipelines -l "app=tekton-pipelines-webhook" && \
rc=0 && break || (echo "Conditions are not matched. Retrying in 10 secs" && sleep 10)
done
set -e
if (( $rc )); then
echo "Installing Openshift pipelines has failed"
exit 1
fi
}

tekton_tasks() {
echo "Creating Pipeline tasks..."
oc apply -f ${source_path}/pkg/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml
oc apply -f ${source_path}/pkg/pipelines/resources/tekton/task/func-s2i/0.1/func-s2i.yaml
oc apply -f ${source_path}/pkg/pipelines/resources/tekton/task/func-buildpacks/0.1/func-buildpacks.yaml
}

tasks_only=false
if [[ $# -ge 1 && "$1" == "--tasks-only" ]]; then
tasks_only=true
elif [[ $# -ge 1 ]]; then
echo "Unknown parameters, use '--tasks-only' to only install Tekton Tasks"
fi

if [ $tasks_only = false ] ; then
openshift_pipelines
wait_pipelines_ready
fi
tekton_tasks

echo Done
12 changes: 12 additions & 0 deletions openshift/ci-operator/build-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG OCP_VERSION=4.16
ARG GOLANG_VERSION=1.21
FROM registry.ci.openshift.org/ocp/${OCP_VERSION}:tools as tools

FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-${GOLANG_VERSION}-openshift-${OCP_VERSION}

COPY --from=tools /usr/bin/oc /usr/bin/
RUN ln -s /usr/bin/oc /usr/bin/kubectl

# Reset the goflags to avoid the -mod=vendor flag
ENV GOFLAGS=

55 changes: 55 additions & 0 deletions openshift/cluster-prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
#
# Prepare Cluster on Openshift CI
# - Creates testing Namespace
# - Setup Openshift Serverless and Openshift Pipelines
# - Creates Test GitServer service

set -o errexit
set -o nounset
set -o pipefail

BASEDIR=$(dirname "$0")
INSTALL_SERVERLESS="${INSTALL_SERVERLESS:-true}"
INSTALL_PIPELINES="${INSTALL_PIPELINES:-true}"
INSTALL_GITSERVER="${INSTALL_GITSERVER:-true}"
GITSERVER_IMAGE="${GITSERVER_IMAGE:-ghcr.io/jrangelramos/gitserver-unpriv:latest}"

go env
source "$(go run knative.dev/hack/cmd/script e2e-tests.sh)"

# Prepare Namespace
TEST_NAMESPACE="${TEST_NAMESPACE:-knfunc-oncluster-test-$(head -c 128 </dev/urandom | LC_CTYPE=C tr -dc 'a-z0-9' | fold -w 6 | head -n 1)}"
oc new-project "${TEST_NAMESPACE}" || true
oc project "${TEST_NAMESPACE}"

# Installs Openshift Serverless
if [ "$INSTALL_SERVERLESS" == "true" ] ; then
header "Installing Openshift Serverless"
oc apply -f "${BASEDIR}/deploy/serverless-subscription.yaml"
wait_until_pods_running openshift-serverless

subheader "Installing Serving and Eventing"
oc apply -f "${BASEDIR}/deploy/knative-serving.yaml"
oc apply -f "${BASEDIR}/deploy/knative-eventing.yaml"
oc wait --for=condition=Ready --timeout=10m knativeserving knative-serving -n knative-serving
oc wait --for=condition=Ready --timeout=10m knativeeventing knative-eventing -n knative-eventing
fi

# Installs Openshift Pipelines
if [ "$INSTALL_PIPELINES" == "true" ] ; then
header "Installing Openshift Pipelines"
oc apply -f "${BASEDIR}/deploy/pipelines-subscription.yaml"
wait_until_pods_running openshift-pipelines
fi

# Installs Test Git Server
if [ "$INSTALL_GITSERVER" == "true" ] ; then
header "Installing Test GitServer"
sed "s!_GITSERVER_IMAGE_!${GITSERVER_IMAGE}!g" "${BASEDIR}/deploy/gitserver-service.yaml" > "${BASEDIR}/deploy/gitserver.yaml"
oc apply -f "${BASEDIR}/deploy/gitserver.yaml"
oc wait pod/gitserver --for=condition=Ready --timeout=15s

subheader "Exposing Test GitServer route"
oc expose service gitserver --name=gitserver --port=8080
fi
28 changes: 28 additions & 0 deletions openshift/deploy/gitserver-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Git Server used by OnCluster tests on Openshift CI
# Default Image is ghcr.io/jrangelramos/gitserver-unpriv:latest
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: gitserver
name: gitserver
spec:
containers:
- image: _GITSERVER_IMAGE_
name: user-container
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: gitserver
spec:
type: NodePort
selector:
app: gitserver
ports:
- protocol: TCP
port: 80
targetPort: 8080
14 changes: 14 additions & 0 deletions openshift/deploy/knative-eventing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: knative-eventing
---
apiVersion: operator.knative.dev/v1beta1
kind: KnativeEventing
metadata:
name: knative-eventing
namespace: knative-eventing
spec:
high-availability:
replicas: 1
14 changes: 14 additions & 0 deletions openshift/deploy/knative-serving.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: knative-serving
---
apiVersion: operator.knative.dev/v1beta1
kind: KnativeServing
metadata:
name: knative-serving
namespace: knative-serving
spec:
high-availability:
replicas: 1
12 changes: 12 additions & 0 deletions openshift/deploy/pipelines-subscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# OpenShift Pipelines subscription
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: openshift-pipelines-operator-rh
namespace: openshift-operators
spec:
channel: latest
name: openshift-pipelines-operator-rh
source: redhat-operators
sourceNamespace: openshift-marketplace
24 changes: 24 additions & 0 deletions openshift/deploy/serverless-subscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# OpenShift Serverless subscription
---
apiVersion: v1
kind: Namespace
metadata:
name: openshift-serverless
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: serverless-operators
namespace: openshift-serverless
spec: {}
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: serverless-operator
namespace: openshift-serverless
spec:
channel: stable
name: serverless-operator
source: redhat-operators
sourceNamespace: openshift-marketplace
Loading

0 comments on commit 762f9aa

Please sign in to comment.