Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helloworld-go : no matches for kind "Function" in version "core.openfunction.io/v1beta1" #46

Open
aBreaking opened this issue Feb 10, 2022 · 18 comments

Comments

@aBreaking
Copy link

following hello-world-go, when i exec command

kubectl apply -f function-sample.yaml

An error occurred :

error: unable to recognize "function-sample.yaml": no matches for kind "Function" in version "core.openfunction.io/v1beta1"

can help me?

I just completely installed ofn. and the pods of ofn components were running that i have checked.

The following existing components will be skipped:
        - CertManager
        - IngressNginx
        - Dapr
        - Keda
        - Knative Serving
        - Tekton Pipelines
        - Shipwright
 ✓ Shipwright - Completed!
 ✓ OpenFunction - Completed!
🚀 Completed in 1m9.205258418s.

@tpiperatgod
Copy link
Member

The ofn installs the latest stable version of OpenFunction (v0.5.0 for now) by default, with the branch of the corresponding sample as release-0.5.

Can you paste the contents of the functions-sample.yaml?

@aBreaking
Copy link
Author

aBreaking commented Feb 11, 2022

@tpiperatgod

functions-sample.yaml

apiVersion: core.openfunction.io/v1beta1
kind: Function
metadata:
  name: function-sample
spec:
  image: "abreaking/sample-go-func:latest"

and i also used official yaml , also same error occurred.

my minikube version:

minikube v1.23.1

pods of openfunction status is :

root@kube-PC:~# k get pods -n openfunction
NAME                                               READY   STATUS    RESTARTS      AGE
openfunction-controller-manager-5f55b55fcf-vhghn   2/2     Running   4 (15h ago)   18h

@tpiperatgod
Copy link
Member

Hi, @aBreaking , you should use this yaml file: https://github.com/OpenFunction/samples/blob/release-0.5/functions/Knative/hello-world-go/function-sample.yaml

Note that spec.build.srcRepo.revision needs to be set to "release-0.5"

apiVersion: core.openfunction.io/v1alpha2
kind: Function
metadata:
  name: function-sample
spec:
  version: "v1.0.0"
  image: "openfunctiondev/sample-go-func:v0.5"
  imageCredentials:
    name: push-secret
  port: 8080 # default to 8080
  build:
    builder: openfunction/builder-go:v0.4.0-1.15
    env:
      FUNC_NAME: "HelloWorld"
      FUNC_TYPE: "http"
    srcRepo:
      revision: "release-0.5"
      url: "https://github.com/OpenFunction/samples.git"
      sourceSubPath: "functions/Knative/hello-world-go"
  serving:
    runtime: Knative # default to Knative
#    template:
#      containers:
#       - name: function
#          # Set imagePullPolicy if needed
#          imagePullPolicy: Always

@aBreaking
Copy link
Author

aBreaking commented Feb 11, 2022

@tpiperatgod hi , i can apply yaml successful, but the BUILDSTATE of function-sample is UndefinedParameter, see:

roott@kube-PC:~/openfunction/hello-world-go# k get function
NAME              BUILDSTATE           SERVINGSTATE   BUILDER         SERVING   AGE
function-sample   UndefinedParameter                  builder-gjkgr             11s

describe:

root@kube-PC:~/openfunction/hello-world-go# k describe function function-sample
Name:         function-sample
Namespace:    default
Labels:       <none>
Annotations:  <none>
API Version:  core.openfunction.io/v1alpha2
Kind:         Function
Metadata:
  Creation Timestamp:  2022-02-11T06:48:58Z
  Generation:          1
  Managed Fields:
    API Version:  core.openfunction.io/v1alpha2
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:kubectl.kubernetes.io/last-applied-configuration:
      f:spec:
        .:
        f:build:
          .:
          f:builder:
          f:env:
            .:
            f:FUNC_NAME:
            f:FUNC_TYPE:
          f:srcRepo:
            .:
            f:revision:
            f:sourceSubPath:
            f:url:
        f:image:
        f:imageCredentials:
          .:
          f:name:
        f:port:
        f:serving:
          .:
          f:runtime:
        f:version:
    Manager:      kubectl-client-side-apply
    Operation:    Update
    Time:         2022-02-11T06:48:58Z
    API Version:  core.openfunction.io/v1alpha2
    Fields Type:  FieldsV1
    fieldsV1:
      f:status:
        .:
        f:build:
          .:
          f:resourceHash:
          f:resourceRef:
          f:state:
    Manager:         openfunction
    Operation:       Update
    Subresource:     status
    Time:            2022-02-11T06:48:59Z
  Resource Version:  2272734
  UID:               f414656d-7b02-42eb-b862-d82835cf030a
Spec:
  Build:
    Builder:  openfunction/builder-go:v0.4.0-1.15
    Env:
      FUNC_NAME:  HelloWorld
      FUNC_TYPE:  http
    Src Repo:
      Revision:         release-0.5
      Source Sub Path:  functions/Knative/hello-world-go
      URL:              https://github.com/OpenFunction/samples.git
  Image:                abreaking/sample-go-func:v0.5
  Image Credentials:
    Name:  push-secret
  Port:    8080
  Serving:
    Runtime:  Knative
  Version:    v1.0.0
Status:
  Build:
    Resource Hash:  17153761573593136027
    Resource Ref:   builder-gjkgr
    State:          UndefinedParameter
Events:             <none>

Is there something wrong with my environment?

thanks

@tpiperatgod
Copy link
Member

There should be an exception in the process of building the function image.

Could you please paste the details of the buildruns.shipwright.io resource?

For example:

kubectl get buildruns.shipwright.io

or

kubectl describe buildruns.shipwright.io <name>

@aBreaking
Copy link
Author

aBreaking commented Feb 11, 2022

@tpiperatgod

root@kube-PC:~/openfunction/hello-world-go#  kubectl get buildruns.shipwright.io
NAME                           SUCCEEDED   REASON                    STARTTIME   COMPLETIONTIME
builder-gjkgr-buildrun-rt7bj   False       BuildRegistrationFailed               11m

describe:

oot@kube-PC:~/openfunction/hello-world-go# k describe buildruns.shipwright.io builder-gjkgr-buildrun-rt7bj
Name:         builder-gjkgr-buildrun-rt7bj
Namespace:    default
Labels:       openfunction.io/builder=builder-gjkgr
Annotations:  <none>
API Version:  shipwright.io/v1alpha1
Kind:         BuildRun
Metadata:
  Creation Timestamp:  2022-02-11T06:48:59Z
  Generate Name:       builder-gjkgr-buildrun-
  Generation:          1
  Managed Fields:
    API Version:  shipwright.io/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:generateName:
        f:labels:
          .:
          f:openfunction.io/builder:
        f:ownerReferences:
          .:
          k:{"uid":"197ee203-fec5-4d19-a514-a5d1c867689b"}:
      f:spec:
        .:
        f:buildRef:
          .:
          f:name:
    Manager:      openfunction
    Operation:    Update
    Time:         2022-02-11T06:48:59Z
    API Version:  shipwright.io/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:status:
        .:
        f:completionTime:
        f:conditions:
    Manager:      shipwright-build-controller
    Operation:    Update
    Subresource:  status
    Time:         2022-02-11T06:49:00Z
  Owner References:
    API Version:           core.openfunction.io/v1alpha2
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  Builder
    Name:                  builder-gjkgr
    UID:                   197ee203-fec5-4d19-a514-a5d1c867689b
  Resource Version:        2272768
  UID:                     a729faec-d4ef-453c-8b57-d06fb5c732f7
Spec:
  Build Ref:
    Name:  builder-gjkgr-build-8zd57
Status:
  Completion Time:  2022-02-11T06:49:00Z
  Conditions:
    Last Transition Time:  2022-02-11T06:49:00Z
    Message:               the Build is not registered correctly, build: builder-gjkgr-build-8zd57, registered status: False, reason: UndefinedParameter
    Reason:                BuildRegistrationFailed
    Status:                False
    Type:                  Succeeded
Events:                    <none>

@benjaminhuo
Copy link
Member

If a build failed, the builder CR will be kept. Take a look at the build pod's log to find out the failure reason

@tpiperatgod
Copy link
Member

and could you pls paste the details of the builds.shipwright.io resource builder-gjkgr-build-8zd57?

@aBreaking
Copy link
Author

@tpiperatgod

root@kube-PC:~/openfunction/hello-world-go# k get builds builder-gjkgr-build-8zd57 -o yaml
apiVersion: shipwright.io/v1alpha1
kind: Build
metadata:
  creationTimestamp: "2022-02-11T06:48:59Z"
  generateName: builder-gjkgr-build-
  generation: 1
  labels:
    openfunction.io/builder: builder-gjkgr
  name: builder-gjkgr-build-8zd57
  namespace: default
  ownerReferences:
  - apiVersion: core.openfunction.io/v1alpha2
    blockOwnerDeletion: true
    controller: true
    kind: Builder
    name: builder-gjkgr
    uid: 197ee203-fec5-4d19-a514-a5d1c867689b
  resourceVersion: "2272728"
  uid: 71057d8e-1329-430b-aace-02d9b86eebcf
spec:
  builder:
    image: openfunction/builder-go:v0.4.0-1.15
  output:
    credentials:
      name: push-secret
    image: abreaking/sample-go-func:v0.5
  paramValues:
  - name: APP_IMAGE
    value: abreaking/sample-go-func:v0.5
  - name: ENV_VARS
    value: FUNC_NAME=HelloWorld#FUNC_TYPE=http#PORT=8080
  source:
    contextDir: functions/Knative/hello-world-go
    revision: release-0.5
    url: https://github.com/OpenFunction/samples.git
  strategy:
    kind: ClusterBuildStrategy
    name: openfunction
status:
  message: 'parameter not defined in the strategies: APP_IMAGE'
  reason: UndefinedParameter
  registered: "False"

is somewhere needs APP_IMAGE?

@aBreaking
Copy link
Author

aBreaking commented Feb 11, 2022

@benjaminhuo No pods found related to ofn in default namespace, need i paste the log of pods which in the namespace shipwright-build or openfunction ?

@tpiperatgod
Copy link
Member

Can you paste the information about the inventory of components in the current cluster? The inventory file is located in the ~/.ofn/ directory by default, with a name such as *-inventory.yaml.

~# cat ~/.ofn/[email protected]
openFunction: 0.5.0
knativeServing: 1.0.1
kourier: 1.0.1
defaultDomain: 1.0.1
keda: 2.4.0
dapr: 1.5.1
tektonPipelines: 0.30.0
shipwright: 0.6.1
certManager: 1.5.4
ingress: 1.1.0

And can you paste the information of the clusterbuildstrategies.shipwright.io resource openfunction in your cluster?

~# kubectl get clusterbuildstrategies.shipwright.io openfunction -oyaml
apiVersion: shipwright.io/v1alpha1
kind: ClusterBuildStrategy
metadata:
  creationTimestamp: "2022-02-10T10:43:20Z"
  generation: 1
  name: openfunction
  resourceVersion: "37337408"
  uid: f17ca6b6-49e7-4da4-b25f-2646f8fd824e
spec:
  buildSteps:
  - args:
    - -c
    - |
      #!/usr/bin/env bash
      set -e

      for path in "/cache" "/tekton/home" "/layers" "/workspace/source"; do
        echo "> Setting permissions on '$path'..."
        chown -R "$(params.USER_ID):$(params.GROUP_ID)" "$path"
      done

      echo "> Processing any environment variables..."
      ENV_DIR="/platform/env"

      echo "--> Creating 'env' directory: $ENV_DIR"
      mkdir -p "$ENV_DIR"

      envs=(`echo $(params.ENV_VARS) | tr '#' ' '`)

      for env in "${envs[@]}"; do
          IFS='=' read -r key value string <<< "$env"
          if [[ "$key" != "" && "$value" != "" ]]; then
              path="${ENV_DIR}/${key}"
              echo "--> Writing ${path}..."
              echo -n "$value" > "$path"
          fi
      done
    command:
    - /usr/local/bin/bash
    image: docker.io/library/bash:5.1.4@sha256:b208215a4655538be652b2769d82e576bc4d0a2bb132144c060efc5be8c3f5d6
    name: prepare
    securityContext:
      privileged: true
    volumeMounts:
    - mountPath: /cache
      name: cache
    - mountPath: /layers
      name: layers-dir
    - mountPath: /platform
      name: $(params.PLATFORM_DIR)
  - args:
    - -app=/workspace/source/$(params.CONTEXT_DIR)
    - -cache-dir=/cache
    - -uid=$(params.USER_ID)
    - -gid=$(params.GROUP_ID)
    - -layers=/layers
    - -platform=/platform
    - -report=/layers/report.toml
    - -process-type=$(params.PROCESS_TYPE)
    - -skip-restore=$(params.SKIP_RESTORE)
    - -previous-image=$(params.shp-output-image)
    - -run-image=$(params.RUN_IMAGE)
    - $(params.shp-output-image)
    command:
    - /cnb/lifecycle/creator
    image: $(params.BUILDER_IMAGE)
    imagePullPolicy: Always
    name: create
    securityContext:
      runAsGroup: 1000
      runAsUser: 1000
    volumeMounts:
    - mountPath: /cache
      name: cache
    - mountPath: /layers
      name: layers-dir
    - mountPath: /platform
      name: $(params.PLATFORM_DIR)
  - args:
    - -c
    - |
      #!/usr/bin/env bash
      set -e
      cat /layers/report.toml | grep "digest" | cut -d'"' -f2 | cut -d'"' -f2 | tr -d '\n' | tee $(results.shp-image-digest.path)
    command:
    - /bin/sh
    image: docker.io/library/bash:5.1.4@sha256:b208215a4655538be652b2769d82e576bc4d0a2bb132144c060efc5be8c3f5d6
    name: results
    volumeMounts:
    - mountPath: /layers
      name: layers-dir
  parameters:
  - default: web
    description: The default process type to set on the image.
    name: PROCESS_TYPE
  - default: ""
    description: Reference to a run image to use.
    name: RUN_IMAGE
  - default: ""
    description: The name of the persistent app cache image (if no cache workspace
      is provided).
    name: CACHE_IMAGE
  - default: "false"
    description: Do not write layer metadata or restore cached layers.
    name: SKIP_RESTORE
  - default: "1000"
    description: The user ID of the builder image user.
    name: USER_ID
  - default: "1000"
    description: The group ID of the builder image user.
    name: GROUP_ID
  - default: empty-dir
    description: The name of the platform directory.
    name: PLATFORM_DIR
  - default: ""
    description: Environment variables to set during _build-time_. The formate is
      `key1=value1,key2=value2`.
    name: ENV_VARS

@aBreaking
Copy link
Author

@tpiperatgod

root@kube-PC:~/.ofn# more minikube-inventory.yaml 
openFunction: 0.5.0
keda: 2.4.0
dapr: 1.5.1
tektonPipelines: 0.30.0
shipwright: 0.6.1
ingress: 1.1.0

and

root@kube-PC:~/.ofn# kubectl get clusterbuildstrategies.shipwright.io openfunction -oyaml
apiVersion: shipwright.io/v1alpha1
kind: ClusterBuildStrategy
metadata:
  creationTimestamp: "2022-02-10T09:27:30Z"
  generation: 1
  name: openfunction
  resourceVersion: "1580795"
  uid: 5d1f7c08-7abf-4a00-b19e-9e09863c7e27
spec:
  buildSteps:
  - args:
    - -c
    - |
      #!/usr/bin/env bash
      set -e

      for path in "/cache" "/tekton/home" "/layers" "/workspace/source"; do
        echo "> Setting permissions on '$path'..."
        chown -R "$(params.USER_ID):$(params.GROUP_ID)" "$path"
      done

      echo "> Processing any environment variables..."
      ENV_DIR="/platform/env"

      echo "--> Creating 'env' directory: $ENV_DIR"
      mkdir -p "$ENV_DIR"

      envs=(`echo $(params.ENV_VARS) | tr '#' ' '`)

      for env in "${envs[@]}"; do
          IFS='=' read -r key value string <<< "$env"
          if [[ "$key" != "" && "$value" != "" ]]; then
              path="${ENV_DIR}/${key}"
              echo "--> Writing ${path}..."
              echo -n "$value" > "$path"
          fi
      done
    command:
    - /usr/local/bin/bash
    image: docker.io/library/bash:5.1.4@sha256:b208215a4655538be652b2769d82e576bc4d0a2bb132144c060efc5be8c3f5d6
    name: prepare
    securityContext:
      privileged: true
    volumeMounts:
    - mountPath: /cache
      name: cache
    - mountPath: /layers
      name: layers-dir
    - mountPath: /platform
      name: $(params.PLATFORM_DIR)
  - args:
    - -app=/workspace/source/$(params.CONTEXT_DIR)
    - -cache-dir=/cache
    - -uid=$(params.USER_ID)
    - -gid=$(params.GROUP_ID)
    - -layers=/layers
    - -platform=/platform
    - -report=/layers/report.toml
    - -process-type=$(params.PROCESS_TYPE)
    - -skip-restore=$(params.SKIP_RESTORE)
    - -previous-image=$(params.shp-output-image)
    - -run-image=$(params.RUN_IMAGE)
    - $(params.shp-output-image)
    command:
    - /cnb/lifecycle/creator
    image: $(params.BUILDER_IMAGE)
    imagePullPolicy: Always
    name: create
    securityContext:
      runAsGroup: 1000
      runAsUser: 1000
    volumeMounts:
    - mountPath: /cache
      name: cache
    - mountPath: /layers
      name: layers-dir
    - mountPath: /platform
      name: $(params.PLATFORM_DIR)
  - args:
    - -c
    - |
      #!/usr/bin/env bash
      set -e
      cat /layers/report.toml | grep "digest" | cut -d'"' -f2 | cut -d'"' -f2 | tr -d '\n' | tee $(results.shp-image-digest.path)
    command:
    - /bin/sh
    image: docker.io/library/bash:5.1.4@sha256:b208215a4655538be652b2769d82e576bc4d0a2bb132144c060efc5be8c3f5d6
    name: results
    volumeMounts:
    - mountPath: /layers
      name: layers-dir
  parameters:
  - default: web
    description: The default process type to set on the image.
    name: PROCESS_TYPE
  - default: ""
    description: Reference to a run image to use.
    name: RUN_IMAGE
  - default: ""
    description: The name of the persistent app cache image (if no cache workspace
      is provided).
    name: CACHE_IMAGE
  - default: "false"
    description: Do not write layer metadata or restore cached layers.
    name: SKIP_RESTORE
  - default: "1000"
    description: The user ID of the builder image user.
    name: USER_ID
  - default: "1000"
    description: The group ID of the builder image user.
    name: GROUP_ID
  - default: empty-dir
    description: The name of the platform directory.
    name: PLATFORM_DIR
  - default: ""
    description: Environment variables to set during _build-time_. The formate is
      `key1=value1,key2=value2`.
    name: ENV_VARS

@tpiperatgod
Copy link
Member

Thx @aBreaking , but I still haven't found the exact reason 😂

The components in your cluster look correct, can you delete the function and apply the following configuration? Pls let me know if this works properly...

apiVersion: core.openfunction.io/v1alpha2
kind: Function
metadata:
  name: function-demo
spec:
  version: "v1.0.0"
  image: "abreaking/sample-go-func:v0.5"
  imageCredentials:
    name: push-secret
  port: 8080
  build:
    builder: openfunction/builder-go:v0.4.0-1.15
    env:
      FUNC_NAME: "HelloWorld"
      FUNC_TYPE: "http"
    srcRepo:
      revision: "release-0.5"
      url: "https://github.com/OpenFunction/samples.git"
      sourceSubPath: "functions/Knative/hello-world-go"
  serving:
    runtime: Knative

@aBreaking
Copy link
Author

@tpiperatgod unfortunately, still the same error 😶

root@kube-PC:~/openfunction/hello-world-go# k get function
NAME            BUILDSTATE           SERVINGSTATE   BUILDER         SERVING   AGE
function-demo   UndefinedParameter                  builder-9trqz             4s
root@kube-PC:~/openfunction/hello-world-go# k get builds
NAME                        REGISTERED   REASON               BUILDSTRATEGYKIND      BUILDSTRATEGYNAME   CREATIONTIME
builder-9trqz-build-97s4s   False        UndefinedParameter   ClusterBuildStrategy   openfunction        8s

@tpiperatgod
Copy link
Member

OK, while I don't know what causes this exception in your cluster, the problem occurs for the following reason:

The OpenFunction controller creates the builds.shipwright.io resource when it builds the function, and there is an APP_IMAGE parameter (it was present in versions earlier than 0.5) in there that cannot be passed to clusterbuildstrategies.

I have not had this problem so far after verifying it in my cluster, so I can't be sure what is wrong with the configuration.

BUT! There is another way to get a taste of OpenFunction: you can use the ofn demo, like:
ofn demo --auto-prune=false (this command would save the demo env)

See more at: https://github.com/OpenFunction/cli/blob/main/docs/demo.md

@aBreaking
Copy link
Author

@tpiperatgod ok , thanks very much for your time, the demo I will try it later . and let me try out shipwright-io, or maybe the issue is belongs shipwright-io.

@tpiperatgod
Copy link
Member

Hi @aBreaking , you can join our community group chat 😄
721644568845_ pic

@benjaminhuo
Copy link
Member

@tpiperatgod ok , thanks very much for your time, the demo I will try it later . and let me try out shipwright-io, or maybe the issue is belongs shipwright-io.

Deleting Shipwright and then install it using ofn could solve the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants