8000 Unify paths · arangodb/kube-arangodb@0fa6741 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fa6741

Browse files
committed
Unify paths
1 parent b61beb8 commit 0fa6741

File tree

5 files changed

+67
-30
lines changed

5 files changed

+67
-30
lines changed

pkg/deployment/resources/config_map_gateway.go

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ import (
4646
)
4747

4848
func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspectorInterface.Inspector, configMaps generic.ModClient[*core.ConfigMap]) error {
49-
deploymentName := r.context.GetAPIObject().GetName()
50-
configMapName := GetGatewayConfigMapName(deploymentName)
51-
52-
log := r.log.Str("section", "gateway-config").Str("name", configMapName)
53-
5449
cfg, err := r.renderGatewayConfig(cachedStatus)
5550
if err != nil {
5651
return errors.WithStack(errors.Wrapf(err, "Failed to generate gateway config"))
@@ -94,20 +89,40 @@ func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspec
9489
return errors.WithStack(errors.Wrapf(err, "Failed to render gateway lds config"))
9590
}
9691

97-
elements, err := r.renderConfigMap(map[string]string{
98-
constants.GatewayConfigFileName: string(gatewayCfgYaml),
99-
constants.GatewayCDSConfigFileName: string(gatewayCfgCDSYaml),
100-
constants.GatewayLDSConfigFileName: string(gatewayCfgLDSYaml),
101-
})
92+
if err := r.ensureGatewayConfigMap(ctx, cachedStatus, configMaps, GetGatewayConfigMapName(r.context.GetAPIObject().GetName()), map[string]string{
93+
constants.GatewayConfigFileName: string(gatewayCfgYaml),
94+
}); err != nil {
95+
return err
96+
}
97+
98+
if err := r.ensureGatewayConfigMap(ctx, cachedStatus, configMaps, GetGatewayConfigMapName(r.context.GetAPIObject().GetName(), "cds"), map[string]string{
99+
constants.GatewayConfigFileName: string(gatewayCfgCDSYaml),
100+
}); err != nil {
101+
return err
102+
}
103+
104+
if err := r.ensureGatewayConfigMap(ctx, cachedStatus, configMaps, GetGatewayConfigMapName(r.context.GetAPIObject().GetName(), "lds"), map[string]string{
105+
constants.GatewayConfigFileName: string(gatewayCfgLDSYaml),
106+
}); err != nil {
107+
return err
108+
}
109+
110+
return nil
111+
}
112+
113+
func (r *Resources) ensureGatewayConfigMap(ctx context.Context, cachedStatus inspectorInterface.Inspector, configMaps generic.ModClient[*core.ConfigMap], name string, data map[string]string) error {
114+
log := r.log.Str("section", "gateway-config").Str("name", name)
115+
116+
elements, err := r.renderConfigMap(data)
102117
if err != nil {
103118
return errors.WithStack(errors.Wrapf(err, "Failed to render gateway config"))
104119
}
105120

106-
if cm, exists := cachedStatus.ConfigMap().V1().GetSimple(configMapName); !exists {
121+
if cm, exists := cachedStatus.ConfigMap().V1().GetSimple(name); !exists {
107122
// Create
108123
cm = &core.ConfigMap{
109124
ObjectMeta: meta.ObjectMeta{
110-
Name: configMapName,
125+
Name: name,
111126
},
112127
Data: elements,
113128
}

pkg/deployment/resources/config_map_gateway_member.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ func (r *Resources) ensureMemberConfigGatewayConfig(ctx context.Context, cachedS
3535
}
3636

3737
data, _, _, err := gateway.NodeDynamicConfig("arangodb", member.Member.ID, &gateway.DynamicConfig{
38-
Path: constants.GatewayVolumeMountDir,
39-
File: constants.GatewayCDSConfigFileName,
38+
Path: constants.GatewayCDSVolumeMountDir,
39+
File: constants.GatewayConfigFileName,
4040
}, &gateway.DynamicConfig{
41-
Path: constants.GatewayVolumeMountDir,
42-
File: constants.GatewayLDSConfigFileName,
41+
Path: constants.GatewayLDSVolumeMountDir,
42+
File: constants.GatewayConfigFileName,
4343
})
4444
if err != nil {
4545
return nil, err
4646
}
4747

4848
return map[string]string{
49-
constants.GatewayDynamicConfigFileName: string(data),
49+
constants.GatewayConfigFileName: string(data),
5050
}, nil
5151
}

pkg/deployment/resources/pod_creator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func createArangoSyncArgs(apiObject meta.Object, spec api.DeploymentSpec, group
290290
func createArangoGatewayArgs(input pod.Input, additionalOptions ...k8sutil.OptionPair) []string {
291291
options := k8sutil.CreateOptionPairs(64)
292292
if input.Deployment.Gateway.IsDynamic() {
293-
options.Add("--config-path", path.Join(constants.MemberConfigVolumeMountDir, constants.GatewayDynamicConfigFileName))
293+
options.Add("--config-path", path.Join(constants.MemberConfigVolumeMountDir, constants.GatewayConfigFileName))
294294
} else {
295295
options.Add("--config-path", path.Join(constants.GatewayVolumeMountDir, constants.GatewayConfigFileName))
296296
}

pkg/deployment/resources/pod_creator_gateway.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package resources
2222

2323
import (
2424
"fmt"
25+
"strings"
2526

2627
core "k8s.io/api/core/v1"
2728

@@ -30,20 +31,36 @@ import (
3031
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3132
)
3233

33-
func GetGatewayConfigMapName(name string) string {
34-
return fmt.Sprintf("%s-gateway", name)
34+
func GetGatewayConfigMapName(name string, parts ...string) string {
35+
if len(parts) == 0 {
36+
return fmt.Sprintf("%s-gateway", name)
37+
}
38+
39+
return fmt.Sprintf("%s-gateway-%s", name, strings.Join(parts, "-"))
3540
}
3641

3742
func createGatewayVolumes(input pod.Input) pod.Volumes {
3843
volumes := pod.NewVolumes()
3944

4045
volumes.AddVolume(k8sutil.CreateVolumeWithConfigMap(constants.GatewayVolumeName, GetGatewayConfigMapName(input.ApiObject.GetName())))
46+
volumes.AddVolume(k8sutil.CreateVolumeWithConfigMap(constants.GatewayCDSVolumeName, GetGatewayConfigMapName(input.ApiObject.GetName(), "cds")))
47+
volumes.AddVolume(k8sutil.CreateVolumeWithConfigMap(constants.GatewayLDSVolumeName, GetGatewayConfigMapName(input.ApiObject.GetName(), "lds")))
4148
volumes.AddVolume(k8sutil.CreateVolumeWithConfigMap(constants.MemberConfigVolumeName, input.ArangoMember.GetName()))
4249
volumes.AddVolumeMount(core.VolumeMount{
4350
Name: constants.GatewayVolumeName,
4451
MountPath: constants.GatewayVolumeMountDir,
4552
ReadOnly: true,
4653
})
54+
volumes.AddVolumeMount(core.VolumeMount{
55+
Name: constants.GatewayCDSVolumeName,
56+
MountPath: constants.GatewayCDSVolumeMountDir,
57+
ReadOnly: true,
58+
})
59+
volumes.AddVolumeMount(core.VolumeMount{
60+
Name: constants.GatewayCDSVolumeName,
61+
MountPath: constants.GatewayCDSVolumeMountDir,
62+
ReadOnly: true,
63+
})
4764
volumes.AddVolumeMount(core.VolumeMount{
4865
Name: constants.MemberConfigVolumeName,
4966
MountPath: constants.MemberConfigVolumeMountDir,

pkg/util/constants/gateway.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,20 @@ package constants
2323
const (
2424
ConfigMapChecksumKey = "CHECKSUM"
2525

26-
ArangoGatewayExecutor = "/usr/local/bin/envoy"
27-
GatewayVolumeMountDir = "/etc/gateway/"
28-
GatewayVolumeName = "gateway"
29-
GatewayConfigFileName = "gateway.yaml"
30-
GatewayDynamicConfigFileName = "gateway.dynamic.yaml"
31-
GatewayCDSConfigFileName = "gateway.dynamic.cds.yaml"
32-
GatewayLDSConfigFileName = "gateway.dynamic.lds.yaml"
33-
GatewayConfigChecksumENV = "GATEWAY_CONFIG_CHECKSUM"
34-
35-
MemberConfigVolumeMountDir = "/etc/member/"
26+
ArangoGatewayExecutor = "/usr/local/bin/envoy"
27+
28+
GatewayConfigFileName = "gateway.yaml"
29+
GatewayConfigChecksumENV = "GATEWAY_CONFIG_CHECKSUM"
30+
31+
GatewayVolumeMountDir = "/etc/gateway/core/"
32+
GatewayVolumeName = "gateway"
33+
34+
GatewayLDSVolumeMountDir = "/etc/gateway/lds/"
35+
GatewayLDSVolumeName = "gateway-lds"
36+
37+
GatewayCDSVolumeMountDir = "/etc/gateway/cds/"
38+
GatewayCDSVolumeName = "gateway-cds"
39+
40+
MemberConfigVolumeMountDir = "/etc/gateway/member/"
3641
MemberConfigVolumeName = "member-config"
3742
)

0 commit comments

Comments
 (0)
0