-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gateway - Keep one Route and manage the rest via a Gateway
This change is part of an effort to re-enable the sfconfig gateway in order to give a technical solution for: - Provide a welcome page - Provide a central point for a global authentication - Provide an unique entry point for incoming http connections (logging) This gateway system can be more flexible than the Openshift Route or k8s Ingress. This change: - enables proxy path for logserver - enables the nodepool-builder log proxypass - enables the nodepool-launcher api proxypass - enables the zuul api proxypass - adds rule to redirect '/' to Zuul tenant page - cleans no longer needed Route resources Change-Id: I13541a9a40d9fbcdb0aaa986e049d38c80ca7866
- Loading branch information
Showing
11 changed files
with
159 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (C) 2024 Red Hat | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// This package contains the git-server configuration. | ||
|
||
package controllers | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/softwarefactory-project/sf-operator/controllers/libs/base" | ||
"github.com/softwarefactory-project/sf-operator/controllers/libs/utils" | ||
appsv1 "k8s.io/api/apps/v1" | ||
apiv1 "k8s.io/api/core/v1" | ||
) | ||
|
||
//go:embed static/gateway/gateway.conf | ||
var gatewayConfig string | ||
|
||
func (r *SFController) DeployHTTPDGateway() bool { | ||
|
||
const ( | ||
ident = "gateway" | ||
port = 8080 | ||
) | ||
|
||
srv := base.MkService(ident, r.ns, ident, []int32{port}, ident) | ||
r.GetOrCreate(&srv) | ||
|
||
r.EnsureConfigMap(ident, map[string]string{ | ||
"gateway.conf": gatewayConfig, | ||
}) | ||
|
||
annotations := map[string]string{ | ||
"image": base.HTTPDImage(), | ||
"httpd-conf": utils.Checksum([]byte(gatewayConfig)), | ||
"serial": "1", | ||
} | ||
|
||
dep := base.MkDeployment(ident, r.ns, base.HTTPDImage()) | ||
dep.Spec.Template.ObjectMeta.Annotations = annotations | ||
dep.Spec.Template.Spec.Volumes = []apiv1.Volume{ | ||
base.MkVolumeCM(ident, ident+"-config-map"), | ||
} | ||
dep.Spec.Template.Spec.Containers[0].VolumeMounts = []apiv1.VolumeMount{ | ||
{ | ||
Name: ident, | ||
MountPath: "/etc/httpd/conf.d/gateway.conf", | ||
ReadOnly: true, | ||
SubPath: "gateway.conf", | ||
}, | ||
} | ||
|
||
current := appsv1.Deployment{} | ||
if r.GetM(ident, ¤t) { | ||
if !utils.MapEquals(¤t.Spec.Template.ObjectMeta.Annotations, &annotations) { | ||
r.log.V(1).Info("gateway configuration changed, rollout gateway pods ...") | ||
current.Spec = dep.DeepCopy().Spec | ||
r.UpdateR(¤t) | ||
return false | ||
} | ||
} else { | ||
current := dep | ||
r.CreateR(¤t) | ||
} | ||
|
||
isDeploymentReady := r.IsDeploymentReady(¤t) | ||
|
||
routeReady := r.ensureHTTPSRoute( | ||
ident, r.cr.Spec.FQDN, | ||
ident, "/", port, map[string]string{}, r.cr.Spec.LetsEncrypt) | ||
|
||
isReady := isDeploymentReady && routeReady | ||
|
||
return isReady | ||
} |
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
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,29 @@ | ||
# LogLevel alert proxy:trace6 | ||
|
||
<IfModule mod_proxy.c> | ||
ProxyVia On | ||
ProxyRequests Off | ||
|
||
# Redirect root requests to Zuul web | ||
ProxyPassMatch "^/?$" "http://zuul-web:9000/" retry=0 | ||
|
||
# Handle logserver requests | ||
ProxyPassMatch "^/logs$" "http://logserver:8080/" retry=0 | ||
ProxyPassMatch "^/logs/(.*)$" "http://logserver:8080/logs/$1" retry=0 | ||
ProxyPassReverse /logs http://logserver:8080/logs | ||
|
||
# Handle nodepool build logs requests | ||
ProxyPassMatch "^/nodepool/builds$" "http://nodepool-builder:8080/" retry=0 | ||
ProxyPassMatch "^/nodepool/builds/(.*)$" "http://nodepool-builder:8080/nodepool/builds/$1" retry=0 | ||
ProxyPassReverse /nodepool/builds http://nodepool-builder:8080/nodepool/builds | ||
|
||
# Handle nodepool API requests | ||
ProxyPassMatch "^/nodepool/api/(.*)$" "http://nodepool-launcher:8006/$1" retry=0 | ||
ProxyPassReverse /nodepool/api http://nodepool-launcher:8006/ | ||
|
||
# Handle Zuul requests | ||
ProxyPassMatch "^/zuul/api/tenant/(.*)/console-stream$" "ws://zuul-web:9000/api/tenant/$1/console-stream" retry=0 | ||
ProxyPassMatch "^/zuul$" "http://zuul-web:9000/" retry=0 | ||
ProxyPassMatch "^/zuul/(.*)$" "http://zuul-web:9000/$1" retry=0 | ||
ProxyPassReverse /zuul http://zuul-web:9000/ | ||
</IfModule> |
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
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