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

Bind services created with AWS Controllers for Kubernetes

September 21, 2022
Baiju Muthukadan
Related topics:
Automation and managementKubernetesOperators
Related products:
Developer ToolsetRed Hat OpenShift Service on AWSRed Hat OpenShiftRed Hat OpenShift Container Platform

    Application developers can define Amazon Web Services (AWS) resources directly from Kubernetes using AWS Controllers for Kubernetes (ACK). You can use the Service Binding Operator to easily connect applications to any AWS service provisioned through ACK.

    This article explores the connection with an RDS database and demonstrates configuring ACK to create a service instance for the AWS Relational Database Service (RDS). You can also learn how to use Service Binding Operator annotations to bind a PostgreSQL service created using RDS and a REST API.

    Benefits of the Service Binding Operator and AWS Controllers for Kubernetes 

    One benefit of the Service Binding Operator and ACK is that they streamline the formation of a connection. The Service Binding Operator implements the Service Binding specification for Kubernetes. This is a Kubernetes-wide specification for automating the process of service secrets communicating to workloads.

    Another benefit of using the Service Binding Operator is that the only focus of applications with many microservices (maybe hundreds of them) is setting the correct label to receive binding data from the services specified by Service Binding Operator resources using the label selector.

    The Service Binding Operator supports the following methods to obtain connection details from a service:

    • Provisioned Service
    • Direct Secret Reference
    • Annotations

    Currently, ACK does not support the Provisioned Service method. And no single secret contains all the connection details. In such a scenario, you can use the annotation support provided by the Service Binding Operator and add this annotation to a Custom Resource (CR) or Custom Resource Definition (CRD).

    The following articles offer more information about ACK, including where the ACK project came from, why the Operator pattern is used, and how to configure and use ACK:

    • How to use Operators with AWS Controllers for Kubernetes
    • Create AWS resources with Kubernetes and Operators

    Step 1:  Prerequisites setup

    The prerequisites for this demonstration are pretty simple. You must have an AWS account and a Red Hat OpenShift cluster with the Service Binding Operator installed.

    AWS account permissions

    Your AWS account must have the IAM role permissions for the Amazon Relational Database Service (RDS) ACK controller. The policy required for RDS is:

    arn:aws:iam::aws:policy/AmazonRDSFullAccess

    OpenShift cluster with the Service Binding Operator

    You need administrator access to an OpenShift cluster. To install the Sevice Binding Operator, create a subscription similar to this example:

    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: my-service-binding-operator
      namespace: openshift-operators
    spec:
      channel: stable
      name: rh-service-binding-operator
      source: redhat-operators
      sourceNamespace: openshift-marketplace

    For example, place this configuration in a file named subscription.yaml. Then use the following oc command to create the resource:

    $ oc apply -f subscription.yaml

    Alternatively, you can install the Service Binding Operator from OperatorHub using the OpenShift administrator console.

    Step 2:  Install the RDS Operator in an OpenShift cluster

    These four steps use the ACK Operator to install the RDS database. The official documentation shows detailed information about configuring ACK in an OpenShift cluster.

    1. Create a namespace

    The following example uses a namespace called ack-system:

    $ oc new-project ack-system

    This is the output you should see:

    Now using project "ack-system" on server "https://example.org:6443".
    ...

    2. Create a config map

    Create a config map with the following content in a config.txt file:

    ACK_ENABLE_DEVELOPMENT_LOGGING=true
    ACK_LOG_LEVEL=debug
    ACK_WATCH_NAMESPACE=
    AWS_REGION=us-west-2
    AWS_ENDPOINT_URL=
    ACK_RESOURCE_TAGS=hellofromocp

    Use this config map in your OpenShift cluster as follows:

    $ oc create configmap --namespace ack-system \
    --from-env-file=config.txt ack-rds-user-config
    

    3. Create a secret

    Save the following authentication values in a file, such as secrets.txt:

    AWS_ACCESS_KEY_ID=<access key id>
    AWS_SECRET_ACCESS_KEY=<secret access key>

    Use this secrets.txt file to create a secret in your OpenShift cluster as follows:

    $ oc create secret generic \
    --namespace ack-system \
    --from-env-file=secrets.txt ack-rds-user-secrets

    Note: Be sure to secure access to this resource and the namespace because you will keep sensitive information in this secret—your AWS Access Key ID and AWS Secret Access Key.

    Alternatively, you can set up secure access using IAM Roles for Service Accounts (IRSA).

    4. Install the relational database service

    Refer to the article How to get Operators to use AWS Controllers for Kubernetes for ACK RDS controller installation instructions. After successful installation, this page (Figure 1) appears in the administrator console.

    This page appears in the OpenShift administrator console after installation.
    Figure 1: After the ACK RDS controller is installed, this page appears in the OpenShift administrator console.

    Step 3:  The consumption of annotations and label selectors

    To enable binding, the Service Binding Operator uses the following annotations that are part of the DBInstance resource in a Helm chart:

    apiVersion: rds.services.k8s.aws/v1alpha1
    kind: DBInstance
    metadata:
      annotations:
        "service.binding/type": "path={.spec.engine}"
        "service.binding/provider": "aws"
        "service.binding/host": "path={.status.endpoint.address}"
        "service.binding/port": "path={.status.endpoint.port}"
        "service.binding/username": "path={.spec.masterUsername}"
        "service.binding/password": 'path={.spec.masterUserPassword.name},objectType=Secret,sourceKey=password'
        "service.binding/database": "path={.spec.engine}"
    ...

    The DBInstance definition represents an AWS RDS resource.

    To define the workload, the Service Binding Operator uses the following label selector (part of the ServiceBinding resource in the Helm chart):

    apiVersion: binding.operators.coreos.com/v1alpha1
    kind: ServiceBinding
    metadata:
      name: servicebinding-rds-endpoint-demo
    spec:
      bindAsFiles: true
      services:
        - group: rds.services.k8s.aws
          version: v1alpha1
          kind: DBInstance
          name: {{ .Values.dbinstance.name }}
      application:
        labelSelector:
          matchLabels:
            psql.provider: aws (*)
        version: v1
        group: apps
        resource: deployments

    (*) This line specifies the label that the Service Binding Operator uses to identify the workload.

    The Helm charts are available in the app-services-samples repository.

    We have not deployed the application yet. Typically, the ServiceBinding controller waits for a workload resource with a matching psql.provider: aws label. As soon as a workload resource is available with the matching label, the Operator uses the ServiceBinding controller to project the binding values to the workload.

    The binding values projects into the /bindings directory inside the container of the workload resource. The following directory structure stores the values:

    /bindings
    └── servicebinding-rds-endpoint-demo
        ├── type
        ├── database
        ├── host
        ├── username
        └── password

    The REST API application uses a suitable and compliant library to consume the projected binding values.

    Step 4:  Create a database instance

    After you clone the app-services-samples repository described in the previous section, change to the openshift-app-services-demos/samples/sbo/ack-rds-blog directory to perform these two steps:

    1. Run Helm on the rds-postgre-chart-demo chart:

    $ helm install rds-postgre-chart-demo -n ack-system rds-postgre-chart-demo

    This is the output you should see:

    NAME: rds-postgre-chart-demo
    LAST DEPLOYED: Thu Aug  4 09:29:26 2022
    NAMESPACE: ack-system
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None

    2. Run the following command to validate the database instance:

    $ kubectl get dbinstance rds-test-demo -n ack-system -o=jsonpath='{.status.dbInstanceStatus}'

    Output:

    available

    Now the database is ready to use.

    Step 5:  Deploy the REST API application

    In this demo, we use the Software Security Module (SSM), a Go-based REST API application. For convenience, deploy the application using the Helm chart in the app-services-samples repository. After you clone the repository, perform the following steps from the openshift-app-services-demos/samples/sbo/ack-rds-blog directory.

    1. Run Helm on the ssm-chart chart:

    $ helm install ssm-chart -n ack-system ssm-chart

    Output:

    NAME: ssm-chart
    LAST DEPLOYED: Thu Aug  4 04:22:24 2022
    NAMESPACE: ack-system
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None

    2. Verify that the deployment of the REST API application is successful by running:

    $ kubectl get deployment -n ack-system

    Output:

    NAME                 READY   UP-TO-DATE   AVAILABLE   AGE
    ack-rds-controller   1/1     1            1           28m

    The deployment is defined as follows in the Helm chart:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: {{ .Values.k8Name }}
      annotations:
          app.kubernetes.io/part-of: ssm
      labels:
          psql.provider: aws (*)
    ...

    (*) This line specifies the required matching label that the ServiceBinding controller uses to identify the workload and project the bindings.

    The ServiceBinding controller watches for a deployment matching the label. After the deployment is ready, the Operator uses the ServiceBinding controller to project the binding values to the workload.

    Step 6:  Access and validate the REST API application

    The ssm-chart Helm chart also creates an ssm service resource for convenient access to the application. The ssm service resource points to the REST API application. Before connecting to this application, make sure you have the DBInstance resource created and ready with an RDS instance provisioned in the AWS.

    Switch to another terminal to run the commands in the following steps.

    1. Access the REST API application by forwarding the port of the service

    An oc command on OpenShift is useful for port forwarding:

    $ oc port-forward --address 0.0.0.0 svc/ssm 8080:8080 -n ack-system

    2. Validate the application

    Validate that the application works as follows:

    Generate a based64-encoded string

    Start by creating a string from random input:

    $ openssl rand 32 | base64

    This output contains the string you will use as input in the next step.:

    rgeR0ENzlxG+Erss6tw0gBkBWdLOPrQhEFQpH8O5t/Y=

     

    Call the wrap API

    Call the application's wrap API to create a cipher from the string by using the based64-encoded string from the previous step as input when calling the wrap API:

    $ curl http://localhost:8080/wrap -d '{"key": "rgeR0ENzlxG+Erss6tw0gBkBWdLOPrQhEFQpH8O5t/Y="}'

    This output contains the cipher string you will use as input in the next step:

    {"cipher":"D/S6wDJPH ... "}

     

    Call the unwrap API

    Now call the application's unwrap API to restore the original based64 -encoded string by submitting the JSON from the output in the previous section to the unwrap API:

    $ curl http://localhost:8080/unwrap -d '{"cipher":"D/S6wDJPH ... "}'

    The output returns the original based64-encoded string:

    {"key":"rgeR0ENzlxG+Erss6tw0gBkBWdLOPrQhEFQpH8O5t/Y="} 

     

    The Service Binding Operator simplifies installation and deployment

    With the annotation support of the Service Binding Operator, you can easily bind ACK services without making any changes to the code. You can use the same label to bind any number of workloads. The REST API application consumes the projected binding values by using one of the libraries compliant with the Service Binding specification for Kubernetes. You can use the REST API application to connect to the AWS RDS service without any specific change.

    Last updated: November 8, 2023

    Related Posts

    • How to use Operators with AWS Controllers for Kubernetes

    • Create AWS resources with Kubernetes and Operators

    • Announcing Service Binding Operator 1.0 GA

    • Bind workloads to services easily with the Service Binding Operator and Red Hat OpenShift

    Recent Posts

    • MCP servers vs. skills: Choosing the right context for your AI

    • How to route external and local LLMs with Models-as-a-Service

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    What’s up next?

    Cover of the ebook OpenShift for Developers

    Get a hands-on introduction to daily life as a developer crafting code on OpenShift, the open source container application platform from Red Hat, with OpenShift for Developers.

    Get the e-book
    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.