Skip to content

Commit 38baa34

Browse files
committed
helm based operator
1 parent 580dbec commit 38baa34

File tree

56 files changed

+1541
-2
lines changed

Some content is hidden

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

56 files changed

+1541
-2
lines changed

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.7.2
3+
4+
ENV HOME=/opt/helm
5+
COPY watches.yaml ${HOME}/watches.yaml
6+
COPY helm-charts ${HOME}/helm-charts
7+
WORKDIR ${HOME}

Makefile

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
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 = "preview,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=preview,fast,stable)
12+
# - use environment variables to overwrite this value (e.g export CHANNELS="preview,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+
# com.ibm/core-dump-operator-bundle:$VERSION and com.ibm/core-dump-operator-catalog:$VERSION.
32+
IMAGE_TAG_BASE ?= quay.io/number9/core-dump-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+
# Image URL to use all building/pushing image targets
39+
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
40+
41+
all: docker-build
42+
43+
##@ General
44+
45+
# The help target prints out all targets with their descriptions organized
46+
# beneath their categories. The categories are represented by '##@' and the
47+
# target descriptions by '##'. The awk commands is responsible for reading the
48+
# entire set of makefiles included in this invocation, looking for lines of the
49+
# file as xyz: ## something, and then pretty-format the target and help. Then,
50+
# if there's a line with ##@ something, that gets pretty-printed as a category.
51+
# More info on the usage of ANSI control characters for terminal formatting:
52+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
53+
# More info on the awk command:
54+
# http://linuxcommand.org/lc3_adv_awk.php
55+
56+
help: ## Display this help.
57+
@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)
58+
59+
##@ Build
60+
61+
run: helm-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
62+
$(HELM_OPERATOR) run
63+
64+
docker-build: ## Build docker image with the manager.
65+
docker build -t ${IMG} .
66+
67+
docker-push: ## Push docker image with the manager.
68+
docker push ${IMG}
69+
70+
##@ Deployment
71+
72+
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
73+
$(KUSTOMIZE) build config/crd | kubectl apply -f -
74+
75+
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
76+
$(KUSTOMIZE) build config/crd | kubectl delete -f -
77+
78+
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
79+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
80+
$(KUSTOMIZE) build config/default | kubectl apply -f -
81+
82+
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
83+
$(KUSTOMIZE) build config/default | kubectl delete -f -
84+
85+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
86+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
87+
88+
.PHONY: kustomize
89+
KUSTOMIZE = $(shell pwd)/bin/kustomize
90+
kustomize: ## Download kustomize locally if necessary.
91+
ifeq (,$(wildcard $(KUSTOMIZE)))
92+
ifeq (,$(shell which kustomize 2>/dev/null))
93+
@{ \
94+
set -e ;\
95+
mkdir -p $(dir $(KUSTOMIZE)) ;\
96+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | \
97+
tar xzf - -C bin/ ;\
98+
}
99+
else
100+
KUSTOMIZE = $(shell which kustomize)
101+
endif
102+
endif
103+
104+
.PHONY: helm-operator
105+
HELM_OPERATOR = $(shell pwd)/bin/helm-operator
106+
helm-operator: ## Download helm-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
107+
ifeq (,$(wildcard $(HELM_OPERATOR)))
108+
ifeq (,$(shell which helm-operator 2>/dev/null))
109+
@{ \
110+
set -e ;\
111+
mkdir -p $(dir $(HELM_OPERATOR)) ;\
112+
curl -sSLo $(HELM_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.7.2/helm-operator_$(OS)_$(ARCH) ;\
113+
chmod +x $(HELM_OPERATOR) ;\
114+
}
115+
else
116+
HELM_OPERATOR = $(shell which helm-operator)
117+
endif
118+
endif
119+
120+
.PHONY: bundle
121+
bundle: kustomize ## Generate bundle manifests and metadata, then validate generated files.
122+
operator-sdk generate kustomize manifests -q
123+
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
124+
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
125+
operator-sdk bundle validate ./bundle
126+
127+
.PHONY: bundle-build
128+
bundle-build: ## Build the bundle image.
129+
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
130+
131+
.PHONY: bundle-push
132+
bundle-push: ## Push the bundle image.
133+
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
134+
135+
.PHONY: opm
136+
OPM = ./bin/opm
137+
opm: ## Download opm locally if necessary.
138+
ifeq (,$(wildcard $(OPM)))
139+
ifeq (,$(shell which opm 2>/dev/null))
140+
@{ \
141+
set -e ;\
142+
mkdir -p $(dir $(OPM)) ;\
143+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$(OS)-$(ARCH)-opm ;\
144+
chmod +x $(OPM) ;\
145+
}
146+
else
147+
OPM = $(shell which opm)
148+
endif
149+
endif
150+
151+
# 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).
152+
# These images MUST exist in a registry and be pull-able.
153+
BUNDLE_IMGS ?= $(BUNDLE_IMG)
154+
155+
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
156+
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
157+
158+
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
159+
ifneq ($(origin CATALOG_BASE_IMG), undefined)
160+
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
161+
endif
162+
163+
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
164+
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
165+
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
166+
.PHONY: catalog-build
167+
catalog-build: opm ## Build a catalog image.
168+
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
169+
170+
# Push the catalog image.
171+
.PHONY: catalog-push
172+
catalog-push: ## Push a catalog image.
173+
$(MAKE) docker-push IMG=$(CATALOG_IMG)

PROJECT

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

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
1-
# core-dump-daemon
2-
A process for collecting core dumps and uploading them to object storage
1+
# core-dump-operator
2+
3+
An **experimental** operator for https://github.com/IBM/core-dump-handler
4+
5+
## install with operator-sdk
6+
7+
Run the operator SDK Install
8+
```
9+
operator-sdk olm install [--olm-namespace=openshift-operator-lifecycle-manager]
10+
```
11+
12+
## install from commandline
13+
14+
```
15+
make deploy
16+
```
17+
18+
## install as bundle
19+
20+
```
21+
operator-sdk run bundle quay.io/number9/core-dump-operator-bundle:v0.0.1 [--olm-namespace=openshift-operator-lifecycle-manager]
22+
```
23+
24+
## deploy the deamonset
25+
26+
Update the S3 values in the `config/samples/charts_v1alpha1_coredumphandler.yaml`
27+
28+
```
29+
kubectl apply -f config/samples/charts_v1alpha1_coredumphandler.yaml
30+
```

bin/kustomize

34.1 MB
Binary file not shown.

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=core-dump-operator
8+
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
9+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.7.1+git
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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
creationTimestamp: null
5+
name: coredumphandlers.charts.com.ibm
6+
spec:
7+
group: charts.com.ibm
8+
names:
9+
kind: CoreDumpHandler
10+
listKind: CoreDumpHandlerList
11+
plural: coredumphandlers
12+
singular: coredumphandler
13+
scope: Namespaced
14+
versions:
15+
- name: v1alpha1
16+
schema:
17+
openAPIV3Schema:
18+
description: CoreDumpHandler is the Schema for the coredumphandlers API
19+
properties:
20+
apiVersion:
21+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
22+
type: string
23+
kind:
24+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
25+
type: string
26+
metadata:
27+
type: object
28+
spec:
29+
description: Spec defines the desired state of CoreDumpHandler
30+
type: object
31+
x-kubernetes-preserve-unknown-fields: true
32+
status:
33+
description: Status defines the observed state of CoreDumpHandler
34+
type: object
35+
x-kubernetes-preserve-unknown-fields: true
36+
type: object
37+
served: true
38+
storage: true
39+
subresources:
40+
status: {}
41+
status:
42+
acceptedNames:
43+
kind: ""
44+
plural: ""
45+
conditions: null
46+
storedVersions: null
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
control-plane: controller-manager
7+
name: core-dump-operator-controller-manager-metrics-service
8+
spec:
9+
ports:
10+
- name: https
11+
port: 8443
12+
targetPort: https
13+
selector:
14+
control-plane: controller-manager
15+
status:
16+
loadBalancer: {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
creationTimestamp: null
5+
name: core-dump-operator-controller-manager
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
leaderElection:
11+
leaderElect: true
12+
resourceName: 811c9dc5.com.ibm
13+
kind: ConfigMap
14+
metadata:
15+
name: core-dump-operator-manager-config

0 commit comments

Comments
 (0)