Overview

Timoni, as a package manager for Kubernetes powered by the CUE language, can integrate with Continuous Integration and Continuous Deployment (CI/CD) systems to manage application delivery efficiently. This documentation outlines the CI/CD workflow for the Timoni project, detailing how to set it up using GitHub workflows for build, test, and deployment processes.

CI/CD Workflow Steps

  1. Build Artifacts

    To create a build artifact suitable for deployment, Timoni can generate OCI-compliant artifacts. Use the following command:

    timoni -n apps build podinfo oci://ghcr.io/stefanprodan/modules/podinfo \
    --values ./staging-values.cue | \
    flux push artifact oci://registry.internal/podinfo:staging \
    --source="http://github.com/stefanprodan/podinfo" \
    --revision="6.3.4" \
    --path=-
    

    Alternatively, you can use a Timoni bundle to build the manifests:

    timoni bundle build -f podinfo.cue | \
    flux push artifact oci://registry.internal/podinfo:staging \
    --source="http://github.com/stefanprodan/podinfo" \
    --revision="6.3.4" \
    --path=-
    

    These commands can be executed in the CI pipeline to automate the packaging of application versions.

  2. Testing Workflow

    A recommended practice is to run tests as part of the CI process. Although specific testing frameworks for Timoni are not provided, implementing a suitable testing procedure that leverages Kubernetes Jobs will be beneficial.

    Example command to run tests within your CI:

    make test
    

    This assumes you have defined a test target in your Makefile to execute your tests.

  3. Push to Container Registry

    After successful building and testing, push the artifact to the container registry. This process is exemplified in the previous commands where we used flux push artifact to push the generates OCI artifact to the specified URL in the container registry.

  4. Deployment and Reconciliation Using Flux

    Example configuration for GitOps with Flux to watch the container registry every minute:

    apiVersion: source.toolkit.fluxcd.io/v1beta2
    kind: OCIRepository
    metadata:
      name: podinfo
      namespace: flux-system
    spec:
      interval: 1m
      url: oci://registry.internal/podinfo
      ref:
        tag: staging
    

    The above configuration allows Flux to automatically reconcile changes found in the specified container registry. When an artifact is pushed to the registry, Flux will detect changes and deploy them onto the Kubernetes cluster.

  5. Maintainability with Makefile

    Utilize the included Makefile to manage your build, test, and deployment cycles easily. The Makefile includes targets such as tidy, docs, build, and others that can be invoked directly to streamline standard CI/CD operations.

    Command to invoke the Makefile:

    make all
    

Conclusion

This documentation provides a comprehensive guide to setting up a CI/CD workflow using Timoni with GitHub actions and Flux for Kubernetes deployments. Following these steps will ensure a robust and automated deployment cycle for your applications.

References

Feel free to integrate these recommendations into your CI/CD strategy to maximize the efficiency and reliability of your Kubernetes applications.