Hello dockerfile World
This is just a small PHP Hello World app that I use to quickly demonstrate dockerfile builds in Openshift.
The process
-
In the Developer Catalog select "From Dockerfile"
-
In the resulting dialog fill in this git repo url, the Dockerfile path, an application name for labeling, a name for resources, resource type DeploymentConfig, and create a route
-
[OPTIONAL] Add a pipeline if the option is available
-
Create the application
Note
|
The 'Application' and 'Name' fields may appear to be the same thing, but they are not. The 'Application' field creates labeling to group app resources. Specifically the app.kubernetes.io/part-of label in the DeploymentConfig. If you deploy a new app and give it the same 'Application' it will be part-of that application group.
|
The pipeline
You should see a 3 step pipeline if you added one. You will see the following steps
-
fetch-repository
-
build
-
deploy
The Service
In the Administrator perspective under 'Networking' or using the OC CLI you will see a new service
$ oc get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-dockerfile-world ClusterIP 172.30.123.220 <none> 8080/TCP 18m
Incidentally service names in OCP can be resolved by internal DNS.
<app-name>-<namespace>
Remembering that pods have limited applications, we have to use what is available to test the DNS resolution…
sh-4.4$ php -r 'echo gethostbyname("hello-dockerfile-world.hello-dockerfile-world");' 172.30.123.220
Note
|
The service name lookup resolved inside the pod to 172.30.123.220 which is what we see above from our OC client command
|
Internal DNS will always resolve service names this way.
The Route
In either the topology view in Developer mode or in the Networking section in Administrator view you can verify the application by clicking the route and opening it in a web browser.
The route will always be the same. It is always built with the following components: