How install openfaas on openshift? - openshift

I try to install OpenFaaS on OpenShift.
What I do :
I clone "https://github.com/openfaas/faas-netes"
I build the dockerfile. (docker build .)
I tag and push the image on my docker hub repository
In Openshift, I deploy this image and I create a route. But the route does not run... I try kubectl in pod terminal but command does not exist.
Any ideas?

Related

How do I build a custom Docker image that installs MySQL and configure Jib to use it as the base image for my Java Application?

Docker newbie here. I'm trying to mount a docker image of my Java App made with Jib on GCE, and hook it up to CloudSQL. However, because GCE makes the docker image use a Container-Optimized boot disk, when I SSH into the instance to try to hook it up to MySQL, I can't install mysql due to 'apt-get not found'.
I read that I could "build a custom image and configure Jib to use it as the base image" in order to have access to apt-get, but I can't seem to find any resources on how to do this.
I tried going the alpine jdk route + using apk instead of apt-get, but someone told me not to use alpine jdk as I will run into problems later.
I already have this set up in my build.gradle:
jib {
from {
image = 'order-routing-helper-image'
}
to {
image = 'gcr.io/myimage'
}
}
EDIT: DOCKERFILE:
FROM openjdk:11
VOLUME /tmp
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","com.mygroup.myapp.OrderRoutingApplication"]
but I don't have a order-routing-helper-image anywhere, I just know I need that line.
If I run gradle jib, and then mount the new image on GCE and SSH into it, I am able to run "sudo apt-get install mysql-client". Right now I'm getting "apt-get: not found".
To add MySQL in Docker image, you to run the update first then add MySQL.
FROM openjdk:11
VOLUME /tmp
RUN apt update && apt install mysql-server -y
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","com.mygroup.myapp.OrderRoutingApplication"]

Procedure to install an Ingress controller

Unable to install ingress-nginx for kubernetes on Docker desktop
I was using the following in cmd line to install ingress nginx so far:
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/cloud-generic.yaml
as shown in the web page: https://che.eclipse.org/running-eclipse-che-on-kubernetes-using-docker-desktop-for-mac-5d972ed511e1
I seems like the installatio procedure has changed. Can anyone let me know step by step instructions to install ingress-nginx? I coudnt install it by following the procedure described here: https://github.com/kubernetes/ingress-nginx/blob/master/docs/deploy/index.md
Installation via helm works perfectly for me. Assuming you have kubectl binary installed and configured to use for your k8s cluster you can follow below steps one by one to achieve installation of nginx-ingress controller
1.Install helm binary (if doesn't exist)
curl -s https://raw.githubusercontent.com/nurlanf/deployments-kubernetes/master/helm/get_helm.sh | bash
2.Install helm for your cluster (if not installed yet)
curl -s https://raw.githubusercontent.com/nurlanf/deployments-kubernetes/master/helm/install.sh | bash
You should see output like
...
Waiting for tiller install...
Helm install complete
3.Then install nginx-ingress via helm
helm install stable/nginx-ingress --name nginx-ingress

to deploy docker on apache2 server

I have my html application that runs in apache2 server and I want to dockerize the html application that should be run in docker container using apache2 package. I tried but got docker build failed. I dont want to use nginx server help me with apache.
Here is the following Dockerfile content in html application
FROM apache2:2.4.18
WORKDIR /var/www/html/startapp
COPY . /var/www/docker
Then I tried to build this with docker using
sudo docker build -t startapp .
It returns:
Sending build context to Docker daemon 335.6MB
Step 1/3 : FROM apache2:2.4.18
pull access denied for apache2, repository does not exist or may require 'docker login'
If its not possible with apache2 so there is change to build by lampp server in ubuntu 16.0.4.
Try replacing the base image (the one that you are using is not available as on default docker registry).
FROM httpd:2.4
Take a look at https://hub.docker.com/_/httpd/ for more information.
It seems like you are trying to use a non-official docker image for Apache, So either you build apache2 image using its Dockerfile if you have it. Or you can login to the private repository that holds apache2 image if you have its credentials. Otherwise you may use the official Apache docker image

How to link two containers for a Jenkins Job?

I have configured my Jenkins to run our Build Jobs and functional Tests in a docker container. For example, when I click on the "Build Now"-Button - Jenkins will build the Dockerfile which is in Git and run the container so the Buildsteps (Jenkinsfile) can be done in this container.
My Question is now: How can I start another Container with MySQL-Server installed and link them to my Build-Job-Container everytime I Build my Job.
Thanks for any tips.
one can use service discovery aka Consul as IPs in docker networks are granted dynamicaly. Or use static ip
docker run --net bridge --ip 172.17.0.254 -it ubuntu bash

Openshift new-app from local Docker image

I'm trying to deploy on an Openshift Origin Pod an image which is available in my Docker repository:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat9demo latest 535da1774da0 9 weeks ago 350.2 MB
When running:
$ oc new-app tomcat9demo --name tomcatdemo
Apparently it seems to find the image from the Docker repository:
--> Found Docker image 535da17 (9 weeks old) from for "tomcat9demo:latest"
* This image will be deployed in deployment config "tomcat9demo"
* Port 8080/tcp will be load balanced by service "tomcat9demo"
* Other containers can access this service through the hostname "tomcat9demo"
* WARNING: Image "tomcat9demo:latest" runs as the 'root' user which may not be permitted by your cluster administrator
--> Creating resources with label app=tomcat9demo ...
deploymentconfig "tomcat9demo" created
service "tomcat9demo" created
--> Success
However the status shows an error. It seems there's an error with the image pull:
$ oc get pods
NAME READY STATUS RESTARTS AGE
tomcat9demo-1-zrj98 0/1 ErrImagePull 0 16s
$ oc status
Error from server: the server could not find the requested resource
Do I need something else to grab the image from my local Docker repository ?
You need to specify the option --docker-image for it to point to your local image repo. Example:
oc new-app tomcat9demo --docker-image tomcat9demo
You should add a tag to the local docker image.
docker build -t image_name .
docker tag image_name:<current tag ot just a latest> image_name:<new tag>
oc new-app mage_name:<new tag> --name=app_name
And you should see:
Found Docker image <your docker image id> (19 minutes old) from for "image_name:<new tag>"
Refer to this awesome youtube video, I was able to successfully deploy my local docker image onto the dedicated openshift platform's docker registry with the help of this:
Push local docker images to openshift registry - minishift
Hope it helps.