Skip to content

Commit

Permalink
feat: add example and instructions to test knative in airgapped (#932)
Browse files Browse the repository at this point in the history
* feat: add example and instructions to test knative in airgap
  • Loading branch information
NohaIhab authored Jun 24, 2024
1 parent 1a7e478 commit d8fb375
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/airgapped/get-all-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ rm -rf resource-dispatcher
# manually retrieve pipelines runner image to test pipelines
IMAGES+=($(echo "charmedkubeflow/pipelines-runner:ckf-1.8"))

# manually retrieve helloworld image to test knative
IMAGES+=($(echo "ghcr.io/knative/helloworld-go:latest"))

# ensure we only show unique images
IMAGES=($(echo "${IMAGES[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))

Expand Down
37 changes: 37 additions & 0 deletions tests/airgapped/knative/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Testing Knative in airgapped

This directory is dedicated to testing Knative in an airgapped environment.

## Prerequisites

Prepare the airgapped environment and deploy CKF by following the steps in [Airgapped test scripts](https://github.com/canonical/bundle-kubeflow/tree/main/tests/airgapped#testing-airgapped-installation).

Once you run the test scripts, the `knative/helloworld-go` image used in the `helloworld` example will be included in your airgapped environment. It's specifically added in the [`get-all-images.sh` script](../../../scripts/airgapped/get-all-images.sh).

## How to test Knative in an Airgapped environment
1. Connect to the dashboard by visiting the IP of your airgapped VM. To get the IP run:
```
lxc ls | grep eth0
```
2. Log in to the dashboard and create a Profile.
3. Apply the `helloworld.yaml` found in this directory to your Profile's Namespace:
```
kubectl apply -f ./helloworld.yaml -n <your namespace>
```
4. Wait for the Knative Service to be `Ready`
```
kubectl get ksvc -n <your namespace>
```
Expected output:
```
NAME URL LATESTCREATED LATESTREADY READY REASON
helloworld http://helloworld.admin.10.64.140.43.nip.io helloworld-00001 helloworld-00001 True
```
5. Curl the Knative Service using the `URL` from the previous step
```
curl -L http://helloworld.admin.10.64.140.43.nip.io
```
Expected output:
```
Hello World!
```
19 changes: 19 additions & 0 deletions tests/airgapped/knative/helloworld.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This example is based on the [Knative Serving tutorial](https://knative.dev/docs/getting-started/first-service/#__tabbed_1_2)
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: hello
spec:
template:
metadata:
labels:
# Disable istio sidecar due to https://github.com/canonical/kserve-operators/issues/216
sidecar.istio.io/inject : "false"
spec:
containers:
- image: 172.17.0.2:5000/knative/helloworld-go:latest
ports:
- containerPort: 8080
env:
- name: TARGET
value: "World"

0 comments on commit d8fb375

Please sign in to comment.