Skip to content

Commit b44e0c5

Browse files
Add hosts in immudb status
1 parent ebc0b05 commit b44e0c5

File tree

6 files changed

+80
-9
lines changed

6 files changed

+80
-9
lines changed

api/v1/immudb_types.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,26 @@ type ImmudbVolumeSpec struct {
6464
type ImmudbStatus struct {
6565
// Important: Run "make" to regenerate code after modifying this file
6666

67-
// Number of ready replicas
67+
// Number of ready replicas.
6868
ReadyReplicas int32 `json:"readyReplicas"`
6969

70-
// Instance ready to accept connections
70+
// Instance ready to accept connections.
7171
Ready bool `json:"ready"`
72+
73+
// Hosts to connect to the database.
74+
// +kubebuilder:validation:Optional
75+
Hosts *HostsStatus `json:"hosts"`
76+
}
77+
78+
type HostsStatus struct {
79+
// +kubebuilder:validation:Required
80+
HTTP string `json:"HTTP"`
81+
82+
// +kubebuilder:validation:Required
83+
Metrics string `json:"Metrics"`
84+
85+
// +kubebuilder:validation:Required
86+
GRPC string `json:"GRPC"`
7287
}
7388

7489
//+kubebuilder:object:root=true

api/v1/zz_generated.deepcopy.go

+21-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/operator/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ apiVersion: v2
22
name: immudb-operator
33
description: Helm chart to deploy [unagex-immudb-operator](https://github.com/unagex/immudb-operator)
44
type: application
5-
version: 0.0.4
6-
appVersion: 0.0.4
5+
version: 0.0.5
6+
appVersion: 0.0.5
77
home: https://github.com/unagex/immudb-operator

charts/operator/templates/crds/unagex.com_immudbs.yaml

+16-2
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,25 @@ spec:
7373
status:
7474
description: ImmudbStatus defines the observed state of Immudb
7575
properties:
76+
hosts:
77+
description: Hosts to connect to the database.
78+
properties:
79+
GRPC:
80+
type: string
81+
HTTP:
82+
type: string
83+
Metrics:
84+
type: string
85+
required:
86+
- GRPC
87+
- HTTP
88+
- Metrics
89+
type: object
7690
ready:
77-
description: Instance ready to accept connections
91+
description: Instance ready to accept connections.
7892
type: boolean
7993
readyReplicas:
80-
description: Number of ready replicas
94+
description: Number of ready replicas.
8195
format: int32
8296
type: integer
8397
required:

config/crd/bases/unagex.com_immudbs.yaml

+16-2
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,25 @@ spec:
7373
status:
7474
description: ImmudbStatus defines the observed state of Immudb
7575
properties:
76+
hosts:
77+
description: Hosts to connect to the database.
78+
properties:
79+
GRPC:
80+
type: string
81+
HTTP:
82+
type: string
83+
Metrics:
84+
type: string
85+
required:
86+
- GRPC
87+
- HTTP
88+
- Metrics
89+
type: object
7690
ready:
77-
description: Instance ready to accept connections
91+
description: Instance ready to accept connections.
7892
type: boolean
7993
readyReplicas:
80-
description: Number of ready replicas
94+
description: Number of ready replicas.
8195
format: int32
8296
type: integer
8397
required:

internal/controller/database.go

+8
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ func (r *ImmudbReconciler) ManageDatabase(ctx context.Context, immudb *unagexcom
5757
if diff {
5858
immudb.Status.ReadyReplicas = sts.Status.ReadyReplicas
5959
immudb.Status.Ready = false
60+
immudb.Status.Hosts = nil
61+
6062
// TODO: instance is ready if quorum and not if different.
6163
if immudb.Status.ReadyReplicas == *immudb.Spec.Replicas {
6264
immudb.Status.Ready = true
65+
immudb.Status.Hosts = &unagexcomv1.HostsStatus{
66+
HTTP: fmt.Sprintf("%s-http.%s.svc.cluster.local:8080", immudb.Name, immudb.Namespace),
67+
Metrics: fmt.Sprintf("%s-http.%s.svc.cluster.local:9497/metrics", immudb.Name, immudb.Namespace),
68+
GRPC: fmt.Sprintf("%s-grpc.%s.svc.cluster.local:3322", immudb.Name, immudb.Namespace),
69+
}
6370
}
71+
6472
err = r.Status().Update(ctx, immudb)
6573
if err != nil {
6674
return fmt.Errorf("error updating immudb field status.readyReplicas: %w", err)

0 commit comments

Comments
 (0)