Skip to content

Commit

Permalink
add optional ingress in specs (#9)
Browse files Browse the repository at this point in the history
* added reverse proxy ingress (draft) #4

* added annotations #4

* fixed ownerships #4

* changes in README.md #4

* changes in README.md #4

* changes in README.md #4

* changes in README.md #4

* finalized ingress #4
  • Loading branch information
akyriako authored Dec 9, 2024
1 parent 5b63fcc commit 979b1cf
Show file tree
Hide file tree
Showing 25 changed files with 698 additions and 150 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ OPERATOR_SDK_VERSION ?= v1.38.0
# Image URL to use all building/pushing image targets
DOCKER_HUB_NAME ?= $(shell docker info | sed '/Username:/!d;s/.* //')
IMG_NAME ?= typesense-operator
IMG_TAG ?= 0.2.0-rc.0
IMG_TAG ?= 0.2.1
IMG ?= $(DOCKER_HUB_NAME)/$(IMG_NAME):$(IMG_TAG)

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
Expand Down Expand Up @@ -200,11 +200,11 @@ undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.

.PHONY: deploy-with-samples
deploy-with-samples: kustomize generate manifests install ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/samples | $(KUBECTL) apply -f -
$(KUSTOMIZE) build config/samples | $(KUBECTL) apply -f config/samples/ts_v1alpha1_typesensecluster_kind.yaml

.PHONY: samples
samples: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/samples | $(KUBECTL) apply -f -
$(KUSTOMIZE) build config/samples | $(KUBECTL) apply -f config/samples/ts_v1alpha1_typesensecluster_kind.yaml

##@ Dependencies

Expand Down
200 changes: 114 additions & 86 deletions README.md

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions api/v1alpha1/typesensecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type TypesenseClusterSpec struct {
CorsDomains *string `json:"corsDomains,omitempty"`

Storage *StorageSpec `json:"storage"`

Ingress *IngressSpec `json:"ingress,omitempty"`
}

type StorageSpec struct {
Expand All @@ -66,12 +68,20 @@ type StorageSpec struct {
StorageClassName string `json:"storageClassName"`
}

type CorsSpec struct {

type IngressSpec struct {
// +optional
// +kubebuilder:default=true
// +kubebuilder:validation:Type=boolean
Enabled bool `json:"enabled,omitempty"`
// +kubebuilder:validation:Pattern:=`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$`
Referer *string `json:"referer,omitempty"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern:=`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$`
Host string `json:"host"`

ClusterIssuer string `json:"clusterIssuer"`

IngressClassName string `json:"ingressClassName"`

Annotations map[string]string `json:"annotations,omitempty"`
}

// TypesenseClusterStatus defines the observed state of TypesenseCluster
Expand Down
25 changes: 21 additions & 4 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions charts/typesense-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.2.1
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.2.0-rc.0"
appVersion: "0.2.1"
4 changes: 1 addition & 3 deletions charts/typesense-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ spec:
kubectl.kubernetes.io/default-container: manager
spec:
containers:
- args:
{{- toYaml .Values.controllerManager.manager.args | nindent 8 }}
- --zap-log-level={{ .Values.controllerManager.manager.logLevel }}
- args: {{- toYaml .Values.controllerManager.manager.args | nindent 8 }}
command:
- /manager
env:
Expand Down
32 changes: 32 additions & 0 deletions charts/typesense-operator/templates/manager-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rules:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
Expand All @@ -30,24 +31,43 @@ rules:
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
Expand All @@ -60,6 +80,18 @@ rules:
verbs:
- create
- patch
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ts.opentelekomcloud.com
resources:
Expand Down
21 changes: 21 additions & 0 deletions charts/typesense-operator/templates/typesensecluster-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ spec:
type: string
image:
type: string
ingress:
properties:
annotations:
additionalProperties:
type: string
type: object
clusterIssuer:
type: string
host:
pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$
type: string
ingressClassName:
type: string
referer:
pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$
type: string
required:
- clusterIssuer
- host
- ingressClassName
type: object
peeringPort:
default: 8107
type: integer
Expand Down
4 changes: 2 additions & 2 deletions charts/typesense-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ controllerManager:
- --metrics-bind-address=:8443
- --leader-elect
- --health-probe-bind-address=:8081
logLevel: debug
- --zap-log-level=info
containerSecurityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
image:
repository: akyriako78/typesense-operator
tag: 0.2.0-rc.0
tag: 0.2.1
resources:
limits:
cpu: 500m
Expand Down
21 changes: 21 additions & 0 deletions config/crd/bases/ts.opentelekomcloud.com_typesenseclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ spec:
type: string
image:
type: string
ingress:
properties:
annotations:
additionalProperties:
type: string
type: object
clusterIssuer:
type: string
host:
pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$
type: string
ingressClassName:
type: string
referer:
pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$
type: string
required:
- clusterIssuer
- host
- ingressClassName
type: object
peeringPort:
default: 8107
type: integer
Expand Down
32 changes: 32 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rules:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
Expand All @@ -29,24 +30,43 @@ rules:
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
Expand All @@ -59,6 +79,18 @@ rules:
verbs:
- create
- patch
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ts.opentelekomcloud.com
resources:
Expand Down
4 changes: 2 additions & 2 deletions config/samples/ts_v1alpha1_typesensecluster_aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/name: typesense-operator
app.kubernetes.io/managed-by: kustomize
name: cluster-1
name: c-aws-1
spec:
image: typesense/typesense:27.1
replicas: 3
Expand All @@ -18,7 +18,7 @@ metadata:
labels:
app.kubernetes.io/name: typesense-operator
app.kubernetes.io/managed-by: kustomize
name: cluster-2
name: c-aws-2
spec:
image: typesense/typesense:27.1
replicas: 1
Expand Down
4 changes: 2 additions & 2 deletions config/samples/ts_v1alpha1_typesensecluster_azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/name: typesense-operator
app.kubernetes.io/managed-by: kustomize
name: cluster-1
name: c-az-1
spec:
image: typesense/typesense:27.1
replicas: 3
Expand All @@ -18,7 +18,7 @@ metadata:
labels:
app.kubernetes.io/name: typesense-operator
app.kubernetes.io/managed-by: kustomize
name: cluster-2
name: c-az-2
spec:
image: typesense/typesense:26.0
replicas: 1
Expand Down
4 changes: 2 additions & 2 deletions config/samples/ts_v1alpha1_typesensecluster_bm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/name: typesense-operator
app.kubernetes.io/managed-by: kustomize
name: cluster-1
name: c-bm-1
spec:
image: typesense/typesense:27.1
replicas: 3
Expand All @@ -18,7 +18,7 @@ metadata:
labels:
app.kubernetes.io/name: typesense-operator
app.kubernetes.io/managed-by: kustomize
name: cluster-2
name: c-bm-2
spec:
image: typesense/typesense:27.1
replicas: 1
Expand Down
Loading

0 comments on commit 979b1cf

Please sign in to comment.