Consuming Applications from RHCC

The intent of a Red Hat Certified Operator is to deploy and manage certified ISV application images from the Red Hat Container Catalog or a private registry. See below for examples.

For Ansible or Helm based operators, this is done simply by setting the image location in the K8s manifest templates contained within your Ansible playbook/role or Helm chart to RHCC. For golang operators, the Go struct(s) representing the Kubernetes manifest(s) of your application must have the image source set to RHCC. In the following examples, replace the example image source string with that of your published application image.

Ansible

To the RHCC image source in Ansible, we'll use an example tasks file from a role. Let's say this file is found at roles/example/tasks/main.yaml within the operator project, and contains the following:

- name: deploy operand
  k8s:
    definition:
      apiVersion: apps/v1
      kind: Deployment
      metadata:
      ...
      spec:
        ...
        spec:
          containers:
          - name: example-app
            image: registry.connect.redhat.com/example-partner/example-app:1.0.0
            ...

You can see where the image is set on the next to last line in the yaml snippet above.

Helm

In this helm example, lets assume the following deployment template exists at helm_charts/example/templates/example-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
...
spec:
  ...
  spec:
    containers:
    - name: example-app
      image: registry.connect.redhat.com/example-partner/example-app:1.0.0
      ... 

The image is shown in the next to last line in the above gotpl snippet.

Go

Below example in Golang (snippet of pkg/apis/example/v1alpha1/types.go from a hypothetical operator-sdk project):

type ExampleSpec struct {
	NodeSelector     map[string]string   `json:"nodeSelector,omitempty"`
	Tolerations      []corev1.Toleration `json:"tolerations,omitempty"`
	WaitReadySeconds *uint16             `json:"waitReadySeconds,omitempty"`
	// Application image
	Image string `json:"image,omitempty"`

In the above, the Spec field contents of the operator CR are defined, with the image field of the manifest being set by theExampleSpec.Image field in the above example. Note that no value is actually set in the struct, though the field is shown to be user-configurable by setting the spec.image field when creating the CR. Ideally, the image source would not be configurable, since we want to guarantee that the certified application images get pulled from RHCC. The default value for ExampleSpec.Image gets set in pkg/apis/example/v1alpha1/defaults.go as in the below example:

func SetDefaults_ExampleSpec(obj *ExampleSpec) {
	if obj.WaitReadySeconds == nil {
		obj.WaitReadySeconds = new(uint16)
		*obj.WaitReadySeconds = 300
	}An example for Helm:
apiVersion: apps/v1kind: Deploymentmetadata:...spec:  ...  spec:    containers:    - name: example-app      image: registry.connect.redhat.com/example-partner/example-app:1.0.0      ... 

	if obj.Image == "" {
		obj.Image = "registry.connect.redhat.com/example-partner/example-app:1.0.0"
	}

You can see the image source value in the next to last line of code in the golang snippet above.

Last updated