appsody / appsody-operator

An Operator for deploying Appsody based applications to Kubernetes. This repo will be archived soon.
Apache License 2.0
18 stars 15 forks source link

Operator fails when deploying app to k8s with knative #247

Closed groeges closed 4 years ago

groeges commented 4 years ago

Bug Report

When trying to deploy an Appsody app to k8s (with knative / istio installed ) and the app-deploy.yaml is configured to use createKnativeServer: true the app is not deployed and the operator has an error: no matches for kind "Route" in version "route.openshift.io/v1"

What did you do?

What did you expect to see?

Expected appsody deploy to succeed and the app to be deployed and able to run it.

What did you see instead?

appsody deploy gave errors as it couldnt find the deployed app kubectl get AppsodyApplication test-mp gave the output below showing the status message: no matches for kind "Route" in version "route.openshift.io/v1":

apiVersion: appsody.dev/v1beta1
kind: AppsodyApplication
metadata:
  annotations:
    commit.stack.appsody.dev/author: Neeraj Laad <neeraj.laad@gmail.com>
    commit.stack.appsody.dev/committer: GitHub <noreply@github.com>
    commit.stack.appsody.dev/contextDir: /incubator/java-microprofile
    commit.stack.appsody.dev/date: Fri Mar 13 10:43:34 2020 +0000
    commit.stack.appsody.dev/message: Change ci-timeout from 40 mins to 60 mins (#714)
    image.opencontainers.org/created: "2020-03-26T11:28:32Z"
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"appsody.dev/v1beta1","kind":"AppsodyApplication","metadata":{"annotations":{"commit.stack.appsody.dev/author":"Neeraj Laad \u003cneeraj.laad@gmail.com\u003e","commit.stack.appsody.dev/committer":"GitHub \u003cnoreply@github.com\u003e","commit.stack.appsody.dev/contextDir":"/incubator/java-microprofile","commit.stack.appsody.dev/date":"Fri Mar 13 10:43:34 2020 +0000","commit.stack.appsody.dev/message":"Change ci-timeout from 40 mins to 60 mins (#714)","image.opencontainers.org/created":"2020-03-26T11:28:32Z","stack.appsody.dev/authors":"Emily Jiang \u003cemijiang6@googlemail.com\u003e, Neeraj Laad \u003cneeraj.laad@gmail.com\u003e, Ozzy \u003cozzy@ca.ibm.com\u003e","stack.appsody.dev/configured":"dev.local/appsody/java-microprofile:0.2","stack.appsody.dev/created":"2020-03-26T10:45:05Z","stack.appsody.dev/description":"Eclipse MicroProfile on Open Liberty \u0026 OpenJ9 using Maven","stack.appsody.dev/documentation":"https://github.com/appsody/stacks/tree/master/incubator/java-microprofile/README.md","stack.appsody.dev/licenses":"Apache-2.0","stack.appsody.dev/revision":"b54922e5ec56dbebb081b2267ba6a2ea33a88fdb","stack.appsody.dev/source":"https://github.com/appsody/stacks/tree/master/incubator/java-microprofile/image","stack.appsody.dev/tag":"dev.local/appsody/java-microprofile:0.2.24","stack.appsody.dev/title":"Eclipse MicroProfile®","stack.appsody.dev/url":"https://github.com/appsody/stacks/tree/master/incubator/java-microprofile"},"creationTimestamp":null,"labels":{"image.opencontainers.org/title":"test-mp","stack.appsody.dev/id":"java-microprofile","stack.appsody.dev/version":"0.2.24"},"name":"test-mp","namespace":"default"},"spec":{"applicationImage":"dev.local/test-mp","createKnativeService":true,"expose":true,"livenessProbe":{"failureThreshold":12,"httpGet":{"path":"/health/live","port":9080},"initialDelaySeconds":5,"periodSeconds":2},"readinessProbe":{"failureThreshold":12,"httpGet":{"path":"/health/ready","port":9080},"initialDelaySeconds":5,"periodSeconds":2,"timeoutSeconds":1},"service":{"annotations":{"prometheus.io/scrape":"true"},"port":9080,"type":"NodePort"},"stack":"java-microprofile","version":"1.0.0"}}
    stack.appsody.dev/authors: Emily Jiang <emijiang6@googlemail.com>, Neeraj Laad
      <neeraj.laad@gmail.com>, Ozzy <ozzy@ca.ibm.com>
    stack.appsody.dev/configured: dev.local/appsody/java-microprofile:0.2
    stack.appsody.dev/created: "2020-03-26T10:45:05Z"
    stack.appsody.dev/description: Eclipse MicroProfile on Open Liberty & OpenJ9 using
      Maven
    stack.appsody.dev/documentation: https://github.com/appsody/stacks/tree/master/incubator/java-microprofile/README.md
    stack.appsody.dev/licenses: Apache-2.0
    stack.appsody.dev/revision: b54922e5ec56dbebb081b2267ba6a2ea33a88fdb
    stack.appsody.dev/source: https://github.com/appsody/stacks/tree/master/incubator/java-microprofile/image
    stack.appsody.dev/tag: dev.local/appsody/java-microprofile:0.2.24
    stack.appsody.dev/title: Eclipse MicroProfile®
    stack.appsody.dev/url: https://github.com/appsody/stacks/tree/master/incubator/java-microprofile
  creationTimestamp: "2020-03-26T14:09:48Z"
  generation: 2
  labels:
    app.kubernetes.io/part-of: test-mp
    image.opencontainers.org/title: test-mp
    stack.appsody.dev/id: java-microprofile
    stack.appsody.dev/version: 0.2.24
  name: test-mp
  namespace: default
  resourceVersion: "19426"
  selfLink: /apis/appsody.dev/v1beta1/namespaces/default/appsodyapplications/test-mp
  uid: 2e8fdd76-6861-4595-97b9-e413ff9410f9
spec:
  applicationImage: dev.local/test-mp
  applicationName: test-mp
  createKnativeService: true
  expose: true
  livenessProbe:
    failureThreshold: 12
    httpGet:
      path: /health/live
      port: 9080
    initialDelaySeconds: 5
    periodSeconds: 2
  pullPolicy: IfNotPresent
  readinessProbe:
    failureThreshold: 12
    httpGet:
      path: /health/ready
      port: 9080
    initialDelaySeconds: 5
    periodSeconds: 2
    timeoutSeconds: 1
  resourceConstraints: {}
  service:
    annotations:
      prometheus.io/scrape: "true"
    port: 9080
    type: NodePort
  stack: java-microprofile
  version: 1.0.0
status:
  conditions:
  - lastTransitionTime: "2020-03-26T14:09:48Z"
    lastUpdateTime: "2020-03-26T14:10:13Z"
    status: "True"
    type: DependenciesSatisfied
  - lastTransitionTime: "2020-03-26T14:09:49Z"
    lastUpdateTime: "2020-03-26T14:10:14Z"
    message: no matches for kind "Route" in version "route.openshift.io/v1"
    status: "False"
    type: Reconciled
  imageReference: dev.local/test-mp

A clear and concise description of what you expected to happen (or insert a code snippet).

Environment

Additional context

Add any other context about the problem here.

navidsh commented 4 years ago

This happens because before creating Knative Service, the operator cleans up non-Knative resources such as route, imagestream, deployment and etc. Since vanilla k8s, doesn't include OpenShift's specific resources, the client.delete call fails.

Workaround: Install route/imagestream CRDs (using oc apply -f ...) to pass the error: openshift-crds.zip

leochr commented 4 years ago

We discussed this in today's scrum and concluded that the operator should check whether the CRD is available on the environment before attempting to delete a the corresponding CR. Similar check is already done at creation time.

leochr commented 4 years ago

Fix was delivered into 0.5.0.