-
Notifications
You must be signed in to change notification settings - Fork 8
Move router service to its own deployment #137
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
Open
NickCao
wants to merge
54
commits into
main
Choose a base branch
from
router
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
b472c39
Router service: drop reference to k8s client
NickCao b1daa08
Init router binary
NickCao cb978ec
Add router deployment
NickCao f9dd425
Drop router service from main binary
NickCao 55c6cea
Update cmd/router/main.go
NickCao 5bda516
Implement LoadRouterConfiguration
NickCao af5126f
Load router config from configmap
NickCao 1ccb2a8
Update helm chart to support multiple routers
NickCao 4efc688
Fixup nginx ingress endpoints
NickCao 5f1bb03
Fixup ingress controller installation
NickCao f11c5e3
Make router config part of the configmap
NickCao a58d236
Load router configuration into controller service
NickCao b5d1930
Select random router from map
NickCao 343d0f4
Deploy another router
NickCao f93fd05
Update deploy/helm/jumpstarter/charts/jumpstarter-controller/template…
NickCao 6106d0b
Add json schema for values
NickCao 4bb71ea
Per router service config
NickCao 969b31c
Allow setting ingress and route per router
NickCao 3481303
Per router ingress class
NickCao a0d8ecc
Reusable definition
NickCao f6014f1
Reusable router definition
NickCao 8ce6e99
Use common definition for controller service
NickCao 4797d79
Use default .Release.Namespace consistently
NickCao b17a218
Add namespace to schema
NickCao 9c138b9
router -> routers
NickCao 970d669
Disallow additionalProperties
NickCao 2ea7a3c
Improve baseDomain handling
NickCao 99801df
Improve router hostname handling
NickCao e2c60b7
Improve endpoint handling
NickCao c4b2285
Fix helm invocation
NickCao d7df05d
strict tls schema
NickCao 20f2805
Set additionalProperties
NickCao fd06955
Pass labels to controller
NickCao ef2dca7
Implement label based router selection
NickCao f560058
add logging
NickCao 24c7840
Improve deploy script
NickCao 328529c
Make ClusterIP service the default
NickCao 7b26bd6
Default grpc.service.type to ClusterIP
NickCao 9a175bc
Make service optional
NickCao cb154eb
[HACK] Test use router branch of e2e
NickCao c7929a0
Stop running regression tests
NickCao f362e01
Disallow additional properties everywhere
NickCao f147b5b
Document parameters in json schema
NickCao 7e59700
Validate config
NickCao d338489
Move configuration to subchart
NickCao 30975f6
Move more
NickCao 3070c01
Validate global options
NickCao 14060ae
Drop unused values.kind.yaml
NickCao 13f0b26
Enable controller by default
NickCao c6003ea
Add dex port to kind cluster
NickCao 984c5a0
Allow prepending to HELM_SETS
NickCao 672799d
Misc helm chart improvements
NickCao 01e1d65
Add provisioning field to schema
NickCao 9dcb23f
Allow to use all routers
NickCao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,75 @@ | ||
/* | ||
Copyright 2024. | ||
|
||
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. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
ctrl "sigs.k8s.io/controller-runtime" | ||
kclient "sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||
|
||
"github.com/go-logr/logr" | ||
"github.com/jumpstarter-dev/jumpstarter-controller/internal/config" | ||
"github.com/jumpstarter-dev/jumpstarter-controller/internal/service" | ||
) | ||
|
||
func main() { | ||
opts := zap.Options{} | ||
opts.BindFlags(flag.CommandLine) | ||
|
||
flag.Parse() | ||
|
||
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) | ||
logger := ctrl.Log.WithName("router") | ||
ctx := logr.NewContext(context.Background(), logger) | ||
|
||
cfg := ctrl.GetConfigOrDie() | ||
client, err := kclient.New(cfg, kclient.Options{}) | ||
if err != nil { | ||
logger.Error(err, "failed to create k8s client") | ||
os.Exit(1) | ||
} | ||
|
||
serverOption, err := config.LoadRouterConfiguration(ctx, client, kclient.ObjectKey{ | ||
Namespace: os.Getenv("NAMESPACE"), | ||
Name: "jumpstarter-controller", | ||
}) | ||
if err != nil { | ||
logger.Error(err, "failed to load router configuration") | ||
os.Exit(1) | ||
} | ||
|
||
svc := service.RouterService{ | ||
ServerOption: serverOption, | ||
} | ||
|
||
err = svc.Start(ctx) | ||
if err != nil { | ||
logger.Error(err, "failed to start router service") | ||
os.Exit(1) | ||
} | ||
|
||
sigs := make(chan os.Signal, 1) | ||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) | ||
sig := <-sigs | ||
logger.Info("received signal, exiting", "signal", sig) | ||
} |
2 changes: 0 additions & 2 deletions
2
deploy/helm/jumpstarter/charts/jumpstarter-controller/templates/_endpoints.tpl
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
deploy/helm/jumpstarter/charts/jumpstarter-controller/templates/_helpers.yaml
This file contains hidden or 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,56 @@ | ||
{{- define "grpc.hostname" -}} | ||
{{- if $.Values.grpc.hostname -}} | ||
{{ $.Values.grpc.hostname }} | ||
{{- else -}} | ||
grpc.{{ $.Values.global.baseDomain | required "a global.baseDomain or a grpc.hostname must be provided" }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- define "grpc.endpoint" -}} | ||
{{- if $.Values.grpc.endpoint -}} | ||
{{ $.Values.grpc.endpoint }} | ||
{{- else -}} | ||
{{ include "grpc.hostname" $ }}:{{ $.Values.grpc.tls.port }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- define "grpc.service.type" -}} | ||
{{- if $.Values.grpc.service -}} | ||
{{ $.Values.grpc.service.type | default "ClusterIP" }} | ||
{{- else -}} | ||
ClusterIP | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- define "router.hostname" -}} | ||
{{- $g := index . 0 -}} | ||
{{- $k := index . 1 -}} | ||
{{- $v := index . 2 -}} | ||
{{- if $v.hostname -}} | ||
{{ $v.hostname }} | ||
{{- else -}} | ||
router-{{ $k }}.{{ $g.Values.global.baseDomain | required "a global.baseDomain or a grpc.router.<name>.hostname must be provided" }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- define "router.endpoint" -}} | ||
{{- $g := index . 0 -}} | ||
{{- $k := index . 1 -}} | ||
{{- $v := index . 2 -}} | ||
{{- if $v.endpoint -}} | ||
{{ $v.endpoint }} | ||
{{- else -}} | ||
{{ include "router.hostname" . }}:{{ $g.Values.grpc.tls.port }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- define "router.service.type" -}} | ||
{{- $g := index . 0 -}} | ||
{{- $k := index . 1 -}} | ||
{{- $v := index . 2 -}} | ||
{{- if $v.service -}} | ||
{{ $v.service.type | default "ClusterIP" }} | ||
{{- else -}} | ||
ClusterIP | ||
{{- end -}} | ||
{{- end -}} |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{{ if eq .Values.grpc.mode "ingress" }} | ||
{{ if .Values.grpc.ingress }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's avoid changes to configuration formats unless we have a good reason, of course. |
||
{{ if .Values.grpc.ingress.enabled }} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
|
@@ -17,11 +18,7 @@ spec: | |
ingressClassName: {{ .Values.grpc.ingress.class }} | ||
{{ end }} | ||
rules: | ||
{{ if .Values.grpc.hostname }} | ||
- host: {{ .Values.grpc.hostname }} | ||
{{ else }} | ||
- host: grpc.{{ .Values.global.baseDomain | required "a global.baseDomain or a grpc.hostname must be provided"}} | ||
{{ end }} | ||
- host: {{ include "grpc.hostname" . }} | ||
http: | ||
paths: | ||
- path: / | ||
|
@@ -33,12 +30,9 @@ spec: | |
number: 8082 | ||
tls: | ||
- hosts: | ||
{{ if .Values.grpc.hostname }} | ||
- {{ .Values.grpc.hostname }} | ||
{{ else }} | ||
- grpc.{{ .Values.global.baseDomain | required "a global.baseDomain or a grpc.hostname must be provided"}} | ||
{{ end }} | ||
- {{ include "grpc.hostname" . }} | ||
{{ if .Values.grpc.tls.controllerCertSecret }} | ||
secretName: {{ .Values.grpc.tls.controllerCertSecret }} | ||
{{ end }} | ||
{{ end }} | ||
{{ end }} |
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{{ if eq .Values.grpc.mode "route" }} | ||
{{ if .Values.grpc.route }} | ||
{{ if .Values.grpc.route.enabled }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
apiVersion: route.openshift.io/v1 | ||
kind: Route | ||
metadata: | ||
|
@@ -11,11 +12,7 @@ metadata: | |
name: jumpstarter-controller-route | ||
namespace: {{ default .Release.Namespace .Values.namespace }} | ||
spec: | ||
{{ if .Values.grpc.hostname }} | ||
host: {{ .Values.grpc.hostname }} | ||
{{ else }} | ||
host: grpc.{{ .Values.global.baseDomain | required "a global.baseDomain or a grpc.hostname must be provided"}} | ||
{{ end }} | ||
host: {{ include "grpc.hostname" . }} | ||
port: | ||
targetPort: 8082 | ||
tls: | ||
|
@@ -32,3 +29,4 @@ spec: | |
weight: 100 | ||
wildcardPolicy: None | ||
{{ end }} | ||
{{ end }} |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.