-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,582 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
|
||
VERSION ?= 0.0.1 | ||
|
||
# CHANNELS define the bundle channels used in the bundle. | ||
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") | ||
# To re-generate a bundle for other specific channels without changing the standard setup, you can: | ||
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable) | ||
# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable") | ||
ifneq ($(origin CHANNELS), undefined) | ||
BUNDLE_CHANNELS := --channels=$(CHANNELS) | ||
endif | ||
|
||
# DEFAULT_CHANNEL defines the default channel used in the bundle. | ||
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable") | ||
# To re-generate a bundle for any other default channel without changing the default setup, you can: | ||
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable) | ||
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable") | ||
ifneq ($(origin DEFAULT_CHANNEL), undefined) | ||
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) | ||
endif | ||
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) | ||
|
||
# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images. | ||
# This variable is used to construct full image tags for bundle and catalog images. | ||
# | ||
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both | ||
# projectnessie.org/nessie-operator-bundle:$VERSION and projectnessie.org/nessie-operator-catalog:$VERSION. | ||
IMAGE_TAG_BASE ?= projectnessie/nessie-operator | ||
|
||
# BUNDLE_IMG defines the image:tag used for the bundle. | ||
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>) | ||
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= $(IMAGE_TAG_BASE):latest | ||
|
||
PULL_POLICY ?= Always | ||
|
||
all: docker-build | ||
|
||
##@ General | ||
|
||
# The help target prints out all targets with their descriptions organized | ||
# beneath their categories. The categories are represented by '##@' and the | ||
# target descriptions by '##'. The awk commands is responsible for reading the | ||
# entire set of makefiles included in this invocation, looking for lines of the | ||
# file as xyz: ## something, and then pretty-format the target and help. Then, | ||
# if there's a line with ##@ something, that gets pretty-printed as a category. | ||
# More info on the usage of ANSI control characters for terminal formatting: | ||
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
# More info on the awk command: | ||
# http://linuxcommand.org/lc3_adv_awk.php | ||
|
||
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) | ||
|
||
##@ Build | ||
|
||
docker-build: ## Build docker image with the manager. | ||
../gradlew --no-build-cache :nessie-operator:clean :nessie-operator:build \ | ||
-Dquarkus.container-image.build=true \ | ||
-Dquarkus.container-image.image=${IMG} \ | ||
-Dquarkus.kubernetes.image-pull-policy=${PULL_POLICY} | ||
|
||
docker-push: ## Build and push docker image with the manager. | ||
../gradlew --no-build-cache :nessie-operator:clean :nessie-operator:build \ | ||
-Dquarkus.container-image.build=true \ | ||
-Dquarkus.container-image.push=true \ | ||
-Dquarkus.container-image.image=${IMG} \ | ||
-Dquarkus.kubernetes.image-pull-policy=${PULL_POLICY} | ||
|
||
##@ Deployment | ||
|
||
install: ## Install CRDs into the K8s cluster specified in ~/.kube/config. | ||
@$(foreach file, $(wildcard build/kubernetes/*-v1.yml), kubectl apply -f $(file);) | ||
|
||
uninstall: ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. | ||
@$(foreach file, $(wildcard build/kubernetes/*-v1.yml), kubectl delete -f $(file);) | ||
|
||
deploy: ## Deploy controller to the K8s cluster specified in ~/.kube/config. | ||
kubectl apply -f build/kubernetes/kubernetes.yml | ||
|
||
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. | ||
kubectl delete -f build/kubernetes/kubernetes.yml | ||
|
||
##@Bundle | ||
.PHONY: bundle | ||
bundle: ## Generate bundle manifests and metadata, then validate generated files. | ||
## marker | ||
cat build/kubernetes/nessies.nessie.projectnessie.org-v1alpha1.yml target/kubernetes/kubernetes.yml | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) | ||
operator-sdk bundle validate ./bundle | ||
|
||
.PHONY: bundle-build | ||
bundle-build: ## Build the bundle image. | ||
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . | ||
|
||
.PHONY: bundle-push | ||
bundle-push: ## Push the bundle image. | ||
docker push $(BUNDLE_IMG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Code generated by tool. DO NOT EDIT. | ||
# This file is used to track the info used to scaffold your project | ||
# and allow the plugins properly work. | ||
# More info: https://book.kubebuilder.io/reference/project-config.html | ||
domain: projectnessie.org | ||
layout: | ||
- quarkus.javaoperatorsdk.io/v1-alpha | ||
projectName: nessie-operator | ||
resources: | ||
- api: | ||
crdVersion: v1 | ||
namespaced: true | ||
domain: projectnessie.org | ||
group: nessie | ||
kind: Nessie | ||
version: v1alpha1 | ||
version: "3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Kubernetes Operator for Nessie | ||
|
||
## Overview | ||
|
||
This module is a Kubernetes Operator for Nessie. | ||
|
||
**WARNING: This is a work in progress and is not ready for production use.** | ||
|
||
## Usage | ||
|
||
TODO describe typical deployment scenarios. | ||
|
||
## Development | ||
|
||
### Prerequisites | ||
|
||
Install the following tools: | ||
|
||
- Kubectl: https://kubernetes.io/docs/tasks/tools/ | ||
- Operator SDK: https://sdk.operatorframework.io/docs/installation/ | ||
- Optional: | ||
- yq: https://github.com/mikefarah/yq | ||
|
||
**IMPORTANT**: The current Operator SDK version, 1.33.0, has [a bug] that prevents it from working | ||
with the latest version of the Kubernetes API (or Quarkus plugin). To work around this, install the | ||
version 1.32.0 of the operator-sdk. | ||
|
||
[a bug]:https://github.com/operator-framework/operator-sdk/issues/6645 | ||
|
||
Using brew: | ||
|
||
```bash | ||
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/6b039d0d8907b70704cd1d87ad235705a77620ae/Formula/o/operator-sdk.rb | ||
brew install -s operator-sdk.rb | ||
operator-sdk version | ||
``` | ||
|
||
### Project generation | ||
|
||
```bash | ||
operator-sdk init --plugins=quarkus --domain=projectnessie.org --project-name=nessie-operator | ||
operator-sdk create api --plugins=quarkus --group nessie --version=v1alpha1 --kind=Nessie | ||
``` | ||
|
||
### Building the operator image | ||
|
||
```bash | ||
make docker-build | ||
``` | ||
|
||
### Adhoc testing with Minikube | ||
|
||
Install [minikube](https://minikube.sigs.k8s.io/docs/start/). | ||
|
||
Build the operator docker image _inside_ minikube to facilitate testing (doesn't need a registry): | ||
|
||
```bash | ||
eval $(minikube docker-env) | ||
make docker-build PULL_POLICY=IfNotPresent | ||
``` | ||
|
||
Note: the `PULL_POLICY=IfNotPresent` is required to avoid pulling the image from a registry. | ||
|
||
Create the nessie-operator and nessie-ns namespaces: | ||
|
||
```bash | ||
kubectl create namespace nessie-operator | ||
kubectl create namespace nessie-ns | ||
``` | ||
|
||
Install the CRDs and deploy the operator in the nessie-operator namespace: | ||
|
||
```bash | ||
make install deploy | ||
``` | ||
|
||
Grant admin rights to the nessie-operator service account: | ||
|
||
```bash | ||
kubectl apply -f examples/nessie-operator-rbac.yaml | ||
``` | ||
|
||
Create a Nessie resource in the nessie-ns namespace: | ||
|
||
```bash | ||
kubectl apply -n nessie-ns -f examples/nessie.yaml | ||
``` | ||
|
||
You should see 1 pod, 1 deployment and 1 service running. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
plugins { | ||
alias(libs.plugins.quarkus) | ||
id("nessie-conventions-quarkus") | ||
id("nessie-jacoco") | ||
} | ||
|
||
extra["maven.name"] = "Nessie - Kubernetes Operator" | ||
|
||
dependencies { | ||
implementation(enforcedPlatform(libs.quarkus.bom)) | ||
implementation(enforcedPlatform(libs.quarkus.operator.sdk.bom)) | ||
|
||
implementation("io.quarkiverse.operatorsdk:quarkus-operator-sdk") | ||
implementation("io.quarkiverse.operatorsdk:quarkus-operator-sdk-bundle-generator") | ||
implementation("io.quarkus:quarkus-micrometer-registry-prometheus") | ||
implementation("io.quarkus:quarkus-container-image-jib") | ||
|
||
testImplementation(enforcedPlatform(libs.quarkus.bom)) | ||
testImplementation("io.quarkus:quarkus-junit5") | ||
testImplementation("io.quarkus:quarkus-junit5-mockito") | ||
testImplementation("io.quarkus:quarkus-test-kubernetes-client") | ||
testImplementation("org.bouncycastle:bcpkix-jdk18on") | ||
testImplementation(platform(libs.junit.bom)) | ||
testImplementation(libs.bundles.junit.testing) | ||
testImplementation(libs.awaitility) | ||
} | ||
|
||
listOf("javadoc", "sourcesJar").forEach { name -> | ||
tasks.named(name).configure { dependsOn(tasks.named("compileQuarkusGeneratedSourcesJava")) } | ||
} | ||
|
||
listOf("checkstyleTest", "compileTestJava").forEach { name -> | ||
tasks.named(name).configure { dependsOn(tasks.named("compileQuarkusTestGeneratedSourcesJava")) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: nessie-operator-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: nessie-operator | ||
namespace: nessie-operator | ||
roleRef: | ||
kind: ClusterRole | ||
name: cluster-admin | ||
apiGroup: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: nessie.projectnessie.org/v1alpha1 | ||
kind: Nessie | ||
metadata: | ||
name: nessie1 | ||
spec: | ||
size: 1 | ||
versionStoreType: IN_MEMORY | ||
logLevel: INFO |
Oops, something went wrong.