This document provides a step-by-step guide on deploying applications in a production environment using the Timoni framework. The process detailed here assumes familiarity with Kubernetes and the Timoni application lifecycle.

Overview

Timoni enables the management of application delivery using a declarative approach, facilitating deployments across multiple clusters. The bundle and runtime capabilities of Timoni allow for tailored configurations that can adapt to various environments, including production.

Set Up the Environment

  1. Install Necessary Tools: Ensure you have the following installed and correctly set up:

    • Go programming language (version 1.17+)
    • Timoni CLI
    • Kubernetes CLI (kubectl)
    • Access to a container registry

    You can verify your environment setup by running:

    go version
    timoni version
    kubectl version
    
  2. Clone the Repository: Clone the Timoni repository to get access to the example bundles and configurations.

    git clone https://github.com/stefanprodan/timoni.git
    cd timoni
    
  3. Makefile Commands: Utilize the provided Makefile for managing your project. Key commands include:

    • make tidy: Cleans and updates dependencies.
    • make build: Compiles the application.
    • make install: Installs the necessary dependencies for the environment.

Define Your Application Bundle

Create a bundle that encapsulates your application’s architecture. This bundle will include definitions for all necessary Kubernetes components such as Deployments, Services, and ConfigMaps. Below is an example of a bundle stored in a YAML file:

apiVersion: "v1alpha1"
name: "apps"
instances:
  app:
    module:
      url: "oci://ghcr.io/stefanprodan/modules/podinfo"
      namespace: "apps"
      values:
        ui:
          message: "Hosted by (_cluster)"
        replicas: 2  # Set for production environment

Deploying to Production

To deploy an application to production using the defined bundle, follow these steps:

  1. Define the Runtime: Create a runtime configuration that specifies how to deploy to your clusters.

    Example runtime.yaml:

    apiVersion: "v1alpha1"
    name: "my-runtime"
    instances:
      myapp:
        module:
          url: "oci://ghcr.io/stefanprodan/modules/podinfo" 
          namespace: "apps"
    
  2. Apply the Bundle: Use the Timoni CLI to apply your bundle to the production environment. The following command will handle the deployment across defined clusters.

    timoni bundle apply --runtime runtime.yaml --values values.yaml
    

    During the apply process, Timoni will iterate over each cluster defined in the runtime, deploying the specified modules and executing health checks.

  3. Monitor Deployment: Keep track of the deployment status using:

    timoni bundle status myapp
    
  4. Execute Health Checks: Once the application is deployed, run end-to-end tests to ensure everything is functioning correctly:

    timoni test myapp
    

Rollback and Uninstallation

If the deployment fails or requires a rollback, Timoni offers a straightforward way to revert the changes:

  1. Rollback to Previous Version: You can easily roll back to a previous version of your application:

    timoni bundle rollback myapp
    
  2. Uninstall the Application: When needed, you can uninstall your application from the production environment:

    timoni bundle delete myapp
    

Conclusion

The above guide outlines the essential steps for deploying your applications using Timoni in a production environment. Timoni offers a flexible and powerful approach to manage application lifecycles across multiple clusters, enhancing the delivery and operational efficiency of Kubernetes-based deployments.

For further details, refer to the Timoni documentation.