Skip to main content
Redhat Developers  Logo
  • 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 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

    • OpenShift AI learning
    • 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.
    • Explore the solution
  • 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

    • Access product downloads to start building and testing right away.
    • 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.
    • Explore the benefits

That app you love, part 8: A blueprint for "that app you love"

October 20, 2016
N. Harrison Ripps
Related topics:
ContainersDeveloper toolsKubernetesMicroservices
Related products:
Red Hat OpenShift Container Platform

    Welcome to the eighth installment of That App You Love, a blog series in which I show you how to you can make almost any app into a first-class cloud citizen. If you want to start from the beginning, jump back and check out Part 1: Making a Connection. You’ll need the docker service and the oc utility to follow along in this post; for instructions check out Part 5: Upping Our (Cloud) Game.

    In Part 7 we learned how to expose container-level environment variables up at the cloud level, and we also got our first taste of Templates and Deployments. Crafting a Template for our ZNC container image that defines those environment variables - and the rules for setting them - is a major step in improving the app’s reusability and basic security. But forget about ZNC because we’re really talking about That App You Love, and what it takes to make it rock the cloud!

    Templates and Parameters: Process, Load, Win!

    By the end of Part 7, we had added 3 environment variables to the Deployment object of our app. The values of those variables were hard-coded, and the password was very easy to guess. If we made a template that included those variables with those values, there’s a good chance that everyone who used that template would end up creating an app deployment with the same username and password. That’s bad.

    Luckily, OpenShift templates support a set of rules, called Parameters, for describing how variables should be populated. Parameters are processed at the time when the objects in the template are created, meaning that every use of a template can result in different settings.

    To see what I mean, try this out:

    1. If you are still running “oc cluster up” from Part 7, it is easiest to start with a clean slate, so run:
      sudo <path_to>/oc cluster down; sudo <path_to>/oc cluster up
      oc login -u developer -p developer --server=<server_IP>:8443

      (If you don’t have a docker environment and the “oc” binary yet, jump back to Part 5 and then come back when your cluster is running.)

    2. Let’s grab a new version of our app template, using wget or curl:
      wget https://raw.githubusercontent.com/nhr/znc-cluster-app/master/znc-template-with-params.yaml
      
    3. Next, process and load the template with this combo-command:
      oc process -v ZNC_USER=clouduser,ZNC_NAME=CloudUser -f znc-template-with-params.yaml | oc create -f -
      
    4. And finally, kick off the Deployment object that we just created:
      oc deploy dc/znc-cluster-app --latest

    Cool right? Ah - except what actually happened?

    Rules of Engagement

    Have a look at the environment variables inside the Deployment object with this command:

    oc get dc/znc-cluster-app -o yaml | sed -n -e '/env:/,$p' | head -7

    You should get output like:

         - env:
            - name: ZNC_USER
              value: clouduser
            - name: ZNC_PASS
              value: F8fpyfBYFl2pBhGq
            - name: ZNC_NAME
              value: CloudUser

    (Note that you can also see these by inspecting the Deployment object from your OpenShift console - navigate to Applications => Deployments => znc-cluster-app and click the Environment tab.)

    The ‘clouduser’ and ‘CloudUser’ values are familiar because we passed them in, but where did that crazy password come from?

    Let’s go back and have a look at that template file we are working with, using this command:

    cat znc-template-with-params.yaml | tail -13

    You should see the wiring behind the boards, which looks like this:

    parameters:
      - name: ZNC_NAME
        description: The display name for the first ZNC user account
        value: Administrator
        required: true
      - name: ZNC_USER
        description: The username for the first ZNC user account
        value: admin
        required: true
      - name: ZNC_PASS
        description: The password for the first ZNC user account
        generate: expression
        from: "[a-zA-Z0-9]{16}"

    Recall that we processed and loaded this template with a combination of two commands (above, in step 3):

    • oc process reads a template and dynamically replaces placeholders with values that can be provided, generated, or defaulted. In our case we replaced ZNC_NAME and ZNC_USER with our own values. “oc process” then transforms the contents of the template into JSON representations of actual objects.
    • oc create reads a file and creates one or more objects in the cluster based on the contents of the file.

    Net result: because we’ve mapped these parameters to the values of the environment variables defined in our Deployment, every time anyone processes our template, a different password is going to get generated. Now we can share this template and enable people to deploy That App You Love without creating a basic, widespread security problem.

    Whack-a-Pod

    For our last trick today, it is useful to understand that while the template now provides us basic security (which we can upon), the OpenShift cluster itself is also providing us with a fair measure of robustness. Check this out:

    1. Find the name of your running ZNC pod:
      oc get pods

      (It will be something like “znc-cluster-app-1-1yb3d”)

    2. Kill the pod with “oc delete”
      oc delete pod <pod_name>
      
    3. Re-list the pods on the cluster:
      oc get pods

    If you run step #3 fast enough, you may catch the cluster with output like this:

    NAME                      READY     STATUS              RESTARTS
    znc-cluster-app-1-1yb3d   1/1       Terminating         0
    znc-cluster-app-1-vae7x   0/1       ContainerCreating   0

    The pod you deleted is briefly in Terminating state, meanwhile a brand new copy of the pod is already spinning up.

    Why did this happen? Another component of the application that was created when we first ran “oc new-app” is a ReplicationController, or ‘rc’. The rc’s job is to make sure that the cluster is always running our desired number of app copies (which is 1 in our case).

    If you play around with the new copy of your pod, you’ll find that it starts with the same settings as the previous one, and any changes you may have made to the original Pod are lost. It’s time to tackle that last challenge of cloud deployments - in the next post we’ll learn how to use attached storage to bring statefulness to the stateless environment of That App You Love!

    See you next time in Part 9: Storage and Statefulness!

    This series will run every Tuesday and Thursday until we've accomplished our goals, so stay tuned in, subscribe, and thanks for reading!

    Title Date
    That app you love, part 1: Making a connection 2016/09/27
    That app you love, part 2: Immutable but flexible – What settings matter? 2016/09/29
    That app you love, part 3: Every setting in its place 2016/10/04
    That app you love, part 4: Designing a config-and-run container 2016/10/06
    That app you love, part 5: Upping our (cloud) game 2016/10/11
    That app you love, part 6: Container, meet cloud 2016/10/13
    That app you love, part 7: Wired for sound 2016/10/18
    That app you love, part 8: A blueprint for “that app you love” 2016/10/20
    That app you love, part 9: Storage and statefulness 2016/10/25
    That app you love, part 10: Long live “that app you love” 2016/10/27

     

    About the Author

    Hi there! My name is N. Harrison Ripps, and I am an engineer and people manager on the Containers team at Red Hat. Together with the greater open source community, our team has taken the combination of the docker container format and Google’s Kubernetes orchestration system, and then extended this framework with a number of administrator- and developer-friendly features that we call the OpenShift Container Platform.

    Last updated: March 17, 2023

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    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

    Chat Support

    Please log in with your Red Hat account to access chat support.