Skip to content

Commit e5b9075

Browse files
committed
add a kubernetes operator for the feast-feature-server
Signed-off-by: Tommy Hughes <tohughes@redhat.com>
1 parent 6ef7852 commit e5b9075

30 files changed

+798
-1
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
needs: [get-version, publish-python-sdk]
5050
strategy:
5151
matrix:
52-
component: [feature-server, feature-server-python-aws, feature-server-java, feature-transformation-server]
52+
component: [feature-server, feature-server-python-aws, feature-server-java, feature-transformation-server, feast-operator]
5353
env:
5454
MAVEN_CACHE: gs://feast-templocation-kf-feast/.m2.2020-08-19.tar
5555
REGISTRY: feastdev

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,18 @@ build-feature-server-java-docker:
395395
-t $(REGISTRY)/feature-server-java:$(VERSION) \
396396
-f java/infra/docker/feature-server/Dockerfile --load .
397397

398+
push-feast-operator-docker:
399+
cd infra/feast-operator && \
400+
IMAGE_TAG_BASE=$(REGISTRY)/feast-operator \
401+
VERSION=$(VERSION) \
402+
$(MAKE) docker-push
403+
404+
build-feast-operator-docker:
405+
cd infra/feast-operator && \
406+
IMAGE_TAG_BASE=$(REGISTRY)/feast-operator \
407+
VERSION=$(VERSION) \
408+
$(MAKE) docker-build
409+
398410
# Dev images
399411

400412
build-feature-server-dev:

infra/feast-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+
*~

infra/feast-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.34.1
3+
4+
ENV HOME=/opt/helm
5+
COPY watches.yaml ${HOME}/watches.yaml
6+
COPY --from=helmcharts feast-feature-server ${HOME}/helm-charts/feast-feature-server
7+
WORKDIR ${HOME}

infra/feast-operator/Makefile

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
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.37.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+
# feastdev/feast-operator-bundle:$VERSION and feastdev/feast-operator-catalog:$VERSION.
32+
IMAGE_TAG_BASE ?= feastdev/feast-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+
# Set the Operator SDK version to use. By default, what is installed on the system is used.
50+
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
51+
OPERATOR_SDK_VERSION ?= v1.34.1
52+
53+
# Image URL to use all building/pushing image targets
54+
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
55+
56+
.PHONY: all
57+
all: docker-build
58+
59+
##@ General
60+
61+
# The help target prints out all targets with their descriptions organized
62+
# beneath their categories. The categories are represented by '##@' and the
63+
# target descriptions by '##'. The awk commands is responsible for reading the
64+
# entire set of makefiles included in this invocation, looking for lines of the
65+
# file as xyz: ## something, and then pretty-format the target and help. Then,
66+
# if there's a line with ##@ something, that gets pretty-printed as a category.
67+
# More info on the usage of ANSI control characters for terminal formatting:
68+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
69+
# More info on the awk command:
70+
# http://linuxcommand.org/lc3_adv_awk.php
71+
72+
.PHONY: help
73+
help: ## Display this help.
74+
@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)
75+
76+
##@ Build
77+
78+
.PHONY: run
79+
run: helm-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
80+
$(HELM_OPERATOR) run
81+
82+
.PHONY: docker-build
83+
docker-build: ## Build docker image with the manager.
84+
docker build --build-context helmcharts=../charts/ -t ${IMG} .
85+
86+
.PHONY: docker-push
87+
docker-push: ## Push docker image with the manager.
88+
docker push ${IMG}
89+
90+
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
91+
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
92+
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
93+
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
94+
# - 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)
95+
# To properly provided solutions that supports more than one platform you should use this option.
96+
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
97+
.PHONY: docker-buildx
98+
docker-buildx: ## Build and push docker image for the manager for cross-platform support
99+
- docker buildx create --name project-v3-builder
100+
- docker buildx use project-v3-builder
101+
- docker buildx build --push --platform=$(PLATFORMS) --build-context helmcharts=../charts/ --tag ${IMG} -f Dockerfile .
102+
- docker buildx rm project-v3-builder
103+
104+
##@ Deployment
105+
106+
.PHONY: install
107+
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
108+
$(KUSTOMIZE) build config/crd | kubectl apply -f -
109+
110+
.PHONY: uninstall
111+
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
112+
$(KUSTOMIZE) build config/crd | kubectl delete -f -
113+
114+
.PHONY: deploy
115+
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
116+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
117+
$(KUSTOMIZE) build config/default | kubectl apply -f -
118+
119+
.PHONY: undeploy
120+
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
121+
$(KUSTOMIZE) build config/default | kubectl delete -f -
122+
123+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
124+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
125+
126+
.PHONY: kustomize
127+
KUSTOMIZE = $(shell pwd)/bin/kustomize
128+
kustomize: ## Download kustomize locally if necessary.
129+
ifeq (,$(wildcard $(KUSTOMIZE)))
130+
ifeq (,$(shell which kustomize 2>/dev/null))
131+
@{ \
132+
set -e ;\
133+
mkdir -p $(dir $(KUSTOMIZE)) ;\
134+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.2.1/kustomize_v5.2.1_$(OS)_$(ARCH).tar.gz | \
135+
tar xzf - -C bin/ ;\
136+
}
137+
else
138+
KUSTOMIZE = $(shell which kustomize)
139+
endif
140+
endif
141+
142+
.PHONY: helm-operator
143+
HELM_OPERATOR = $(shell pwd)/bin/helm-operator
144+
helm-operator: ## Download helm-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
145+
ifeq (,$(wildcard $(HELM_OPERATOR)))
146+
ifeq (,$(shell which helm-operator 2>/dev/null))
147+
@{ \
148+
set -e ;\
149+
mkdir -p $(dir $(HELM_OPERATOR)) ;\
150+
curl -sSLo $(HELM_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.34.1/helm-operator_$(OS)_$(ARCH) ;\
151+
chmod +x $(HELM_OPERATOR) ;\
152+
}
153+
else
154+
HELM_OPERATOR = $(shell which helm-operator)
155+
endif
156+
endif
157+
158+
.PHONY: operator-sdk
159+
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
160+
operator-sdk: ## Download operator-sdk locally if necessary.
161+
ifeq (,$(wildcard $(OPERATOR_SDK)))
162+
ifeq (, $(shell which operator-sdk 2>/dev/null))
163+
@{ \
164+
set -e ;\
165+
mkdir -p $(dir $(OPERATOR_SDK)) ;\
166+
curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(OS)_$(ARCH) ;\
167+
chmod +x $(OPERATOR_SDK) ;\
168+
}
169+
else
170+
OPERATOR_SDK = $(shell which operator-sdk)
171+
endif
172+
endif
173+
174+
.PHONY: bundle
175+
bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
176+
$(OPERATOR_SDK) generate kustomize manifests -q
177+
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
178+
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
179+
$(OPERATOR_SDK) bundle validate ./bundle
180+
181+
.PHONY: bundle-build
182+
bundle-build: ## Build the bundle image.
183+
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
184+
185+
.PHONY: bundle-push
186+
bundle-push: ## Push the bundle image.
187+
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
188+
189+
.PHONY: opm
190+
OPM = $(LOCALBIN)/opm
191+
opm: ## Download opm locally if necessary.
192+
ifeq (,$(wildcard $(OPM)))
193+
ifeq (,$(shell which opm 2>/dev/null))
194+
@{ \
195+
set -e ;\
196+
mkdir -p $(dir $(OPM)) ;\
197+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$(OS)-$(ARCH)-opm ;\
198+
chmod +x $(OPM) ;\
199+
}
200+
else
201+
OPM = $(shell which opm)
202+
endif
203+
endif
204+
205+
# 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).
206+
# These images MUST exist in a registry and be pull-able.
207+
BUNDLE_IMGS ?= $(BUNDLE_IMG)
208+
209+
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
210+
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
211+
212+
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
213+
ifneq ($(origin CATALOG_BASE_IMG), undefined)
214+
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
215+
endif
216+
217+
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
218+
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
219+
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
220+
.PHONY: catalog-build
221+
catalog-build: opm ## Build a catalog image.
222+
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
223+
224+
# Push the catalog image.
225+
.PHONY: catalog-push
226+
catalog-push: ## Push a catalog image.
227+
$(MAKE) docker-push IMG=$(CATALOG_IMG)

infra/feast-operator/PROJECT

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
5+
domain: feast.dev
6+
layout:
7+
- helm.sdk.operatorframework.io/v1
8+
plugins:
9+
manifests.sdk.operatorframework.io/v2: {}
10+
scorecard.sdk.operatorframework.io/v2: {}
11+
projectName: feast-operator
12+
resources:
13+
- api:
14+
crdVersion: v1
15+
namespaced: true
16+
domain: feast.dev
17+
group: charts
18+
kind: FeastFeatureServer
19+
version: v1alpha1
20+
version: "3"

infra/feast-operator/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Feast Feature Server Helm-based Operator
2+
3+
Leverages [operator-sdk](https://github.com/operator-framework/operator-sdk) and the [feast-feature-server helm chart](/infra/charts/feast-feature-server).
4+
5+
### To run against an K8S cluster -
6+
```bash
7+
$ make deploy
8+
9+
# test the operator by deploying a feature server sample CR
10+
$ oc apply -f config/samples/charts_v1alpha1_feastfeatureserver.yaml
11+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: feastfeatureservers.charts.feast.dev
6+
spec:
7+
group: charts.feast.dev
8+
names:
9+
kind: FeastFeatureServer
10+
listKind: FeastFeatureServerList
11+
plural: feastfeatureservers
12+
singular: feastfeatureserver
13+
scope: Namespaced
14+
versions:
15+
- name: v1alpha1
16+
schema:
17+
openAPIV3Schema:
18+
description: FeastFeatureServer is the Schema for the feastfeatureservers 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 FeastFeatureServer
34+
type: object
35+
x-kubernetes-preserve-unknown-fields: true
36+
status:
37+
description: Status defines the observed state of FeastFeatureServer
38+
type: object
39+
x-kubernetes-preserve-unknown-fields: true
40+
type: object
41+
served: true
42+
storage: true
43+
subresources:
44+
status: {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This kustomization.yaml is not intended to be run by itself,
2+
# since it depends on service name and namespace that are out of this kustomize package.
3+
# It should be run by config/default
4+
resources:
5+
- bases/charts.feast.dev_feastfeatureservers.yaml
6+
#+kubebuilder:scaffold:crdkustomizeresource
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Adds namespace to all resources.
2+
namespace: feast-operator-system
3+
4+
# Value of this field is prepended to the
5+
# names of all resources, e.g. a deployment named
6+
# "wordpress" becomes "alices-wordpress".
7+
# Note that it should also match with the prefix (text before '-') of the namespace
8+
# field above.
9+
namePrefix: feast-operator-
10+
11+
# Labels to add to all resources and selectors.
12+
#labels:
13+
#- includeSelectors: true
14+
# pairs:
15+
# someName: someValue
16+
17+
resources:
18+
- ../crd
19+
- ../rbac
20+
- ../manager

0 commit comments

Comments
 (0)