Skip to content

Commit

Permalink
Bump libs and documentation. Improve make flow
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosedp committed Dec 8, 2023
1 parent f76f04e commit dbb8ca5
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 29 deletions.
42 changes: 27 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# Current Operator version
VERSION ?= 0.4.0
VERSION ?= 0.4.1
# VERSION ?= $(shell git describe --tags | sed 's/^v//') # Use this to get the latest tag
# Previous Operator version
PREV_VERSION ?= $(shell git describe --abbrev=0 --tags $(shell git rev-list --tags --skip=1 --max-count=1) | sed 's/^v//')

# Operator repository
REPO ?= docker.io/carlosedp
REPO ?= quay.io/carlosedp

# Publishing channel
CHANNELS = "beta"
DEFAULT_CHANNEL = "beta"

# Architectures to build binaries and Docker images
ARCHS ?= amd64 arm64 ppc64le s390x
# Interpolated platform and architecture list for docker buildx separated by comma
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
PLATFORMS = $(shell echo $(ARCHS) | sed -e 's~[^ ]*~linux/&~g' | tr ' ' ',')

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26

Expand Down Expand Up @@ -66,6 +80,10 @@ all: build
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

.PHONY: print-%
print-%: ## Print any variable from the Makefile. Use as `make print-VARIABLE`
@echo $($*)

##@ Development

.PHONY: manifests
Expand Down Expand Up @@ -114,10 +132,9 @@ docker-build: ## Build docker image for the operator locally (linux/amd64).
docker-push: ## Build and push docker image for the operator.
$(BUILDER) push ${IMG}

ARCHS ?= amd64 arm64 ppc64le s390x

.PHONY: docker-cross
docker-cross: ## Build operator binaries locally and then build/push the Docker image
# docker-cross: test bundle
@for ARCH in $(ARCHS) ; do \
OS=linux ; \
echo "Building binary for $$ARCH at output/manager-$$OS-$$ARCH" ; \
Expand All @@ -126,15 +143,9 @@ docker-cross: ## Build operator binaries locally and then build/push the Docker
-ldflags '-X "main.Version=$(VERSION)" -s -w -extldflags "-static"' \
-o output/manager-$$OS-$$ARCH main.go ; \
done
docker buildx build -t ${IMG} --platform=linux/amd64,linux/arm64,linux/ppc64le --push -f Dockerfile .
docker buildx build -t ${IMG} --platform=$(PLATFORMS) --push -f Dockerfile .

# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
Expand Down Expand Up @@ -260,10 +271,10 @@ olm-validate: bundle-push catalog-push ## Validates the bundle image.

.PHONY: olm-run
olm-run: olm-validate ## Runs the bundle image in a KIND cluster
ifeq ($(shell kind get clusters), test-operator)
ifeq ($(shell kind get clusters > /dev/null 2>&1), test-operator)
@echo "Cluster already running"
else
$(shell kind create cluster --name test-operator)
$(shell kind create cluster --name test-operator > /dev/null 2>&1)
endif
kubectl config use-context kind-test-operator
operator-sdk olm install --version=0.21.2 --timeout=5m || true
Expand All @@ -286,7 +297,8 @@ scorecard-run: ## Runs the scorecard validation (depends on a KIND cluster)

.PHONY: testenv-teardown
testenv-teardown:
kind delete cluster --name test-operator
kind delete cluster --name test-operator > /dev/null 2>&1

.PHONY: dist
dist: docker-cross bundle olm-validate ## Build manifests and container image, pushing it to the registry
dist: bundle olm-validate docker-cross ## Build manifests and container images, pushing them to the registry
@sed -i -e 's|v[0-9]*\.[0-9]*\.[0-9]*|v$(VERSION)|g' Readme.md
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The main users for this operator is enterprise deployments or clusters composed
Apply the operator manifest into the cluster:

```sh
kubectl apply -f https://github.com/carlosedp/lbconfig-operator/raw/v0.4.0/manifests/deploy.yaml
kubectl apply -f https://github.com/carlosedp/lbconfig-operator/raw/v0.4.1/manifests/deploy.yaml
```

This creates the operator Namespace, CRD and deployment using the latest container version. The container image is built for `amd64`, `arm64` and `ppc64le` architectures.
Expand Down
10 changes: 5 additions & 5 deletions bundle/manifests/lbconfig-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ metadata:
capabilities: Auto Pilot
categories: Networking
certified: "false"
containerImage: docker.io/carlosedp/lbconfig-operator:v0.4.0
createdAt: "2023-12-08T13:13:24Z"
containerImage: quay.io/carlosedp/lbconfig-operator:v0.4.1
createdAt: "2023-12-08T20:44:53Z"
description: The LBConfig Operator, manages the configuration of External Load
Balancer instances (on third-party equipment) and creates VIPs and IP Pools
dynamically via API.
Expand All @@ -108,7 +108,7 @@ metadata:
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/carlosedp/lbconfig-operator
support: ""
name: lbconfig-operator.v0.4.0
name: lbconfig-operator.v0.4.1
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -437,7 +437,7 @@ spec:
- --leader-elect
command:
- /manager
image: docker.io/carlosedp/lbconfig-operator:v0.4.0
image: quay.io/carlosedp/lbconfig-operator:v0.4.1
imagePullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -532,4 +532,4 @@ spec:
provider:
name: Carlos Eduardo de Paula
selector: {}
version: 0.4.0
version: 0.4.1
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: docker.io/carlosedp/lbconfig-operator
newTag: v0.4.0
newName: quay.io/carlosedp/lbconfig-operator
newTag: v0.4.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
capabilities: Auto Pilot
categories: Networking
certified: "false"
containerImage: docker.io/carlosedp/lbconfig-operator:v0.0.0
containerImage: quay.io/carlosedp/lbconfig-operator:v0.0.0
createdAt: "2022-08-15T12:00:00Z"
description: The LBConfig Operator, manages the configuration of External Load
Balancer instances (on third-party equipment) and creates VIPs and IP Pools
Expand Down Expand Up @@ -344,7 +344,7 @@ spec:
- --leader-elect
command:
- /manager
image: docker.io/carlosedp/lbconfig-operator:v0.0.0
image: quay.io/carlosedp/lbconfig-operator:v0.0.0
livenessProbe:
httpGet:
path: /healthz
Expand Down
7 changes: 4 additions & 3 deletions config/manifests/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resources:
- ../default
- ../samples
- ../scorecard
- bases/lbconfig-operator.clusterserviceversion.yaml
- ../default
- ../samples
- ../scorecard
34 changes: 34 additions & 0 deletions docs/Release_new_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Releasing a new version

Instructions to build and release a new operator version.

## Build docker images and manifest bundle

1. If Docker doesn't have a crossbuild instance, create one with `docker buildx create --use`.
2. Login to Quay.io with `docker login quay.io`.
3. Bump version on Makefile

Run `make dist` which will do automatically the following steps:

1. Build binaries for all supported platforms on `output` directory (amd64, arm64, ...)
2. Cross-build docker images for all supported platforms and push to Quay.io
3. Build catalog and bundle images and push them to Quay.io
4. Build manifest bundles on `./bundle`
5. Validate the bundle with operator-sdk
6. Update the image version on Readme

If all is ok, commit the remaining changes to the repository and push to GitHub.

## Release to GitHub

1. Tag the release with `git tag -a $(make print-VERSION) -m "$(make print-VERSION) - Description"`
2. Push the tag to the repo with `git push origin $(make print-VERSION)`
3. On GitHub, create a release based on this tag.

## Update OperatorHub for both community and OpenShift

For OperatorHub community, checkout <https://github.com/k8s-operatorhub/community-operators>, create the version directory in `community-operators/lbconfig-operator` and copy the whole `bundle` diretory to it.

Fork the repo, create a branch, commit and open a PR upstream.

For OpenShift OperatorHub, checkout <> and do a similar process as above.
2 changes: 1 addition & 1 deletion manifests/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ spec:
- --leader-elect
command:
- /manager
image: docker.io/carlosedp/lbconfig-operator:v0.4.0
image: quay.io/carlosedp/lbconfig-operator:v0.4.1
imagePullPolicy: Always
livenessProbe:
httpGet:
Expand Down

0 comments on commit dbb8ca5

Please sign in to comment.