Skip to content

Commit

Permalink
fix lookout cancellation bug; slim down redis; rename postgres -> pos…
Browse files Browse the repository at this point in the history
…tgresql (#320)

Signed-off-by: Dejan Zele Pejchev <pejcev.dejan@gmail.com>
  • Loading branch information
dejanzele authored Aug 6, 2024
1 parent 7cfe1e7 commit 6ea2d95
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 83 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ helm-uninstall-pulsar: ## Uninstall Apache Pulsar using Helm.

.PHONY: helm-install-postgres
helm-install-postgres: helm-repos ## Install PostgreSQL using Helm.
helm upgrade --install postgres bitnami/postgresql --values dev/quickstart/postgres.values.yaml --create-namespace --namespace data
helm upgrade --install postgresql bitnami/postgresql --values dev/quickstart/postgres.values.yaml --create-namespace --namespace data

.PHONY: helm-uninstall-postgres
helm-uninstall-postgres: ## Uninstall PostgreSQL using Helm.
helm uninstall postgres --namespace data
helm uninstall postgresql --namespace data

.PHONY: helm-install-redis
helm-install-redis: helm-repos ## Install Redis using Helm.
Expand Down
13 changes: 10 additions & 3 deletions api/install/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import (
"sigs.k8s.io/yaml"
)

const (
defaultHTTPPort = 8080
defaultGRPCPort = 50051
defaultMetricsPort = 9000
)

type Image struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Pattern:="^([a-z0-9]+(?:[._-][a-z0-9]+)*/*)+$"
Expand Down Expand Up @@ -73,6 +79,7 @@ type PortConfig struct {
MetricsPort int32 `json:"metricsPort"`
}

// CommonSpecBase is the common configuration for all services.
// NOTE(Clif): You must label this with `json:""` when using it as an embedded
// struct in order for controller-gen to use the promoted fields as expected.
type CommonSpecBase struct {
Expand Down Expand Up @@ -114,9 +121,9 @@ func BuildPortConfig(rawAppConfig runtime.RawExtension) (PortConfig, error) {
}
// defaults
portConfig := PortConfig{
HttpPort: 8080,
GrpcPort: 50051,
MetricsPort: 9000,
HttpPort: defaultHTTPPort,
GrpcPort: defaultGRPCPort,
MetricsPort: defaultMetricsPort,
}
err = yaml.Unmarshal([]byte(appConfig), &portConfig)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions dev/crd/out.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ _Appears in:_



CommonSpecBase is the common configuration for all services.
NOTE(Clif): You must label this with `json:""` when using it as an embedded
struct in order for controller-gen to use the promoted fields as expected.

Expand Down
36 changes: 23 additions & 13 deletions dev/quickstart/armada-crs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ spec:
replicas: 1
image:
repository: gresearch/armada-server
tag: 0.8.2
tag: latest
applicationConfig:
httpNodePort: 30001
grpcNodePort: 30002
schedulerApiConnection:
armadaUrl: "armada-scheduler.armada.svc.cluster.local:50051"
forceNoTls: true
corsAllowedOrigins:
- "http://localhost:3000"
- "http://localhost:8089"
- "http://localhost:10000"
- "http://localhost:30000"
auth:
anonymousAuth: true
permissionGroupMapping:
Expand All @@ -33,7 +41,7 @@ spec:
- redis-ha.data.svc.cluster.local:6379
postgres:
connection:
host: postgres-postgresql.data.svc.cluster.local
host: postgresql.data.svc.cluster.local
port: 5432
user: postgres
password: psw
Expand All @@ -42,7 +50,7 @@ spec:
queryapi:
postgres:
connection:
host: postgres-postgresql.data.svc.cluster.local
host: postgresql.data.svc.cluster.local
port: 5432
user: postgres
password: psw
Expand All @@ -62,7 +70,7 @@ metadata:
spec:
image:
repository: gresearch/armada-executor
tag: 0.8.2
tag: latest
applicationConfig:
executorApiConnection:
armadaUrl: armada-scheduler.armada.svc.cluster.local:50051
Expand All @@ -79,7 +87,7 @@ spec:
ingressClass: "nginx"
image:
repository: gresearch/armada-lookout-v2
tag: 0.8.2
tag: latest
prometheus:
enabled: true
applicationConfig:
Expand All @@ -89,9 +97,11 @@ spec:
apiPort: 8080
corsAllowedOrigins:
- "http://localhost"
uiConfig:
armadaApiBaseUrl: "http://localhost:30001"
postgres:
connection:
host: postgres-postgresql.data.svc.cluster.local
host: postgresql.data.svc.cluster.local
port: 5432
user: postgres
password: psw
Expand All @@ -106,11 +116,11 @@ metadata:
spec:
image:
repository: gresearch/armada-lookout-ingester-v2
tag: 0.8.2
tag: latest
applicationConfig:
postgres:
connection:
host: postgres-postgresql.data.svc.cluster.local
host: postgresql.data.svc.cluster.local
port: 5432
user: postgres
password: psw
Expand All @@ -130,7 +140,7 @@ spec:
ingressClass: "nginx"
image:
repository: gresearch/armada-scheduler
tag: 0.8.2
tag: latest
applicationConfig:
grpc:
port: 50051
Expand All @@ -143,7 +153,7 @@ spec:
URL: pulsar://pulsar-broker.data.svc.cluster.local:6650
postgres:
connection:
host: postgres-postgresql.data.svc.cluster.local
host: postgresql.data.svc.cluster.local
port: 5432
user: postgres
password: psw
Expand All @@ -159,11 +169,11 @@ spec:
replicas: 1
image:
repository: gresearch/armada-scheduler-ingester
tag: 0.8.2
tag: latest
applicationConfig:
postgres:
connection:
host: postgres-postgresql.data.svc.cluster.local
host: postgresql.data.svc.cluster.local
port: 5432
user: postgres
password: psw
Expand All @@ -181,7 +191,7 @@ spec:
replicas: 1
image:
repository: gresearch/armada-event-ingester
tag: 0.8.2
tag: latest
applicationConfig:
pulsar:
URL: pulsar://pulsar-broker.data.svc.cluster.local:6650
Expand Down
24 changes: 24 additions & 0 deletions dev/quickstart/example-job-preemptible.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
queue: example
jobSetId: job-set-1
jobs:
- namespace: default
priority: 0
podSpec:
priorityClassName: armada-preemptible
terminationGracePeriodSeconds: 0
restartPolicy: Never
containers:
- name: sleeper
image: alpine:latest
command:
- sh
args:
- -c
- sleep $(( (RANDOM % 60) + 10 ))
resources:
limits:
memory: 128Mi
cpu: 0.5
requests:
memory: 128Mi
cpu: 0.5
5 changes: 3 additions & 2 deletions dev/quickstart/example-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jobs:
- namespace: default
priority: 0
podSpec:
priorityClassName: armada-default
terminationGracePeriodSeconds: 0
restartPolicy: Never
containers:
Expand All @@ -17,7 +18,7 @@ jobs:
resources:
limits:
memory: 128Mi
cpu: 0.2
cpu: 2
requests:
memory: 128Mi
cpu: 0.2
cpu: 2
7 changes: 7 additions & 0 deletions dev/quickstart/preemptible-priority-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: armada-preemptible
value: 1000
globalDefault: false
description: "Priority class for armada preemptible pods."
2 changes: 1 addition & 1 deletion dev/quickstart/priority-class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: armada-default
value: 1000000
value: 1000
globalDefault: false
description: "This priority class should be as a default for Armada jobs."
2 changes: 1 addition & 1 deletion dev/quickstart/redis.values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
replicas: 3
replicas: 1
11 changes: 3 additions & 8 deletions hack/kind-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@ kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
# Lookout UI
- containerPort: 30000
hostPort: 30000
protocol: TCP
# Armada Server REST API
- containerPort: 30001
hostPort: 30001
protocol: TCP
# Armada Server gRPC API
- containerPort: 30002
hostPort: 30002
protocol: TCP
# Add two worker nodes
- role: worker
- role: worker
2 changes: 1 addition & 1 deletion hack/wait-for-deps.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

STATEFULSETS=(
"postgres-postgresql"
"postgresql"
"pulsar-bookie"
"pulsar-broker"
"pulsar-proxy"
Expand Down
3 changes: 2 additions & 1 deletion internal/controller/install/armadaserver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (r *ArmadaServerReconciler) Reconcile(ctx context.Context, req ctrl.Request
return ctrl.Result{}, err
}
as.Spec.PortConfig = pc

var components *CommonComponents
components, err = generateArmadaServerInstallComponents(&as, r.Scheme)
if err != nil {
Expand Down Expand Up @@ -192,7 +193,7 @@ func (r *ArmadaServerReconciler) Reconcile(ctx context.Context, req ctrl.Request
}

if components.IngressHttp != nil {
logger.Info("Upserting ArmadaServer IngressHttp object")
logger.Info("Upserting ArmadaServer REST Ingress object")
if _, err := controllerutil.CreateOrUpdate(ctx, r.Client, components.IngressHttp, mutateFn); err != nil {
return ctrl.Result{}, err
}
Expand Down
16 changes: 4 additions & 12 deletions internal/controller/install/common_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,12 @@ import (
type AppName string

const (
defaultPrometheusInterval = 1 * time.Second
appConfigFlag = "--config"
appConfigFilepath = "/config/application_config.yaml"
AppArmada AppName = "armada"
AppExecutor AppName = "executor"
AppScheduler AppName = "scheduler"
AppSchedulerIngester AppName = "scheduleringester"
AppLookout AppName = "lookout"
AppLookoutIngester AppName = "lookoutingesterv2"
AppEventIngester AppName = "eventingester"
AppBinoculars AppName = "binoculars"
defaultPrometheusInterval = 1 * time.Second
appConfigFlag = "--config"
appConfigFilepath = "/config/application_config.yaml"
)

// CommonComponents are the base components for all of the Armada services
// CommonComponents are the base components for all Armada services
type CommonComponents struct {
Deployment *appsv1.Deployment
IngressGrpc *networkingv1.Ingress
Expand Down
40 changes: 1 addition & 39 deletions internal/controller/install/scheduler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (r *SchedulerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, err
}

pc, err := buildSchedulerPortConfig(scheduler.Spec.ApplicationConfig)
pc, err := installv1alpha1.BuildPortConfig(scheduler.Spec.ApplicationConfig)
if err != nil {
return ctrl.Result{}, err
}
Expand Down Expand Up @@ -675,44 +675,6 @@ func createSchedulerCronJob(scheduler *installv1alpha1.Scheduler) (*batchv1.Cron
return &job, nil
}

// schedulerPortConfigs will unmarshal ports from the scheduler app config
type schedulerPortConfigs struct {
Grpc schedulerPortConfig
Metrics schedulerPortConfig
}

// schedulerPortConfig will unmarshal a port from the scheduler app config
type schedulerPortConfig struct {
Port int32
}

// buildSchedulerPortConfig extracts ports from the ApplicationConfig and applies inplace
// as the PortConfig
func buildSchedulerPortConfig(rawAppConfig runtime.RawExtension) (installv1alpha1.PortConfig, error) {
appConfig, err := installv1alpha1.ConvertRawExtensionToYaml(rawAppConfig)
if err != nil {
return installv1alpha1.PortConfig{}, err
}

// default ports
schedulerPorts := schedulerPortConfigs{
Grpc: schedulerPortConfig{Port: 50051},
Metrics: schedulerPortConfig{Port: 9000},
}

// unmarshall app config
err = yaml.Unmarshal([]byte(appConfig), &schedulerPorts)
if err != nil {
return installv1alpha1.PortConfig{}, err
}

portConfig := installv1alpha1.PortConfig{
GrpcPort: schedulerPorts.Grpc.Port,
MetricsPort: schedulerPorts.Metrics.Port,
}
return portConfig, nil
}

// SetupWithManager sets up the controller with the Manager.
func (r *SchedulerReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Expand Down

0 comments on commit 6ea2d95

Please sign in to comment.