Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ check: | verify test-unit

IMAGE_REGISTRY?=registry.svc.ci.openshift.org

TAGS ?= ocp

# This will call a macro called "build-image" which will generate image specific targets based on the parameters:
# $0 - macro name
# $1 - target name
Expand All @@ -37,6 +39,9 @@ $(call add-profile-manifests,manifests,./profile-patches,./manifests)

GO_UNIT_TEST_PACKAGES :=./pkg/... ./cmd/...

build:
go build -tags '$(TAGS)' -o $@ ./cmd/console/main.go

# Run tests
test: test-unit test-e2e

Expand All @@ -59,6 +64,13 @@ else
go-junit-report --version
endif

# download the dependencies and put them in the /vendor directory.
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
go mod verify

# Remove all build artifacts.
#
# Example:
Expand Down
38 changes: 9 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,22 @@ Now we should be ready to build & deploy the operator with our changes.

#### Preparation to Deploy Operator Changes Quickly

Typically to build your binary you will use the `make` command:
Typically to build your binary you would use the `make` command:

```bash
# this will build for your platform:
# this will build locally:
make
# if you are running OSX, you will need to build for linux doing something like:
OS_DEBUG=true OS_BUILD_PLATFORMS=linux/amd64 make
# note that you can build for mulitiple platforms with:
make build-cross
```
But the `make` step is included in the `Dockerfile`, so this does not need to be done manually.
You can instead simply build the container image and push the it to your own registry:
But the build step is included in the `Dockerfile.rhel7`, so this does not need to be done manually.
You can instead simply build the container image and push it to your own registry:

```bash
# the pattern is:
docker build -t <registry>/<your-username>/console-operator:<version> .
# following: docker.io/openshift/origin-console-operator:latest
docker build -f Dockerfile.rhel7 -t <registry>/<your-username>/console-operator:<version>
# conforming to: docker.io/openshift/origin-console-operator:latest
# for development, you are going to push to an alternate registry.
# specifically it can look something like this:
docker build -f Dockerfile.rhel7 -t quay.io/benjaminapetersen/console-operator:latest .
```
You can optionally build a specific version.
Note: If you are running on macOS, you need to pass the --platform linux/amd64 flag to the Docker build command.

Then, push your image:

Expand All @@ -189,30 +183,16 @@ docker push <registry>/<your-username>/console-operator:<version>
# Be sure your repository is public else the image will not be able to be pulled later
docker push quay.io/benjaminapetersen/console-operator:latest
```
Then, you will want to deploy your new container. This means duplicating the `manifests/07-operator.yaml`
and updating the line `image: docker.io/openshift/origin-console-operator:latest` to instead use the
image you just pushed.

```bash
# duplicate the operator manifest to /examples or your ~/ home dir
cp manifests/07-operator.yaml ~/07-operator-alt-image.yaml
```
Then, update the image & replicas in your `07-operator-alt-image.yaml` file:
Then, you will want to deploy your new container to the cluster. This can be done by updating the `image` field in the `example/07-operator.yaml` file to instead use the image you just pushed:

```yaml
# before
replicas: 2
image: docker.io/openshift/origin-console-operator:latest
# after
# image: <registry>/<your-username>/console-operator:<version>
replicas: 1
image: quay.io/benjaminapetersen/console-operator:latest
```
And ensure that the `imagePullPolicy` is still `Always`. This will ensure a fast development feedback loop.

```yaml
imagePullPolicy: Always
```
Note: To guarantee a fast development feedback loop make sure the `imagePullPolicy` is set to `Always`.

#### Deploying

Expand Down
2 changes: 1 addition & 1 deletion examples/07-operator-alt-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
# docker build quay.io/<your-user>/console-operator:latest .
# docker push quay.io/<your-user>/console-operator:latest
# then
# oc apply -f examples/05-operator-alt-image.yaml
# oc apply -f examples/07-operator-alt-image.yaml
# with this line updated:
image: quay.io/<your-user>/console-operator:latest
ports:
Expand Down