Skip to content

Commit

Permalink
[#4108] Fix schemas and topics screens (#4109)
Browse files Browse the repository at this point in the history
* [#4108] Start Rest Karapace by default

* Update docs for custom partitions

* Add Kafka proxy to the airy-controller

* Fix lint

* Fix Helm test
  • Loading branch information
ljupcovangelski authored Jul 13, 2023
1 parent 7c12413 commit 71fd9f5
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/docs/getting-started/installation/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ Run the following command to create the `Airy` platform without the bundled inst
helm install airy airy/airy --timeout 10m --set prerequisites.kafka.enabled=false --values ./airy.yaml
```

### Kafka partitions per topic

Currently all the default topics in the Airy instance are created with 10 partitions. To create these topics with a different number of partitions, add the following to your `airy.yaml` file before running `helm install` (before the initial creation of the topics):

```
provisioning:
kafka:
partitions: 2
```

### Beanstalkd

The default installation creates its own [Beanstalkd](https://beanstalkd.github.io/) deployment, as it is a prerequisite for using the `integration/webhook` component.
Expand Down
1 change: 1 addition & 0 deletions infrastructure/controller/pkg/endpoints/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_library(
"components_list.go",
"components_update.go",
"cors.go",
"proxy.go",
"server.go",
"services.go",
],
Expand Down
58 changes: 58 additions & 0 deletions infrastructure/controller/pkg/endpoints/proxy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package endpoints

import (
"log"
"net/http"
"net/http/httputil"
"net/url"
"strings"

"k8s.io/client-go/kubernetes"
"k8s.io/helm/cmd/helm/search"
)

type proxyTarget struct {
name string
url string
stripUri string
}

type KafkaSubjects struct {
ClientSet *kubernetes.Clientset
Namespace string
Index *search.Index
}

type KafkaTopics struct {
ClientSet *kubernetes.Clientset
Namespace string
Index *search.Index
}

func (s *KafkaSubjects) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var proxyUpstream = proxyTarget{"subjects", "http://schema-registry:8081/subjects", "/kafka/subjects"}
proxyRequest(w, r, proxyUpstream)
}

func (s *KafkaTopics) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var proxyUpstream = proxyTarget{"subjects", "http://schema-registry:8082/topics", "/kafka/topics"}
proxyRequest(w, r, proxyUpstream)
}

func proxyRequest(w http.ResponseWriter, r *http.Request, proxyUpstream proxyTarget) {
target, err := url.Parse(proxyUpstream.url)
if err != nil {
log.Printf("Error parsing target URL: %v\n", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}

proxy := httputil.NewSingleHostReverseProxy(target)
r.URL.Host = target.Host
r.URL.Scheme = target.Scheme
r.Header.Set("X-Forwarded-Host", r.Header.Get("Host"))
r.Host = target.Host
r.URL.Path = strings.TrimPrefix(r.URL.Path, proxyUpstream.stripUri)

proxy.ServeHTTP(w, r)
}
6 changes: 6 additions & 0 deletions infrastructure/controller/pkg/endpoints/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func Serve(clientSet *kubernetes.Clientset, namespace string, kubeConfig *rest.C
componentsList := ComponentsList{ClientSet: clientSet, Namespace: namespace, Index: helmIndex}
r.Handle("/components.list", &componentsList)

kafkaSubjects := KafkaSubjects{ClientSet: clientSet, Namespace: namespace, Index: helmIndex}
r.Handle("/kafka/subjects", &kafkaSubjects)

kafkaTopics := KafkaTopics{ClientSet: clientSet, Namespace: namespace, Index: helmIndex}
r.Handle("/kafka/topics", &kafkaTopics)

log.Fatal(http.ListenAndServe(":8080", r))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ spec:
ports:
- name: schema-registry
port: {{ .Values.servicePort }}
{{- if .Values.restEnabled }}
- name: rest-api
port: {{ .Values.restPort }}
{{- end}}
selector:
app: schema-registry
release: {{ .Release.Name }}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ kafka:
bootstrapServers: kafka-headless:9092
minBrokers: 1
resources: {}
restEnabled: false
restEnabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ spec:
pathType: Prefix
backend:
service:
name: api-admin
name: airy-controller
port:
number: 80
- path: /kafka
Expand Down

0 comments on commit 71fd9f5

Please sign in to comment.