Skip to content

Latest commit

 

History

History
43 lines (26 loc) · 2.16 KB

kubernetes-putting-everything-together.md

File metadata and controls

43 lines (26 loc) · 2.16 KB

Putting everything together

end goal

Tasks

  • Create a Deployment, e.g. of a webserver consisting of two Pods.

  • Expose your deployment to the internet.

  • Add some content to the webserver.

  • Add a Liveness probe for the Apache webserver deployment.

OpenShift Notes

  • 💡 Use registry.redhat.io/ubi8/httpd-24 instead of httpd because of security constraints (user ids and ports).
  • Have a look at the page returned by httpd (tip: you can oc port-forward deployment/httpd 8080:8080).
  • 💡 Health checks will fail with this httpd's default configuration until you add your own content; you can inspect the config using oc exec -it <podname> -- cat /etc/httpd/conf.d/welcome.conf. If you're not familiar with apache configs: it will return a static test page with a HTTP error code 403 if the requested file is not found at /var/www/html/; the default page is defined as index.html.
  • We will add content to /var/www/html in a second, so the fallback configuration to the test page will not be used anymore.

Store the website on a PersistentVolume

Store the website on a PersistentVolume shared by the Pods of the Deployment. The Apache webserver serves content from /var/www/html.

💡 kubectl cp can be used to copy files to containers.

💡 Use kubectl cp -h for help & examples on how to use it.

Health Checks

Add a liveness probe to the deployment. See the example from the presentation demo.

Route

If you're operating on an OpenShift Cluster, you should add routes instead of ingress resources.

  • Create a ClusterIP Service for the apache webserver deployment
  • Expose the service to the internet; either by
    • creating an ingress resource (consult the ingress guide for help), or
    • an edge-terminated route exposing the service, see OpenShift Routes for the official documentation.

💡 If you don't provide a hostname to the route, it will be autogenerated based on project and app name.