-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
7c12413
commit 71fd9f5
Showing
7 changed files
with
81 additions
and
2 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,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) | ||
} |
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 |
---|---|---|
|
@@ -9,4 +9,4 @@ kafka: | |
bootstrapServers: kafka-headless:9092 | ||
minBrokers: 1 | ||
resources: {} | ||
restEnabled: false | ||
restEnabled: true |
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