Skip to main content
Gå til innhold

Example projects

We have created some example project for the Platon PaaS. These projects show how different applications can be deployed to the Platon PaaS. They also show how to use different functionality in the Platon PaaS platform.

Project README-files

Each project is documented using a README file in the project. The README file goes through the project and describes the contents of it. Click through to the project site at gitlab.sikt.no to see this file.

hello-world

The hello-world project serves as a minimal example. It deploys a simple static web page to the Platon PaaS Kubernetes cluster. It shows:

  • Creating a simple Docker container image.
  • Running the container on the Platon PaaS.
  • Setting up a GitLab CI/CD pipeline with review, staging and production environments.

hello-world-all-resources

This example is suitable for when you need to customize the resources (Ingress, Service and NetworkPolicy) that kubernetes-deploy usually create for you.

php-hello

The php-hello project serves as an example of a minimal PHP website. It deploys a simple PHP web page to the Platon PaaS Kubernetes cluster.

This project is heavily based on the hello-world project, but with some minimal adjustments to run a PHP application instead. It shows:

  • Running a simple PHP application using Apache in a container.
  • Configuring Apache to use correct client source IP address from the Platon PaaS ingress controllers.
  • Ensuring Apache generates correct redirects for the site.

python-hello

The python-hello project is an example of a minimal Python application. It deploys a simple Python microservice to the Platon PaaS Kubernetes cluster.

The application is implemented using the Flask web framework. To host the application, it uses the Gunicorn WSGI server.

This project reuses much of the GitLab CI/CD workflow and Kubernetes deployment configuration from the hello-world project, but is updated to run a Python application instead. It shows:

  • Building a Docker container image from a minimal Python project.
  • A minimal Python application using the Flask web framework.
  • Running a Python WSGI application using Gunicorn.
  • Using the ProxyFix WSGI middleware to access the client source IP address from the Platon PaaS ingress controllers.
  • Pinning Python package versions using requirements-frozen.txt.

python-django

The python-django project is an example of a more advanced Python application. It deploys a Django project to the Platon PaaS Kubernetes cluster.

It uses many of the techniques from the python-hello example, but adds the following:

  • Using Secrets in Kubernetes to store database credentials and other information.
  • Separate development databases for review and staging copies of the application.
  • A Docker Compose based development environment with a PostgreSQL database server running in a container.
  • Serving static files from a WSGI application (using WhiteNoise).
  • How to configure an application through environment variables.
  • Running database migrations when deploying new versions of the application.

cronjob-example

This project serves as a basic example of a Kubernetes CronJob resource which can be used for running periodic tasks.

python-metrics-hello

Example project deploying a Python application that show how custom app metrics can be used for alerts sent to Zabbix. It shows how to:

  • Instrument your application using the Python Prometheus client library
  • Expose the metrics to Prometheus using a ServiceMonitor Kubernetes resource
  • Create an alert using a PrometheusRule Kubernetes resource
  • Configure a host in Zabbix that the alerts will belong to

hello-world-kdk

KDK uses a python based deployment method based on cdk8s.io. It is an alternative to writing static manifest and is well suited if you have need for dynamic creation of resources.

hello-storage

Using Deployment

Example project:

The hello-storage-deployment project is an example of a simple application with persistent storage. It deploys a minimal static web page to the Platon PaaS Kubernetes cluster.

It shows:

  • How to deploy using Deployment, which is suitable when you have a single pod that uses one or more storage volumes
  • How to configure persistent storage using a PersistentVolumeClaim

Using Statefulset

warning

Note that Statefulsets does not deploy if the current running pod is in a failure state. The current pod must be manually deleted in this case with kubectl.

Example project:

The hello-storage-statefulset project is an example of a simple application with persistent storage. It deploys a minimal static web page to the Platon PaaS Kubernetes cluster.

It shows:

  • How to deploy using StatefulSet, which is suitable for stateful applications
  • How to configure persistent storage using volumeClaimTemplates

StatefulSets are valuable for applications that require one or more of the following.

  • Stable, unique network identifiers.
  • Stable, persistent storage.
  • Ordered, graceful deployment and scaling.
  • Ordered, automated rolling updates.

Using a Vault Agent

A Vault Agent can be used in an init container or as a sidecar to fetch secrets from vault.sikt.no and make them available for containers in a pod.

Example project: