Skip to content

Commit 8f3bfca

Browse files
committed
Add FAQ for install OpenFunction in offline environment
Signed-off-by: wrongerror <wangyifei@kubesphere.io>
1 parent 634873f commit 8f3bfca

File tree

2 files changed

+320
-0
lines changed

2 files changed

+320
-0
lines changed

content/en/docs/getting-started/installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ OpenFunction supports Kubernetes 1.25 starting from v0.8.1
3131
Now you can install OpenFunction and all its dependencies with helm charts.
3232
> The `ofn` CLI install method is deprecated.
3333
34+
If you want to install OpenFunction in an offline environment, please refer to [Install OpenFunction in an offline environment](https://openfunction.dev/docs/reference/faq/#q-how-to-install-openfunction-in-an-offline-environment)
35+
3436
### Requirements
3537
- Kubernetes version: `>=v1.20.0-0`
3638
- Helm version: `>=v3.6.3`

content/en/docs/reference/faq.md

Lines changed: 318 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,321 @@ spec:
233233
A: You may be prompted with errors like `Unsupported type of credentials provided, either SSH private key or username/password is supported (exit code 110)` when using `spec.build.srcRepo.credentials`, which means you are using an incorrect Secret resource as source repository crendital.
234234

235235
OpenFunction currently implements the function image building framework based on [ShipWright](https://shipwright.io/), so we need to refer to this [document](https://shipwright.io/docs/build/authentication/#authentication-for-git) to setup the correct source repository credential.
236+
237+
## Q: How to install OpenFunction in an offline environment?
238+
239+
A: You can install and use OpenFunction in an offline environment by following steps:
240+
241+
### Pull the Helm Chart
242+
243+
Pull the helm chart in an environment that can access GitHub:
244+
245+
```shell
246+
helm repo add openfunction https://openfunction.github.io/charts/
247+
helm repo update
248+
helm pull openfunction/openfunction
249+
```
250+
251+
Then use tools like scp to copy the helm package to your offline environment, e.g.:
252+
253+
```shell
254+
scp openfunction-v0.8.1-v0.4.0.tgz <username>@<your-machine-ip>:/home/<username>/
255+
```
256+
257+
### Synchronize images
258+
You need to sync these images to your private image repository:
259+
260+
```
261+
# dapr
262+
docker.io/daprio/dashboard:0.10.0
263+
docker.io/daprio/dapr:1.8.3
264+
265+
# keda
266+
openfunction/keda:2.8.1
267+
openfunction/keda-metrics-apiserver:2.8.1
268+
269+
# contour
270+
docker.io/bitnami/contour:1.21.1-debian-11-r5
271+
docker.io/bitnami/envoy:1.22.2-debian-11-r6
272+
docker.io/bitnami/nginx:1.21.6-debian-11-r10
273+
274+
# tekton-pipelines
275+
openfunction/tektoncd-pipeline-cmd-controller:v0.37.2
276+
openfunction/tektoncd-pipeline-cmd-kubeconfigwriter:v0.37.2
277+
openfunction/tektoncd-pipeline-cmd-git-init:v0.37.2
278+
openfunction/tektoncd-pipeline-cmd-entrypoint:v0.37.2
279+
openfunction/tektoncd-pipeline-cmd-nop:v0.37.2
280+
openfunction/tektoncd-pipeline-cmd-imagedigestexporter:v0.37.2
281+
openfunction/tektoncd-pipeline-cmd-pullrequest-init:v0.37.2
282+
openfunction/tektoncd-pipeline-cmd-workingdirinit:v0.37.2
283+
openfunction/cloudsdktool-cloud-sdk@sha256:27b2c22bf259d9bc1a291e99c63791ba0c27a04d2db0a43241ba0f1f20f4067f
284+
openfunction/distroless-base@sha256:b16b57be9160a122ef048333c68ba205ae4fe1a7b7cc6a5b289956292ebf45cc
285+
openfunction/tektoncd-pipeline-cmd-webhook:v0.37.2
286+
287+
# knative-serving
288+
openfunction/knative.dev-serving-cmd-activator:v1.3.2
289+
openfunction/knative.dev-serving-cmd-autoscaler:v1.3.2
290+
openfunction/knative.dev-serving-cmd-queue:v1.3.2
291+
openfunction/knative.dev-serving-cmd-controller:v1.3.2
292+
openfunction/knative.dev-serving-cmd-domain-mapping:v1.3.2
293+
openfunction/knative.dev-serving-cmd-domain-mapping-webhook:v1.3.2
294+
openfunction/knative.dev-net-contour-cmd-controller:v1.3.0
295+
openfunction/knative.dev-serving-cmd-default-domain:v1.3.2
296+
openfunction/knative.dev-serving-cmd-webhook:v1.3.2
297+
298+
# shipwright-build
299+
openfunction/shipwright-shipwright-build-controller:v0.10.0
300+
openfunction/shipwright-io-build-git:v0.10.0
301+
openfunction/shipwright-mutate-image:v0.10.0
302+
openfunction/shipwright-bundle:v0.10.0
303+
openfunction/shipwright-waiter:v0.10.0
304+
305+
# openfunction
306+
openfunction/openfunction:v0.8.1
307+
openfunction/kube-rbac-proxy:v0.8.0
308+
openfunction/eventsource-handler:v4
309+
openfunction/trigger-handler:v4
310+
openfunction/dapr-proxy:v0.1.1
311+
```
312+
313+
### Create custom values
314+
315+
Create `custom-values.yaml` in your offline environment:
316+
317+
```shell
318+
touch custom-values.yaml
319+
```
320+
321+
Edit `custom-values.yaml`, add the following content:
322+
323+
```yaml
324+
knative-serving:
325+
activator:
326+
activator:
327+
image:
328+
repository: <your-private-image-repository>/knative.dev-serving-cmd-activator
329+
autoscaler:
330+
autoscaler:
331+
image:
332+
repository: <your-private-image-repository>/knative.dev-serving-cmd-autoscaler
333+
configDeployment:
334+
queueSidecarImage:
335+
repository: <your-private-image-repository>/knative.dev-serving-cmd-queue
336+
controller:
337+
controller:
338+
image:
339+
repository: <your-private-image-repository>/knative.dev-serving-cmd-controller
340+
domainMapping:
341+
domainMapping:
342+
image:
343+
repository: <your-private-image-repository>/knative.dev-serving-cmd-domain-mapping
344+
domainmappingWebhook:
345+
domainmappingWebhook:
346+
image:
347+
repository: <your-private-image-repository>/knative.dev-serving-cmd-domain-mapping-webhook
348+
netContourController:
349+
controller:
350+
image:
351+
repository: <your-private-image-repository>/knative.dev-net-contour-cmd-controller
352+
defaultDomain:
353+
job:
354+
image:
355+
repository: <your-private-image-repository>/knative.dev-serving-cmd-default-domain
356+
webhook:
357+
webhook:
358+
image:
359+
repository: <your-private-image-repository>/knative.dev-serving-cmd-webhook
360+
shipwright-build:
361+
shipwrightBuildController:
362+
shipwrightBuild:
363+
image:
364+
repository: <your-private-image-repository>/shipwright-shipwright-build-controller
365+
GIT_CONTAINER_IMAGE:
366+
repository: <your-private-image-repository>/shipwright-io-build-git
367+
MUTATE_IMAGE_CONTAINER_IMAGE:
368+
repository: <your-private-image-repository>/shipwright-mutate-image
369+
BUNDLE_CONTAINER_IMAGE:
370+
repository: <your-private-image-repository>/shipwright-bundle
371+
WAITER_CONTAINER_IMAGE:
372+
repository: <your-private-image-repository>/shipwright-waiter
373+
tekton-pipelines:
374+
controller:
375+
tektonPipelinesController:
376+
image:
377+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-controller
378+
kubeconfigWriterImage:
379+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-kubeconfigwriter
380+
gitImage:
381+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-git-init
382+
entrypointImage:
383+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-entrypoint
384+
nopImage:
385+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-nop
386+
imagedigestExporterImage:
387+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-imagedigestexporter
388+
prImage:
389+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-pullrequest-init
390+
workingdirinitImage:
391+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-workingdirinit
392+
gsutilImage:
393+
repository: <your-private-image-repository>/cloudsdktool-cloud-sdk
394+
digest: sha256:27b2c22bf259d9bc1a291e99c63791ba0c27a04d2db0a43241ba0f1f20f4067f
395+
shellImage:
396+
repository: <your-private-image-repository>/distroless-base
397+
digest: sha256:b16b57be9160a122ef048333c68ba205ae4fe1a7b7cc6a5b289956292ebf45cc
398+
webhook:
399+
webhook:
400+
image:
401+
repository: <your-private-image-repository>/tektoncd-pipeline-cmd-webhook
402+
keda:
403+
image:
404+
keda:
405+
repository: <your-private-image-repository>/keda
406+
tag: 2.8.1
407+
metricsApiServer:
408+
repository: <your-private-image-repository>/keda-metrics-apiserver
409+
tag: 2.8.1
410+
dapr:
411+
registry: <your-private-image-registry>/daprio
412+
tag: '1.8.3'
413+
contour:
414+
contour:
415+
image:
416+
registry: <your-private-image-registry>
417+
repository: <your-private-image-repository>/contour
418+
tag: 1.21.1-debian-11-r5
419+
envoy:
420+
image:
421+
registry: <your-private-image-registry>
422+
repository: <your-private-image-repository>/envoy
423+
tag: 1.22.2-debian-11-r6
424+
defaultBackend:
425+
image:
426+
registry: <your-private-image-registry>
427+
repository: <your-private-image-repository>/nginx
428+
tag: 1.21.6-debian-11-r10
429+
```
430+
431+
### Install OpenFunction
432+
433+
Run the following command in an offline environment to try to install OpenFunction:
434+
```shell
435+
kubectl create namespace openfunction
436+
helm install openfunction openfunction-v0.8.1-v0.4.0.tgz -n openfunction -f custom-values.yaml
437+
```
438+
439+
{{% alert title="Note" color="success" %}}
440+
441+
If the `helm install` command gets stuck, it may be caused by the job `contour-contour-cergen`.
442+
443+
Run the following command to confirm whether the job is executed successfully:
444+
445+
```shell
446+
kubectl get job contour-contour-cergen -n projectcontour
447+
```
448+
449+
If the job exists and the job status is completed, run the following command to complete the installation:
450+
451+
```shell
452+
helm uninstall openfunction -n openfunction --no-hooks
453+
helm install openfunction openfunction-v0.8.1-v0.4.0.tgz -n openfunction -f custom-values.yaml --no-hooks
454+
```
455+
456+
{{% /alert %}}
457+
458+
## Q: How to build and run functions in an offline environment
459+
460+
A: Let's take [Java functions](https://github.com/OpenFunction/samples/tree/main/functions/knative/java) as an example to illustrate how to build and run functions in an offline environment:
461+
462+
- Synchronize `https://github.com/OpenFunction/samples.git` to your private code repository
463+
464+
- Follow this [prerequisites](https://openfunction.dev/docs/getting-started/quickstarts/prerequisites/) doc to create `push-secret` and `git-repo-secret`
465+
466+
- Change public maven repository to private maven repository:
467+
```xml
468+
<?xml version="1.0" encoding="UTF-8"?>
469+
<project xmlns="http://maven.apache.org/POM/4.0.0"
470+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
471+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
472+
<modelVersion>4.0.0</modelVersion>
473+
474+
<groupId>dev.openfunction.samples</groupId>
475+
<artifactId>samples</artifactId>
476+
<version>1.0-SNAPSHOT</version>
477+
478+
<properties>
479+
<maven.compiler.source>11</maven.compiler.source>
480+
<maven.compiler.target>11</maven.compiler.target>
481+
</properties>
482+
483+
<repositories>
484+
<repository>
485+
<id>snapshots</id>
486+
<name>Maven snapshots</name>
487+
<!--<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>-->
488+
<url>your private maven repository</url>
489+
<releases>
490+
<enabled>false</enabled>
491+
</releases>
492+
<snapshots>
493+
<enabled>true</enabled>
494+
</snapshots>
495+
</repository>
496+
</repositories>
497+
498+
<dependencies>
499+
<dependency>
500+
<groupId>dev.openfunction.functions</groupId>
501+
<artifactId>functions-framework-api</artifactId>
502+
<version>1.0.0-SNAPSHOT</version>
503+
</dependency>
504+
</dependencies>
505+
506+
</project>
507+
```
508+
> Make sure to commit the changes to the code repo.
509+
510+
- Synchronize `openfunction/buildpacks-java18-run:v1` to your private image repository
511+
512+
- Modify `functions/knative/java/hello-world/function-sample.yaml` according to your environment:
513+
```yaml
514+
apiVersion: core.openfunction.io/v1beta1
515+
kind: Function
516+
metadata:
517+
name: function-http-java
518+
spec:
519+
version: "v2.0.0"
520+
image: "<your private image repository>/sample-java-func:v1"
521+
imageCredentials:
522+
name: push-secret
523+
port: 8080 # default to 8080
524+
build:
525+
builder: <your private image repository>/builder-java:v2-18
526+
params:
527+
RUN_IMAGE: "<your private image repository>/buildpacks-java18-run:v1"
528+
env:
529+
FUNC_NAME: "dev.openfunction.samples.HttpFunctionImpl"
530+
FUNC_CLEAR_SOURCE: "true"
531+
srcRepo:
532+
url: "https://<your private code repository>/OpenFunction/samples.git"
533+
sourceSubPath: "functions/knative/java"
534+
revision: "main"
535+
credentials:
536+
name: git-repo-secret
537+
serving:
538+
template:
539+
containers:
540+
- name: function # DO NOT change this
541+
imagePullPolicy: IfNotPresent
542+
runtime: "knative"
543+
```
544+
545+
> If your private mirror repository is insecure, please refer to [Use private image repository in an insecure way](https://openfunction.dev/docs/reference/faq/#q-how-to-use-private-image-repositories-in-openfunction)
546+
547+
- Run the following commands to build and run the function:
548+
549+
```shell
550+
kubectl apply -f functions/knative/java/hello-world/function-sample.yaml
551+
```
552+
553+

0 commit comments

Comments
 (0)