Building and Pushing Image

Setup Quay.io account (for testing only)

Before we build our operator image we will want to setup an account on Quay.io. We will need to push this image to quay.io so that we can test the Metadata Files discussed in the next section. To setup an account on quay.io:
  1. 1.
    Go to: quay.io
  2. 2.
    Click on the SIGN IN button located on the upper right side
  3. 3.
    You can either Sign In with your GitHub account or click Create Account
  4. 4.
    Once logged into Quay, click CREATE REPOSITORY to create a place to push your operator image for testing (example name: wordpress-operator)

Build and Push Operator Image

Now that your project is setup with Labels and Licenses, and your quay.io account is setup we can build the operator image. In this example, replace rhc4tp with your quay.io account username:
1
sudo make docker-build docker-push IMG=quay.io/rhc4tp/wordpress-operator:v0.0.1
Copied!
Now that you pushed your image to quay.io you need to edit the config/manager/manager.yaml file and change the image field to reflect your image repository. (Note: line 19)
manager.yaml
1
apiVersion: v1
2
kind: Namespace
3
metadata:
4
labels:
5
control-plane: controller-manager
6
name: system
7
---
8
apiVersion: apps/v1
9
kind: Deployment
10
metadata:
11
name: wordpress-operator
12
spec:
13
replicas: 1
14
selector:
15
matchLabels:
16
name: wordpress-operator
17
template:
18
metadata:
19
labels:
20
name: wordpress-operator
21
spec:
22
serviceAccountName: wordpress-operator
23
containers:
24
- name: wordpress-operator
25
# Replace this with the built image name
26
image: quay.io/rhc4tp/wordpress-operator:v0.0.1
27
imagePullPolicy: Always
28
env:
29
- name: WATCH_NAMESPACE
30
valueFrom:
31
fieldRef:
32
fieldPath: metadata.namespace
33
- name: POD_NAME
34
valueFrom:
35
fieldRef:
36
fieldPath: metadata.name
37
- name: OPERATOR_NAME
38
value: "wordpress-operator"
39
- name: RELATED_IMAGE_WORDPRESS
40
value: docker.io/bitnami/wordpress:5.3.2-debian-10-10
Copied!
Keep in mind this is for testing only, this does not certify your operator image. Once your image is certified you will need to got back to config/manager/manager.yaml and change the image repository. If you want to certify your image see instructions here: Certifying your Operator.
Last modified 1yr ago