1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Feature] [Integration] Basic Envs (#1749)

This commit is contained in:
Adam Janikowski 2024-10-23 11:42:32 +02:00 committed by GitHub
parent 846b6218af
commit f91155478a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 76 additions and 3 deletions

View file

@ -7,6 +7,7 @@
- (Feature) (Integration) SchedulerV2 Definition
- (Maintenance) Proto Lint
- (Feature) (Integration) SchedulerV2
- (Feature) (Integration) Basic Envs
## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
- (Feature) ArangoRoute CRD

View file

@ -0,0 +1,28 @@
# Integration
## Profile
## Sidecar
### Resource Types
Integration Sidecar is supported in a few resources managed by Operator:
- ArangoSchedulerDeployment (scheduler.arangodb.com/v1beta1)
- ArangoSchedulerBatchJob (scheduler.arangodb.com/v1beta1)
- ArangoSchedulerCronJob (scheduler.arangodb.com/v1beta1)
- ArangoSchedulerPod (scheduler.arangodb.com/v1beta1)
### Envs
#### ARANGO_DEPLOYMENT_NAME
ArangoDeployment name.
Example: `deployment`
#### ARANGO_DEPLOYMENT_ENDPOINT
HTTP/S Endpoint of the ArangoDeployment Internal Service.
Example: `https://deployment.default.svc:8529`

View file

@ -25,11 +25,15 @@ import (
"fmt"
"time"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
schedulerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1"
schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container"
schedulerContainerResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container/resources"
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/deployment/patch"
"github.com/arangodb/kube-arangodb/pkg/integrations/sidecar"
"github.com/arangodb/kube-arangodb/pkg/metrics"
@ -109,7 +113,7 @@ func (r *Resources) EnsureArangoProfiles(ctx context.Context, cachedStatus inspe
integration, err := sidecar.NewIntegration(&schedulerContainerResourcesApi.Image{
Image: util.NewType(r.context.GetOperatorImage()),
}, spec.Integration.GetSidecar(), r.arangoDeploymentProfileTemplate())
}, spec.Integration.GetSidecar(), r.arangoDeploymentProfileTemplate(cachedStatus))
if err != nil {
return "", nil, err
}
@ -144,8 +148,48 @@ func (r *Resources) EnsureArangoProfiles(ctx context.Context, cachedStatus inspe
return reconcileRequired.Reconcile(ctx)
}
func (r *Resources) arangoDeploymentProfileTemplate() *schedulerApi.ProfileTemplate {
return nil
func (r *Resources) arangoDeploymentInternalAddress(cachedStatus inspectorInterface.Inspector) string {
spec := r.context.GetSpec()
apiObject := r.context.GetAPIObject()
deploymentName := apiObject.GetName()
proto := util.BoolSwitch(spec.IsSecure(), "https", "http")
svc, ok := cachedStatus.Service().V1().GetSimple(deploymentName)
if !ok {
return ""
}
if spec.CommunicationMethod.Get() == api.DeploymentCommunicationMethodIP {
if ip := svc.Spec.ClusterIP; ip != core.ClusterIPNone && ip != "" {
return fmt.Sprintf("%s://%s:%d", proto, ip, shared.ArangoPort)
}
}
return fmt.Sprintf("%s://%s:%d", proto, k8sutil.CreateDatabaseClientServiceDNSNameWithDomain(svc, spec.ClusterDomain), shared.ArangoPort)
}
func (r *Resources) arangoDeploymentProfileTemplate(cachedStatus inspectorInterface.Inspector) *schedulerApi.ProfileTemplate {
apiObject := r.context.GetAPIObject()
deploymentName := apiObject.GetName()
return &schedulerApi.ProfileTemplate{
Container: &schedulerApi.ProfileContainerTemplate{
All: &schedulerContainerApi.Generic{
Environments: &schedulerContainerResourcesApi.Environments{
Env: []core.EnvVar{
{
Name: "ARANGO_DEPLOYMENT_NAME",
Value: deploymentName,
},
{
Name: "ARANGO_DEPLOYMENT_ENDPOINT",
Value: r.arangoDeploymentInternalAddress(cachedStatus),
},
},
},
},
},
}
}
func (r *Resources) ensureArangoProfilesFactory(ctx context.Context, cachedStatus inspectorInterface.Inspector, expected ...func() (string, *schedulerApi.ArangoProfile, error)) (bool, error) {