Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add crd for pulsar package & function & connector #206

Merged
merged 55 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f1a9f8f
add crd for pulsar package & function & connector
freeznet Jun 18, 2024
3ef1bd8
add controllers
freeznet Jun 20, 2024
0adfd1f
add tests
freeznet Jun 20, 2024
1ed859e
Update api/v1alpha1/zz_generated.deepcopy.go
freeznet Jun 20, 2024
9524d0d
fix ci
freeznet Jun 20, 2024
da1a663
fix lint
freeznet Jun 20, 2024
705296e
fix build
freeznet Jun 20, 2024
de4ffda
fix build
freeznet Jun 20, 2024
1a99291
fix test
freeznet Jun 20, 2024
e7381a5
fix lint
freeznet Jun 20, 2024
f8e1322
fix golint
freeznet Jun 20, 2024
4ecfb0f
fix install
freeznet Jun 20, 2024
2f47057
add to charts
freeznet Jun 20, 2024
0a83daa
fix role
freeznet Jun 20, 2024
885d421
fix controller
freeznet Jun 20, 2024
b098130
fix controller
freeznet Jun 20, 2024
471aea5
fix package
freeznet Jun 20, 2024
bf8bbd2
remove package test
freeznet Jun 20, 2024
f38328f
fix ci
freeznet Jun 20, 2024
0b7daca
fix
freeznet Jun 20, 2024
230f190
use functions worker
freeznet Jun 20, 2024
ba13847
revert
freeznet Jun 20, 2024
4fab3d3
fix admin cli
freeznet Jun 21, 2024
4d10922
fix
freeznet Jun 21, 2024
2ef3153
fix charts
freeznet Jun 21, 2024
c710d84
fix license
freeznet Jun 21, 2024
220f28d
fix client version
freeznet Jun 21, 2024
9700005
fix
freeznet Jun 21, 2024
8aefd4a
skip function package
freeznet Jun 21, 2024
c0df511
fix reconcile
freeznet Jun 21, 2024
4e12e77
fix ci
freeznet Jun 21, 2024
126c42f
fix
freeznet Jun 21, 2024
69e4cdf
fix pulsar
freeznet Jun 21, 2024
9ae5c00
fix rep
freeznet Jun 21, 2024
e149496
fix url
freeznet Jun 21, 2024
031cd09
fix tab
freeznet Jun 21, 2024
49edc20
fix
freeznet Jun 21, 2024
01576b4
cleanup proxy
freeznet Jun 21, 2024
c04b98b
fix container name
freeznet Jun 21, 2024
ebc43d2
fix builtin
freeznet Jun 21, 2024
55470bc
fix connectors
freeznet Jun 21, 2024
be7e33e
use pulsar-all
freeznet Jun 21, 2024
2a0594b
docker hub login
freeznet Jun 21, 2024
6043a88
fix pulsarctl
freeznet Jun 21, 2024
35f6e79
fix narExtractionDirectory
freeznet Jun 21, 2024
de600cf
timeout
freeznet Jun 21, 2024
d5fc9f4
fix name
freeznet Jun 21, 2024
1e232dd
add docs
freeznet Jun 21, 2024
35c1eb2
fix license
freeznet Jun 21, 2024
8806ed9
fix chart role
freeznet Jun 21, 2024
96dc91c
Merge branch 'main' into freeznet/add-functions-connectors-admin
freeznet Jun 24, 2024
60bfcda
fix
freeznet Jun 24, 2024
e3bb921
Merge branch 'main' into freeznet/add-functions-connectors-admin
nlu90 Jun 24, 2024
24bf63b
fix license and lint
nlu90 Jun 24, 2024
087c81e
fix lint
nlu90 Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .ci/clusters/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Copyright 2022 StreamNative
#
# 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.

## deployed withh emptyDir
volumes:
persistence: false

# disabled AntiAffinity
affinity:
anti_affinity: false

# disable auto recovery
components:
autorecovery: false
pulsar_manager: false
sql_worker: false
proxy: false
toolset: false

## disable monitoring stack
monitoring:
# monitoring - prometheus
prometheus: false
# monitoring - grafana
grafana: false
# monitoring - node_exporter
node_exporter: false
# alerting - alert-manager
alert_manager: false
# monitoring - loki
loki: false
# monitoring - datadog
datadog: false

images:
zookeeper:
repository: streamnative/sn-platform
tag: 2.10.4.3
bookie:
repository: streamnative/sn-platform
tag: 2.10.4.3
broker:
repository: streamnative/sn-platform
tag: 2.10.4.3
functions:
repository: streamnative/sn-platform
tag: 2.10.4.3

zookeeper:
replicaCount: 1
resources:
requests:
memory: 256Mi
cpu: 10m

bookkeeper:
replicaCount: 1
metadata:
image:
repository: streamnative/sn-platform
tag: 2.10.4.3
resources:
requests:
memory: 256Mi
cpu: 10m
configData:
PULSAR_PREFIX_autoRecoveryDaemonEnabled: "false"
PULSAR_PREFIX_dlog.bkcEnsembleSize: "1"
PULSAR_PREFIX_dlog.bkcWriteQuorumSize: "1"
PULSAR_PREFIX_dlog.bkcAckQuorumSize: "1"
# `BOOKIE_MEM` is used for `bookie shell`
BOOKIE_MEM: >
-Xms128m
-Xmx256m
-XX:MaxDirectMemorySize=256m
# we use `bin/pulsar` for starting bookie daemons
PULSAR_MEM: >
-Xms128m
-Xmx256m
-XX:MaxDirectMemorySize=256m
PULSAR_GC: >
-XX:+UseG1GC
-XX:MaxGCPauseMillis=10
-XX:+ParallelRefProcEnabled
-XX:+UnlockExperimentalVMOptions
-XX:+AggressiveOpts
-XX:+DoEscapeAnalysis
-XX:ParallelGCThreads=4
-XX:ConcGCThreads=4
-XX:G1NewSizePercent=50
-XX:+DisableExplicitGC
-XX:-ResizePLAB
-XX:+ExitOnOutOfMemoryError
-XX:+PerfDisableSharedMem

pulsar_metadata:
image:
repository: streamnative/sn-platform
tag: 2.10.4.3

broker:
replicaCount: 1
configData:
## Enable `autoSkipNonRecoverableData` since bookkeeper is running
## without persistence
autoSkipNonRecoverableData: "true"
# storage settings
managedLedgerDefaultEnsembleSize: "1"
managedLedgerDefaultWriteQuorum: "1"
managedLedgerDefaultAckQuorum: "1"
enablePackagesManagement: "true"
PULSAR_PREFIX_enablePackagesManagement: "true"
resources:
requests:
memory: 256Mi
cpu: 10m

functions:
functionState: false
useDedicatedRunner: false
configData:
narExtractionDirectory: /pulsar/data
4 changes: 4 additions & 0 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
diff config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnamespaces.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarpermissions.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpermissions.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsartenants.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartenants.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarfunctions.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarfunctions.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarsinks.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsinks.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarsources.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsources.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarpackages.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpackages.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsartopics.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartopics.yaml

- name: Set up Helm
Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
ALWAYS_UPDATE_PULSAR_RESOURCE: ${{ matrix.alwaysUpdatePulsar }}
GOPRIVATE: github.com/streamnative
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
IMAGE: apachepulsar/pulsar:latest
IMAGE: streamnative/sn-platform:2.10.4.3
WATCH_CERT_MANAGER_CRDS: "false"
steps:
- name: clean disk
Expand All @@ -54,6 +54,13 @@ jobs:
run: |
git config --global url."https://${ACCESS_TOKEN}:@github.com/".insteadOf "https://github.com/"

- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Ginkgo
run: |
go install github.com/onsi/ginkgo/ginkgo@latest
Expand All @@ -64,7 +71,7 @@ jobs:
# TODO the k8s version should be configurable
- name: Setup K8s cluster
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64
chmod +x ./kind
export PATH="$PWD:$PATH"
kind version
Expand All @@ -79,15 +86,21 @@ jobs:
df -h


- name: Install Pulsar Operators and sn-platform
- name: Install Pulsar Operators and sn-platform
run: |
helm repo add streamnative https://charts.streamnative.io
helm repo add jetstack https://charts.jetstack.io
helm repo update
kubectl create namespace sn-system
helm install pulsar-operators --namespace sn-system streamnative/pulsar-operator
helm install cert-manager --namespace sn-system jetstack/cert-manager --set installCRDs=true
helm install test streamnative/sn-platform --version 1.2.38 --set initialize=true,auth.authentication.enabled=false,auth.authorization.enabled=false,components.toolset=false,components.streamnative_console=false,components.vault=false,components.pulsar_detector=false,monitoring.prometheus=false,monitoring.grafana=false,monitoring.node_exporter=false,monitoring.alert_manager=false,zookeeper.resources.requests.cpu=10m,bookkeeper.resources.requests.cpu=10m,broker.resources.requests.cpu=10m,proxy.resources.requests.cpu=10m
helm install cert-manager jetstack/cert-manager --set installCRDs=true --version v1.8.2

rm -rf pulsar-charts/
git clone --branch pulsar-operator-0.17.10 https://github.com/streamnative/charts.git pulsar-charts
cd pulsar-charts/
./scripts/pulsar/prepare_helm_release.sh -n default -k test -c
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm dependency update charts/pulsar
helm install test --set initialize=true --values ../.ci/clusters/values.yaml charts/pulsar
df -h

- name: Build and Setup Pulsar Resources Operator
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23

# Architecture to use envtest with
ENVTEST_ARCH ?= amd64

KUBE_RBAC_PROXY_IMG ?= gcr.io/kubebuilder/kube-rbac-proxy:v0.14.4

REDHAT_SCAN_REGITRY ?= "quay.io"
Expand Down Expand Up @@ -112,7 +115,7 @@ vet: ## Run go vet against code.

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --arch=${ENVTEST_ARCH} -p path)" go test ./... -coverprofile cover.out

##@ Build

Expand Down Expand Up @@ -181,7 +184,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
.PHONY: controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.8.0)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0)

KUSTOMIZE = $(shell pwd)/bin/kustomize
.PHONY: kustomize
Expand Down Expand Up @@ -289,7 +292,7 @@ husky:
LICENSE_EYE = $(shell pwd)/bin/license-eye
.PHONY: license-eye
license-eye: ## Download license-eye locally if necessary. https://github.com/apache/skywalking-eyes
$(call go-get-tool,$(LICENSE_EYE),github.com/apache/skywalking-eyes/cmd/license-eye@0.4.0)
$(call go-get-tool,$(LICENSE_EYE),github.com/apache/skywalking-eyes/cmd/license-eye@v0.4.0)

## Check if the specified files have the license header in the config file.
.PHONY: license-check
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Currently, the Pulsar Resources Operator provides full lifecycle management for
- Namespaces
- Topics
- Permissions
- Packages
- Functions
- Sinks
- Sources


# Installation
Expand Down Expand Up @@ -98,6 +102,10 @@ In this tutorial, a Kubernetes namespace called `test` is used for examples, whi
- [PulsarNamespace](docs/pulsar_namespace.md)
- [PulsarTopic](docs/pulsar_topic.md)
- [PulsarPermission](docs/pulsar_permission.md)
- [PulsarPackage](docs/pulsar_package.md)
- [PulsarFunction](docs/pulsar_function.md)
- [PulsarSink](docs/pulsar_sink.md)
- [PulsarSource](docs/pulsar_source.md)

## Contributing

Expand Down
49 changes: 49 additions & 0 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,52 @@ func IsPulsarResourceReady(instance reconciler.Object) bool {
instance.GetGeneration() == observedGeneration &&
meta.IsStatusConditionTrue(conditions, ConditionReady)
}

// PackageContentRef indicates the package content reference
type PackageContentRef struct {
// +optional
// persistentVolumeTemplate *corev1.PersistentVolumeClaim `json:"persistentVolumeTemplate,omitempty"`

// +optional
URL string `json:"url,omitempty"`
}

// Resources indicates the resources for the pulsar functions and connectors
type Resources struct {
CPU string `json:"cpu"`
Disk int64 `json:"disk"`
RAM int64 `json:"ram"`
}

// ProducerConfig represents the configuration for the producer of the pulsar functions and connectors
type ProducerConfig struct {
MaxPendingMessages int `json:"maxPendingMessages" yaml:"maxPendingMessages"`
MaxPendingMessagesAcrossPartitions int `json:"maxPendingMessagesAcrossPartitions" yaml:"maxPendingMessagesAcrossPartitions"`

UseThreadLocalProducers bool `json:"useThreadLocalProducers" yaml:"useThreadLocalProducers"`
CryptoConfig *CryptoConfig `json:"cryptoConfig" yaml:"cryptoConfig"`
BatchBuilder string `json:"batchBuilder" yaml:"batchBuilder"`
CompressionType string `json:"compressionType" yaml:"compressionType"`
}

// ConsumerConfig represents the configuration for the consumer of the pulsar functions and connectors
type ConsumerConfig struct {
SchemaType string `json:"schemaType,omitempty" yaml:"schemaType"`
SerdeClassName string `json:"serdeClassName,omitempty" yaml:"serdeClassName"`
RegexPattern bool `json:"regexPattern,omitempty" yaml:"regexPattern"`
ReceiverQueueSize int `json:"receiverQueueSize,omitempty" yaml:"receiverQueueSize"`
SchemaProperties map[string]string `json:"schemaProperties,omitempty" yaml:"schemaProperties"`
ConsumerProperties map[string]string `json:"consumerProperties,omitempty" yaml:"consumerProperties"`
CryptoConfig *CryptoConfig `json:"cryptoConfig,omitempty" yaml:"cryptoConfig"`
PoolMessages bool `json:"poolMessages,omitempty" yaml:"poolMessages"`
}

// CryptoConfig represents the configuration for the crypto of the pulsar functions and connectors
type CryptoConfig struct {
CryptoKeyReaderClassName string `json:"cryptoKeyReaderClassName" yaml:"cryptoKeyReaderClassName"`
CryptoKeyReaderConfig map[string]string `json:"cryptoKeyReaderConfig" yaml:"cryptoKeyReaderConfig"`

EncryptionKeys []string `json:"encryptionKeys" yaml:"encryptionKeys"`
ProducerCryptoFailureAction string `json:"producerCryptoFailureAction" yaml:"producerCryptoFailureAction"`
ConsumerCryptoFailureAction string `json:"consumerCryptoFailureAction" yaml:"consumerCryptoFailureAction"`
}
Loading
Loading