Skip to content

Commit f911554

Browse files
authored
[Feature] [Integration] Basic Envs (#1749)
1 parent 846b621 commit f911554

File tree

3 files changed

+76
-3
lines changed

3 files changed

+76
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- (Feature) (Integration) SchedulerV2 Definition
88
- (Maintenance) Proto Lint
99
- (Feature) (Integration) SchedulerV2
10+
- (Feature) (Integration) Basic Envs
1011

1112
## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
1213
- (Feature) ArangoRoute CRD

docs/integration-sidecar.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Integration
2+
3+
## Profile
4+
5+
## Sidecar
6+
7+
### Resource Types
8+
9+
Integration Sidecar is supported in a few resources managed by Operator:
10+
11+
- ArangoSchedulerDeployment (scheduler.arangodb.com/v1beta1)
12+
- ArangoSchedulerBatchJob (scheduler.arangodb.com/v1beta1)
13+
- ArangoSchedulerCronJob (scheduler.arangodb.com/v1beta1)
14+
- ArangoSchedulerPod (scheduler.arangodb.com/v1beta1)
15+
16+
### Envs
17+
18+
#### ARANGO_DEPLOYMENT_NAME
19+
20+
ArangoDeployment name.
21+
22+
Example: `deployment`
23+
24+
#### ARANGO_DEPLOYMENT_ENDPOINT
25+
26+
HTTP/S Endpoint of the ArangoDeployment Internal Service.
27+
28+
Example: `https://deployment.default.svc:8529`

pkg/deployment/resources/arango_profiles.go

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ import (
2525
"fmt"
2626
"time"
2727

28+
core "k8s.io/api/core/v1"
2829
"k8s.io/apimachinery/pkg/api/equality"
2930
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3031

32+
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3133
schedulerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1"
34+
schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container"
3235
schedulerContainerResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container/resources"
36+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
3337
"github.com/arangodb/kube-arangodb/pkg/deployment/patch"
3438
"github.com/arangodb/kube-arangodb/pkg/integrations/sidecar"
3539
"github.com/arangodb/kube-arangodb/pkg/metrics"
@@ -109,7 +113,7 @@ func (r *Resources) EnsureArangoProfiles(ctx context.Context, cachedStatus inspe
109113

110114
integration, err := sidecar.NewIntegration(&schedulerContainerResourcesApi.Image{
111115
Image: util.NewType(r.context.GetOperatorImage()),
112-
}, spec.Integration.GetSidecar(), r.arangoDeploymentProfileTemplate())
116+
}, spec.Integration.GetSidecar(), r.arangoDeploymentProfileTemplate(cachedStatus))
113117
if err != nil {
114118
return "", nil, err
115119
}
@@ -144,8 +148,48 @@ func (r *Resources) EnsureArangoProfiles(ctx context.Context, cachedStatus inspe
144148
return reconcileRequired.Reconcile(ctx)
145149
}
146150

147-
func (r *Resources) arangoDeploymentProfileTemplate() *schedulerApi.ProfileTemplate {
148-
return nil
151+
func (r *Resources) arangoDeploymentInternalAddress(cachedStatus inspectorInterface.Inspector) string {
152+
spec := r.context.GetSpec()
153+
apiObject := r.context.GetAPIObject()
154+
deploymentName := apiObject.GetName()
155+
156+
proto := util.BoolSwitch(spec.IsSecure(), "https", "http")
157+
svc, ok := cachedStatus.Service().V1().GetSimple(deploymentName)
158+
if !ok {
159+
return ""
160+
}
161+
162+
if spec.CommunicationMethod.Get() == api.DeploymentCommunicationMethodIP {
163+
if ip := svc.Spec.ClusterIP; ip != core.ClusterIPNone && ip != "" {
164+
return fmt.Sprintf("%s://%s:%d", proto, ip, shared.ArangoPort)
165+
}
166+
}
167+
168+
return fmt.Sprintf("%s://%s:%d", proto, k8sutil.CreateDatabaseClientServiceDNSNameWithDomain(svc, spec.ClusterDomain), shared.ArangoPort)
169+
}
170+
171+
func (r *Resources) arangoDeploymentProfileTemplate(cachedStatus inspectorInterface.Inspector) *schedulerApi.ProfileTemplate {
172+
apiObject := r.context.GetAPIObject()
173+
deploymentName := apiObject.GetName()
174+
175+
return &schedulerApi.ProfileTemplate{
176+
Container: &schedulerApi.ProfileContainerTemplate{
177+
All: &schedulerContainerApi.Generic{
178+
Environments: &schedulerContainerResourcesApi.Environments{
179+
Env: []core.EnvVar{
180+
{
181+
Name: "ARANGO_DEPLOYMENT_NAME",
182+
Value: deploymentName,
183+
},
184+
{
185+
Name: "ARANGO_DEPLOYMENT_ENDPOINT",
186+
Value: r.arangoDeploymentInternalAddress(cachedStatus),
187+
},
188+
},
189+
},
190+
},
191+
},
192+
}
149193
}
150194

151195
func (r *Resources) ensureArangoProfilesFactory(ctx context.Context, cachedStatus inspectorInterface.Inspector, expected ...func() (string, *schedulerApi.ArangoProfile, error)) (bool, error) {

0 commit comments

Comments
 (0)