nerc-project / operations

Issues related to the operation of the NERC OpenShift environment
1 stars 0 forks source link

KNative Deployment Pipelines #597

Open cbolles opened 4 weeks ago

cbolles commented 4 weeks ago

Summary

I'd like the ability to re-deploy knative functions in OpenShift via git actions so that deployments don't depend on a single person. Currently, when creating a serverless function in the OpenShift UI, OpenShift generates a trigger annotation for redeploying from an ImageStream change, however, it does not seem like the knative services actually support integration with the ImageStream trigger.

From the Red Hat documentation below

https://docs.openshift.com/serverless/1.32/functions/serverless-functions-on-cluster-builds.html

Step 5 of "Building and deploying a function on the cluster" shows that redeployment should be handled via a Tekton pipeline. Trying to configure the pipeline based on that documentation produces the following error.

Error: failed to run generate pipeline: could not detect Pipelines as Code configmap on the cluster, please reinstall 

Would we be able to have the cluster configured so that KNative serverless deployments can be re-deployed via GitHub actions?

computate commented 3 weeks ago

Hello @cbolles , are your projects and Serverless resources you are trying to deploy in GitHub somewhere for me to test and reproduce?

cbolles commented 3 weeks ago

@computate

Sure! If you like you can check out this repo/package which needs a Mongo DB to connect to and just stores emails.

Alternatively any Knative starter project (potentially with an environment variable or two) would work for testing

computate commented 3 weeks ago

Here are some observations from my testing.

git clone git@github.com:computate/wage-gap-calculator.git
cd wage-gap-calculator/
git remote add upstream git@github.com:hicsail/wage-gap-calculator.git
git checkout -b cbolles
git pull upstream chore/cbolles/openshift-deploy
git push
cd packages/submit/

Should deploy like this:

(python) [ctate@tower1 submit]$ kn func deploy --remote
Creating Pipeline resourcesRunning Pipeline Task: Building function image on the cluster
E0604 11:49:20.046001 3598456 v2.go:150] use of closed network connection
Running Pipeline Task: Deploying function to the cluster
✅ Function deployed in namespace "christophertate-dev" and exposed at URL: 
   https://submit-christophertate-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com

Actual deployment on NERC asks for credentials to the image registry.

(python) [ctate@tower1 submit]$ kn func deploy --remote
Creating Pipeline resourcesPlease provide credentials for image registry (image-registry.openshift-image-registry.svc:5000).
? Username: E0604 11:57:35.692539 3601377 v2.go:150] use of closed network connection
X Sorry, your reply was invalid: Value is required

@cbolles did you get asked for credentials to the image registry? I am able to successfully deploy your wage-gap-calculator submit function in NERC OpenShift by providing a registry and an image in an external registry like quay.io to work around the internal OpenShift image registry that it looks like users don't have push access to.

(python) [ctate@tower1 submit]$ kn func deploy --remote -r quay.io/computate -i quay.io/computate/wage-gap-calculator-submit
Creating Pipeline resources
Please provide credentials for image registry (quay.io).
? Username: computate
? Password: ****************
Credentials will not be saved.
If you would like to save your credentials in the future,
you can install docker credential helper https://github.com/docker/docker-credential-helpers.
Running Pipeline Task: Building function image on the cluster
Running Pipeline Task: Deploying function to the cluster
✅ Function updated in namespace "smart-village-faeeb6c" and exposed at URL: 
   https://submit-smart-village-faeeb6c.apps.shift.nerc.mghpcc.org
cbolles commented 3 weeks ago

I have been deploying the serverless components from within OpenShift itself either via

Developer > Add > Create Serverless Function

Or by manually deploying the YAML (under packages/submit/deploy/deploy.yaml).

That way you shouldn't be pestered about the image registry issue.

computate commented 3 weeks ago

Thanks for the feedback @cbolles . I am able to reproduce the error in 2 places, both NERC and the Red Hat OpenShift Developer Sandbox:

kn func config git set -n smart-village-faeeb6c
Error: failed to run generate pipeline: could not detect Pipelines as Code configmap on the cluster, please reinstall

There seems to be a TektonConfig in NERC as suggested in the Pipelines As Code docs. I'll probably create a Red Hat Support case to see what the problem is.

computate commented 3 weeks ago

@cbolles Red Hat support has verified that this is currently a bug in the Serverless+Pipelines product for non-admin users, and they will be looking into it. I created a Red Hat Support case to track the issue: https://access.redhat.com/support/cases/#/case/03839981

hpdempsey commented 3 weeks ago

On Wed, Jun 5, 2024 at 2:02 PM Christopher Tate @.***> wrote:

@cbolles https://github.com/cbolles Red Hat support has verified that this is currently a bug in the Serverless+Pipelines product for non-admin users, and they will be looking into it. I created a Red Hat Support case to track the issue: https://access.redhat.com/support/cases/#/case/03839981

Do you think this is likely to be addressed? If not, can we substitute one of our more standard ways of deploying services in NERC? I'm not clear on the use case here, so I'm not sure the extent to which it needs to be dynamic.

— Reply to this email directly, view it on GitHub https://github.com/nerc-project/operations/issues/597#issuecomment-2150646534, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGMIEPWZ5SM67WA3NXHAJTZF5HCTAVCNFSM6AAAAABIRGEPAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJQGY2DMNJTGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

computate commented 3 weeks ago

@hpdempsey I'm working with the RH engineers in knative-functions Slack on this issue, and they suggest they may have an idea how to fix this in the cluster, before a permanent fix in the product is available.

computate commented 3 weeks ago

@hpdempsey @cbolles A fix for this has just been made upstream, possibly for the next release of the Serverless Operator.

hpdempsey commented 2 weeks ago

On Thu, Jun 6, 2024 at 12:08 PM Christopher Tate @.***> wrote:

@hpdempsey https://github.com/hpdempsey @cbolles https://github.com/cbolles A fix for this https://github.com/openshift-knative/kn-plugin-func/pull/783/files has just been made upstream, possibly for the next release of the Serverless Operator.

Is this the same fix you were talking about earlier? When is the next release of the Serverless Operator happening?

— Reply to this email directly, view it on GitHub https://github.com/nerc-project/operations/issues/597#issuecomment-2152900832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGMIEIX3VHLL5GTTY6MZVDZGCCQFAVCNFSM6AAAAABIRGEPAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJSHEYDAOBTGI . You are receiving this because you were mentioned.Message ID: @.***>

computate commented 1 day ago

I got an update today that Red Hat engineering changed the issue from New to Release Pending, so it looks like they are preparing the fix for an upcoming release. I don't have information about the release schedule yet.