Openshift: Simplest way to create an ImageStream from a github project - openshift

I have a project which is available on github. I can actually add a new Java Enterprise app based on this project and have the ImageStream available:
$ oc new-app https://github.com/ocpuser/ocpdemos.git --image-stream="openshift/wildfly:latest"
$ oc get is
NAME DOCKER REPO TAGS UPDATED
javaeedemo 172.30.1.1:5000/myproject/javaeedemo
However, what is the simplest way to create just the ImageStream (without adding a new app)? My purpose is to add the ImageStream to the internal repository so that I can use it in Openshift Operators requiring it.
Thanks

Related

github action on new release build docker container

I'm new to github actions and trying to automate creating a docker container when I create a release.
Ideally when I create a new release in github I want it to :
compile the typescript (package.json "build" script)
build the docker image (from existing docker file)
push it to the git hub container repository
I'm using a monorepo with multiple projects and package.json / docker files so I'll want to have a workflow for each and I'm assuming some
I have a secret called ENV_FILE which has my env variables.
Ideally when I create a release I want my docker output to reflect this version.
I've found various bits and pieces but struggling to put it all together.

Run docker container on OpenShift from Nexus unsecure private registry

I'm trying to run a containerized app which is stored in Nexus docker hosted on url 12.23.34.55:8086
I'm trying to run it on my Openshift Cluster, but I'm getting error. Commands I'm using to run
oc create secret docker-registry mysecret --docker-server=http://12.23.34.55/ --docker-username=aditya --docker-password=aditya --docker-email=aditya#example.org
oc secrets link default mysecret --for=pull
My nexus is running on http://12.23.34.55:8081
Now I'm using command to launch in OpenShift using below command.
oc new-app 12.23.34.55:8085/mytestapp:11 --insecure-registry=true
as per $ oc new-app myregistry:5000/example/myimage
https://docs.openshift.com/container-platform/4.1/applications/application_life_cycle_management/creating-new-applications.html
But it does not work, it asks for password and not able to deploy from console too, can anyone help me with exact commmand.
Creating the secret is not enough for OpenShift to be able to pull from the registry. You still need to link that secret as well.
Take a look at the official documentation here:
https://docs.openshift.com/container-platform/4.1/openshift_images/managing_images/using-image-pull-secrets.html#images-allow-pods-to-reference-images-from-secure-registries_using-image-pull-secrets
Okay! I found an answer, so using private registry first we should import image using
oc import name url/imagename:tag
then we can create new app with the same
oc new app name

How can I specify Dockerfile build in buildConfig for OpenShift Online?

Openshfit details:
Paid Professional version.
Version Information:
Been trying to create a build from a Dockerfile in Openshift.
Its tough going.
So I tried to use the existing templates in the Cluster Console.
One of which is the Docker one. When i press "Try it" it generates a sample BuildConfig, when I try to then Create it, it gives me the error:
(i have now raised the above in the Origin upstream issue tracker)
Anyhoo...anyone know how to specify a buildConfig an image from a Dockerfile in a git repo? I would be grateful to know.
You can see the build strategies allowed for OpenShift Online on the product website: https://www.openshift.com/products/online. Dockerfile build isn't deprecated, it's just explicitly disallowed in OpenShift Online. You can build your Dockerfile locally and push it directly to the OpenShift internal registry (commands for docker login and docker push are on your cluster's About page).
However, in other environments (not OpenShift Online), you can specify a Dockerfile build as follows and providing a Git Repo with a Dockerfile contained within (located at BuildConfig.spec.source.contextDir)
strategy:
type: Docker
There are additional options that can be configured for a Dockerfile build as well, outlined in https://docs.okd.io/latest/dev_guide/builds/build_strategies.html#docker-strategy-options.

Redeploy Openshift Application when Docker Hub Image Changes?

Is there a way to trigger a re-deploy when I push an image to docker hub? I used S2I to build an image, put it up on docker hub, and did a deployment from there. How can I trigger a new deployment when I push a new image to docker hub?
Perhaps there is a better way? I created a wildfly image with the changes to the standalone.xml I needed. Then I used S2I to build my local source into a runnable wildfly application image, which is what I pushed and deployed. I'm trying to get around having to go through a github repository.
I'm thinking I could create an application with the customer wildfly image that I created and use the direct from IDE option to the application, but what if I want to use the command line?
You can set a scheduled flag on the image stream to have a remote registry periodically polled. This will only work though if the OpenShift cluster has been configured globally to allow that. If using OpenShift Online I don't believe that feature is enabled.
https://docs.openshift.com/container-platform/latest/dev_guide/managing_images.html#importing-tag-and-image-metadata
If you want to avoid using a Git repository, you can use a binary input build instead. This allows you to push files direct from your local computer. This means you can compile binary artifacts locally and push them into the S2I build done by OpenShift.
https://docs.openshift.com/container-platform/latest/dev_guide/builds/build_inputs.html#binary-source

Is it possible to change the primary cartridge in an OpenShift application?

I've created Tomcat7 application on openshift but now I want to change it to JBoss Application Server 7. Is it possible without recreating app (delete T7 and then create JB AS 7)?
Unfortunately no, you will have to delete your gear and redeploy with a JBoss Application Server cartridge. However the war files shouldn't need to be altered.
It should be noted that you can archive the app's deployments and deploy the resulting artifact to another application. So, for your use case, you would:
Create an archive of your current application using rhc snapshot save --deployment (passing -a <app name> if not in that application's git repo directory).
Create a new application of the desired type.
Deploy the archive created in step 1 to the new application using rhc deploy --ref <path to archive> (passing -a <app name> if not in that application's git repo direcory).
You could use this approach to test your app on another flavor of JBoss.