Skip to content

Commit 12bf0af

Browse files
authored
Pelorus Operator v0.0.1 (#715)
Generated pelorus operator based on Helm Charts Signed-off-by: Michal Pryc <mpryc@redhat.com> Signed-off-by: Michal Pryc <mpryc@redhat.com>
1 parent 8101c33 commit 12bf0af

98 files changed

Lines changed: 6262 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,7 @@ _test/prometheus/rules.yaml
151151
# Helm
152152
charts/pelorus/Chart.lock
153153
charts/pelorus/subcharts/*.tgz
154+
155+
# Operator
156+
pelorus-operator/Makefile.orig
157+
*.tgz

pelorus-operator/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
bin
9+
10+
# editor and IDE paraphernalia
11+
.idea
12+
*.swp
13+
*.swo
14+
*~

pelorus-operator/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Build the manager binary
2+
FROM quay.io/operator-framework/helm-operator:v1.24.1
3+
4+
ENV HOME=/opt/helm
5+
COPY watches.yaml ${HOME}/watches.yaml
6+
COPY helm-charts ${HOME}/helm-charts
7+
WORKDIR ${HOME}

pelorus-operator/Makefile

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# VERSION defines the project version for the bundle.
2+
# Update this value when you upgrade the version of your project.
3+
# To re-generate a bundle for another specific version without changing the standard setup, you can:
4+
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
5+
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6+
VERSION ?= 0.0.1
7+
8+
# CHANNELS define the bundle channels used in the bundle.
9+
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
10+
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
11+
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable)
12+
# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable")
13+
ifneq ($(origin CHANNELS), undefined)
14+
BUNDLE_CHANNELS := --channels=$(CHANNELS)
15+
endif
16+
17+
# DEFAULT_CHANNEL defines the default channel used in the bundle.
18+
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
19+
# To re-generate a bundle for any other default channel without changing the default setup, you can:
20+
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
21+
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
22+
ifneq ($(origin DEFAULT_CHANNEL), undefined)
23+
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
24+
endif
25+
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
26+
27+
# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
28+
# This variable is used to construct full image tags for bundle and catalog images.
29+
#
30+
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
31+
# pelorus.konveyor.io/pelorus-operator-bundle:$VERSION and pelorus.konveyor.io/pelorus-operator-catalog:$VERSION.
32+
IMAGE_TAG_BASE ?= quay.io/migtools/pelorus-operator
33+
34+
# BUNDLE_IMG defines the image:tag used for the bundle.
35+
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
36+
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
37+
38+
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
39+
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
40+
41+
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
42+
# You can enable this value if you would like to use SHA Based Digests
43+
# To enable set flag to true
44+
USE_IMAGE_DIGESTS ?= false
45+
ifeq ($(USE_IMAGE_DIGESTS), true)
46+
BUNDLE_GEN_FLAGS += --use-image-digests
47+
endif
48+
49+
# Image URL to use all building/pushing image targets
50+
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
51+
52+
.PHONY: all
53+
all: podman-build
54+
55+
##@ General
56+
57+
# The help target prints out all targets with their descriptions organized
58+
# beneath their categories. The categories are represented by '##@' and the
59+
# target descriptions by '##'. The awk commands is responsible for reading the
60+
# entire set of makefiles included in this invocation, looking for lines of the
61+
# file as xyz: ## something, and then pretty-format the target and help. Then,
62+
# if there's a line with ##@ something, that gets pretty-printed as a category.
63+
# More info on the usage of ANSI control characters for terminal formatting:
64+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
65+
# More info on the awk command:
66+
# http://linuxcommand.org/lc3_adv_awk.php
67+
68+
.PHONY: help
69+
help: ## Display this help.
70+
@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)
71+
72+
##@ Build
73+
74+
.PHONY: run
75+
run: helm-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
76+
$(HELM_OPERATOR) run
77+
78+
.PHONY: podman-build
79+
podman-build: ## Build podman image with the manager.
80+
podman build -t ${IMG} .
81+
82+
.PHONY: podman-push
83+
podman-push: ## Push podman image with the manager.
84+
podman push ${IMG}
85+
86+
##@ Deployment
87+
88+
.PHONY: install
89+
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
90+
$(KUSTOMIZE) build config/crd | kubectl apply -f -
91+
92+
.PHONY: uninstall
93+
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
94+
$(KUSTOMIZE) build config/crd | kubectl delete -f -
95+
96+
.PHONY: deploy
97+
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
98+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
99+
$(KUSTOMIZE) build config/default | kubectl apply -f -
100+
101+
.PHONY: undeploy
102+
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
103+
$(KUSTOMIZE) build config/default | kubectl delete -f -
104+
105+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
106+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
107+
108+
.PHONY: kustomize
109+
KUSTOMIZE = $(shell pwd)/bin/kustomize
110+
kustomize: ## Download kustomize locally if necessary.
111+
ifeq (,$(wildcard $(KUSTOMIZE)))
112+
ifeq (,$(shell which kustomize 2>/dev/null))
113+
@{ \
114+
set -e ;\
115+
mkdir -p $(dir $(KUSTOMIZE)) ;\
116+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_$(OS)_$(ARCH).tar.gz | \
117+
tar xzf - -C bin/ ;\
118+
}
119+
else
120+
KUSTOMIZE = $(shell which kustomize)
121+
endif
122+
endif
123+
124+
.PHONY: helm-operator
125+
HELM_OPERATOR = $(shell pwd)/bin/helm-operator
126+
helm-operator: ## Download helm-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
127+
ifeq (,$(wildcard $(HELM_OPERATOR)))
128+
ifeq (,$(shell which helm-operator 2>/dev/null))
129+
@{ \
130+
set -e ;\
131+
mkdir -p $(dir $(HELM_OPERATOR)) ;\
132+
curl -sSLo $(HELM_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.24.1/helm-operator_$(OS)_$(ARCH) ;\
133+
chmod +x $(HELM_OPERATOR) ;\
134+
}
135+
else
136+
HELM_OPERATOR = $(shell which helm-operator)
137+
endif
138+
endif
139+
140+
.PHONY: bundle
141+
bundle: kustomize ## Generate bundle manifests and metadata, then validate generated files.
142+
operator-sdk generate kustomize manifests -q
143+
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
144+
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)
145+
operator-sdk bundle validate ./bundle
146+
147+
.PHONY: bundle-build
148+
bundle-build: ## Build the bundle image.
149+
podman build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
150+
151+
.PHONY: bundle-push
152+
bundle-push: ## Push the bundle image.
153+
$(MAKE) podman-push IMG=$(BUNDLE_IMG)
154+
155+
.PHONY: opm
156+
OPM = ./bin/opm
157+
opm: ## Download opm locally if necessary.
158+
ifeq (,$(wildcard $(OPM)))
159+
ifeq (,$(shell which opm 2>/dev/null))
160+
@{ \
161+
set -e ;\
162+
mkdir -p $(dir $(OPM)) ;\
163+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$(OS)-$(ARCH)-opm ;\
164+
chmod +x $(OPM) ;\
165+
}
166+
else
167+
OPM = $(shell which opm)
168+
endif
169+
endif
170+
171+
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
172+
# These images MUST exist in a registry and be pull-able.
173+
BUNDLE_IMGS ?= $(BUNDLE_IMG)
174+
175+
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
176+
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
177+
178+
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
179+
ifneq ($(origin CATALOG_BASE_IMG), undefined)
180+
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
181+
endif
182+
183+
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
184+
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
185+
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
186+
.PHONY: catalog-build
187+
catalog-build: opm ## Build a catalog image.
188+
$(OPM) index add --container-tool podman --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
189+
190+
# Push the catalog image.
191+
.PHONY: catalog-push
192+
catalog-push: ## Push a catalog image.
193+
$(MAKE) podman-push IMG=$(CATALOG_IMG)

pelorus-operator/PROJECT

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
domain: pelorus.konveyor.io
2+
layout:
3+
- helm.sdk.operatorframework.io/v1
4+
plugins:
5+
manifests.sdk.operatorframework.io/v2: {}
6+
scorecard.sdk.operatorframework.io/v2: {}
7+
projectName: pelorus-operator
8+
resources:
9+
- api:
10+
crdVersion: v1
11+
namespaced: true
12+
domain: pelorus.konveyor.io
13+
group: charts
14+
kind: Pelorus
15+
version: v1alpha1
16+
version: "3"

pelorus-operator/bundle.Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM scratch
2+
3+
# Core bundle labels.
4+
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
5+
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
6+
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
7+
LABEL operators.operatorframework.io.bundle.package.v1=pelorus-operator
8+
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
9+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.24.1
10+
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
11+
LABEL operators.operatorframework.io.metrics.project_layout=helm.sdk.operatorframework.io/v1
12+
13+
# Labels for testing.
14+
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
15+
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
16+
17+
# Copy files to locations specified by labels.
18+
COPY bundle/manifests /manifests/
19+
COPY bundle/metadata /metadata/
20+
COPY bundle/tests/scorecard /tests/scorecard/
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
creationTimestamp: null
5+
name: pelorus.charts.pelorus.konveyor.io
6+
spec:
7+
group: charts.pelorus.konveyor.io
8+
names:
9+
kind: Pelorus
10+
listKind: PelorusList
11+
plural: pelorus
12+
singular: pelorus
13+
scope: Namespaced
14+
versions:
15+
- name: v1alpha1
16+
schema:
17+
openAPIV3Schema:
18+
description: Pelorus is the Schema for the pelorus API
19+
properties:
20+
apiVersion:
21+
description: 'APIVersion defines the versioned schema of this representation
22+
of an object. Servers should convert recognized schemas to the latest
23+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
24+
type: string
25+
kind:
26+
description: 'Kind is a string value representing the REST resource this
27+
object represents. Servers may infer this from the endpoint the client
28+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
29+
type: string
30+
metadata:
31+
type: object
32+
spec:
33+
description: Spec defines the desired state of Pelorus
34+
type: object
35+
x-kubernetes-preserve-unknown-fields: true
36+
status:
37+
description: Status defines the observed state of Pelorus
38+
type: object
39+
x-kubernetes-preserve-unknown-fields: true
40+
type: object
41+
served: true
42+
storage: true
43+
subresources:
44+
status: {}
45+
status:
46+
acceptedNames:
47+
kind: ""
48+
plural: ""
49+
conditions: null
50+
storedVersions: null
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
control-plane: controller-manager
7+
name: pelorus-operator-controller-manager-metrics-service
8+
spec:
9+
ports:
10+
- name: https
11+
port: 8443
12+
protocol: TCP
13+
targetPort: https
14+
selector:
15+
control-plane: controller-manager
16+
status:
17+
loadBalancer: {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: v1
2+
data:
3+
controller_manager_config.yaml: |
4+
apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
5+
kind: ControllerManagerConfig
6+
health:
7+
healthProbeBindAddress: :8081
8+
metrics:
9+
bindAddress: 127.0.0.1:8080
10+
11+
leaderElection:
12+
leaderElect: true
13+
resourceName: 811c9dc5.pelorus.konveyor.io
14+
# leaderElectionReleaseOnCancel defines if the leader should step down volume
15+
# when the Manager ends. This requires the binary to immediately end when the
16+
# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
17+
# speeds up voluntary leader transitions as the new leader don't have to wait
18+
# LeaseDuration time first.
19+
# In the default scaffold provided, the program ends immediately after
20+
# the manager stops, so would be fine to enable this option. However,
21+
# if you are doing or is intended to do any operation such as perform cleanups
22+
# after the manager stops then its usage might be unsafe.
23+
# leaderElectionReleaseOnCancel: true
24+
kind: ConfigMap
25+
metadata:
26+
name: pelorus-operator-manager-config
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
creationTimestamp: null
5+
name: pelorus-operator-metrics-reader
6+
rules:
7+
- nonResourceURLs:
8+
- /metrics
9+
verbs:
10+
- get

0 commit comments

Comments
 (0)