Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Init Container Build Pattern: Knative build with plain old Kubernetes deployment

April 1, 2019
Kamesh Sampath
Related topics:
JavaContainersKubernetesQuarkus

    With Kubernetes evolving at supersonic speed and seeing a lot of adoption in the enterprise world, the developer community is now looking for solutions to common Kubernetes problems, such as patterns. In this article, I will explore a new Kubernetes pattern using Init Containers.

    Let's start with the use case that gave birth to this problem: Quarkus—Supersonic and Subatomic Java—has excited the Java developer community with its amazing speed and all new native build artifact for Java applications. As one of those excited developers, I want to quickly build and deploy a Quarkus application on to Kubernetes.

    Before we deploy the Quarkus application on Kubernetes, however, we need to solve the following problems:

    • How to build a container image natively on Kubernetes.
    • How to make the Kubernetes deployment wait for build image before deploying the application.

    Analyzing these problems, we see that they do not apply only to this use case. These are common issues for developers who want to build and deploy Java or other applications on Kubernetes.

    So, what is the solution?  Let's address them one by one:

    How to build a container image natively on Kubernetes

    At this point, Kubernetes does not provide any out-of-the-box way to build applications natively on Kubernetes, that is, something like kubectl build myapp. This made us look for something that can do a build on Kubernetes; fortunately, we have Knative Build that does the work for us.

    "What? Knative build? I'm not running a serverless application." That's a usual reaction from developers when we talk about Knative build. To be clear, Knative build is not just for the serverless world; it can be used with any Kubernetes cluster without the need for any other Knative components and Istio. With just Knative build installed in a Kubernetes cluster, the builds can be run to make Linux container images out of the given source code.

    How to make the Kubernetes deployment wait for build image before deploying the application

    The Kubernetes deployment has to wait for the build to complete before starting to deploy itself. The solution to this problem is to use Init Containers. Adding an init container to the Kubernetes deployment makes the pod’s containers start in a sequence based on the completion state of the previous container in the chain.

    If one of the init containers fails, then the whole deployment is deemed failed with the init container being restarted. The following diagram explains how the pattern works inside Kubernetes.

    Init Container Pattern

    For example, here is a Kubernetes deployment using init containers (see line #31-36):

    https://gist.github.com/kameshsampath/b219a1c8cb803233878cc8085426ab46

    You can find a complete end-to-end example here and instructions on how to get a Quarkus application built and deployed to your Kubernetes cluster. My colleagues Roland Huß and Bilgin Ibryam have written an excellent book, called Kubernetes Patterns, which explains many patterns that are applicable to everyday cloud-native application development.

    If you want to learn more about Knative basics, check out our multi-hour detailed Knative tutorial, which offers demonstrations and explains concepts in a simple and easy way.

    Last updated: September 23, 2019

    Recent Posts

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    • Control multicluster costs with right-sizing in Red Hat Advanced Cluster Management 5

    • Lightbits is now certified for Red Hat OpenStack Services on OpenShift

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI